Jeck - Fix for issue 320, also fix for countByName.
This commit is contained in:
@@ -327,7 +327,7 @@ void GameStateDeckViewer::Update(float dt)
|
||||
{
|
||||
MTGCard * card = cardIndex[2];
|
||||
if (card && displayed_deck->count(card)){
|
||||
int price = pricelist->getSellPrice(card->getMTGId());
|
||||
price = pricelist->getSellPrice(card->getMTGId());
|
||||
sprintf(buffer,"%s : %i %s",_(card->data->getName()).c_str(),price,_("credits").c_str());
|
||||
sellMenu = NEW SimpleMenu(2,this,Constants::MAIN_FONT,SCREEN_WIDTH-300,SCREEN_HEIGHT/2,buffer);
|
||||
sellMenu->Add(20,"Yes");
|
||||
|
||||
@@ -145,9 +145,13 @@ string GameStateShop::descPurchase(int controlId, bool tiny){
|
||||
return buffer;
|
||||
}
|
||||
|
||||
if(tiny)
|
||||
return name;
|
||||
if(tiny){
|
||||
if(controlId < BOOSTER_SLOTS)
|
||||
return name;
|
||||
|
||||
sprintf(buffer,_("%s (%i)").c_str(),name.c_str(),mCounts[controlId]);
|
||||
return buffer;
|
||||
}
|
||||
if(mCounts[controlId] < 1)
|
||||
sprintf(buffer,_("%s : %i credits").c_str(),name.c_str(),mPrices[controlId]);
|
||||
else
|
||||
@@ -224,8 +228,8 @@ void GameStateShop::purchaseCard(int controlId){
|
||||
return;
|
||||
myCollection->Add(c);
|
||||
playerdata->credits -= mPrices[controlId];
|
||||
mCounts[controlId]++;
|
||||
mInventory[controlId]--;
|
||||
updateCounts();
|
||||
mTouched = true;
|
||||
menu->Close();
|
||||
}
|
||||
@@ -291,7 +295,13 @@ int GameStateShop::purchasePrice(int offset){
|
||||
}
|
||||
return (int) price + price * (filteradd*srcCards->filterFee());
|
||||
}
|
||||
|
||||
void GameStateShop::updateCounts(){
|
||||
for(int i=BOOSTER_SLOTS;i<SHOP_ITEMS;i++){
|
||||
MTGCard * c = srcCards->getCard(i-BOOSTER_SLOTS);
|
||||
if(!c) mCounts[i] = 0;
|
||||
else mCounts[i] = myCollection->countByName(c);
|
||||
}
|
||||
}
|
||||
void GameStateShop::load(){
|
||||
int nbsets = 0;
|
||||
int nbboostersets = 0;
|
||||
|
||||
@@ -53,7 +53,6 @@ JQuad * WSrcCards::getImage( int offset){
|
||||
return resources.RetrieveCard(getCard(offset),RETRIEVE_EXISTING);
|
||||
}
|
||||
#endif
|
||||
|
||||
return resources.RetrieveCard(getCard(offset));
|
||||
}
|
||||
JQuad * WSrcCards::getThumb( int offset){
|
||||
@@ -397,11 +396,14 @@ int WSrcDeck::countByName(MTGCard * card, bool editions){
|
||||
int total = 0;
|
||||
vector<MTGCard*>::iterator it;
|
||||
for(it = cards.begin();it!=cards.end();it++){
|
||||
if(*it && (*it)->data->getLCName() == card->data->getLCName()){
|
||||
if(*it && (*it)->data->getLCName() == name){
|
||||
if(editions)
|
||||
total++;
|
||||
else
|
||||
total += copies[card->getMTGId()];
|
||||
else{
|
||||
map<int,int>::iterator mi = copies.find((*it)->getMTGId());
|
||||
if(mi != copies.end())
|
||||
total += mi->second;
|
||||
}
|
||||
}
|
||||
}
|
||||
return total;
|
||||
|
||||
Reference in New Issue
Block a user