From aa4f5793b8448c3284b27f759572ad14209fe377 Mon Sep 17 00:00:00 2001 From: "wagic.laurent" Date: Tue, 30 Jun 2009 13:38:55 +0000 Subject: [PATCH] Laurent - Updated MoveAll, Foreach and the ALifeModifierPutinplay. ALifeModifierPutinplay is now with TargetChooser, means it can probably be used for a wider range of cards (need to test megrim...). Also updated MoveAll (should now be able to target graveyard and hand). Last update is on the "countcards" means all foreach should now take graveyard and hand as legal target... . I did not test these additions yet...but test suite runs fine (it includes ankh of mishra so it means the first modification should go fine...). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If everything work fine it means also some hardcoded cards could be removed and softcoded like spoil of war, spoil of evil, ancestor choosen.. etc... GrĂ¼. L. --- projects/mtg/src/MTGAbility.cpp | 78 +++++++++++++++++++-------------- 1 file changed, 45 insertions(+), 33 deletions(-) diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index 6059b4348..ae83fca48 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -15,19 +15,22 @@ int AbilityFactory::countCards(TargetChooser * tc, Player * player, int option){ GameObserver * game = GameObserver::GetInstance(); for (int i = 0; i < 2 ; i++){ if (player && player!= game->players[i]) continue; - for (int j = game->players[i]->game->inPlay->nb_cards-1; j >=0 ; j--){ - MTGCardInstance * current = game->players[i]->game->inPlay->cards[j]; - if (tc->canTarget(current)){ - switch (option){ + MTGGameZone * zones[] = {game->players[i]->game->inPlay,game->players[i]->game->graveyard,game->players[i]->game->hand}; + for (int k = 0; k < 3; k++){ + for (int j = zones[k]->nb_cards-1; j >=0 ; j--){ + MTGCardInstance * current = zones[k]->cards[j]; + if (tc->canTarget(current)){ + switch (option){ case COUNT_POWER: result+= current->power; break; default: result++; break; - } - } - } + } + } + } + } } return result; } @@ -85,12 +88,15 @@ int AbilityFactory::moveAll(TargetChooser * tc, string destinationZone){ tc->source = NULL; // This is to prevent protection from... as objects that destroy all do not actually target GameObserver * g = GameObserver::GetInstance(); for (int i = 0; i < 2 ; i++){ - for (int j = g->players[i]->game->inPlay->nb_cards-1; j >=0 ; j--){ - MTGCardInstance * current = g->players[i]->game->inPlay->cards[j]; - if (tc->canTarget(current)){ - AZoneMover::moveTarget(current,destinationZone , source); - } - } + MTGGameZone * zones[] = {g->players[i]->game->inPlay,g->players[i]->game->graveyard,g->players[i]->game->hand}; + for (int k = 0; k < 3; k++){ + for (int j = zones[k]->nb_cards-1; j >=0 ; j--){ + MTGCardInstance * current = zones[k]->cards[j]; + if (tc->canTarget(current)){ + AZoneMover::moveTarget(current,destinationZone , source); + } + } + } } tc->source = source; //restore source return 1; @@ -968,11 +974,11 @@ int AbilityFactory::magicText(int id, Spell * spell, MTGCardInstance * card){ ManaCost * FinalOutput = NEW ManaCost(); if (lordType == PARSER_FOREACH){ int multiplier = countCards(lordTargets); - for (int i = 0; i < Constants::MTG_NB_COLORS; i++){ - if (output->hasColor(i)){ - FinalOutput->add(i,multiplier); - } - } + for (int i = 0; i < Constants::MTG_NB_COLORS; i++){ + if (output->hasColor(i)){ + FinalOutput->add(i,multiplier); + } + } game->addObserver (NEW AManaProducer(id, target,FinalOutput, input,doTap)); }else{ if (multi){ @@ -1109,8 +1115,11 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){ } case 1094: //Ank Of Mishra { - game->addObserver (NEW ALifeModifierPutinplay(_id,card,"land",-2,2,1)); - break; + TargetChooser * tc = NULL; + TargetChooserFactory tcf; + tc = tcf.createTargetChooser("land", card); + game->addObserver (NEW ALifeModifierPutinplay(_id,card,tc,-2,2,1)); + break; } case 1095: //Armageddon clock { @@ -1231,11 +1240,11 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){ } case 1105: //dingus Egg { -// ADingusEgg * ability = NEW ADingusEgg(_id,card); -// game->addObserver(ability); - game->addObserver (NEW ALifeModifierPutinplay(_id,card,"land",-2,2,0)); - - break; + TargetChooser * tc = NULL; + TargetChooserFactory tcf; + tc = tcf.createTargetChooser("land", card); + game->addObserver (NEW ALifeModifierPutinplay(_id,card,tc,-2,2,0)); + break; } case 1106: //Disrupting Scepter { @@ -1383,12 +1392,12 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){ case 1312: //Red Elemental Blast { if (card->target){ - card->target->controller()->game->putInGraveyard(card->target); - }else{ - Spell * starget = spell->getNextSpellTarget(); - game->mLayers->stackLayer()->Fizzle(starget); - } - break; + card->target->controller()->game->putInGraveyard(card->target); + }else{ + Spell * starget = spell->getNextSpellTarget(); + game->mLayers->stackLayer()->Fizzle(starget); + } + break; } case 1136: //Soul Net { @@ -1960,8 +1969,11 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){ //-- addon 10E--- case 129740: // Soul Warden { - game->addObserver ( NEW ALifeModifierPutinplay(_id,card,"creature",1,1,1)); - break; + TargetChooser * tc = NULL; + TargetChooserFactory tcf; + tc = tcf.createTargetChooser("creature", card); + game->addObserver ( NEW ALifeModifierPutinplay(_id,card,tc,1,1,1)); + break; } case 129710: //Angelic Chorus