Jeck - Basic set metadata support. Also a minor improvement to WGuiImage.
* Metadata is currently only used in exactly one place: the set's "Pretty Name" is displayed when the set is first unlocked. * WGuiImage now has a function to set scaling.
This commit is contained in:
@@ -66,8 +66,6 @@ class MTGCard {
|
|||||||
char getRarity();
|
char getRarity();
|
||||||
void setRarity(char _rarity);
|
void setRarity(char _rarity);
|
||||||
|
|
||||||
const char * getSetName();
|
|
||||||
|
|
||||||
//void setImageName( char * value);
|
//void setImageName( char * value);
|
||||||
char * getImageName ();
|
char * getImageName ();
|
||||||
|
|
||||||
|
|||||||
@@ -16,25 +16,66 @@ using std::string;
|
|||||||
class GameApp;
|
class GameApp;
|
||||||
class MTGCard;
|
class MTGCard;
|
||||||
|
|
||||||
|
#define SET_METADATA "setinfo.txt"
|
||||||
|
|
||||||
#define MAX_SETS 100
|
class MTGSetInfo{
|
||||||
|
public:
|
||||||
|
MTGSetInfo(string _id);
|
||||||
|
string id; //Short name: 10E, RAV, etc. Automatic from folder.
|
||||||
|
string author; //Author of set, for crediting mod makers, etc.
|
||||||
|
string name; //Long name: Tenth Edition
|
||||||
|
int block; //For future use by tournament mode, etc.
|
||||||
|
int year; //The year the set was released.
|
||||||
|
//TODO Way to group cards by name, rather than mtgid.
|
||||||
|
|
||||||
|
void count(MTGCard * c);
|
||||||
|
|
||||||
|
int totalCards();
|
||||||
|
string getName();
|
||||||
|
string getBlock();
|
||||||
|
int boosterCost();
|
||||||
|
int boosterSize();
|
||||||
|
|
||||||
class MtgSets{
|
enum {
|
||||||
protected:
|
//For memoized counts
|
||||||
public:
|
LAND = 0,
|
||||||
int nb_items;
|
COMMON = 1,
|
||||||
string values[MAX_SETS];
|
UNCOMMON = 2,
|
||||||
|
RARE = 3,
|
||||||
public:
|
MAX_RARITY = 4, //For boosters, mythic is part of rare... always.
|
||||||
static MtgSets * SetsList;
|
MYTHIC = 4,
|
||||||
MtgSets();
|
TOTAL_CARDS = 5,
|
||||||
int Add(const char * subtype);
|
MAX_COUNT = 6
|
||||||
int find(string value);
|
};
|
||||||
|
|
||||||
|
bool bZipped; //Is this set's images present as a zip file?
|
||||||
|
bool bThemeZipped; //[...] in the theme?
|
||||||
|
int counts[MTGSetInfo::MAX_COUNT];
|
||||||
|
int booster[MAX_RARITY];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class MTGSets{
|
||||||
|
public:
|
||||||
|
friend class MTGSetInfo;
|
||||||
|
MTGSets();
|
||||||
|
|
||||||
|
int Add(const char * subtype);
|
||||||
|
int findSet(string value);
|
||||||
|
int findBlock(string s);
|
||||||
|
|
||||||
|
int size();
|
||||||
|
|
||||||
|
int operator[](string id); //Returns set id index, -1 for failure.
|
||||||
|
string operator[](int id); //Returns set id name, "" for failure.
|
||||||
|
|
||||||
|
MTGSetInfo* getInfo(int setID);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
vector<string> blocks;
|
||||||
|
vector<MTGSetInfo*> setinfo;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern MTGSets setlist;
|
||||||
|
|
||||||
class MTGAllCards {
|
class MTGAllCards {
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -111,6 +111,19 @@ class Constants
|
|||||||
RARITY_C = 'C',
|
RARITY_C = 'C',
|
||||||
RARITY_L = 'L',
|
RARITY_L = 'L',
|
||||||
|
|
||||||
|
//Price for singles
|
||||||
|
PRICE_1M = 3000,
|
||||||
|
PRICE_1R = 500,
|
||||||
|
PRICE_1U = 100,
|
||||||
|
PRICE_1C = 20,
|
||||||
|
PRICE_1L = 5,
|
||||||
|
|
||||||
|
//Price in booster
|
||||||
|
PRICE_XM = 2500,
|
||||||
|
PRICE_XR = 355,
|
||||||
|
PRICE_XU = 88,
|
||||||
|
PRICE_XC = 8,
|
||||||
|
PRICE_XL = 1,
|
||||||
|
|
||||||
MAIN_FONT = 0,
|
MAIN_FONT = 0,
|
||||||
MENU_FONT = 1,
|
MENU_FONT = 1,
|
||||||
|
|||||||
@@ -270,6 +270,7 @@ public:
|
|||||||
virtual void Render();
|
virtual void Render();
|
||||||
virtual float getHeight();
|
virtual float getHeight();
|
||||||
|
|
||||||
|
virtual void imageScale(float w, float h);
|
||||||
protected:
|
protected:
|
||||||
bool exact;
|
bool exact;
|
||||||
int margin;
|
int margin;
|
||||||
@@ -337,7 +338,7 @@ public:
|
|||||||
virtual void Reload();
|
virtual void Reload();
|
||||||
virtual void Update(float dt);
|
virtual void Update(float dt);
|
||||||
virtual void ButtonPressed(int controllerId, int controlId);
|
virtual void ButtonPressed(int controllerId, int controlId);
|
||||||
virtual void Add(WGuiBase* item);
|
virtual void Add(WGuiBase* item); //Remember, does not set X & Y of items automatically.
|
||||||
virtual void confirmChange(bool confirmed);
|
virtual void confirmChange(bool confirmed);
|
||||||
|
|
||||||
WGuiBase * Current();
|
WGuiBase * Current();
|
||||||
|
|||||||
@@ -274,19 +274,19 @@ void CardGui::alternateRender(MTGCard * card, const Pos& pos){
|
|||||||
char buf[512];
|
char buf[512];
|
||||||
switch(card->getRarity()){
|
switch(card->getRarity()){
|
||||||
case Constants::RARITY_M:
|
case Constants::RARITY_M:
|
||||||
sprintf(buf,_("%s Mythic").c_str(),MtgSets::SetsList->values[card->setId].c_str());
|
sprintf(buf,_("%s Mythic").c_str(),setlist[card->setId].c_str());
|
||||||
break;
|
break;
|
||||||
case Constants::RARITY_R:
|
case Constants::RARITY_R:
|
||||||
sprintf(buf,_("%s Rare").c_str(),MtgSets::SetsList->values[card->setId].c_str());
|
sprintf(buf,_("%s Rare").c_str(),setlist[card->setId].c_str());
|
||||||
break;
|
break;
|
||||||
case Constants::RARITY_U:
|
case Constants::RARITY_U:
|
||||||
sprintf(buf,_("%s Uncommon").c_str(),MtgSets::SetsList->values[card->setId].c_str());
|
sprintf(buf,_("%s Uncommon").c_str(),setlist[card->setId].c_str());
|
||||||
break;
|
break;
|
||||||
case Constants::RARITY_C:
|
case Constants::RARITY_C:
|
||||||
sprintf(buf,_("%s Common").c_str(),MtgSets::SetsList->values[card->setId].c_str());
|
sprintf(buf,_("%s Common").c_str(),setlist[card->setId].c_str());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
sprintf(buf,"%s",MtgSets::SetsList->values[card->setId].c_str());
|
sprintf(buf,"%s",setlist[card->setId].c_str());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -105,7 +105,8 @@ void Credits::compute(Player * _p1, Player * _p2, GameApp * _app){
|
|||||||
unlockedQuad = resources.RetrieveQuad("set_unlocked.png", 2, 2, 396, 96);
|
unlockedQuad = resources.RetrieveQuad("set_unlocked.png", 2, 2, 396, 96);
|
||||||
options[Options::optionSet(unlocked - 1)] = GameOption(1);
|
options[Options::optionSet(unlocked - 1)] = GameOption(1);
|
||||||
options.save();
|
options.save();
|
||||||
unlockedString = MtgSets::SetsList->values[unlocked -1];
|
MTGSetInfo * si = setlist.getInfo(unlocked - 1);
|
||||||
|
if(si) unlockedString = si->getName(); //Show the set's pretty name for unlocks.
|
||||||
}
|
}
|
||||||
if (unlocked && options[Options::SFXVOLUME].number > 0){
|
if (unlocked && options[Options::SFXVOLUME].number > 0){
|
||||||
JSample * sample = resources.RetrieveSample("bonus.wav");
|
JSample * sample = resources.RetrieveSample("bonus.wav");
|
||||||
@@ -238,7 +239,7 @@ int Credits::isRandomDeckUnlocked(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
int Credits::unlockRandomSet(){
|
int Credits::unlockRandomSet(){
|
||||||
int setId = WRand() % MtgSets::SetsList->nb_items;
|
int setId = WRand() % setlist.size();
|
||||||
|
|
||||||
if (1 == options[Options::optionSet(setId)].number)
|
if (1 == options[Options::optionSet(setId)].number)
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -210,7 +210,6 @@ void GameApp::Destroy()
|
|||||||
delete(DeckStats::GetInstance());
|
delete(DeckStats::GetInstance());
|
||||||
|
|
||||||
SAFE_DELETE(Subtypes::subtypesList);
|
SAFE_DELETE(Subtypes::subtypesList);
|
||||||
SAFE_DELETE(MtgSets::SetsList);
|
|
||||||
|
|
||||||
SAFE_DELETE(music);
|
SAFE_DELETE(music);
|
||||||
Translator::EndInstance();
|
Translator::EndInstance();
|
||||||
|
|||||||
@@ -66,8 +66,8 @@ int Options::getID(string name){
|
|||||||
|
|
||||||
//Is it an unlocked set?
|
//Is it an unlocked set?
|
||||||
string setname = name.substr(strlen("unlocked_"));
|
string setname = name.substr(strlen("unlocked_"));
|
||||||
if(MtgSets::SetsList && MtgSets::SetsList->nb_items){
|
if(setlist.size()){
|
||||||
int unlocked = MtgSets::SetsList->find(setname);
|
int unlocked = setlist[setname];
|
||||||
if(unlocked != -1)
|
if(unlocked != -1)
|
||||||
return Options::optionSet(unlocked);
|
return Options::optionSet(unlocked);
|
||||||
}
|
}
|
||||||
@@ -86,14 +86,10 @@ string Options::getName(int option){
|
|||||||
return optionNames[option];
|
return optionNames[option];
|
||||||
|
|
||||||
//Unlocked sets.
|
//Unlocked sets.
|
||||||
if(MtgSets::SetsList){
|
int setID = option - SET_UNLOCKS;
|
||||||
int setID = option - SET_UNLOCKS;
|
char buf[512];
|
||||||
if(setID >= 0 && setID < MtgSets::SetsList->nb_items){
|
sprintf(buf,"unlocked_%s",setlist[setID].c_str());
|
||||||
char buf[512];
|
return buf;
|
||||||
sprintf(buf,"unlocked_%s",MtgSets::SetsList->values[setID].c_str());
|
|
||||||
return buf;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Failed.
|
//Failed.
|
||||||
return "";
|
return "";
|
||||||
@@ -101,7 +97,7 @@ string Options::getName(int option){
|
|||||||
|
|
||||||
int Options::optionSet(int setID){
|
int Options::optionSet(int setID){
|
||||||
//Sanity check if possible
|
//Sanity check if possible
|
||||||
if(setID < 0 || (MtgSets::SetsList && setID > MtgSets::SetsList->nb_items))
|
if(setID < 0 || (setID > setlist.size()))
|
||||||
return INVALID_OPTION;
|
return INVALID_OPTION;
|
||||||
|
|
||||||
return SET_UNLOCKS + setID;
|
return SET_UNLOCKS + setID;
|
||||||
@@ -380,7 +376,6 @@ GameSettings::GameSettings()
|
|||||||
}
|
}
|
||||||
|
|
||||||
GameSettings::~GameSettings(){
|
GameSettings::~GameSettings(){
|
||||||
//Destructor no longer saves, to prevent conflicts when MtgSets::SetsList == NULL
|
|
||||||
SAFE_DELETE(globalOptions);
|
SAFE_DELETE(globalOptions);
|
||||||
SAFE_DELETE(profileOptions);
|
SAFE_DELETE(profileOptions);
|
||||||
SAFE_DELETE(keypad);
|
SAFE_DELETE(keypad);
|
||||||
@@ -497,7 +492,7 @@ void GameSettings::checkProfile(){
|
|||||||
//Find the set for which we have the most variety
|
//Find the set for which we have the most variety
|
||||||
int setId = 0;
|
int setId = 0;
|
||||||
int maxcards = 0;
|
int maxcards = 0;
|
||||||
for (int i=0; i< MtgSets::SetsList->nb_items; i++){
|
for (int i=0; i< setlist.size(); i++){
|
||||||
int value = theGame->collection->countBySet(i);
|
int value = theGame->collection->countBySet(i);
|
||||||
if (value > maxcards){
|
if (value > maxcards){
|
||||||
maxcards = value;
|
maxcards = value;
|
||||||
|
|||||||
@@ -202,10 +202,10 @@ void GameStateMenu::fillScroller(){
|
|||||||
|
|
||||||
//Unlocked sets
|
//Unlocked sets
|
||||||
int nbunlocked = 0;
|
int nbunlocked = 0;
|
||||||
for (int i = 0; i < MtgSets::SetsList->nb_items; i++){
|
for (int i = 0; i < setlist.size(); i++){
|
||||||
if (1 == options[Options::optionSet(i)].number) nbunlocked++;
|
if (1 == options[Options::optionSet(i)].number) nbunlocked++;
|
||||||
}
|
}
|
||||||
sprintf(buff2, _("You have unlocked %i expansions out of %i").c_str(),nbunlocked, MtgSets::SetsList->nb_items);
|
sprintf(buff2, _("You have unlocked %i expansions out of %i").c_str(),nbunlocked, setlist.size());
|
||||||
scroller->Add(buff2);
|
scroller->Add(buff2);
|
||||||
|
|
||||||
DeckDataWrapper* ddw = NEW DeckDataWrapper(NEW MTGDeck(options.profileFile(PLAYER_COLLECTION).c_str(), mParent->collection));
|
DeckDataWrapper* ddw = NEW DeckDataWrapper(NEW MTGDeck(options.profileFile(PLAYER_COLLECTION).c_str(), mParent->collection));
|
||||||
|
|||||||
@@ -71,9 +71,10 @@ void GameStateShop::load(){
|
|||||||
//Unlock a default set if no set is unlocked
|
//Unlock a default set if no set is unlocked
|
||||||
int ok = 0;
|
int ok = 0;
|
||||||
int defaultSet = 0;
|
int defaultSet = 0;
|
||||||
for (int i = 0; i < MtgSets::SetsList->nb_items; i++){
|
|
||||||
string s = MtgSets::SetsList->values[i];
|
for (int i = 0; i < setlist.size(); i++){
|
||||||
if (s.compare("10E") == 0) defaultSet = i;
|
|
||||||
|
if (setlist[i].compare("10E") == 0) defaultSet = i;
|
||||||
|
|
||||||
unlocked[i] = options[Options::optionSet(i)].number;
|
unlocked[i] = options[Options::optionSet(i)].number;
|
||||||
if (unlocked[i])
|
if (unlocked[i])
|
||||||
@@ -85,7 +86,7 @@ void GameStateShop::load(){
|
|||||||
options.save();
|
options.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < MtgSets::SetsList->nb_items; i++){
|
for (int i = 0; i < setlist.size(); i++){
|
||||||
if (unlocked[i]){
|
if (unlocked[i]){
|
||||||
sets[nbsets] = i;
|
sets[nbsets] = i;
|
||||||
nbsets++;
|
nbsets++;
|
||||||
@@ -101,7 +102,7 @@ void GameStateShop::load(){
|
|||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
for (int i = 0; i < SHOP_BOOSTERS; i++){
|
for (int i = 0; i < SHOP_BOOSTERS; i++){
|
||||||
setIds[i] = (rand() % MtgSets::SetsList->nb_items);
|
setIds[i] = (rand() % setlist.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
JQuad * mBackThumb = resources.GetQuad("back_thumb");
|
JQuad * mBackThumb = resources.GetQuad("back_thumb");
|
||||||
@@ -109,9 +110,14 @@ void GameStateShop::load(){
|
|||||||
|
|
||||||
|
|
||||||
shop = NEW ShopItems(10, this, itemFont, 10, 0, mParent->collection, setIds);
|
shop = NEW ShopItems(10, this, itemFont, 10, 0, mParent->collection, setIds);
|
||||||
|
MTGSetInfo * si = NULL;
|
||||||
for (int i = 0; i < SHOP_BOOSTERS; i++){
|
for (int i = 0; i < SHOP_BOOSTERS; i++){
|
||||||
sprintf(setNames[i], "%s Booster (15 %s)",MtgSets::SetsList->values[setIds[i]].c_str(), _("cards").c_str());
|
si = setlist.getInfo(setIds[i]);
|
||||||
shop->Add(setNames[i],mBack,mBackThumb, 700);
|
if(!si)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
sprintf(setNames[i], "%s %s (%i %s)", si->id.c_str(), _("Booster").c_str(), si->boosterSize(), _("Cards").c_str());
|
||||||
|
shop->Add(setNames[i],mBack,mBackThumb, si->boosterCost());
|
||||||
}
|
}
|
||||||
|
|
||||||
MTGDeck * tempDeck = NEW MTGDeck(mParent->collection);
|
MTGDeck * tempDeck = NEW MTGDeck(mParent->collection);
|
||||||
|
|||||||
@@ -25,11 +25,6 @@ MTGCard::MTGCard(int set_id){
|
|||||||
init();
|
init();
|
||||||
setId = set_id;
|
setId = set_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char * MTGCard::getSetName(){
|
|
||||||
return MtgSets::SetsList->values[setId].c_str();
|
|
||||||
}
|
|
||||||
|
|
||||||
MTGCard::MTGCard(MTGCard * source){
|
MTGCard::MTGCard(MTGCard * source){
|
||||||
for(map<int,int>::const_iterator it = source->basicAbilities.begin(); it != source->basicAbilities.end(); ++it){
|
for(map<int,int>::const_iterator it = source->basicAbilities.begin(); it != source->basicAbilities.end(); ++it){
|
||||||
basicAbilities[it->first] = source->basicAbilities[it->first];
|
basicAbilities[it->first] = source->basicAbilities[it->first];
|
||||||
@@ -166,7 +161,7 @@ int MTGCard::hasColor(int color){
|
|||||||
|
|
||||||
int MTGCard::countColors(){
|
int MTGCard::countColors(){
|
||||||
int result = 0;
|
int result = 0;
|
||||||
for(int i=Constants::MTG_COLOR_GREEN;i<=Constants::MTG_COLOR_WHITE;i++){
|
for(int i=Constants::MTG_COLOR_GREEN;i<=Constants::MTG_COLOR_WHITE;i++){
|
||||||
if (hasColor(i)) result++;
|
if (hasColor(i)) result++;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -12,43 +12,14 @@ using std::string;
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//MTGAllCards
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
MtgSets * MtgSets::SetsList = NEW MtgSets();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
MtgSets::MtgSets(){
|
|
||||||
nb_items = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int MtgSets::Add(const char * name){
|
|
||||||
string value = name;
|
|
||||||
values[nb_items] = value;
|
|
||||||
nb_items++;
|
|
||||||
return nb_items - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int MtgSets::find(string name){
|
|
||||||
std::transform(name.begin(), name.end(), name.begin(),::tolower );
|
|
||||||
for (int i = 0; i < nb_items; i++){
|
|
||||||
string set = values[i];
|
|
||||||
std::transform(set.begin(), set.end(), set.begin(),::tolower );;
|
|
||||||
if (set.compare(name) == 0) return i;
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int MTGAllCards::processConfLine(string s, MTGCard *card){
|
int MTGAllCards::processConfLine(string s, MTGCard *card){
|
||||||
unsigned int i = s.find_first_of("=");
|
unsigned int i = s.find_first_of("=");
|
||||||
if (i == string::npos){
|
if (i == string::npos){
|
||||||
#if defined (_DEBUG)
|
#if defined (_DEBUG)
|
||||||
if (s.size() && s[0] == '#') return 0;
|
if (s.size() && s[0] == '#') return 0;
|
||||||
char buffer[4096];
|
char buffer[4096];
|
||||||
sprintf(buffer, "MTGDECK: Bad Line in %s/_cards.dat:\n %s\n", MtgSets::SetsList->values[card->setId].c_str(), s.c_str());
|
sprintf(buffer, "MTGDECK: Bad Line in %s/_cards.dat:\n %s\n", setlist[card->setId], s.c_str());
|
||||||
OutputDebugString(buffer);
|
OutputDebugString(buffer);
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
@@ -141,7 +112,7 @@ int MTGAllCards::processConfLine(string s, MTGCard *card){
|
|||||||
card->setType( "Error");
|
card->setType( "Error");
|
||||||
#if defined (_DEBUG)
|
#if defined (_DEBUG)
|
||||||
char buffer[4096];
|
char buffer[4096];
|
||||||
sprintf(buffer, "MTGDECK: Bad Card Type in %s/_cards.dat:\n %s\n", MtgSets::SetsList->values[card->setId].c_str(), s.c_str());
|
sprintf(buffer, "MTGDECK: Bad Card Type in %s/_cards.dat:\n %s\n", setlist[card->setId], s.c_str());
|
||||||
OutputDebugString(buffer);
|
OutputDebugString(buffer);
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
@@ -196,7 +167,7 @@ void MTGAllCards::init(){
|
|||||||
|
|
||||||
int MTGAllCards::load(const char * config_file, const char * set_name,int autoload){
|
int MTGAllCards::load(const char * config_file, const char * set_name,int autoload){
|
||||||
conf_read_mode = 0;
|
conf_read_mode = 0;
|
||||||
int set_id = MtgSets::SetsList->Add(set_name);
|
int set_id = setlist.Add(set_name);
|
||||||
|
|
||||||
std::ifstream setFile(config_file);
|
std::ifstream setFile(config_file);
|
||||||
|
|
||||||
@@ -326,8 +297,11 @@ int MTGAllCards::readConfLine(std::ifstream &file, int set_id){
|
|||||||
if (it != t->tempValues.end()) {
|
if (it != t->tempValues.end()) {
|
||||||
tempCard->setText(it->second);
|
tempCard->setText(it->second);
|
||||||
}
|
}
|
||||||
|
collection[newId] = tempCard; //Push card into collection.
|
||||||
|
MTGSetInfo * si = setlist.getInfo(set_id);
|
||||||
|
if(si)
|
||||||
|
si->count(tempCard); //Count card in set info
|
||||||
|
|
||||||
collection[newId] = tempCard;
|
|
||||||
total_cards++;
|
total_cards++;
|
||||||
#if defined (_DEBUG)
|
#if defined (_DEBUG)
|
||||||
committed = true;
|
committed = true;
|
||||||
@@ -371,7 +345,7 @@ MTGCard * MTGAllCards::getCardByName(string name){
|
|||||||
size_t end = name.find(")");
|
size_t end = name.find(")");
|
||||||
string setName = name.substr(found+2,end-found-2);
|
string setName = name.substr(found+2,end-found-2);
|
||||||
name = name.substr(0,found);
|
name = name.substr(0,found);
|
||||||
setId = MtgSets::SetsList->find(setName);
|
setId = setlist[setName];
|
||||||
}
|
}
|
||||||
map<int,MTGCard *>::iterator it;
|
map<int,MTGCard *>::iterator it;
|
||||||
for (it = collection.begin(); it!=collection.end(); it++){
|
for (it = collection.begin(); it!=collection.end(); it++){
|
||||||
@@ -385,8 +359,7 @@ MTGCard * MTGAllCards::getCardByName(string name){
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//MTGDeck
|
||||||
|
|
||||||
MTGDeck::MTGDeck(MTGAllCards * _allcards){
|
MTGDeck::MTGDeck(MTGAllCards * _allcards){
|
||||||
total_cards = 0;
|
total_cards = 0;
|
||||||
database = _allcards;
|
database = _allcards;
|
||||||
@@ -460,6 +433,9 @@ MTGCard * MTGDeck::getCardById(int mtgId){
|
|||||||
|
|
||||||
|
|
||||||
int MTGDeck::addRandomCards(int howmany, int * setIds, int nbSets, int rarity, const char * _subtype, int * colors, int nbcolors){
|
int MTGDeck::addRandomCards(int howmany, int * setIds, int nbSets, int rarity, const char * _subtype, int * colors, int nbcolors){
|
||||||
|
if(howmany <= 0)
|
||||||
|
return 1;
|
||||||
|
|
||||||
int unallowedColors[Constants::MTG_NB_COLORS+1];
|
int unallowedColors[Constants::MTG_NB_COLORS+1];
|
||||||
for (int i=0; i < Constants::MTG_NB_COLORS; ++i){
|
for (int i=0; i < Constants::MTG_NB_COLORS; ++i){
|
||||||
if (nbcolors) unallowedColors[i] = 1;
|
if (nbcolors) unallowedColors[i] = 1;
|
||||||
@@ -630,4 +606,191 @@ int MTGDeck::save(){
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//MTGSets
|
||||||
|
MTGSets setlist; //Our global.
|
||||||
|
|
||||||
|
MTGSets::MTGSets(){
|
||||||
|
}
|
||||||
|
|
||||||
|
MTGSetInfo* MTGSets::getInfo(int setID){
|
||||||
|
if(setID < 0 || setID >= (int) setinfo.size())
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return setinfo[setID];
|
||||||
|
}
|
||||||
|
|
||||||
|
int MTGSets::Add(const char * name){
|
||||||
|
int setid = findSet(name);
|
||||||
|
if(setid != -1)
|
||||||
|
return setid;
|
||||||
|
|
||||||
|
MTGSetInfo* s = NEW MTGSetInfo(name);
|
||||||
|
setinfo.push_back(s);
|
||||||
|
setid = (int) setinfo.size();
|
||||||
|
|
||||||
|
return setid - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int MTGSets::findSet(string name){
|
||||||
|
std::transform(name.begin(), name.end(), name.begin(),::tolower );
|
||||||
|
|
||||||
|
for (int i = 0; i < (int) setinfo.size(); i++){
|
||||||
|
MTGSetInfo* s = setinfo[i];
|
||||||
|
if(!s) continue;
|
||||||
|
string set = s->id;
|
||||||
|
std::transform(set.begin(), set.end(), set.begin(),::tolower);
|
||||||
|
if (set.compare(name) == 0) return i;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int MTGSets::findBlock(string s){
|
||||||
|
if(!s.size())
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
string comp = s;
|
||||||
|
std::transform(comp.begin(), comp.end(), comp.begin(),::tolower);
|
||||||
|
for(int i=0;i<(int)blocks.size();i++){
|
||||||
|
string b = blocks[i];
|
||||||
|
std::transform(b.begin(), b.end(), b.begin(),::tolower);
|
||||||
|
if(b.compare(comp) == 0) return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
blocks.push_back(s);
|
||||||
|
return ((int) blocks.size()) -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int MTGSets::operator[](string id){
|
||||||
|
return findSet(id);
|
||||||
|
}
|
||||||
|
string MTGSets::operator[](int id){
|
||||||
|
if(id < 0 || id >= (int) setinfo.size())
|
||||||
|
return "";
|
||||||
|
|
||||||
|
MTGSetInfo * si = setinfo[id];
|
||||||
|
if(!si)
|
||||||
|
return "";
|
||||||
|
|
||||||
|
return si->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
int MTGSets::size(){
|
||||||
|
return (int) setinfo.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//MTGSetInfo
|
||||||
|
MTGSetInfo::MTGSetInfo(string _id) {
|
||||||
|
id = _id;
|
||||||
|
block = -1;
|
||||||
|
year = -1;
|
||||||
|
for(int i=0;i<MTGSetInfo::MAX_COUNT;i++)
|
||||||
|
counts[i] = 0;
|
||||||
|
|
||||||
|
booster[MTGSetInfo::LAND] = 1;
|
||||||
|
booster[MTGSetInfo::COMMON] = 10;
|
||||||
|
booster[MTGSetInfo::UNCOMMON] = 3;
|
||||||
|
booster[MTGSetInfo::RARE] = 1;
|
||||||
|
|
||||||
|
//Load metadata.
|
||||||
|
char buf[512];
|
||||||
|
sprintf(buf,RESPATH"/sets/%s/"SET_METADATA,id.c_str());
|
||||||
|
ifstream file(buf);
|
||||||
|
if(file){
|
||||||
|
string s;
|
||||||
|
while(std::getline(file,s)){
|
||||||
|
unsigned int i = s.find_first_of("=");
|
||||||
|
if (i == string::npos)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
string key = s.substr(0,i);
|
||||||
|
string value = s.substr(i+1);
|
||||||
|
|
||||||
|
if(key.compare("name") == 0)
|
||||||
|
name = value;
|
||||||
|
else if(key.compare("author") == 0)
|
||||||
|
author = value;
|
||||||
|
else if(key.compare("block") == 0)
|
||||||
|
block = setlist.findBlock(value.c_str());
|
||||||
|
else if(key.compare("year") == 0)
|
||||||
|
year = atoi(value.c_str());
|
||||||
|
else if(key.compare("booster_r") == 0)
|
||||||
|
booster[MTGSetInfo::RARE] = atoi(value.c_str());
|
||||||
|
else if(key.compare("booster_u") == 0)
|
||||||
|
booster[MTGSetInfo::UNCOMMON] = atoi(value.c_str());
|
||||||
|
else if(key.compare("booster_c") == 0)
|
||||||
|
booster[MTGSetInfo::COMMON] = atoi(value.c_str());
|
||||||
|
else if(key.compare("booster_l") == 0)
|
||||||
|
booster[MTGSetInfo::LAND] = atoi(value.c_str());
|
||||||
|
}
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void MTGSetInfo::count(MTGCard*c){
|
||||||
|
if(!c)
|
||||||
|
return;
|
||||||
|
|
||||||
|
switch(c->getRarity()){
|
||||||
|
case Constants::RARITY_M:
|
||||||
|
counts[MTGSetInfo::MYTHIC]++;
|
||||||
|
break;
|
||||||
|
case Constants::RARITY_R:
|
||||||
|
counts[MTGSetInfo::RARE]++;
|
||||||
|
break;
|
||||||
|
case Constants::RARITY_U:
|
||||||
|
counts[MTGSetInfo::UNCOMMON]++;
|
||||||
|
break;
|
||||||
|
case Constants::RARITY_C:
|
||||||
|
counts[MTGSetInfo::COMMON]++;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
case Constants::RARITY_L:
|
||||||
|
counts[MTGSetInfo::LAND]++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
counts[MTGSetInfo::TOTAL_CARDS]++;
|
||||||
|
}
|
||||||
|
|
||||||
|
int MTGSetInfo::totalCards(){
|
||||||
|
return counts[MTGSetInfo::TOTAL_CARDS];
|
||||||
|
}
|
||||||
|
|
||||||
|
int MTGSetInfo::boosterSize(){
|
||||||
|
int size = 0;
|
||||||
|
|
||||||
|
for(int i = 0; i<MTGSetInfo::MAX_RARITY;i++)
|
||||||
|
size += booster[i];
|
||||||
|
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
int MTGSetInfo::boosterCost(){
|
||||||
|
int price = 0;
|
||||||
|
for(int i = 0; i<MTGSetInfo::MAX_RARITY;i++){
|
||||||
|
if(i == MTGSetInfo::LAND)
|
||||||
|
price += booster[i] * Constants::PRICE_XL;
|
||||||
|
else if(i == MTGSetInfo::COMMON)
|
||||||
|
price += booster[i] * Constants::PRICE_XC;
|
||||||
|
else if(i == MTGSetInfo::UNCOMMON)
|
||||||
|
price += booster[i] * Constants::PRICE_XU;
|
||||||
|
else
|
||||||
|
price += booster[i] * Constants::PRICE_XR;
|
||||||
|
}
|
||||||
|
|
||||||
|
return price;
|
||||||
|
}
|
||||||
|
|
||||||
|
string MTGSetInfo::getName(){
|
||||||
|
if(name.size())
|
||||||
|
return _(name); //Pretty name is translated.
|
||||||
|
return id; //Ugly name is not.
|
||||||
|
}
|
||||||
|
string MTGSetInfo::getBlock(){
|
||||||
|
if(block < 0 || block >= (int) setlist.blocks.size())
|
||||||
|
return "None";
|
||||||
|
|
||||||
|
return setlist.blocks[block];
|
||||||
|
}
|
||||||
@@ -208,7 +208,7 @@ void OptionProfile::populate(){
|
|||||||
options[Options::ACTIVE_PROFILE].str = selections[value];
|
options[Options::ACTIVE_PROFILE].str = selections[value];
|
||||||
PlayerData * pdata = NEW PlayerData(app->collection);
|
PlayerData * pdata = NEW PlayerData(app->collection);
|
||||||
|
|
||||||
int unlocked = 0, sets = MtgSets::SetsList->nb_items;
|
int unlocked = 0, sets = setlist.size();
|
||||||
std::ifstream file(options.profileFile(PLAYER_SETTINGS).c_str());
|
std::ifstream file(options.profileFile(PLAYER_SETTINGS).c_str());
|
||||||
std::string s;
|
std::string s;
|
||||||
if(file){
|
if(file){
|
||||||
@@ -903,13 +903,18 @@ void WDecoConfirm::ButtonPressed(int controllerId, int controlId){
|
|||||||
|
|
||||||
//WDecoImage
|
//WDecoImage
|
||||||
WGuiImage::WGuiImage(string _file, int _w, int _h, int _margin): WGuiItem("") {
|
WGuiImage::WGuiImage(string _file, int _w, int _h, int _margin): WGuiItem("") {
|
||||||
imgW = _w;
|
imgW = 0;
|
||||||
imgH = _h;
|
imgH = 0;
|
||||||
margin = _margin;
|
margin = _margin;
|
||||||
filename = _file;
|
filename = _file;
|
||||||
exact = false;
|
exact = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WGuiImage::imageScale(float w, float h){
|
||||||
|
imgH = h;
|
||||||
|
imgW = w;
|
||||||
|
}
|
||||||
|
|
||||||
float WGuiImage::getHeight(){
|
float WGuiImage::getHeight(){
|
||||||
|
|
||||||
if(imgH == 0 ){
|
if(imgH == 0 ){
|
||||||
@@ -920,6 +925,7 @@ float WGuiImage::getHeight(){
|
|||||||
|
|
||||||
return MAX(height,imgH+(2*margin));
|
return MAX(height,imgH+(2*margin));
|
||||||
}
|
}
|
||||||
|
|
||||||
JQuad * WGuiImage::getImage(){
|
JQuad * WGuiImage::getImage(){
|
||||||
if(exact)
|
if(exact)
|
||||||
return resources.RetrieveQuad(filename,0,0,0,0,"temporary",RETRIEVE_NORMAL,TEXTURE_SUB_EXACT);
|
return resources.RetrieveQuad(filename,0,0,0,0,"temporary",RETRIEVE_NORMAL,TEXTURE_SUB_EXACT);
|
||||||
@@ -931,7 +937,13 @@ void WGuiImage::Render(){
|
|||||||
JRenderer * renderer = JRenderer::GetInstance();
|
JRenderer * renderer = JRenderer::GetInstance();
|
||||||
JQuad * q = getImage();
|
JQuad * q = getImage();
|
||||||
if(q){
|
if(q){
|
||||||
renderer->RenderQuad(q,x+margin, y+margin,0,1,1);
|
float xS = 1, yS = 1;
|
||||||
|
if(imgH != 0 && q->mHeight != 0)
|
||||||
|
yS = imgH / q->mHeight;
|
||||||
|
if(imgW != 0 && q->mWidth != 0)
|
||||||
|
xS = imgW / q->mWidth;
|
||||||
|
|
||||||
|
renderer->RenderQuad(q,x+margin, y+margin,0,xS,yS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1208,4 +1220,4 @@ void WGuiTabMenu::save(){
|
|||||||
confirmChange(true);
|
confirmChange(true);
|
||||||
setData();
|
setData();
|
||||||
::options.save();
|
::options.save();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,22 +43,22 @@ int PriceList::getPrice(int cardId){
|
|||||||
char rarity = collection->getCardById(cardId)->getRarity();
|
char rarity = collection->getCardById(cardId)->getRarity();
|
||||||
switch(rarity){
|
switch(rarity){
|
||||||
case Constants::RARITY_M:
|
case Constants::RARITY_M:
|
||||||
return 3000;
|
return Constants::PRICE_1M;
|
||||||
break;
|
break;
|
||||||
case Constants::RARITY_R:
|
case Constants::RARITY_R:
|
||||||
return 500;
|
return Constants::PRICE_1R;
|
||||||
break;
|
break;
|
||||||
case Constants::RARITY_U:
|
case Constants::RARITY_U:
|
||||||
return 100;
|
return Constants::PRICE_1U;
|
||||||
break;
|
break;
|
||||||
case Constants::RARITY_C:
|
case Constants::RARITY_C:
|
||||||
return 20;
|
return Constants::PRICE_1C;
|
||||||
break;
|
break;
|
||||||
case Constants::RARITY_L:
|
case Constants::RARITY_L:
|
||||||
return 5;
|
return Constants::PRICE_1L;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return 20;
|
return Constants::PRICE_1C;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -395,10 +395,12 @@ void ShopItems::ButtonPressed(int controllerId, int controlId){
|
|||||||
int rnd = rand() % 8;
|
int rnd = rand() % 8;
|
||||||
if (rnd == 0) rare_or_mythic = Constants::RARITY_M;
|
if (rnd == 0) rare_or_mythic = Constants::RARITY_M;
|
||||||
int sets[] = {setIds[showPriceDialog]};
|
int sets[] = {setIds[showPriceDialog]};
|
||||||
|
MTGSetInfo* si = setlist.getInfo(setIds[showPriceDialog]);
|
||||||
|
|
||||||
tempDeck->addRandomCards(1, sets,1,rare_or_mythic);
|
tempDeck->addRandomCards(si->booster[MTGSetInfo::RARE], sets,1,rare_or_mythic);
|
||||||
tempDeck->addRandomCards(3, sets,1,Constants::RARITY_U);
|
tempDeck->addRandomCards(si->booster[MTGSetInfo::UNCOMMON], sets,1,Constants::RARITY_U);
|
||||||
tempDeck->addRandomCards(11, sets,1,Constants::RARITY_C);
|
tempDeck->addRandomCards(si->booster[MTGSetInfo::COMMON], sets,1,Constants::RARITY_C);
|
||||||
|
tempDeck->addRandomCards(si->booster[MTGSetInfo::LAND], sets,1,Constants::RARITY_L);
|
||||||
|
|
||||||
//Check for duplicates. Does not guarentee none, just makes them extremely unlikely.
|
//Check for duplicates. Does not guarentee none, just makes them extremely unlikely.
|
||||||
//Code is kind of inefficient, but shouldn't be used often enough to matter.
|
//Code is kind of inefficient, but shouldn't be used often enough to matter.
|
||||||
@@ -425,13 +427,14 @@ void ShopItems::ButtonPressed(int controllerId, int controlId){
|
|||||||
}
|
}
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for(int cycle=0;cycle<3;cycle++)
|
for(int cycle=0;cycle<4;cycle++)
|
||||||
for (map<int,int>::iterator it = tempDeck->cards.begin(); it!=tempDeck->cards.end(); it++){
|
for (map<int,int>::iterator it = tempDeck->cards.begin(); it!=tempDeck->cards.end(); it++){
|
||||||
MTGCard * c = tempDeck->getCardById(it->first);
|
MTGCard * c = tempDeck->getCardById(it->first);
|
||||||
char rarity = c->getRarity();
|
char rarity = c->getRarity();
|
||||||
if((cycle == 0 && (rarity == Constants::RARITY_C || rarity == Constants::RARITY_L))
|
if((cycle == 0 && rarity == Constants::RARITY_L)
|
||||||
|| (cycle == 1 && rarity == Constants::RARITY_U)
|
|| (cycle == 1 && rarity == Constants::RARITY_C)
|
||||||
|| (cycle == 2 && (rarity == Constants::RARITY_R || rarity == Constants::RARITY_M)))
|
|| (cycle == 2 && rarity == Constants::RARITY_U)
|
||||||
|
|| (cycle == 3 && (rarity == Constants::RARITY_R || rarity == Constants::RARITY_M)))
|
||||||
for (int j = 0; j < it->second; j++){
|
for (int j = 0; j < it->second; j++){
|
||||||
MTGCardInstance * card = NEW MTGCardInstance(c, NULL);
|
MTGCardInstance * card = NEW MTGCardInstance(c, NULL);
|
||||||
displayCards[i] = card;
|
displayCards[i] = card;
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ JQuad * WResourceManager::RetrieveCard(MTGCard * card, int style, int submode){
|
|||||||
|
|
||||||
submode = submode | TEXTURE_SUB_CARD;
|
submode = submode | TEXTURE_SUB_CARD;
|
||||||
|
|
||||||
string filename = card->getSetName();
|
string filename = setlist[card->setId];
|
||||||
filename += "/";
|
filename += "/";
|
||||||
filename += card->getImageName();
|
filename += card->getImageName();
|
||||||
int id = card->getMTGId();
|
int id = card->getMTGId();
|
||||||
@@ -650,13 +650,7 @@ string WResourceManager::cardFile(const string filename){
|
|||||||
char zipname[512];
|
char zipname[512];
|
||||||
sprintf(zipname, "Res/sets/%s/%s.zip", set.c_str(),set.c_str());
|
sprintf(zipname, "Res/sets/%s/%s.zip", set.c_str(),set.c_str());
|
||||||
if (fs->AttachZipFile(zipname))
|
if (fs->AttachZipFile(zipname))
|
||||||
{
|
|
||||||
for(i = 0;i < filename.size();i++){
|
|
||||||
if(filename[i] == '\\' || filename[i] == '/')
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return filename.substr(i+1);
|
return filename.substr(i+1);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Failure. Check for unzipped file in sets
|
//Failure. Check for unzipped file in sets
|
||||||
|
|||||||
Reference in New Issue
Block a user