- fixed a bug (crash if a card that had an ability until end of turn would be put into the graveyard before the end of the turn)
- Added a new game Mode : Random 1 or 2 color.
This commit is contained in:
wagic.the.homebrew@gmail.com
2009-07-18 08:50:14 +00:00
parent 4606d88048
commit 3e7ecb3016
15 changed files with 155 additions and 20 deletions
+25 -4
View File
@@ -351,6 +351,8 @@ MTGDeck::MTGDeck(TexturesCache * cache, MTGAllCards * _allcards){
mCache = cache;
total_cards = 0;
database = _allcards;
filename ="";
meta_name = "";
}
MTGDeck::MTGDeck(const char * config_file, TexturesCache * cache, MTGAllCards * _allcards, int meta_only){
@@ -418,10 +420,20 @@ MTGCard * MTGDeck::getCardById(int mtgId){
return database->getCardById(mtgId);
}
int MTGDeck::addRandomCards(int howmany, int setId, int rarity, const char * _subtype){
int MTGDeck::addRandomCards(int howmany, int setId, int rarity, const char * _subtype, int * colors, int nbcolors){
int unallowedColors[Constants::MTG_NB_COLORS+1];
for (int i=0; i < Constants::MTG_NB_COLORS; ++i){
if (nbcolors) unallowedColors[i] = 1;
else unallowedColors[i] = 0;
}
for (int i=0; i < nbcolors; ++i){
unallowedColors[colors[i]] = 0;
}
int collectionTotal = database->totalCards();
if (!collectionTotal) return 0;
if (setId == -1 && rarity == -1 && !_subtype){
if (setId == -1 && rarity == -1 && !_subtype && !nbcolors){
for (int i = 0; i < howmany; i++){
add(database->randomCardId());
}
@@ -440,8 +452,17 @@ int MTGDeck::addRandomCards(int howmany, int setId, int rarity, const char * _su
(rarity == -1 || card->getRarity()==rarity) &&
(!_subtype || card->hasSubtype(subtype))
){
subcollection.push_back(card->getId());
subtotal++;
int ok = 1;
for (int j=0; j < Constants::MTG_NB_COLORS; ++j){
if (unallowedColors[j] && card->hasColor(j)){
ok = 0;
break;
}
}
if (ok){
subcollection.push_back(card->getId());
subtotal++;
}
}
}
if (subtotal == 0) return 0;