From 37ad16d90e01e0aa42275e770cd39da363c55ff6 Mon Sep 17 00:00:00 2001 From: "wagic.jeck" Date: Wed, 18 Nov 2009 09:27:24 +0000 Subject: [PATCH] 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. --- projects/mtg/include/MTGCard.h | 2 - projects/mtg/include/MTGDeck.h | 65 +++++-- projects/mtg/include/MTGDefinitions.h | 13 ++ projects/mtg/include/OptionItem.h | 3 +- projects/mtg/src/CardGui.cpp | 10 +- projects/mtg/src/Credits.cpp | 5 +- projects/mtg/src/GameApp.cpp | 1 - projects/mtg/src/GameOptions.cpp | 21 +-- projects/mtg/src/GameStateMenu.cpp | 4 +- projects/mtg/src/GameStateShop.cpp | 20 ++- projects/mtg/src/MTGCard.cpp | 7 +- projects/mtg/src/MTGDeck.cpp | 237 ++++++++++++++++++++++---- projects/mtg/src/OptionItem.cpp | 22 ++- projects/mtg/src/PriceList.cpp | 12 +- projects/mtg/src/ShopItem.cpp | 17 +- projects/mtg/src/WResourceManager.cpp | 8 +- 16 files changed, 334 insertions(+), 113 deletions(-) diff --git a/projects/mtg/include/MTGCard.h b/projects/mtg/include/MTGCard.h index f9e984c72..301285967 100644 --- a/projects/mtg/include/MTGCard.h +++ b/projects/mtg/include/MTGCard.h @@ -66,8 +66,6 @@ class MTGCard { char getRarity(); void setRarity(char _rarity); - const char * getSetName(); - //void setImageName( char * value); char * getImageName (); diff --git a/projects/mtg/include/MTGDeck.h b/projects/mtg/include/MTGDeck.h index 899ea1c41..23d9aa150 100644 --- a/projects/mtg/include/MTGDeck.h +++ b/projects/mtg/include/MTGDeck.h @@ -16,25 +16,66 @@ using std::string; class GameApp; 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{ - protected: - public: - int nb_items; - string values[MAX_SETS]; - - public: - static MtgSets * SetsList; - MtgSets(); - int Add(const char * subtype); - int find(string value); + enum { + //For memoized counts + LAND = 0, + COMMON = 1, + UNCOMMON = 2, + RARE = 3, + MAX_RARITY = 4, //For boosters, mythic is part of rare... always. + MYTHIC = 4, + TOTAL_CARDS = 5, + MAX_COUNT = 6 + }; + 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 blocks; + vector setinfo; +}; + +extern MTGSets setlist; class MTGAllCards { private: diff --git a/projects/mtg/include/MTGDefinitions.h b/projects/mtg/include/MTGDefinitions.h index a61a2c719..0fa4720f3 100644 --- a/projects/mtg/include/MTGDefinitions.h +++ b/projects/mtg/include/MTGDefinitions.h @@ -111,6 +111,19 @@ class Constants RARITY_C = 'C', 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, MENU_FONT = 1, diff --git a/projects/mtg/include/OptionItem.h b/projects/mtg/include/OptionItem.h index f06190982..ab1d60d45 100644 --- a/projects/mtg/include/OptionItem.h +++ b/projects/mtg/include/OptionItem.h @@ -270,6 +270,7 @@ public: virtual void Render(); virtual float getHeight(); + virtual void imageScale(float w, float h); protected: bool exact; int margin; @@ -337,7 +338,7 @@ public: virtual void Reload(); virtual void Update(float dt); 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); WGuiBase * Current(); diff --git a/projects/mtg/src/CardGui.cpp b/projects/mtg/src/CardGui.cpp index aa669c388..095994203 100644 --- a/projects/mtg/src/CardGui.cpp +++ b/projects/mtg/src/CardGui.cpp @@ -274,19 +274,19 @@ void CardGui::alternateRender(MTGCard * card, const Pos& pos){ char buf[512]; switch(card->getRarity()){ 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; 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; 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; 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; default: - sprintf(buf,"%s",MtgSets::SetsList->values[card->setId].c_str()); + sprintf(buf,"%s",setlist[card->setId].c_str()); break; } diff --git a/projects/mtg/src/Credits.cpp b/projects/mtg/src/Credits.cpp index f1fce8770..ffae93bfa 100644 --- a/projects/mtg/src/Credits.cpp +++ b/projects/mtg/src/Credits.cpp @@ -105,7 +105,8 @@ void Credits::compute(Player * _p1, Player * _p2, GameApp * _app){ unlockedQuad = resources.RetrieveQuad("set_unlocked.png", 2, 2, 396, 96); options[Options::optionSet(unlocked - 1)] = GameOption(1); 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){ JSample * sample = resources.RetrieveSample("bonus.wav"); @@ -238,7 +239,7 @@ int Credits::isRandomDeckUnlocked(){ } int Credits::unlockRandomSet(){ - int setId = WRand() % MtgSets::SetsList->nb_items; + int setId = WRand() % setlist.size(); if (1 == options[Options::optionSet(setId)].number) return 0; diff --git a/projects/mtg/src/GameApp.cpp b/projects/mtg/src/GameApp.cpp index f5a70e410..73a7b04bc 100644 --- a/projects/mtg/src/GameApp.cpp +++ b/projects/mtg/src/GameApp.cpp @@ -210,7 +210,6 @@ void GameApp::Destroy() delete(DeckStats::GetInstance()); SAFE_DELETE(Subtypes::subtypesList); - SAFE_DELETE(MtgSets::SetsList); SAFE_DELETE(music); Translator::EndInstance(); diff --git a/projects/mtg/src/GameOptions.cpp b/projects/mtg/src/GameOptions.cpp index 20b738d62..85bebff5a 100644 --- a/projects/mtg/src/GameOptions.cpp +++ b/projects/mtg/src/GameOptions.cpp @@ -66,8 +66,8 @@ int Options::getID(string name){ //Is it an unlocked set? string setname = name.substr(strlen("unlocked_")); - if(MtgSets::SetsList && MtgSets::SetsList->nb_items){ - int unlocked = MtgSets::SetsList->find(setname); + if(setlist.size()){ + int unlocked = setlist[setname]; if(unlocked != -1) return Options::optionSet(unlocked); } @@ -86,14 +86,10 @@ string Options::getName(int option){ return optionNames[option]; //Unlocked sets. - if(MtgSets::SetsList){ - int setID = option - SET_UNLOCKS; - if(setID >= 0 && setID < MtgSets::SetsList->nb_items){ - char buf[512]; - sprintf(buf,"unlocked_%s",MtgSets::SetsList->values[setID].c_str()); - return buf; - } - } + int setID = option - SET_UNLOCKS; + char buf[512]; + sprintf(buf,"unlocked_%s",setlist[setID].c_str()); + return buf; //Failed. return ""; @@ -101,7 +97,7 @@ string Options::getName(int option){ int Options::optionSet(int setID){ //Sanity check if possible - if(setID < 0 || (MtgSets::SetsList && setID > MtgSets::SetsList->nb_items)) + if(setID < 0 || (setID > setlist.size())) return INVALID_OPTION; return SET_UNLOCKS + setID; @@ -380,7 +376,6 @@ GameSettings::GameSettings() } GameSettings::~GameSettings(){ - //Destructor no longer saves, to prevent conflicts when MtgSets::SetsList == NULL SAFE_DELETE(globalOptions); SAFE_DELETE(profileOptions); SAFE_DELETE(keypad); @@ -497,7 +492,7 @@ void GameSettings::checkProfile(){ //Find the set for which we have the most variety int setId = 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); if (value > maxcards){ maxcards = value; diff --git a/projects/mtg/src/GameStateMenu.cpp b/projects/mtg/src/GameStateMenu.cpp index e3251c0df..d3258fae1 100644 --- a/projects/mtg/src/GameStateMenu.cpp +++ b/projects/mtg/src/GameStateMenu.cpp @@ -202,10 +202,10 @@ void GameStateMenu::fillScroller(){ //Unlocked sets 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++; } - 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); DeckDataWrapper* ddw = NEW DeckDataWrapper(NEW MTGDeck(options.profileFile(PLAYER_COLLECTION).c_str(), mParent->collection)); diff --git a/projects/mtg/src/GameStateShop.cpp b/projects/mtg/src/GameStateShop.cpp index e2eb00d81..a6fad5ca6 100644 --- a/projects/mtg/src/GameStateShop.cpp +++ b/projects/mtg/src/GameStateShop.cpp @@ -71,9 +71,10 @@ void GameStateShop::load(){ //Unlock a default set if no set is unlocked int ok = 0; int defaultSet = 0; - for (int i = 0; i < MtgSets::SetsList->nb_items; i++){ - string s = MtgSets::SetsList->values[i]; - if (s.compare("10E") == 0) defaultSet = i; + + for (int i = 0; i < setlist.size(); i++){ + + if (setlist[i].compare("10E") == 0) defaultSet = i; unlocked[i] = options[Options::optionSet(i)].number; if (unlocked[i]) @@ -85,7 +86,7 @@ void GameStateShop::load(){ options.save(); } - for (int i = 0; i < MtgSets::SetsList->nb_items; i++){ + for (int i = 0; i < setlist.size(); i++){ if (unlocked[i]){ sets[nbsets] = i; nbsets++; @@ -101,7 +102,7 @@ void GameStateShop::load(){ } }else{ 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"); @@ -109,9 +110,14 @@ void GameStateShop::load(){ shop = NEW ShopItems(10, this, itemFont, 10, 0, mParent->collection, setIds); + MTGSetInfo * si = NULL; 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()); - shop->Add(setNames[i],mBack,mBackThumb, 700); + si = setlist.getInfo(setIds[i]); + 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); diff --git a/projects/mtg/src/MTGCard.cpp b/projects/mtg/src/MTGCard.cpp index 3c397ac2a..4faa02e17 100644 --- a/projects/mtg/src/MTGCard.cpp +++ b/projects/mtg/src/MTGCard.cpp @@ -25,11 +25,6 @@ MTGCard::MTGCard(int set_id){ init(); setId = set_id; } - -const char * MTGCard::getSetName(){ - return MtgSets::SetsList->values[setId].c_str(); -} - MTGCard::MTGCard(MTGCard * source){ for(map::const_iterator it = source->basicAbilities.begin(); it != source->basicAbilities.end(); ++it){ basicAbilities[it->first] = source->basicAbilities[it->first]; @@ -166,7 +161,7 @@ int MTGCard::hasColor(int color){ int MTGCard::countColors(){ 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++; } return result; diff --git a/projects/mtg/src/MTGDeck.cpp b/projects/mtg/src/MTGDeck.cpp index 80cc96c29..6d56e1a53 100644 --- a/projects/mtg/src/MTGDeck.cpp +++ b/projects/mtg/src/MTGDeck.cpp @@ -12,43 +12,14 @@ using std::string; #include #endif - - - - -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; -} - - +//MTGAllCards int MTGAllCards::processConfLine(string s, MTGCard *card){ unsigned int i = s.find_first_of("="); if (i == string::npos){ #if defined (_DEBUG) if (s.size() && s[0] == '#') return 0; 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); #endif return 0; @@ -141,7 +112,7 @@ int MTGAllCards::processConfLine(string s, MTGCard *card){ card->setType( "Error"); #if defined (_DEBUG) 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); #endif break; @@ -196,7 +167,7 @@ void MTGAllCards::init(){ int MTGAllCards::load(const char * config_file, const char * set_name,int autoload){ conf_read_mode = 0; - int set_id = MtgSets::SetsList->Add(set_name); + int set_id = setlist.Add(set_name); std::ifstream setFile(config_file); @@ -326,8 +297,11 @@ int MTGAllCards::readConfLine(std::ifstream &file, int set_id){ if (it != t->tempValues.end()) { 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++; #if defined (_DEBUG) committed = true; @@ -371,7 +345,7 @@ MTGCard * MTGAllCards::getCardByName(string name){ size_t end = name.find(")"); string setName = name.substr(found+2,end-found-2); name = name.substr(0,found); - setId = MtgSets::SetsList->find(setName); + setId = setlist[setName]; } map::iterator it; for (it = collection.begin(); it!=collection.end(); it++){ @@ -385,8 +359,7 @@ MTGCard * MTGAllCards::getCardByName(string name){ return NULL; } - - +//MTGDeck MTGDeck::MTGDeck(MTGAllCards * _allcards){ total_cards = 0; 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){ + if(howmany <= 0) + return 1; + int unallowedColors[Constants::MTG_NB_COLORS+1]; for (int i=0; i < Constants::MTG_NB_COLORS; ++i){ if (nbcolors) unallowedColors[i] = 1; @@ -630,4 +606,191 @@ int MTGDeck::save(){ 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;igetRarity()){ + 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= (int) setlist.blocks.size()) + return "None"; + + return setlist.blocks[block]; +} \ No newline at end of file diff --git a/projects/mtg/src/OptionItem.cpp b/projects/mtg/src/OptionItem.cpp index 5979ecb92..49747e2ba 100644 --- a/projects/mtg/src/OptionItem.cpp +++ b/projects/mtg/src/OptionItem.cpp @@ -208,7 +208,7 @@ void OptionProfile::populate(){ options[Options::ACTIVE_PROFILE].str = selections[value]; 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::string s; if(file){ @@ -903,13 +903,18 @@ void WDecoConfirm::ButtonPressed(int controllerId, int controlId){ //WDecoImage WGuiImage::WGuiImage(string _file, int _w, int _h, int _margin): WGuiItem("") { - imgW = _w; - imgH = _h; + imgW = 0; + imgH = 0; margin = _margin; filename = _file; exact = false; } +void WGuiImage::imageScale(float w, float h){ + imgH = h; + imgW = w; +} + float WGuiImage::getHeight(){ if(imgH == 0 ){ @@ -920,6 +925,7 @@ float WGuiImage::getHeight(){ return MAX(height,imgH+(2*margin)); } + JQuad * WGuiImage::getImage(){ if(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(); JQuad * q = getImage(); 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); setData(); ::options.save(); -} \ No newline at end of file +} diff --git a/projects/mtg/src/PriceList.cpp b/projects/mtg/src/PriceList.cpp index dcf20ca8e..e88063610 100644 --- a/projects/mtg/src/PriceList.cpp +++ b/projects/mtg/src/PriceList.cpp @@ -43,22 +43,22 @@ int PriceList::getPrice(int cardId){ char rarity = collection->getCardById(cardId)->getRarity(); switch(rarity){ case Constants::RARITY_M: - return 3000; + return Constants::PRICE_1M; break; case Constants::RARITY_R: - return 500; + return Constants::PRICE_1R; break; case Constants::RARITY_U: - return 100; + return Constants::PRICE_1U; break; case Constants::RARITY_C: - return 20; + return Constants::PRICE_1C; break; case Constants::RARITY_L: - return 5; + return Constants::PRICE_1L; break; default: - return 20; + return Constants::PRICE_1C; break; } diff --git a/projects/mtg/src/ShopItem.cpp b/projects/mtg/src/ShopItem.cpp index 80fe970ce..511e203a6 100644 --- a/projects/mtg/src/ShopItem.cpp +++ b/projects/mtg/src/ShopItem.cpp @@ -395,10 +395,12 @@ void ShopItems::ButtonPressed(int controllerId, int controlId){ int rnd = rand() % 8; if (rnd == 0) rare_or_mythic = Constants::RARITY_M; int sets[] = {setIds[showPriceDialog]}; + MTGSetInfo* si = setlist.getInfo(setIds[showPriceDialog]); - tempDeck->addRandomCards(1, sets,1,rare_or_mythic); - tempDeck->addRandomCards(3, sets,1,Constants::RARITY_U); - tempDeck->addRandomCards(11, sets,1,Constants::RARITY_C); + tempDeck->addRandomCards(si->booster[MTGSetInfo::RARE], sets,1,rare_or_mythic); + tempDeck->addRandomCards(si->booster[MTGSetInfo::UNCOMMON], sets,1,Constants::RARITY_U); + 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. //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; - for(int cycle=0;cycle<3;cycle++) + for(int cycle=0;cycle<4;cycle++) for (map::iterator it = tempDeck->cards.begin(); it!=tempDeck->cards.end(); it++){ MTGCard * c = tempDeck->getCardById(it->first); char rarity = c->getRarity(); - if((cycle == 0 && (rarity == Constants::RARITY_C || rarity == Constants::RARITY_L)) - || (cycle == 1 && rarity == Constants::RARITY_U) - || (cycle == 2 && (rarity == Constants::RARITY_R || rarity == Constants::RARITY_M))) + if((cycle == 0 && rarity == Constants::RARITY_L) + || (cycle == 1 && rarity == Constants::RARITY_C) + || (cycle == 2 && rarity == Constants::RARITY_U) + || (cycle == 3 && (rarity == Constants::RARITY_R || rarity == Constants::RARITY_M))) for (int j = 0; j < it->second; j++){ MTGCardInstance * card = NEW MTGCardInstance(c, NULL); displayCards[i] = card; diff --git a/projects/mtg/src/WResourceManager.cpp b/projects/mtg/src/WResourceManager.cpp index 7aa9af2fd..2f8e4056c 100644 --- a/projects/mtg/src/WResourceManager.cpp +++ b/projects/mtg/src/WResourceManager.cpp @@ -197,7 +197,7 @@ JQuad * WResourceManager::RetrieveCard(MTGCard * card, int style, int submode){ submode = submode | TEXTURE_SUB_CARD; - string filename = card->getSetName(); + string filename = setlist[card->setId]; filename += "/"; filename += card->getImageName(); int id = card->getMTGId(); @@ -650,13 +650,7 @@ string WResourceManager::cardFile(const string filename){ char zipname[512]; sprintf(zipname, "Res/sets/%s/%s.zip", set.c_str(),set.c_str()); if (fs->AttachZipFile(zipname)) - { - for(i = 0;i < filename.size();i++){ - if(filename[i] == '\\' || filename[i] == '/') - break; - } return filename.substr(i+1); - } } //Failure. Check for unzipped file in sets