WSrcCards * MTGPack::getPool(string poolstr) { WSrcCards * mySrc = NULL; size_t s = poolstr.find("all"); WCFilterFactory * ff = WCFilterFactory::GetInstance(); if (s == string::npos) { //Default to just unlocked cards mySrc = NEW WSrcUnlockedCards(); s = poolstr.find("unlocked"); string sub = poolstr; if (s != string::npos) sub = trim(poolstr.substr(s + 8)); if (sub.size()) { mySrc->addFilter(ff->Construct(sub)); mySrc->bakeFilters(); } } else { //Use everything. mySrc = NEW WSrcCards(); string sub = poolstr.substr(s + 3); if (sub.size()) { mySrc->addFilter(ff->Construct(sub)); mySrc->loadMatches(MTGCollection()); mySrc->bakeFilters(); } else mySrc->loadMatches(MTGCollection()); } mySrc->Shuffle(); return mySrc; }
void GameStateShop::Start() { menu = NULL; bListCards = false; mTouched = false; mStage = STAGE_FADE_IN; mElapsed = 0; needLoad = true; booster = NULL; srcCards = NEW WSrcUnlockedCards(0); srcCards->setElapsed(15); srcCards->addFilter(NEW WCFilterNOT(NEW WCFilterRarity("T"))); srcCards->addFilter(NEW WCFilterNOT(NEW WCFilterSet(MTGSets::INTERNAL_SET))); bigSync = 0; shopMenu = NEW WGuiMenu(JGE_BTN_DOWN, JGE_BTN_UP, true, &bigSync); MTGAllCards * ac = MTGCollection(); playerdata = NEW PlayerData(ac); myCollection = NEW DeckDataWrapper(playerdata->collection); pricelist = NEW PriceList("settings/prices.dat", ac); for (int i = 0; i < SHOP_SLOTS; i++) { WGuiCardDistort * dist; if (i < BOOSTER_SLOTS) dist = NEW WGuiCardDistort(NULL, true); else { dist = NEW WGuiCardDistort(srcCards, true); dist->mOffset.setOffset(i - BOOSTER_SLOTS); } dist->xy = WDistort(_x1[i], _y1[i], _x2[i], _y2[i], _x3[i], _y3[i], _x4[i], _y4[i]); shopMenu->Add(NEW WGuiButton(dist, -102, i, this)); } shopMenu->Entering(JGE_BTN_NONE); if (!bigDisplay) { bigDisplay = NEW WGuiCardImage(srcCards); bigDisplay->mOffset.Hook(&bigSync); bigDisplay->mOffset.setOffset(-BOOSTER_SLOTS); bigDisplay->setX(385); bigDisplay->setY(135); } for (int i = 0; i < 8; ++i) { std::ostringstream stream; stream << "iconspsp" << i; pspIcons[i] = WResourceManager::Instance()->RetrieveQuad("iconspsp.png", (float) i * 32, 0, 32, 32, stream.str(), RETRIEVE_MANAGE); pspIcons[i]->SetHotSpot(16, 16); } JRenderer::GetInstance()->EnableVSync(true); taskList = NULL; packlist = NEW MTGPacks(); packlist->loadAll(); load(); }
bool MTGPack::meetsRequirements() { bool unlocked = true; WCFilterFactory * ff = WCFilterFactory::GetInstance(); WSrcCards * myC = getPool(pool); if (!myC || myC->Size() < maxCards) unlocked = false; //Top pool lacks cards. SAFE_DELETE(myC); if (!check.size() || !unlocked) return unlocked; myC = NEW WSrcUnlockedCards(); //Requirements are independent of pool; WCardFilter * cf = ff->Construct(check); unlocked = !myC->isEmptySet(cf); //Quick check for empty set status. SAFE_DELETE(cf); //delete requirement filter SAFE_DELETE(myC); //delete pool. return unlocked; }