diff --git a/projects/mtg/bin/Res/test/_tests.txt b/projects/mtg/bin/Res/test/_tests.txt index 8efc8ac72..edfb0f4ce 100644 --- a/projects/mtg/bin/Res/test/_tests.txt +++ b/projects/mtg/bin/Res/test/_tests.txt @@ -28,6 +28,7 @@ ardakar_wastes.txt ascendant_evincar.txt ascendant_evincar2.txt ascendant_evincar3.txt +ashen_firebeast.txt blessed_wine.txt bottle_gnomes.txt boggart_arsonists.txt @@ -119,4 +120,5 @@ zombify.txt ######################## #Momir Basic Tests ######################## -momir/keldon_warlord.txt \ No newline at end of file +momir/keldon_warlord.txt +momir/overcost.txt \ No newline at end of file diff --git a/projects/mtg/bin/Res/test/ashen_firebeast.txt b/projects/mtg/bin/Res/test/ashen_firebeast.txt new file mode 100644 index 000000000..e472397ee --- /dev/null +++ b/projects/mtg/bin/Res/test/ashen_firebeast.txt @@ -0,0 +1,20 @@ +#Testing Ashen firebeast: {1}{R}: Ashen Firebeast deals 1 damage to each creature without flying. +[INIT] +FIRSTMAIN +[PLAYER1] +inplay:Ashen Firebeast,Benalish Hero,Birds of Paradise +manapool:{1}{R} +[PLAYER2] +inplay:plague rats,drudge skelettons,El_Hajaj,Air elemental +[DO] +Ashen Firebeast +[ASSERT] +FIRSTMAIN +[PLAYER1] +graveyard:Benalish Hero +inplay:Ashen Firebeast,Birds of Paradise +manapool:{0} +[PLAYER2] +graveyard:plague rats,drudge skelettons,El_Hajaj +inplay:Air elemental +[END] \ No newline at end of file diff --git a/projects/mtg/bin/Res/test/momir/overcost.txt b/projects/mtg/bin/Res/test/momir/overcost.txt new file mode 100644 index 000000000..4a60b901a --- /dev/null +++ b/projects/mtg/bin/Res/test/momir/overcost.txt @@ -0,0 +1,18 @@ +#Testing That Paying a great cost does not crash momir +MOMIR +[INIT] +FIRSTMAIN +[PLAYER1] +manapool:{20} +hand:plains +[PLAYER2] +[DO] +plains +choice 1 +[ASSERT] +FIRSTMAIN +[PLAYER1] +graveyard:plains +inplay:* +[PLAYER2] +[END] \ No newline at end of file diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index 81d70dd91..114dd19e8 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -1350,6 +1350,34 @@ class AForeach:public ListMaintainerAbility{ }; +//Damage all.... ActivatedAbility +class AAllDamager:public ActivatedAbility{ + public: + int damage; + AAllDamager(int _id, MTGCardInstance * _source, ManaCost * _cost, int _damage, TargetChooser * _tc ,int doTap =1):ActivatedAbility(_id,_source,_cost,0,doTap),damage(_damage){ + tc = _tc; + + } + + int resolve(){ + AbilityFactory af; + af.damageAll(tc,damage); + return 1; + } + + const char * getMenuText(){ + return "Damage All..."; + } + + virtual ostream& toString(ostream& out) const + { + out << "AAllDamager ::: damage : " << damage + << " ("; + return ActivatedAbility::toString(out) << ")"; + } + +}; + /* Standard Damager, can choose a NEW target each time the price is paid */ class ADamager:public TargetAbility{ diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index dc2731533..e00d6e561 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -565,7 +565,12 @@ int AbilityFactory::magicText(int id, Spell * spell, MTGCardInstance * card){ } if (tc){ if (all){ - damageAll(tc,damage); + if (cost){ + MTGAbility * a = NEW AAllDamager(id, card, cost, damage, tc,doTap); + game->addObserver(a); + }else{ + damageAll(tc,damage); + } }else{ MTGAbility * a = NEW ADamager(id, card, cost, damage, tc,doTap); if (multi){ @@ -578,7 +583,6 @@ int AbilityFactory::magicText(int id, Spell * spell, MTGCardInstance * card){ if (multi){ Damageable * target = parseCollateralTarget(card, s); if (!target) target = spell->getNextDamageableTarget(); - if (!target)OutputDebugString("NO TARGET FOR DAMAGE\n"); multi->Add(NEW DamageEvent(card,target,damage)); }else{ game->mLayers->stackLayer()->addDamage(card,spell->getNextDamageableTarget(), damage); diff --git a/projects/mtg/src/MTGRules.cpp b/projects/mtg/src/MTGRules.cpp index 9bf44c09e..4e742844c 100644 --- a/projects/mtg/src/MTGRules.cpp +++ b/projects/mtg/src/MTGRules.cpp @@ -241,11 +241,17 @@ MTGCardInstance * MTGMomirRule::genCreature( int id){ } int MTGMomirRule::genRandomCreatureId(int convertedCost){ - if (convertedCost > 20) convertedCost = 20; + if (convertedCost >= 20) convertedCost = 19; int total_cards = 0; int i = convertedCost; while (!total_cards && i >=0){ +#ifdef WIN32 + char buf[4096]; + sprintf(buf,"Converted Cost in momir: %i\n", i); + OutputDebugString(buf); +#endif total_cards = pool[i].size(); + convertedCost = i; i--; } if (!total_cards) return 0; diff --git a/projects/mtg/src/TestSuiteAI.cpp b/projects/mtg/src/TestSuiteAI.cpp index a17ca34d9..db4dcf385 100644 --- a/projects/mtg/src/TestSuiteAI.cpp +++ b/projects/mtg/src/TestSuiteAI.cpp @@ -19,6 +19,7 @@ TestSuiteAI::TestSuiteAI(TestSuite * _suite, int playerId):AIPlayer(_suite->buil int TestSuite::getMTGId(string cardName){ int cardnb = atoi(cardName.c_str()); if (cardnb) return cardnb; + if (cardName.compare("*") == 0) return -1; //Any card MTGCard * card = collection->getCardByName(cardName); if (card) return card->getMTGId(); return 0; @@ -329,13 +330,15 @@ int TestSuite::assertGame(){ return 0; } for (int k = 0; k < endState.playerData[i].zones[j].nbitems; k++){ - int cardid = endState.playerData[i].zones[j].cards[k]; - MTGCardInstance * card = getCardByMTGId(cardid); - if (!card || !zone->hasCard(card)){ - sprintf(result, "==Card ID not the same. Didn't find %i
", cardid); - Log(result); - error++; - } + int cardid = endState.playerData[i].zones[j].cards[k]; + if (cardid != -1){ + MTGCardInstance * card = getCardByMTGId(cardid); + if (!card || !zone->hasCard(card)){ + sprintf(result, "==Card ID not the same. Didn't find %i
", cardid); + Log(result); + error++; + } + } } } }