From 853b8ea5c648a155e6b3e1d44148f1fa537f3e24 Mon Sep 17 00:00:00 2001 From: "omegablast2002@yahoo.com" Date: Sat, 29 Jan 2011 21:58:29 +0000 Subject: [PATCH] fixed gravetitan bug reported, added new keyword "retarget" as another support for newtarget... reworked the handling of new target...auras and equipments can not be treated the same...doing so allowed the player to then use the equip function of the card and gain a double bonus. now i call directly on the equip function to do the equiping so that it works with its own function to add the effects. keeping a person from gaining double bonus. --- projects/mtg/include/AllAbilities.h | 5 ++-- projects/mtg/src/AllAbilities.cpp | 43 ++++++++++++++++++++++++----- projects/mtg/src/MTGAbility.cpp | 20 ++++++++++---- 3 files changed, 53 insertions(+), 15 deletions(-) diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index 4f4b02962..947647d1c 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -427,7 +427,7 @@ public: bool sourceUntapped; bool opponentPoisoned; TrCardAttacked(int id, MTGCardInstance * source, TargetChooser * tc,bool sourceUntapped,bool opponentPoisoned) : - TriggeredAbility(id, source), tc(tc), sourceUntapped(sourceUntapped) + TriggeredAbility(id, source), tc(tc), sourceUntapped(sourceUntapped),opponentPoisoned(opponentPoisoned) { } @@ -3414,7 +3414,8 @@ public: class AANewTarget: public ActivatedAbility { public: - AANewTarget(int id, MTGCardInstance * card, MTGCardInstance * _target, ManaCost * _cost = NULL, int doTap = 0); +bool retarget; + AANewTarget(int id, MTGCardInstance * card, MTGCardInstance * _target,bool retarget = false, ManaCost * _cost = NULL, int doTap = 0); int resolve(); const char * getMenuText(); AANewTarget * clone() const; diff --git a/projects/mtg/src/AllAbilities.cpp b/projects/mtg/src/AllAbilities.cpp index 99f80efa5..f0c208368 100644 --- a/projects/mtg/src/AllAbilities.cpp +++ b/projects/mtg/src/AllAbilities.cpp @@ -720,8 +720,8 @@ AAFrozen * AAFrozen::clone() const } // chose a new target for an aura or enchantment and equip it note: VERY basic right now. -AANewTarget::AANewTarget(int id, MTGCardInstance * card, MTGCardInstance * _target, ManaCost * _cost, int doTap) : -ActivatedAbility(id, card, _cost, 0, doTap) +AANewTarget::AANewTarget(int id, MTGCardInstance * card, MTGCardInstance * _target,bool retarget, ManaCost * _cost, int doTap) : +ActivatedAbility(id, card, _cost, 0, doTap),retarget(retarget) { target = _target; } @@ -729,20 +729,48 @@ ActivatedAbility(id, card, _cost, 0, doTap) int AANewTarget::resolve() { MTGCardInstance * _target = (MTGCardInstance *) target; + if(retarget) + { + _target = source; + source = (MTGCardInstance *) target; + } if (_target) { while (_target->next) - _target = _target->next; //This is for cards such as rampant growth - + _target = _target->next; _target->controller()->game->putInZone(_target, _target->currentZone, _target->owner->game->exile); _target = _target->next; - + MTGCardInstance * refreshed = source->controller()->game->putInZone(_target,_target->currentZone,source->controller()->game->battlefield); Spell * reUp = NEW Spell(refreshed); - reUp->source->target = source; - reUp->resolve(); + if(reUp->source->hasSubtype("aura")) + { + reUp->source->target = source; + reUp->resolve(); + } + if(_target->hasSubtype("equipment")) + { + reUp->resolve(); + GameObserver * g = g->GetInstance(); + for (int i = 1; i < g->mLayers->actionLayer()->mCount; i++) + { + MTGAbility * a = ((MTGAbility *) g->mLayers->actionLayer()->mObjects[i]); + AEquip * eq = dynamic_cast (a); + if (eq && eq->source == reUp->source) + { + ((AEquip*)a)->unequip(); + ((AEquip*)a)->equip(source); + } + } + } delete reUp; + if(retarget) + { + target = source; + source = _target; + } + } return 1; } @@ -756,6 +784,7 @@ AANewTarget * AANewTarget::clone() const { AANewTarget * a = NEW AANewTarget(*this); a->isClone = 1; + a->oneShot = 1; return a; } // morph a card diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index 7b8564a7e..60c3cfac4 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -2581,17 +2581,25 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG a->oneShot = 1; return a; } - - //get a new target - found = s.find("newtarget"); + + //get a new target + found = s.find("retarget"); if (found != string::npos) { - MTGAbility * a = NEW AANewTarget(id, card, target); + MTGAbility * a = NEW AANewTarget(id, card,target,true); a->oneShot = 1; return a; } - - //morph + + //get a new target + found = s.find("newtarget"); + if (found != string::npos) + { + MTGAbility * a = NEW AANewTarget(id, card, target,false); + a->oneShot = 1; + return a; + } + //morph found = s.find("morph"); if (found != string::npos) {