From ae33977e10a2800df7148d37692993d55673724a Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Tue, 26 Jul 2016 09:56:13 +0800 Subject: [PATCH] Add Snapcaster Mage Ability tempflashback - flashback using manacost --- projects/mtg/bin/Res/sets/primitives/mtg.txt | 28 +++++++++++ .../bin/Res/sets/primitives/unsupported.txt | 21 -------- projects/mtg/include/MTGAbility.h | 1 + projects/mtg/include/MTGDefinitions.h | 3 +- projects/mtg/include/MTGRules.h | 15 ++++++ projects/mtg/src/MTGAbility.cpp | 1 + projects/mtg/src/MTGDefinitions.cpp | 3 +- projects/mtg/src/MTGRules.cpp | 49 +++++++++++++++++++ 8 files changed, 98 insertions(+), 23 deletions(-) diff --git a/projects/mtg/bin/Res/sets/primitives/mtg.txt b/projects/mtg/bin/Res/sets/primitives/mtg.txt index aa3248ec3..9ad6cc6e3 100644 --- a/projects/mtg/bin/Res/sets/primitives/mtg.txt +++ b/projects/mtg/bin/Res/sets/primitives/mtg.txt @@ -78212,6 +78212,14 @@ mana={X}{X}{U} type=Sorcery [/card] [card] +name=Past in Flames +auto=all(instant,sorcery|mygraveyard) tempflashback ueot +flashback={4}{R} +text=Each instant and sorcery card in your graveyard gains flashback until end of turn. The flashback cost is equal to its mana cost. -- Flashback {4}{R} (You may cast this card from your graveyard for its flashback cost. Then exile it.) +mana={3}{R} +type=Sorcery +[/card] +[card] name=Patagia Golem auto={3}:flying text={3}: Patagia Golem gains flying until end of turn. @@ -86217,6 +86225,15 @@ mana={2}{B} type=Sorcery [/card] [card] +name=Recoup +target=sorcery|mygraveyard +auto=transforms((,newability[tempflashback])) ueot +flashback={3}{R} +text=Target sorcery card in your graveyard gains flashback until end of turn. The flashback cost is equal to its mana cost. (Mana cost includes color.) -- Flashback {3}{R} (You may cast this card from your graveyard for its flashback cost. Then exile it.) +mana={1}{R} +type=Sorcery +[/card] +[card] name=Recumbent Bliss target=creature auto=cantattack @@ -100590,6 +100607,17 @@ mana={1}{U} type=Instant [/card] [card] +name=Snapcaster Mage +abilities=flash +auto=target(instant,sorcery|mygraveyard) tempflashback ueot +text=Flash -- When Snapcaster Mage enters the battlefield, target instant or sorcery card in your graveyard gains flashback until end of turn. The flashback cost is equal to its mana cost. (You may cast that card from your graveyard for its flashback cost. Then exile it.) +mana={1}{U} +type=Creature +subtype=Human Wizard +power=2 +toughness=1 +[/card] +[card] name=Snap target=creature auto=moveTo(ownerhand) diff --git a/projects/mtg/bin/Res/sets/primitives/unsupported.txt b/projects/mtg/bin/Res/sets/primitives/unsupported.txt index b96327d74..dd2476efd 100644 --- a/projects/mtg/bin/Res/sets/primitives/unsupported.txt +++ b/projects/mtg/bin/Res/sets/primitives/unsupported.txt @@ -12447,12 +12447,6 @@ type=Enchantment subtype=Aura [/card] [card] -name=Past in Flames -text=Each instant and sorcery card in your graveyard gains flashback until end of turn. The flashback cost is equal to its mana cost. -- Flashback {4}{R} (You may cast this card from your graveyard for its flashback cost. Then exile it.) -mana={3}{R} -type=Sorcery -[/card] -[card] name=Pathbreaker Ibex text=Whenever Pathbreaker Ibex attacks, creatures you control gain trample and get +X/+X until end of turn, where X is the greatest power among creatures you control. mana={4}{G}{G} @@ -13846,12 +13840,6 @@ mana={2}{G}{W} type=Enchantment [/card] [card] -name=Recoup -text=Target sorcery card in your graveyard gains flashback until end of turn. The flashback cost is equal to its mana cost. (Mana cost includes color.) -- Flashback {3}{R} (You may cast this card from your graveyard for its flashback cost. Then exile it.) -mana={1}{R} -type=Sorcery -[/card] -[card] name=Recross the Paths text=Reveal cards from the top of your library until you reveal a land card. Put that card onto the battlefield and the rest on the bottom of your library in any order. Clash with an opponent. If you win, return Recross the Paths to its owner's hand. (Each clashing player reveals the top card of his or her library, then puts that card on the top or bottom. A player wins if his or her card had a higher converted mana cost.) mana={2}{G} @@ -16092,15 +16080,6 @@ type=Enchantment subtype=Aura [/card] [card] -name=Snapcaster Mage -text=Flash -- When Snapcaster Mage enters the battlefield, target instant or sorcery card in your graveyard gains flashback until end of turn. The flashback cost is equal to its mana cost. (You may cast that card from your graveyard for its flashback cost. Then exile it.) -mana={1}{U} -type=Creature -subtype=Human Wizard -power=2 -toughness=1 -[/card] -[card] name=Snow Mercy text=Whenever a creature deals damage to you, put a globe counter on it. -- {T}, {untap}, {T}, {untap}, {T}: Tap all creatures with globe counters on them. mana={2}{W}{W} diff --git a/projects/mtg/include/MTGAbility.h b/projects/mtg/include/MTGAbility.h index 752c5341e..1211405b6 100644 --- a/projects/mtg/include/MTGAbility.h +++ b/projects/mtg/include/MTGAbility.h @@ -219,6 +219,7 @@ public: BESTOW_COST = 35, ATTACK_COST = 36, BLOCK_COST = 37, + GRANTEDFLASHBACK_COST = 38, }; }; diff --git a/projects/mtg/include/MTGDefinitions.h b/projects/mtg/include/MTGDefinitions.h index b72b67f08..c7db25290 100644 --- a/projects/mtg/include/MTGDefinitions.h +++ b/projects/mtg/include/MTGDefinitions.h @@ -255,7 +255,8 @@ class Constants OVERLOAD = 133, SHACKLER = 134, FLYERSONLY = 135,//can attack only if it has flying - NB_BASIC_ABILITIES = 136, + TEMPFLASHBACK = 136, + NB_BASIC_ABILITIES = 137, RARITY_S = 'S', //Special Rarity RARITY_M = 'M', //Mythics diff --git a/projects/mtg/include/MTGRules.h b/projects/mtg/include/MTGRules.h index 1b52f72e3..92eacfc07 100644 --- a/projects/mtg/include/MTGRules.h +++ b/projects/mtg/include/MTGRules.h @@ -150,6 +150,21 @@ public: virtual MTGFlashBackRule * clone() const; }; +class MTGTempFlashBackRule: public MTGAlternativeCostRule +{ +public: + + int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL); + int reactToClick(MTGCardInstance * card); + virtual ostream& toString(ostream& out) const; + MTGTempFlashBackRule(GameObserver* observer, int _id); + const string getMenuText() + { + return "Flashback Manacost"; + } + virtual MTGTempFlashBackRule * clone() const; +}; + class MTGRetraceRule: public MTGAlternativeCostRule { public: diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index f354162a1..27b113a2b 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -1176,6 +1176,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG if(found != string::npos) { observer->addObserver(NEW MTGFlashBackRule(observer, -1)); + observer->addObserver(NEW MTGTempFlashBackRule(observer, -1)); return NULL; } //alternative cost type flashback diff --git a/projects/mtg/src/MTGDefinitions.cpp b/projects/mtg/src/MTGDefinitions.cpp index 5d40a9513..2d73f2708 100644 --- a/projects/mtg/src/MTGDefinitions.cpp +++ b/projects/mtg/src/MTGDefinitions.cpp @@ -166,7 +166,8 @@ const char* Constants::MTGBasicAbilities[] = { "dethrone", "overload", "shackler", - "flyersonly" + "flyersonly", + "tempflashback" }; map Constants::MTGBasicAbilitiesMap; diff --git a/projects/mtg/src/MTGRules.cpp b/projects/mtg/src/MTGRules.cpp index 6793a2ac1..befb63824 100644 --- a/projects/mtg/src/MTGRules.cpp +++ b/projects/mtg/src/MTGRules.cpp @@ -1056,6 +1056,55 @@ MTGFlashBackRule * MTGFlashBackRule::clone() const return NEW MTGFlashBackRule(*this); } +//temporary flashback +MTGTempFlashBackRule::MTGTempFlashBackRule(GameObserver* observer, int _id) : +MTGAlternativeCostRule(observer, _id) +{ + aType = MTGAbility::GRANTEDFLASHBACK_COST; +} +int MTGTempFlashBackRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana) +{ + Player * player = game->currentlyActing(); + if (!player->game->graveyard->hasCard(card)) + return 0; + if (!card->has(Constants::TEMPFLASHBACK)) + return 0; + ManaCost * flashbackCost = card->getManaCost(); + if(flashbackCost->extraCosts) + for(unsigned int i = 0; i < flashbackCost->extraCosts->costs.size();i++) + { + flashbackCost->extraCosts->costs[i]->setSource(card); + } + return MTGAlternativeCostRule::isReactingToClick(card, mana, flashbackCost ); +} + +int MTGTempFlashBackRule::reactToClick(MTGCardInstance * card) +{ + ManaCost * flashbackCost = card->getManaCost(); + if(flashbackCost->extraCosts) + for(unsigned int i = 0; i < flashbackCost->extraCosts->costs.size();i++) + { + flashbackCost->extraCosts->costs[i]->setSource(card); + } + if (!isReactingToClick(card)) + return 0; + + card->paymenttype = MTGAbility::FLASHBACK_COST; + + return MTGAlternativeCostRule::reactToClick(card, flashbackCost, ManaCost::MANA_PAID_WITH_FLASHBACK); + +} + +ostream& MTGTempFlashBackRule::toString(ostream& out) const +{ + out << "MTGTempFlashBackRule ::: ("; + return MTGAbility::toString(out) << ")"; +} +MTGTempFlashBackRule * MTGTempFlashBackRule::clone() const +{ + return NEW MTGTempFlashBackRule(*this); +} + //------------------------------------------------------------------------- //------------------------------------------------------------------------- //-------------------------------------------------------------------------