diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index e9d537ebe..46445b8db 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -646,6 +646,33 @@ public: } }; +class TrCardForetold: public Trigger +{ +public: + bool limitOnceATurn; + int triggeredTurn; + TrCardForetold(GameObserver* observer, int id, MTGCardInstance * source, TargetChooser * tc,bool once = false,bool limitOnceATurn = false) : + Trigger(observer, id, source,once, tc),limitOnceATurn(limitOnceATurn) + { + } + + int triggerOnEventImpl(WEvent * event) + { + WEventCardForetold * e = dynamic_cast (event); + if (!e) return 0; + if (limitOnceATurn && triggeredTurn == game->turn) + return 0; + if (!tc->canTarget(e->card)) return 0; + triggeredTurn = game->turn; + return 1; + } + + TrCardForetold * clone() const + { + return NEW TrCardForetold(*this); + } +}; + class TrCardScryed: public Trigger { public: diff --git a/projects/mtg/include/WEvent.h b/projects/mtg/include/WEvent.h index 9dc1b0d73..945b3d294 100644 --- a/projects/mtg/include/WEvent.h +++ b/projects/mtg/include/WEvent.h @@ -366,6 +366,12 @@ struct WEventCardSurveiled : public WEventCardUpdate { virtual Targetable * getTarget(int target); }; +//foretell event +struct WEventCardForetold : public WEventCardUpdate { + WEventCardForetold(MTGCardInstance * card); + virtual Targetable * getTarget(int target); +}; + //scry event struct WEventCardScryed : public WEventCardUpdate { WEventCardScryed(MTGCardInstance * card); diff --git a/projects/mtg/src/AllAbilities.cpp b/projects/mtg/src/AllAbilities.cpp index 6ed184f72..8a98aeeb1 100644 --- a/projects/mtg/src/AllAbilities.cpp +++ b/projects/mtg/src/AllAbilities.cpp @@ -2110,12 +2110,15 @@ int AAForetell::resolve() MTGCardInstance * _target = (MTGCardInstance *) target; if (_target) { - if(_target->mutation && _target->parentCards.size() > 0) return 0; // Mutated down cards cannot be foretell, they will follow the fate of top-card + if(_target->mutation && _target->parentCards.size() > 0) return 0; // Mutated down cards cannot be foretold, they will follow the fate of top-card Player * p = _target->controller(); if(p){ MTGCardInstance * tmp = p->game->putInExile(_target); - if(tmp) + if(tmp){ tmp->foretellTurn = source->getObserver()->turn; + WEvent * e = NEW WEventCardForetold(tmp); + game->receiveEvent(e); + } } while(_target->next) @@ -7847,7 +7850,8 @@ void APhaseAction::Update(float dt) { if(checkexile) { - if(((MTGCardInstance *)target)->next->getCurrentZone() != ((MTGCardInstance *)target)->owner->game->exile) + MTGCardInstance* tocheck = (((MTGCardInstance *)target)->next)?((MTGCardInstance *)target)->next:((MTGCardInstance *)target); + if((tocheck->getCurrentZone() != ((MTGCardInstance *)target)->owner->game->exile) && (tocheck->getCurrentZone() != ((MTGCardInstance *)target)->owner->opponent()->game->exile)) { this->forceDestroy = 1; return; diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index 2259cea99..1f48056cd 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -1228,6 +1228,10 @@ TriggeredAbility * AbilityFactory::parseTrigger(string s, string, int id, Spell if (TargetChooser * tc = parseSimpleTC(s, "surveiled", card)) return NEW TrCardSurveiled(observer, id, card, tc, once, limitOnceATurn); + //Foretell has been performed from a card + if (TargetChooser * tc = parseSimpleTC(s, "foretold", card)) + return NEW TrCardForetold(observer, id, card, tc, once, limitOnceATurn); + //Scry has been performed from a card if (TargetChooser * tc = parseSimpleTC(s, "scryed", card)) return NEW TrCardScryed(observer, id, card, tc, once, limitOnceATurn); @@ -3166,7 +3170,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG } //foretell - found = s.find("foretell"); + found = s.find("doforetell"); if (found != string::npos) { MTGAbility * a = NEW AAForetell(observer, id, card, target); diff --git a/projects/mtg/src/WEvent.cpp b/projects/mtg/src/WEvent.cpp index 67a017a85..9e4440cdb 100644 --- a/projects/mtg/src/WEvent.cpp +++ b/projects/mtg/src/WEvent.cpp @@ -297,6 +297,11 @@ WEventCardSurveiled::WEventCardSurveiled(MTGCardInstance * card) : { } +WEventCardForetold::WEventCardForetold(MTGCardInstance * card) : + WEventCardUpdate(card) +{ +} + WEventCardScryed::WEventCardScryed(MTGCardInstance * card) : WEventCardUpdate(card) { @@ -536,6 +541,12 @@ Targetable * WEventCardSurveiled::getTarget(int target) return NULL; } +Targetable * WEventCardForetold::getTarget(int target) +{ + if (target) return card; + return NULL; +} + Targetable * WEventCardScryed::getTarget(int target) { if (target) return card; diff --git a/projects/mtg/src/WParsedInt.cpp b/projects/mtg/src/WParsedInt.cpp index 0a6c4dc1c..3856a41f3 100644 --- a/projects/mtg/src/WParsedInt.cpp +++ b/projects/mtg/src/WParsedInt.cpp @@ -211,10 +211,6 @@ void WParsedInt::init(string s, Spell * spell, MTGCardInstance * card) { intValue = (s == "mutations")?target->mutation:target->countColors(); } - else if (s == "manacost") - { - intValue = (target->currentZone == target->controller()->game->stack)?(target->myconvertedcost + target->castX):target->myconvertedcost;//X is 0 except if it's on the stack - } else if (s.find("type:") != string::npos) { size_t begins = s.find("type:"); @@ -571,6 +567,16 @@ void WParsedInt::init(string s, Spell * spell, MTGCardInstance * card) { intValue = card->isFlipped; } + else if (s == "manacost") //Return the converted manacost + { + intValue = (target->currentZone == target->controller()->game->stack)?(target->myconvertedcost + target->castX):target->myconvertedcost;//X is 0 except if it's on the stack + } + else if(s == "snowdiffmana") //Return 1 if the difference between snowpool and converted manacost is more than 0 + { + int snowpool = target->controller()->snowManaG + target->controller()->snowManaU + target->controller()->snowManaR + target->controller()->snowManaB + target->controller()->snowManaW + target->controller()->snowManaC; + int manacost = (target->currentZone == target->controller()->game->stack)?(target->myconvertedcost + target->castX):target->myconvertedcost;//X is 0 except if it's on the stack + intValue = (snowpool >= manacost)?1:0; + } else if (s == "mysnowpoolcount" || s == "opponentsnowpoolcount") // snowpoolcount is just to count the number of snow mana produced ... { intValue = (s == "mysnowpoolcount")?(target->controller()->snowManaG + target->controller()->snowManaU + target->controller()->snowManaR + target->controller()->snowManaB + target->controller()->snowManaW + target->controller()->snowManaC):(target->controller()->opponent()->snowManaG + target->controller()->opponent()->snowManaU + target->controller()->opponent()->snowManaR + target->controller()->opponent()->snowManaB + target->controller()->opponent()->snowManaW + target->controller()->opponent()->snowManaC);