diff --git a/projects/mtg/bin/Res/sets/ICE/_cards.dat b/projects/mtg/bin/Res/sets/ICE/_cards.dat index 81822d236..1eb5847c4 100644 --- a/projects/mtg/bin/Res/sets/ICE/_cards.dat +++ b/projects/mtg/bin/Res/sets/ICE/_cards.dat @@ -1292,7 +1292,7 @@ mana={G}{G} [card] text=Bury all artifacts, creatures, and lands. id=2631 -auto=destroy +auto=bury all(artifact,creature,land) name=Jokulhaups rarity=R type=Sorcery @@ -1350,6 +1350,7 @@ mana={B} [/card] [card] text=Destroy all white permanents. +auto=destroy all(*[white]) id=2606 name=Anarchy rarity=U diff --git a/projects/mtg/bin/Res/sets/RV/_cards.dat b/projects/mtg/bin/Res/sets/RV/_cards.dat index 662eae378..48e20034f 100644 --- a/projects/mtg/bin/Res/sets/RV/_cards.dat +++ b/projects/mtg/bin/Res/sets/RV/_cards.dat @@ -69,6 +69,7 @@ mana={2} [/card] [card] text=Destroy all lands. +auto=destroy all(land) id=1328 name=Armageddon rarity=R @@ -737,6 +738,7 @@ subtype=Aura [card] text=Destroy all Plains. id=1293 +auto=destroy all(plains) name=Flashfires rarity=U type=Sorcery @@ -1885,6 +1887,7 @@ mana={1}{R} [/card] [card] text=Destroy all artifacts. They can't be regenerated. +auto=bury all(artifact) id=1317 name=Shatterstorm rarity=U @@ -2089,6 +2092,7 @@ toughness=1 [card] text=Destroy all enchantments. id=1270 +auto=destroy all(enchantment) name=Tranquility rarity=C type=Sorcery @@ -2107,6 +2111,7 @@ subtype=Island Forest [card] text=Destroy all Islands. id=1271 +auto=destroy all(island) name=Tsunami rarity=U type=Sorcery @@ -2434,6 +2439,7 @@ mana={1} [/card] [card] text=Destroy all creatures. They can't be regenerated. +auto=bury all(creature) id=1372 name=Wrath of God rarity=R diff --git a/projects/mtg/bin/Res/test/_tests.txt b/projects/mtg/bin/Res/test/_tests.txt index ede37459e..1a8868ec7 100644 --- a/projects/mtg/bin/Res/test/_tests.txt +++ b/projects/mtg/bin/Res/test/_tests.txt @@ -11,6 +11,7 @@ generic/wither.txt ######################## #Specific Cards ######################## +anarchy.txt animate_dead.txt animate_dead2.txt ascendant_evincar.txt @@ -45,4 +46,5 @@ shock.txt stasis.txt terror.txt volcanic_island.txt -white_knight1.txt \ No newline at end of file +white_knight1.txt +wrath_of_god.txt \ No newline at end of file diff --git a/projects/mtg/bin/Res/test/anarchy.txt b/projects/mtg/bin/Res/test/anarchy.txt new file mode 100644 index 000000000..c896cd3d4 --- /dev/null +++ b/projects/mtg/bin/Res/test/anarchy.txt @@ -0,0 +1,21 @@ +#Does anarchy destroy all white permanents ? +[INIT] +FIRSTMAIN +[PLAYER1] +hand:2606 +manapool:{2}{R}{R} +inplay:2672,2718 +[PLAYER2] +inplay:2697,2732, 1393, 2771 +[DO] +2606 +[ASSERT] +FIRSTMAIN +[PLAYER1] +graveyard:2606,2672 +inplay:2718 +manapool:{0} +[PLAYER2] +graveyard:2732,2697 +inplay:1393,2771 +[END] \ No newline at end of file diff --git a/projects/mtg/bin/Res/test/wrath_of_god.txt b/projects/mtg/bin/Res/test/wrath_of_god.txt new file mode 100644 index 000000000..05f54c5c5 --- /dev/null +++ b/projects/mtg/bin/Res/test/wrath_of_god.txt @@ -0,0 +1,21 @@ +#Does Wrath of god destroy all creatures ? +[INIT] +FIRSTMAIN +[PLAYER1] +hand:1372 +manapool:{2}{W}{W} +inplay:1188,1145,1250,1236,1092,1385 +[PLAYER2] +inplay:1323,1268,1151,1393 +[DO] +1372 +[ASSERT] +FIRSTMAIN +[PLAYER1] +graveyard:1188,1145,1250,1236,1372 +inplay:1092,1385 +manapool:{0} +[PLAYER2] +graveyard:1323,1268 +inplay:1393,1151 +[END] \ No newline at end of file diff --git a/projects/mtg/include/MTGAbility.h b/projects/mtg/include/MTGAbility.h index ea2308907..5f2746dd9 100644 --- a/projects/mtg/include/MTGAbility.h +++ b/projects/mtg/include/MTGAbility.h @@ -178,8 +178,7 @@ public: /* Ability Factory */ class AbilityFactory{ private: - int destroyAllFromTypeInPlay(const char * type, MTGCardInstance * source, int bury = 0); - int destroyAllFromColorInPlay(int color, MTGCardInstance * source, int bury = 0); + int destroyAllInPlay(TargetChooser * tc, int bury = 0); int putInPlayFromZone(MTGCardInstance * card, MTGGameZone * zone, Player * p); Trigger * parseTrigger(string magicText); public: diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index 9545e2f7e..e4e565e61 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -8,12 +8,14 @@ #include "../include/CardGui.h" #include "../include/MTGDeck.h" -int AbilityFactory::destroyAllFromTypeInPlay(const char * type, MTGCardInstance * source, int bury){ + +int AbilityFactory::destroyAllInPlay(TargetChooser * tc, int bury){ + tc->source = NULL; // This is to prevent protection from... as objects that destroy all do not actually target GameObserver * game = GameObserver::GetInstance(); for (int i = 0; i < 2 ; i++){ for (int j = 0; j < game->players[i]->game->inPlay->nb_cards; j++){ MTGCardInstance * current = game->players[i]->game->inPlay->cards[j]; - if (current->hasType(type)){ + if (tc->canTarget(current)){ if (bury){ game->players[i]->game->putInGraveyard(current); }else{ @@ -25,22 +27,6 @@ int AbilityFactory::destroyAllFromTypeInPlay(const char * type, MTGCardInstance return 1; } -int AbilityFactory::destroyAllFromColorInPlay(int color, MTGCardInstance * source, int bury){ - GameObserver * game = GameObserver::GetInstance(); - for (int i = 0; i < 2 ; i++){ - for (int j = 0; j < game->players[i]->game->inPlay->nb_cards; j++){ - MTGCardInstance * current = game->players[i]->game->inPlay->cards[j]; - if (current->hasColor(color)){ - if (bury){ - game->players[i]->game->putInGraveyard(current); - }else{ - game->mLayers->stackLayer()->addPutInGraveyard(current); - } - } - } - } - return 1; -} int AbilityFactory::putInPlayFromZone(MTGCardInstance * card, MTGGameZone * zone, Player * p){ Spell * spell = NEW Spell(card); @@ -122,9 +108,9 @@ int AbilityFactory::magicText(int id, Spell * spell, MTGCardInstance * card){ found = s.find("target("); if (found != string::npos){ int end = s.find(")"); - string target = s.substr(found + 7,end - found - 7); + string starget = s.substr(found + 7,end - found - 7); TargetChooserFactory tcf; - tc = tcf.createTargetChooser(target, card); + tc = tcf.createTargetChooser(starget, card); } @@ -205,23 +191,43 @@ int AbilityFactory::magicText(int id, Spell * spell, MTGCardInstance * card){ found = s.find("bury"); if (found != string::npos){ if (dryMode) return BAKA_EFFECT_BAD; - if (tc){ - game->addObserver(NEW ABurier(id, card,tc)); - }else{ - target->controller()->game->putInGraveyard(target); - } + found = s.find("all("); + if (found != string::npos){ + int end = s.find(")"); + string starget = s.substr(found + 4,end - found - 4); + TargetChooserFactory tcf; + TargetChooser * targetAll = tcf.createTargetChooser(starget, card); + this->destroyAllInPlay(targetAll,1); + delete targetAll; + }else{ + if (tc){ + game->addObserver(NEW ABurier(id, card,tc)); + }else{ + target->controller()->game->putInGraveyard(target); + } + } result++; continue; } //Destroy found = s.find("destroy"); if (found != string::npos){ - if (dryMode) return BAKA_EFFECT_BAD; - if (tc){ - game->addObserver(NEW ADestroyer(id, card,tc)); - }else{ - game->mLayers->stackLayer()->addPutInGraveyard(target); - } + if (dryMode) return BAKA_EFFECT_BAD; //TODO compute according to nb in case of destroy all + found = s.find("all("); + if (found != string::npos){ + int end = s.find(")"); + string starget = s.substr(found + 4,end - found - 4); + TargetChooserFactory tcf; + TargetChooser * targetAll = tcf.createTargetChooser(starget, card); + this->destroyAllInPlay(targetAll); + delete targetAll; + }else{ + if (tc){ + game->addObserver(NEW ADestroyer(id, card,tc)); + }else{ + game->mLayers->stackLayer()->addPutInGraveyard(target); + } + } result++; continue; } @@ -1044,16 +1050,8 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){ spell->getNextPlayerTarget()->life += x; break; } - case 1270: //tranquility - { - destroyAllFromTypeInPlay("enchantment", card); - break; - } - case 1271: //Tsunami - { - destroyAllFromTypeInPlay("island", card); - break; - } + + case 1231: //Volcanic Eruption { int x = spell->cost->getConvertedCost() - 3; @@ -1126,11 +1124,7 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){ game->addObserver(NEW AFastbond(_id, card)); break; } - case 1293: //FlashFires - { - destroyAllFromTypeInPlay("plains", card); - break; - } + case 1301: // Keldon Warlord { game->addObserver(NEW AKeldonWarlord(_id, card)); @@ -1151,11 +1145,6 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){ game->addObserver(NEW AOrcishOriflame(_id, card)); break; } - case 1317: //ShatterStorm - { - destroyAllFromTypeInPlay("artifact", card, 1); - break; - } case 1326: //Wheel of fortune { for (int i = 0; i < 2; i++){ @@ -1170,11 +1159,6 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){ } break; } - case 1328: //Armageddon - { - destroyAllFromTypeInPlay("land", card); - break; - } case 1331: //Black Ward { game->addObserver(NEW AProtectionFrom( _id,card, card->target, MTG_COLOR_BLACK)); @@ -1281,11 +1265,7 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){ game->addObserver(NEW AProtectionFrom( _id,card, card->target, MTG_COLOR_WHITE)); break; } - case 1372: //Wrath of God - { - destroyAllFromTypeInPlay("creature", card); //TODO -> bury !!! - break; - } + //Addons The Dark case 1797: //Inferno does 6 damage to all players and all creatures. @@ -1308,18 +1288,8 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){ break; } - case 1818: //Tivadar's Crusade - { - destroyAllFromTypeInPlay("goblin", card); - break; - } //Addons Legends - case 1470: //Acid Rain - { - destroyAllFromTypeInPlay("forest", card); - break; - } case 1427: //Abomination { game->addObserver(NEW AAbomination(_id,card)); @@ -1342,13 +1312,6 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){ break; } //Addons ICE-AGE Cards - case 2631: //Jokulhaups - { - destroyAllFromTypeInPlay("artifact", card); - destroyAllFromTypeInPlay("creature", card); - destroyAllFromTypeInPlay("land", card); - break; - } case 2650: //Pyroclasm Need to be improved copied from hurricane with does 0 dammage to player and does 2 dammage to each creature { @@ -1389,11 +1352,7 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){ game->currentlyActing()->getManaPool()->add(MTG_COLOR_BLACK, mana); break; } - case 2606: //Anarchy - { - destroyAllFromColorInPlay(MTG_COLOR_WHITE, card); - break; - } + case 2474: //Minion of Leshrac { game->addObserver(NEW AMinionofLeshrac( _id, card)); diff --git a/projects/mtg/src/TargetChooser.cpp b/projects/mtg/src/TargetChooser.cpp index 5f4cd7ede..5a80fa62d 100644 --- a/projects/mtg/src/TargetChooser.cpp +++ b/projects/mtg/src/TargetChooser.cpp @@ -159,6 +159,9 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta cd->colors[cid] = -1; }else{ cd->colors[cid] = 1; +#ifdef WIN32 +OutputDebugString("COLOR FOUND !!!"); +#endif } } }