diff --git a/projects/mtg/include/MTGAbility.h b/projects/mtg/include/MTGAbility.h index 1211405b6..59e3ef5b1 100644 --- a/projects/mtg/include/MTGAbility.h +++ b/projects/mtg/include/MTGAbility.h @@ -425,6 +425,19 @@ public: }; +class TriggerRebound : public TriggerAtPhase +{ +public: + int destroyActivated; + bool sourceUntapped; + bool sourceTap; + bool once,activeTrigger; + TriggerRebound(GameObserver* observer, int id, MTGCardInstance * source, Targetable * target,int _phaseId, int who = 0,bool sourceUntapped = false,bool sourceTap = false,bool once = false); + virtual TriggerRebound* clone() const; + virtual int testDestroy(); + +}; + class GenericTriggeredAbility : public TriggeredAbility, public NestedAbility { diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index 9cc146c83..3f5368917 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -1112,6 +1112,13 @@ TriggeredAbility * AbilityFactory::parseTrigger(string s, string, int id, Spell } } + //rebound trigger controller upkeep... + found = s.find("rebounded"); + if (found != string::npos) + { + return NEW TriggerRebound(observer, id, card, target, 2, 1,sourceUntapped,once); + } + return NULL; } @@ -6046,6 +6053,30 @@ TriggerNextPhase* TriggerNextPhase::clone() const return NEW TriggerNextPhase(*this); } +TriggerRebound::TriggerRebound(GameObserver* observer, int id, MTGCardInstance * source, Targetable * target, int _phaseId, int who,bool sourceUntapped, bool sourceTap,bool once) : + TriggerAtPhase(observer, id, source, target, _phaseId, who, sourceUntapped, sourceTap, once) +{ + destroyActivated = 0; + activeTrigger = true; +} + +int TriggerRebound::testDestroy() +{ + if(newPhase <= phaseId && !destroyActivated && game->currentPlayer == source->controller()) + destroyActivated=1; + if(destroyActivated > 1||(newPhase > phaseId && destroyActivated)) + { + destroyActivated++; + return 1; + } + return 0; +} + +TriggerRebound* TriggerRebound::clone() const +{ + return NEW TriggerRebound(*this); +} + GenericTriggeredAbility::GenericTriggeredAbility(GameObserver* observer, int id, MTGCardInstance * _source, TriggeredAbility * _t, MTGAbility * a, MTGAbility * dc, Targetable * _target) : TriggeredAbility(observer, id, _source, _target), NestedAbility(a)