Fixes for Boosters in the Shop. Fixes issue 644 and issue 621
This commit is contained in:
@@ -321,12 +321,16 @@ void GameStateShop::purchaseBooster(int controlId)
|
||||
ddw->Sort(WSrcCards::SORT_COLLECTOR);
|
||||
else
|
||||
ddw->Sort(WSrcCards::SORT_RARITY);
|
||||
|
||||
for (int x = 0; x < ddw->Size(); x++)
|
||||
{
|
||||
MTGCard * c = ddw->getCard(x);
|
||||
MTGCardInstance * ci = NEW MTGCardInstance(c, NULL);
|
||||
boosterDisplay->AddCard(ci);
|
||||
subBooster.push_back(ci);
|
||||
for (int copies = 0; copies < ddw->count(c); ++copies)
|
||||
{
|
||||
MTGCardInstance * ci = NEW MTGCardInstance(c, NULL);
|
||||
boosterDisplay->AddCard(ci);
|
||||
subBooster.push_back(ci);
|
||||
}
|
||||
}
|
||||
SAFE_DELETE(ddw);
|
||||
|
||||
@@ -963,7 +967,7 @@ bool ShopBooster::unitTest()
|
||||
DeckDataWrapper* ddw = NEW DeckDataWrapper(d);
|
||||
bool res = true;
|
||||
|
||||
int u = 0, r = 0;
|
||||
int u = 0, r = 0, s = 0;
|
||||
int card = 0;
|
||||
for(int i=0;i<ddw->Size(true);i++)
|
||||
{
|
||||
@@ -973,12 +977,16 @@ bool ShopBooster::unitTest()
|
||||
r+=ddw->count(c);
|
||||
else if(c->getRarity() == Constants::RARITY_U)
|
||||
u+=ddw->count(c);
|
||||
else if(c->getRarity() == Constants::RARITY_S)
|
||||
s+=ddw->count(c);
|
||||
card++;
|
||||
}
|
||||
int count = ddw->getCount();
|
||||
SAFE_DELETE(ddw);
|
||||
SAFE_DELETE(d);
|
||||
if(r != 1 || u != 3 )
|
||||
//Note: When there are special cards, the count IS going to be messed up, so do not perform the check for Rare and Uncommon in that case
|
||||
//also see http://code.google.com/p/wagic/issues/detail?id=644
|
||||
if(!s && (r != 1 || u != 3) )
|
||||
{
|
||||
sprintf(result, "<span class=\"error\">==Unexpected rarity count==</span><br />");
|
||||
TestSuite::Log(result);
|
||||
|
||||
@@ -46,9 +46,11 @@ int MTGPackSlot::add(WSrcCards * ocean, MTGDeck *to, int carryover)
|
||||
myPool = MTGPack::getPool(pool);
|
||||
if (!myPool)
|
||||
myPool = ocean;
|
||||
|
||||
for (int i = 0; i < amt; i++)
|
||||
{
|
||||
size_t pos = rand() % entries.size();
|
||||
std::random_shuffle(entries.begin(), entries.end());
|
||||
size_t pos = 0;
|
||||
while (pos < entries.size() && entries[pos]->addCard(myPool, to))
|
||||
pos++;
|
||||
if (pos == entries.size())
|
||||
@@ -378,6 +380,10 @@ MTGPack * MTGPacks::getDefault()
|
||||
defaultBooster.slotss.push_back(ps);
|
||||
defaultBooster.bValid = true;
|
||||
defaultBooster.unlockStatus = 1;
|
||||
for (size_t i = 0; i < defaultBooster.slotss.size(); ++ i)
|
||||
{
|
||||
defaultBooster.slotss[i]->addEntry(NEW MTGPackEntryRandom("rarity:special;"));
|
||||
}
|
||||
}
|
||||
}
|
||||
return &defaultBooster;
|
||||
|
||||
Reference in New Issue
Block a user