From a97a7edca6ad6254f69f9fb240a232ca4bafc878 Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Tue, 31 Jan 2017 22:01:19 +0800 Subject: [PATCH] minor refactor --- projects/mtg/bin/Res/sets/primitives/mtg.txt | 26 ++++++++++---------- projects/mtg/src/MTGAbility.cpp | 8 ++++++ 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/projects/mtg/bin/Res/sets/primitives/mtg.txt b/projects/mtg/bin/Res/sets/primitives/mtg.txt index 22faeb4da..0c2c4d3f7 100644 --- a/projects/mtg/bin/Res/sets/primitives/mtg.txt +++ b/projects/mtg/bin/Res/sets/primitives/mtg.txt @@ -29396,7 +29396,7 @@ type=Instant [/card] [card] name=Dismiss into Dream -auto=lord(creature|opponentbattlefield) transforms((Illusion,newability[@targeted(this):sacrifice])) +auto=lord(creature|opponentbattlefield) transforms((Illusion,newability[while(restriction{cardistargeted}) sacrifice])) text=Enchantment. -- Each creature your opponents control is an Illusion in addition to its other types and has "When this creature becomes the target of a spell or ability, sacrifice it." mana={6}{U} type=Enchantment @@ -42891,7 +42891,7 @@ toughness=2 [/card] [card] name=Frost Walker -auto=@targeted(this):sacrifice +auto=while(restriction{cardistargeted}) sacrifice text=When Frost Walker becomes the target of a spell or ability, sacrifice it. mana={1}{U} type=Creature @@ -48227,7 +48227,7 @@ toughness=2 [card] name=Gossamer Phantasm abilities=flying -auto=@targeted(this):sacrifice +auto=while(restriction{cardistargeted}) sacrifice text=Flying -- When Gossamer Phantasm becomes the target of a spell or ability, sacrifice it. mana={1}{U} type=Creature @@ -55990,7 +55990,7 @@ toughness=4 [card] name=Illusionary Servant abilities=flying -auto=@targeted(this):sacrifice +auto=while(restriction{cardistargeted}) sacrifice text=Flying -- When Illusionary Servant becomes the target of a spell or ability, sacrifice it. mana={1}{U}{U} type=Creature @@ -83968,7 +83968,7 @@ toughness=1 [card] name=Phantasmal Abomination abilities=defender -auto=@targeted(this):sacrifice +auto=while(restriction{cardistargeted}) sacrifice text=Defender -- When Phantasmal Abomination becomes the target of a spell or ability, sacrifice it. mana={1}{U}{U} type=Creature @@ -83978,7 +83978,7 @@ toughness=5 [/card] [card] name=Phantasmal Bear -auto=@targeted(this):sacrifice +auto=while(restriction{cardistargeted}) sacrifice text=When Phantasmal Bear becomes the target of a spell or ability, sacrifice it. mana={U} type=Creature @@ -83989,7 +83989,7 @@ toughness=2 [card] name=Phantasmal Dragon abilities=flying -auto=@targeted(this):sacrifice +auto=while(restriction{cardistargeted}) sacrifice text=Flying -- When Phantasmal Dragon becomes the target of a spell or ability, sacrifice it. mana={2}{U}{U} type=Creature @@ -84022,7 +84022,7 @@ toughness=1 [card] name=Phantasmal Image auto=may copy NotATarget(creature) -auto=while(restriction{copiedacard}) transforms((Illusion,newability[@targeted(this):sacrifice])) forever +auto=while(restriction{copiedacard}) transforms((Illusion,newability[while(restriction{cardistargeted}) sacrifice])) forever text=You may have Phantasmal Image enter the battlefield as a copy of any creature on the battlefield, except it's an Illusion in addition to its other types and it gains "When this creature becomes the target of a spell or ability, sacrifice it." mana={1}{U} type=Creature @@ -84093,7 +84093,7 @@ toughness=2 [/card] [card] name=Phantom Beast -auto=@targeted(this):sacrifice +auto=while(restriction{cardistargeted}) sacrifice text=When Phantom Beast becomes the target of a spell or ability, sacrifice it. mana={3}{U} type=Creature @@ -104621,7 +104621,7 @@ type=Instant [/card] [card] name=Skulking Fugitive -auto=@targeted(this):sacrifice +auto=while(restriction{cardistargeted}) sacrifice text=When Skulking Fugitive becomes the target of a spell or ability, sacrifice it. mana={2}{B} type=Creature @@ -104632,7 +104632,7 @@ toughness=4 [card] name=Skulking Ghost abilities=flying -auto=@targeted(this):sacrifice +auto=while(restriction{cardistargeted}) sacrifice text=Flying -- When Skulking Ghost becomes the target of a spell or ability, sacrifice it. mana={1}{B} type=Creature @@ -104643,7 +104643,7 @@ toughness=1 [card] name=Skulking Knight abilities=flanking -auto=@targeted(this):sacrifice +auto=while(restriction{cardistargeted}) sacrifice text=Flanking (Whenever a creature without flanking blocks this creature, the blocking creature gets -1/-1 until end of turn.) -- When Skulking Knight becomes the target of a spell or ability, sacrifice it. mana={2}{B} type=Creature @@ -115504,7 +115504,7 @@ type=Artifact [/card] [card] name=Tar Pit Warrior -auto=@targeted(this):sacrifice +auto=while(restriction{cardistargeted}) sacrifice text=When Tar Pit Warrior becomes the target of a spell or ability, sacrifice it. mana={2}{B} type=Creature diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index ef20270f4..f0a4446b3 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -536,6 +536,14 @@ int AbilityFactory::parseCastRestrictions(MTGCardInstance * card, Player * playe if(!card->discarded) return 0; } + + check = restriction[i].find("cardistargeted"); + if(check != string::npos) + { + bool istarget = card->isTargetted(); + if(!istarget) + return 0; + } check = restriction[i].find("copiedacard"); if(check != string::npos)