-display the number of cards you own with the same name for each individual card in the shop
This commit is contained in:
wagic.the.homebrew@gmail.com
2009-05-20 13:50:58 +00:00
parent 283987c0eb
commit 04d429b82c
4 changed files with 73 additions and 9 deletions

View File

@@ -74,6 +74,50 @@ int DeckDataWrapper::Remove(MTGCard * card){
return 1;
}
int DeckDataWrapper::count(MTGCard * card){
if(cards.find(card) == cards.end()){
cards[card] = 0;
}
return cards[card];
}
int DeckDataWrapper::countByName(MTGCard * card){
string name = card->name;
int total = 0;
map<MTGCard *,int,Cmp1>::iterator it;
it = cards.find(card);
if(cards.find(card) == cards.end()){
cards[card] = 0;
it = cards.find(card);
}
while(it !=cards.end()){
MTGCard * _card = (*it).first;
if (name.compare(_card->name) !=0){
it = cards.end();
}else{
total+= (*it).second;
it++;
}
}
it = cards.find(card);
it--;
while(1){
MTGCard * _card = (*it).first;
if (name.compare(_card->name) !=0){
break;
}else{
total+= (*it).second;
if (it == cards.begin()) break;
it--;
}
}
return total;
}
MTGCard * DeckDataWrapper::getNext(MTGCard * previous, int color){
map<MTGCard *,int,Cmp1>::iterator it;