diff --git a/projects/mtg/bin/Res/sets/ALA/_cards.dat b/projects/mtg/bin/Res/sets/ALA/_cards.dat index 561376efe..67d77d15f 100644 --- a/projects/mtg/bin/Res/sets/ALA/_cards.dat +++ b/projects/mtg/bin/Res/sets/ALA/_cards.dat @@ -17,7 +17,7 @@ abilities=exalted [/card] [card] text=Shroud Whenever another creature is put into a graveyard from the battlefield, you may put a +1/+1 counter on Algae Gharial. -auto=@movedTo(other creature|graveyard) from(battlefield):may counter(1/1) +auto=@movedTo(graveyard) from(other creature|battlefield):may counter(1/1) id=174986 name=Algae Gharial rarity=U @@ -218,7 +218,7 @@ abilities=flying [card] text=Enchant artifact or creature. Enchanted permanent doesn't untap during its controller's untap step. id=175042 - + target=creature,artifact auto=doesnotuntap name=Coma Veil @@ -308,7 +308,7 @@ toughness=2 [/card] [card] text=Whenever another creature is put into a graveyard from the battlefield, you may gain 1 life. -auto=@movedTo(other creature|graveyard) from(battlefield):may life:1 +auto=@movedTo(graveyard) from(other creature|battlefield):may life:1 id=175073 name=Deathgreeter rarity=C @@ -589,7 +589,7 @@ abilities=flying,trample,haste [/card] [card] text=Whenever another creature is put into a graveyard from the battlefield, you may have Hissing Iguanar deal 1 damage to target player. -auto=@movedTo(other creature|graveyard) from(battlefield):may damage:1 target(player) +auto=@movedTo(graveyard) from(other creature|battlefield):may damage:1 target(player) id=174873 name=Hissing Iguanar rarity=C @@ -1178,7 +1178,7 @@ toughness=7 [/card] [card] text=First strike Whenever another creature is put into a graveyard from the battlefield, you may put a +1/+1 counter on Rockslide Elemental. -auto=@movedTo(other creature|graveyard) from(battlefield):may counter(1/1) +auto=@movedTo(graveyard) from(other creature|battlefield):may counter(1/1) id=174988 name=Rockslide Elemental rarity=U @@ -1239,7 +1239,7 @@ type=Land [/card] [card] text=Flying Whenever another creature is put into a graveyard from the battlefield, you may put a +1/+1 counter on Scavenger Drake. -auto=@movedTo(other creature|graveyard) from(battlefield):may counter(1/1) +auto=@movedTo(graveyard) from(other creature|battlefield):may counter(1/1) id=174987 name=Scavenger Drake rarity=U diff --git a/projects/mtg/bin/Res/sets/ARB/_cards.dat b/projects/mtg/bin/Res/sets/ARB/_cards.dat index e53af91b2..ed325f5d9 100644 --- a/projects/mtg/bin/Res/sets/ARB/_cards.dat +++ b/projects/mtg/bin/Res/sets/ARB/_cards.dat @@ -411,7 +411,7 @@ type=Sorcery [card] text=Whenever Mycoid Shepherd or another creature you control with power 5 or greater is put into a graveyard from the battlefield, you may gain 5 life. auto=@movedTo(this|graveyard) from(myBattlefield):may life:5 controller -auto=@movedTo(other creature[power>=5]|graveyard) from(myBattlefield):may life:5 controller +auto=@movedTo(graveyard) from(other creature[power>=5]|myBattlefield):may life:5 controller id=179548 name=Mycoid Shepherd rarity=R diff --git a/projects/mtg/bin/Res/sets/CFX/_cards.dat b/projects/mtg/bin/Res/sets/CFX/_cards.dat index 0c616ec28..3ae62a628 100644 --- a/projects/mtg/bin/Res/sets/CFX/_cards.dat +++ b/projects/mtg/bin/Res/sets/CFX/_cards.dat @@ -996,7 +996,7 @@ abilities=flying [card] text=Enchant creature When a creature is put into a graveyard from the battlefield, destroy enchanted creature. target=creature -auto=@movedTo(creature|graveyard) from(battlefield):destroy +auto=@movedTo(graveyard) from(creature|battlefield):destroy id=179891 name=Yoke of the Damned rarity=C diff --git a/projects/mtg/bin/Res/sets/CSP/_cards.dat b/projects/mtg/bin/Res/sets/CSP/_cards.dat index aea7134ab..cdceba694 100644 --- a/projects/mtg/bin/Res/sets/CSP/_cards.dat +++ b/projects/mtg/bin/Res/sets/CSP/_cards.dat @@ -369,7 +369,7 @@ toughness=2 [/card] [card] text=Whenever another nontoken creature you control is put into a graveyard from the battlefield, put a 3/1 black and red Graveborn creature token with haste onto the battlefield. -auto=@movedto(other creature|myGraveyard) from(myBattlefield):token(Graveborn, Creature Graveborn,3/1,haste red black) +auto=@movedto(myGraveyard) from(other creature|myBattlefield):token(Graveborn, Creature Graveborn,3/1,haste red black) id=121261 name=Sek'Kuar, Deathkeeper rarity=R diff --git a/projects/mtg/bin/Res/sets/LRW/_cards.dat b/projects/mtg/bin/Res/sets/LRW/_cards.dat index 0cb71f7f0..7170109c5 100644 --- a/projects/mtg/bin/Res/sets/LRW/_cards.dat +++ b/projects/mtg/bin/Res/sets/LRW/_cards.dat @@ -1016,7 +1016,7 @@ subtype=Aura [/card] [card] text=Whenever another nontoken Elf is put into your graveyard from the battlefield, you may put a 1/1 green Elf Warrior creature token onto the battlefield. -auto=@movedTo(other elf|graveyard) from(battlefield):may token(Elf Warrior,creature elf warrior,1/1,green) +auto=@movedTo(graveyard) from(other elf|battlefield):may token(Elf Warrior,creature elf warrior,1/1,green) id=146167 name=Prowess of the Fair rarity=U diff --git a/projects/mtg/bin/Res/sets/MRD/_cards.dat b/projects/mtg/bin/Res/sets/MRD/_cards.dat index b8961367d..71d3ff8a2 100644 --- a/projects/mtg/bin/Res/sets/MRD/_cards.dat +++ b/projects/mtg/bin/Res/sets/MRD/_cards.dat @@ -224,7 +224,7 @@ subtype=Aura [card] text=Whenever an artifact is put into a graveyard from the battlefield, you may have target opponent lose 1 life. id=49090 -auto=@movedTo(artifact|graveyard) from(battlefield):may life:-1 opponent +auto=@movedTo(graveyard) from(artifact|battlefield):may life:-1 opponent name=Disciple of the Vault rarity=C mana={B} @@ -244,7 +244,7 @@ type=Artifact [/card] [card] text=Protection from white. At the end of your turn, you lose 4 life. Whenever a creature is put into a graveyard from the battlefield, you gain 2 life. -auto=@movedTo(creature|graveyard) from(battlefield):life:2 +auto=@movedTo(graveyard) from(creature|battlefield):life:2 auto=@each my end:life:-4 controller id=50537 name=Dross Harvester @@ -270,7 +270,7 @@ abilities=fear [/card] [card] text=Whenever Dross Scorpion or another artifact creature is put into a graveyard from the battlefield, you may untap target artifact. -auto=@movedTo(creature[artifact]|graveyard) from(battlefield):may untap target(artifact) +auto=@movedTo(graveyard) from(creature[artifact]|battlefield):may untap target(artifact) id=46434 name=Dross Scorpion rarity=C @@ -869,7 +869,7 @@ subtype=Mountain [/card] [card] text=When Myr Retriever is put into a graveyard from the battlefield, return another target artifact card from your graveyard to your hand. -auto=@movedTo(this|graveyard) from(battlefield):moveTo(myhand) target(other artifact|mygraveyard) +auto=@movedTo(this|graveyard) from(battlefield):moveTo(myhand) target(other artifact|mygraveyard) id=46126 name=Myr Retriever diff --git a/projects/mtg/bin/Res/sets/MRQ/_cards.dat b/projects/mtg/bin/Res/sets/MRQ/_cards.dat index ccae9649a..6331b6ec9 100644 --- a/projects/mtg/bin/Res/sets/MRQ/_cards.dat +++ b/projects/mtg/bin/Res/sets/MRQ/_cards.dat @@ -992,7 +992,7 @@ abilities=flying [card] text=Whenever a creature is put into a graveyard from the battlefield, you gain 1 life. id=136514 -auto=@movedTo(creature|graveyard) from(battlefield):life:1 controller +auto=@movedTo(graveyard) from(creature|battlefield):life:1 controller name=Moonlit Wake rarity=U mana={2}{W} diff --git a/projects/mtg/bin/Res/sets/ODY/_cards.dat b/projects/mtg/bin/Res/sets/ODY/_cards.dat index 2123f9477..f497b0387 100644 --- a/projects/mtg/bin/Res/sets/ODY/_cards.dat +++ b/projects/mtg/bin/Res/sets/ODY/_cards.dat @@ -1606,7 +1606,7 @@ abilities=reach [/card] [card] text=Flying Whenever a creature with flying is put into a graveyard from the battlefield, put a +1/+1 counter on Soulcatcher. -auto=@movedTo(creature[flying]|graveyard) from(battlefield):counter(1/1) +auto=@movedTo(graveyard) from(creature[flying]|battlefield):counter(1/1) id=31865 name=Soulcatcher rarity=U diff --git a/projects/mtg/bin/Res/sets/ONS/_cards.dat b/projects/mtg/bin/Res/sets/ONS/_cards.dat index 1543d7048..8e67ed024 100644 --- a/projects/mtg/bin/Res/sets/ONS/_cards.dat +++ b/projects/mtg/bin/Res/sets/ONS/_cards.dat @@ -632,7 +632,7 @@ mana={2}{R} type=Creature subtype=Goblin auto={T}:Damage:1 target(creature,player) -auto=@movedTo(creature|graveyard) from(battlefield):untap +auto=@movedTo(graveyard) from(creature|battlefield):untap power=1 toughness=1 abilities=doesnotuntap @@ -1130,7 +1130,7 @@ mana={2}{B} type=Creature subtype=Zombie Cleric auto=@movedTo(this|graveyard) from(battlefield):token(Zombie,creature token Zombie, 2/2,black) -auto=@movedTo(other cleric|graveyard) from(battlefield):token(Zombie,creature token Zombie, 2/2,black) +auto=@movedTo(graveyard) from(other cleric|battlefield):token(Zombie,creature token Zombie, 2/2,black) power=2 toughness=2 [/card] diff --git a/projects/mtg/bin/Res/sets/RAV/_cards.dat b/projects/mtg/bin/Res/sets/RAV/_cards.dat index 9950cffde..c12eb139f 100644 --- a/projects/mtg/bin/Res/sets/RAV/_cards.dat +++ b/projects/mtg/bin/Res/sets/RAV/_cards.dat @@ -549,7 +549,7 @@ abilities=mountainwalk [card] text=Whenever a nontoken creature you control is put into a graveyard from the battlefield, put a 1/1 green Saproling creature token onto the battlefield. id=89069 -auto=@movedto(creature[-token]|graveyard) from(myBattlefield):token(Saproling,creature saproling, 1/1,green) +auto=@movedto(graveyard) from(creature[-token]|myBattlefield):token(Saproling,creature saproling, 1/1,green) name=Golgari Germination rarity=U type=Enchantment diff --git a/projects/mtg/bin/Res/sets/SOK/_cards.dat b/projects/mtg/bin/Res/sets/SOK/_cards.dat index fe49bff77..901574a9e 100644 --- a/projects/mtg/bin/Res/sets/SOK/_cards.dat +++ b/projects/mtg/bin/Res/sets/SOK/_cards.dat @@ -397,7 +397,7 @@ rarity=U mana={3}{B} auto=@next my endofturn:bury auto=@next my endofturn:life:-8 controller -auto=@movedto(* other|graveyard):moveto(opponentBattlefield) +auto=@movedto(graveyard) from(* other|*):moveto(opponentBattlefield) type=Enchantment [/card] [card] @@ -540,8 +540,8 @@ toughness=1 [/card] [card] text=When a creature you control is put into a graveyard from the battlefield, sacrifice Promise of Bunrei. If you do, put four 1/1 colorless Spirit creature tokens onto the battlefield. -auto=@movedto(creature|graveyard) from(myBattlefield):token(Spirit,Creature Spirit,1/1,)*4 -auto=@movedto(creature|graveyard) from(myBattlefield):bury +auto=@movedto(graveyard) from(creature|myBattlefield):token(Spirit,Creature Spirit,1/1,)*4 +auto=@movedto(graveyard) from(creature|myBattlefield):bury id=84376 name=Promise of Bunrei rarity=R diff --git a/projects/mtg/bin/Res/sets/TMP/_cards.dat b/projects/mtg/bin/Res/sets/TMP/_cards.dat index 199b2d052..a7407c9f1 100644 --- a/projects/mtg/bin/Res/sets/TMP/_cards.dat +++ b/projects/mtg/bin/Res/sets/TMP/_cards.dat @@ -377,7 +377,7 @@ type=Enchantment [/card] [card] text=Shadow (This creature can block or be blocked by only creatures with shadow.) Whenever a creature with shadow is put into a graveyard from the battlefield, put a +1/+1 counter on Dauthi Ghoul. -auto=@movedTo(creature[shadow]|graveyard) from(battlefield):counter(1/1) +auto=@movedTo(graveyard) from(creature[shadow]|battlefield):counter(1/1) id=4649 name=Dauthi Ghoul rarity=U @@ -1490,7 +1490,7 @@ toughness=1 [card] text=Enchant creature Whenever a creature is put into a graveyard from the battlefield, put a +1/+1 counter on enchanted creature. target=creature -auto=@movedTo(creature|graveyard) from(battlefield):counter(1/1) +auto=@movedTo(graveyard) from(creature|battlefield):counter(1/1) id=4682 name=Sadistic Glee rarity=C diff --git a/projects/mtg/bin/Res/sets/WTH/_cards.dat b/projects/mtg/bin/Res/sets/WTH/_cards.dat index f2ef1f75d..f5c593f58 100644 --- a/projects/mtg/bin/Res/sets/WTH/_cards.dat +++ b/projects/mtg/bin/Res/sets/WTH/_cards.dat @@ -130,8 +130,8 @@ abilities=flying,cloud [card] text=Whenever a creature is put into a graveyard from the battlefield, Dingus Staff deals 2 damage to that creature's controller. id=4432 -auto=@movedTo(creature|mygraveyard) from(myBattlefield):life:-2 controller -auto=@movedTo(creature|opponentgraveyard) from(opponentBattlefield):life:-2 opponent +auto=@movedTo(mygraveyard) from(creature|myBattlefield):life:-2 controller +auto=@movedTo(opponentgraveyard) from(creature|opponentBattlefield):life:-2 opponent name=Dingus Staff rarity=U mana={4} diff --git a/projects/mtg/bin/Res/test/_tests.txt b/projects/mtg/bin/Res/test/_tests.txt index ff13b5bc6..327f81071 100644 --- a/projects/mtg/bin/Res/test/_tests.txt +++ b/projects/mtg/bin/Res/test/_tests.txt @@ -269,6 +269,7 @@ kird_ape.txt kjeldoran_frostbeast1.txt knight_captain_of_eos_i294.txt knight_captain_of_eos_i294_2.txt +kormus_bell_i301.txt krosan_beast.txt krosan_beast2.txt kraken_eye.txt diff --git a/projects/mtg/bin/Res/test/bugs/kormus_bell_i301.txt b/projects/mtg/bin/Res/test/kormus_bell_i301.txt similarity index 100% rename from projects/mtg/bin/Res/test/bugs/kormus_bell_i301.txt rename to projects/mtg/bin/Res/test/kormus_bell_i301.txt diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index 7cab6d008..f38182a3b 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -101,8 +101,9 @@ public: class TrCardAddedToZone:public TriggeredAbility{ public: TargetChooser * toTc; - TargetZoneChooser * fromTc; - TrCardAddedToZone(int id, MTGCardInstance * source, TargetChooser * toTc, TargetZoneChooser * fromTc = NULL):TriggeredAbility(id,source), toTc(toTc), fromTc(fromTc){} + TargetZoneChooser * fromTcZone; + TargetChooser * fromTcCard; + TrCardAddedToZone(int id, MTGCardInstance * source, TargetChooser * toTc, TargetZoneChooser * fromTcZone = NULL,TargetChooser * fromTcCard = NULL):TriggeredAbility(id,source), toTc(toTc), fromTcZone(fromTcZone), fromTcCard(fromTcCard){} int resolve(){ return 0; //This is a trigger, this function should not be called @@ -111,8 +112,10 @@ public: int triggerOnEvent(WEvent * event){ WEventZoneChange * e = dynamic_cast(event); if (!e) return 0; + if (!toTc->canTarget(e->card)) return 0; - if (fromTc && !fromTc->targetsZone(e->from)) return 0; + if (fromTcZone && !fromTcZone->targetsZone(e->from)) return 0; + if (fromTcCard && !fromTcCard->canTarget(e->card->previous)) return 0; //Battlefield is a special case. We usually don't want to trigger when a card comes from battlefield to battlefield // http://code.google.com/p/wagic/issues/detail?id=179 @@ -125,7 +128,8 @@ public: ~TrCardAddedToZone(){ SAFE_DELETE(toTc); - SAFE_DELETE(fromTc); + SAFE_DELETE(fromTcZone); + SAFE_DELETE(fromTcCard); } TrCardAddedToZone * clone() const{ diff --git a/projects/mtg/include/MTGGameZones.h b/projects/mtg/include/MTGGameZones.h index a3dd8ca61..33c79395c 100644 --- a/projects/mtg/include/MTGGameZones.h +++ b/projects/mtg/include/MTGGameZones.h @@ -20,6 +20,8 @@ class MTGGameZone { public: enum{ + ALL_ZONES = -1, + MY_GRAVEYARD = 11, OPPONENT_GRAVEYARD = 12, TARGET_OWNER_GRAVEYARD = 13, diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index 47ded38b3..637c19ec6 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -64,20 +64,30 @@ TriggeredAbility * AbilityFactory::parseTrigger(string magicText, int id, Spell if (found != string::npos){ size_t end = s.find (")"); string starget = s.substr(found+8,end - found - 8); + if (starget.find("|") == string::npos) starget.insert(0,"*|"); TargetChooserFactory tcf; TargetChooser *toTc = tcf.createTargetChooser(starget,card); toTc->targetter = NULL; TargetChooser *fromTc = NULL; + TargetChooser * fromTcCard = NULL; found = s.find("from("); if (found != string::npos){ + end = s.find ("|", found); + if (end == string::npos) { + fromTcCard = tcf.createTargetChooser("*",card); + found = found + 5; + }else{ + fromTcCard = tcf.createTargetChooser(s.substr(found + 5, end - found - 5).append("|*"),card); + found = end + 1; + } + fromTcCard->setAllZones(); end = s.find (")", found); - starget = s.substr(found+5,end - found - 5); - if (starget.find("|") == string::npos) starget.insert(0,"*|"); + starget = s.substr(found,end - found).insert(0,"*|"); fromTc = tcf.createTargetChooser(starget,card); fromTc->targetter = NULL; } - return NEW TrCardAddedToZone(id,card,toTc,(TargetZoneChooser *)fromTc); + return NEW TrCardAddedToZone(id,card,toTc,(TargetZoneChooser *)fromTc,fromTcCard); } //Card Tapped diff --git a/projects/mtg/src/TargetChooser.cpp b/projects/mtg/src/TargetChooser.cpp index 538620261..8d00fa890 100644 --- a/projects/mtg/src/TargetChooser.cpp +++ b/projects/mtg/src/TargetChooser.cpp @@ -56,8 +56,9 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta } zones[nbzones] = MTGGameZone::MY_BATTLEFIELD; - //Graveyards - if(zoneName.compare("graveyard") == 0){ + if(zoneName.compare("*") == 0){ + zones[nbzones] = MTGGameZone::ALL_ZONES; + }else if(zoneName.compare("graveyard") == 0){ zones[nbzones] = MTGGameZone::MY_GRAVEYARD; nbzones++; zones[nbzones] = MTGGameZone::OPPONENT_GRAVEYARD; @@ -590,21 +591,10 @@ int TargetZoneChooser::init(int * _zones, int _nbzones){ int TargetZoneChooser::setAllZones(){ int zones[] = { - MTGGameZone::MY_BATTLEFIELD, - MTGGameZone::MY_EXILE, - MTGGameZone::MY_GRAVEYARD, - MTGGameZone::MY_HAND, - MTGGameZone::MY_LIBRARY, - MTGGameZone::MY_STACK, - MTGGameZone::OPPONENT_BATTLEFIELD, - MTGGameZone::OPPONENT_EXILE, - MTGGameZone::OPPONENT_GRAVEYARD, - MTGGameZone::OPPONENT_HAND, - MTGGameZone::OPPONENT_LIBRARY, - MTGGameZone::OPPONENT_STACK + MTGGameZone::ALL_ZONES, }; - init(zones,12); + init(zones,1); return 1; } @@ -613,8 +603,10 @@ bool TargetZoneChooser::canTarget(Targetable * target){ if (!TargetChooser::canTarget(target)) return false; if (target->typeAsTarget() == TARGET_CARD){ MTGCardInstance * card = (MTGCardInstance *) target; - for (int i = 0; ihasCard(card)) return true; + } }else if (target->typeAsTarget() == TARGET_STACKACTION){ OutputDebugString ("CHECKING INTERRUPTIBLE\n"); Interruptible * action = (Interruptible *) target;