From 7f5312be20c56fae97153c9b229b6f77e4b192c2 Mon Sep 17 00:00:00 2001 From: "wagic.the.homebrew" Date: Sat, 6 Dec 2008 14:50:10 +0000 Subject: [PATCH] Erwan - fixed a bug with creature bond - fixed a bug with control magic --- projects/mtg/bin/Res/test/_tests.txt | 1 + projects/mtg/bin/Res/test/creature_bond.txt | 43 +++++++++++++++++++++ projects/mtg/include/AllAbilities.h | 13 +++++-- projects/mtg/src/MTGAbility.cpp | 2 +- 4 files changed, 54 insertions(+), 5 deletions(-) create mode 100644 projects/mtg/bin/Res/test/creature_bond.txt diff --git a/projects/mtg/bin/Res/test/_tests.txt b/projects/mtg/bin/Res/test/_tests.txt index 9bbcc3a43..10b52f82d 100644 --- a/projects/mtg/bin/Res/test/_tests.txt +++ b/projects/mtg/bin/Res/test/_tests.txt @@ -25,6 +25,7 @@ control_magic2.txt counsel_of_the_soratami.txt counterspell.txt counterspell2.txt +creature_bond.txt drain_life.txt flare.txt force_of_nature.txt diff --git a/projects/mtg/bin/Res/test/creature_bond.txt b/projects/mtg/bin/Res/test/creature_bond.txt new file mode 100644 index 000000000..765d1d0d1 --- /dev/null +++ b/projects/mtg/bin/Res/test/creature_bond.txt @@ -0,0 +1,43 @@ +#Testing Creature Bond on a fire elemental in opponent's play, then testing what happens when the elemental gets killed. +#opponent should lose life +[INIT] +FIRSTMAIN +[PLAYER1] +hand:1197 +inplay:1239 +manapool:{1}{U} +[PLAYER2] +inplay:1290 +[DO] +1197 +1290 +eot +#untap +next +#upkeep +next +#draw +next +#main 1 +next +#cbt begins +next +#attackers +1290 +next +#defensers +1239 +next +#damage +next +#combat end +[ASSERT] +COMBATEND +[PLAYER1] +graveyard:1197,1239 +manapool:{0} +life:20 +[PLAYER2] +graveyard:1290 +life:16 +[END] \ No newline at end of file diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index 8a282bc61..8ee0b9ec8 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -1108,12 +1108,12 @@ class AControlStealAura: public MTGAbility{ int destroy(){ MTGCardInstance * _target = (MTGCardInstance *) target; - if (_target->controller()->game->inPlay->hasCard(_target)){ //if the target is still in game -> spell was destroyed + Player * p = _target->controller(); + if (p && p->game->inPlay->hasCard(_target)){ //if the target is still in game -> spell was destroyed _target->changeController(originalController); } return 1; } - //TODO put it back into owners's graveyard if needed... }; @@ -1481,15 +1481,20 @@ class AConservator: public MTGAbility{ //Creature bond class ACreatureBond:public TriggeredAbility{ public: + int mTriggered; int resolved; ACreatureBond(int _id, MTGCardInstance * _source, MTGCardInstance * _target):TriggeredAbility(_id,_source,_target){ - resolved = 1; + mTriggered = 0; + resolved = 0; } int trigger(){ MTGCardInstance * _target = (MTGCardInstance *) target; for (int i = 0; i < 2; i++){ - if (game->players[i]->game->graveyard->hasCard(_target)) return 1; + if (!mTriggered && game->players[i]->game->graveyard->hasCard(_target)){ + mTriggered = 1; + return 1; + } } return 0; } diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index 0dce80350..d87794060 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -999,7 +999,7 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){ } case 1194: //Control Magic { - game->addObserver(NEW ATakeControlAura(_id, card, card->target)); + game->addObserver(NEW AControlStealAura(_id, card, card->target)); break; }