From 7f8c78bb4bae69a25910c8fc266797e8b3f08b20 Mon Sep 17 00:00:00 2001 From: jendave Date: Sat, 6 Aug 2011 08:35:13 +0000 Subject: [PATCH] - Added "When CARDNAME becomes the target of a spell or ability, return CARDNAME to its owner's hand." "When CARDNAME becomes the target of a spell or ability, sacrifice it." "When CARDNAME becomes the target of a spell or ability, destroy CARDNAME." keywords. - Added some cards. --- .gitattributes | 10 +++++ res/cardsfolder/gossamer_phantasm.txt | 11 ++++++ res/cardsfolder/illusionary_servant.txt | 11 ++++++ res/cardsfolder/mirozel.txt | 11 ++++++ res/cardsfolder/petrahydrox.txt | 10 +++++ res/cardsfolder/phantasmal_abomination.txt | 11 ++++++ res/cardsfolder/phantom_beast.txt | 10 +++++ res/cardsfolder/skulking_fugitive.txt | 10 +++++ res/cardsfolder/skulking_ghost.txt | 11 ++++++ res/cardsfolder/skulking_knight.txt | 11 ++++++ res/cardsfolder/tar_pit_warrior.txt | 10 +++++ src/forge/CardFactoryUtil.java | 43 ++++++++++++++++++++++ src/forge/ComputerAI_General.java | 2 +- src/forge/MagicStack.java | 21 +++++++---- src/forge/SpellAbility.java | 2 + 15 files changed, 175 insertions(+), 9 deletions(-) create mode 100644 res/cardsfolder/gossamer_phantasm.txt create mode 100644 res/cardsfolder/illusionary_servant.txt create mode 100644 res/cardsfolder/mirozel.txt create mode 100644 res/cardsfolder/petrahydrox.txt create mode 100644 res/cardsfolder/phantasmal_abomination.txt create mode 100644 res/cardsfolder/phantom_beast.txt create mode 100644 res/cardsfolder/skulking_fugitive.txt create mode 100644 res/cardsfolder/skulking_ghost.txt create mode 100644 res/cardsfolder/skulking_knight.txt create mode 100644 res/cardsfolder/tar_pit_warrior.txt diff --git a/.gitattributes b/.gitattributes index c54589740d7..9315c09b902 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1612,6 +1612,7 @@ res/cardsfolder/gorgon_flail.txt -text svneol=native#text/plain res/cardsfolder/gorgon_recluse.txt -text svneol=native#text/plain res/cardsfolder/gorilla_chieftain.txt -text svneol=native#text/plain res/cardsfolder/gorilla_warrior.txt -text svneol=native#text/plain +res/cardsfolder/gossamer_phantasm.txt -text svneol=native#text/plain res/cardsfolder/graceful_adept.txt -text svneol=native#text/plain res/cardsfolder/grand_arbiter_augustin_iv.txt -text svneol=native#text/plain res/cardsfolder/grand_coliseum.txt -text svneol=native#text/plain @@ -1853,6 +1854,7 @@ res/cardsfolder/ihsans_shade.txt -text svneol=native#text/plain res/cardsfolder/iizuka_the_ruthless.txt -text svneol=native#text/plain res/cardsfolder/ikiral_outrider.txt -text svneol=native#text/plain res/cardsfolder/illusionary_forces.txt -text svneol=native#text/plain +res/cardsfolder/illusionary_servant.txt -text svneol=native#text/plain res/cardsfolder/illusionary_wall.txt -text svneol=native#text/plain res/cardsfolder/illusions_of_grandeur.txt -text svneol=native#text/plain res/cardsfolder/immaculate_magistrate.txt -text svneol=native#text/plain @@ -2427,6 +2429,7 @@ res/cardsfolder/minotaur_warrior.txt -text svneol=native#text/plain res/cardsfolder/mirari.txt -text svneol=native#text/plain res/cardsfolder/mire_boa.txt -text svneol=native#text/plain res/cardsfolder/mire_kavu.txt -text svneol=native#text/plain +res/cardsfolder/mirozel.txt -text svneol=native#text/plain res/cardsfolder/mirri_cat_warrior.txt -text svneol=native#text/plain res/cardsfolder/mirri_the_cursed.txt -text svneol=native#text/plain res/cardsfolder/mirror_entity.txt -text svneol=native#text/plain @@ -2766,10 +2769,13 @@ res/cardsfolder/pestermite.txt -text svneol=native#text/plain res/cardsfolder/pestilence.txt -text svneol=native#text/plain res/cardsfolder/pestilence_demon.txt -text svneol=native#text/plain res/cardsfolder/pestilent_kathari.txt -text svneol=native#text/plain +res/cardsfolder/petrahydrox.txt -text svneol=native#text/plain res/cardsfolder/petravark.txt -text svneol=native#text/plain res/cardsfolder/pewter_golem.txt -text svneol=native#text/plain +res/cardsfolder/phantasmal_abomination.txt -text svneol=native#text/plain res/cardsfolder/phantasmal_forces.txt -text svneol=native#text/plain res/cardsfolder/phantasmal_terrain.txt -text svneol=native#text/plain +res/cardsfolder/phantom_beast.txt -text svneol=native#text/plain res/cardsfolder/phantom_centaur.txt -text svneol=native#text/plain res/cardsfolder/phantom_monster.txt -text svneol=native#text/plain res/cardsfolder/phantom_nishoba.txt -text svneol=native#text/plain @@ -3403,6 +3409,9 @@ res/cardsfolder/skitter_of_lizards.txt -text svneol=native#text/plain res/cardsfolder/skittering_invasion.txt -text svneol=native#text/plain res/cardsfolder/skittish_kavu.txt -text svneol=native#text/plain res/cardsfolder/skred.txt -text svneol=native#text/plain +res/cardsfolder/skulking_fugitive.txt -text svneol=native#text/plain +res/cardsfolder/skulking_ghost.txt -text svneol=native#text/plain +res/cardsfolder/skulking_knight.txt -text svneol=native#text/plain res/cardsfolder/skull_catapult.txt -text svneol=native#text/plain res/cardsfolder/skull_of_ramos.txt -text svneol=native#text/plain res/cardsfolder/skullclamp.txt -text svneol=native#text/plain @@ -3782,6 +3791,7 @@ res/cardsfolder/tangle_spider.txt -text svneol=native#text/plain res/cardsfolder/tanglebloom.txt -text svneol=native#text/plain res/cardsfolder/taoist_hermit.txt -text svneol=native#text/plain res/cardsfolder/taoist_mystic.txt -text svneol=native#text/plain +res/cardsfolder/tar_pit_warrior.txt -text svneol=native#text/plain res/cardsfolder/tar_pitcher.txt -text svneol=native#text/plain res/cardsfolder/tarfire.txt -text svneol=native#text/plain res/cardsfolder/tarmogoyf.txt -text svneol=native#text/plain diff --git a/res/cardsfolder/gossamer_phantasm.txt b/res/cardsfolder/gossamer_phantasm.txt new file mode 100644 index 00000000000..fc33f8289b2 --- /dev/null +++ b/res/cardsfolder/gossamer_phantasm.txt @@ -0,0 +1,11 @@ +Name:Gossamer Phantasm +ManaCost:1 U +Types:Creature Illusion +Text:no text +PT:2/1 +K:Flying +K:When CARDNAME becomes the target of a spell or ability, sacrifice it. +SVar:RemAIDeck:True +SVar:Rarity:Common +SVar:Picture:http://www.wizards.com/global/images/magic/general/gossamer_phantasm.jpg +End diff --git a/res/cardsfolder/illusionary_servant.txt b/res/cardsfolder/illusionary_servant.txt new file mode 100644 index 00000000000..78d80a25b4d --- /dev/null +++ b/res/cardsfolder/illusionary_servant.txt @@ -0,0 +1,11 @@ +Name:Illusionary Servant +ManaCost:1 U U +Types:Creature Illusion +Text:no text +PT:3/4 +K:Flying +K:When CARDNAME becomes the target of a spell or ability, sacrifice it. +SVar:RemAIDeck:True +SVar:Rarity:Common +SVar:Picture:http://www.wizards.com/global/images/magic/general/illusionary_servant.jpg +End diff --git a/res/cardsfolder/mirozel.txt b/res/cardsfolder/mirozel.txt new file mode 100644 index 00000000000..eeb78b4bd24 --- /dev/null +++ b/res/cardsfolder/mirozel.txt @@ -0,0 +1,11 @@ +Name:Mirozel +ManaCost:3 U +Types:Creature Illusion +Text:no text +PT:2/3 +K:Flying +K:When CARDNAME becomes the target of a spell or ability, return CARDNAME to its owner's hand. +SVar:RemAIDeck:True +SVar:Rarity:Uncommon +SVar:Picture:http://www.wizards.com/global/images/magic/general/mirozel.jpg +End diff --git a/res/cardsfolder/petrahydrox.txt b/res/cardsfolder/petrahydrox.txt new file mode 100644 index 00000000000..daca1dcad38 --- /dev/null +++ b/res/cardsfolder/petrahydrox.txt @@ -0,0 +1,10 @@ +Name:Petrahydrox +ManaCost:3 UR +Types:Creature Weird +Text:no text +PT:3/3 +K:When CARDNAME becomes the target of a spell or ability, return CARDNAME to its owner's hand. +SVar:RemAIDeck:True +SVar:Rarity:common +SVar:Picture:http://www.wizards.com/global/images/magic/general/petrahydrox.jpg +End diff --git a/res/cardsfolder/phantasmal_abomination.txt b/res/cardsfolder/phantasmal_abomination.txt new file mode 100644 index 00000000000..a520ddd709a --- /dev/null +++ b/res/cardsfolder/phantasmal_abomination.txt @@ -0,0 +1,11 @@ +Name:Phantasmal Abomination +ManaCost:1 U U +Types:Creature Illusion +Text:no text +PT:5/5 +K:Defender +K:When CARDNAME becomes the target of a spell or ability, sacrifice it. +SVar:RemAIDeck:True +SVar:Rarity:Uncommon +SVar:Picture:http://www.wizards.com/global/images/magic/general/phantasmal_abomination.jpg +End diff --git a/res/cardsfolder/phantom_beast.txt b/res/cardsfolder/phantom_beast.txt new file mode 100644 index 00000000000..3ecfc3b3b25 --- /dev/null +++ b/res/cardsfolder/phantom_beast.txt @@ -0,0 +1,10 @@ +Name:Phantom Beast +ManaCost:3 U +Types:Creature Illusion Beast +Text:no text +PT:4/5 +K:When CARDNAME becomes the target of a spell or ability, sacrifice it. +SVar:RemAIDeck:True +SVar:Rarity:Common +SVar:Picture:http://www.wizards.com/global/images/magic/general/phantom_beast.jpg +End \ No newline at end of file diff --git a/res/cardsfolder/skulking_fugitive.txt b/res/cardsfolder/skulking_fugitive.txt new file mode 100644 index 00000000000..d9f7ac66b03 --- /dev/null +++ b/res/cardsfolder/skulking_fugitive.txt @@ -0,0 +1,10 @@ +Name:Skulking Fugitive +ManaCost:2 B +Types:Creature Horror Mercenary +Text:no text +PT:3/4 +K:When CARDNAME becomes the target of a spell or ability, sacrifice it. +SVar:RemAIDeck:True +SVar:Rarity:Common +SVar:Picture:http://www.wizards.com/global/images/magic/general/skulking_fugitive.jpg +End \ No newline at end of file diff --git a/res/cardsfolder/skulking_ghost.txt b/res/cardsfolder/skulking_ghost.txt new file mode 100644 index 00000000000..84f9dad6102 --- /dev/null +++ b/res/cardsfolder/skulking_ghost.txt @@ -0,0 +1,11 @@ +Name:Skulking Ghost +ManaCost:1 B +Types:Creature Ghost +Text:no text +PT:2/1 +K:Flying +K:When CARDNAME becomes the target of a spell or ability, sacrifice it. +SVar:RemAIDeck:True +SVar:Rarity:Common +SVar:Picture:http://www.wizards.com/global/images/magic/general/skulking_ghost.jpg +End \ No newline at end of file diff --git a/res/cardsfolder/skulking_knight.txt b/res/cardsfolder/skulking_knight.txt new file mode 100644 index 00000000000..21b514abb49 --- /dev/null +++ b/res/cardsfolder/skulking_knight.txt @@ -0,0 +1,11 @@ +Name:Skulking Knight +ManaCost:2 B +Types:Creature Zombie Knight +Text:no text +PT:3/3 +K:Flanking +K:When CARDNAME becomes the target of a spell or ability, sacrifice it. +SVar:RemAIDeck:True +SVar:Rarity:Common +SVar:Picture:http://www.wizards.com/global/images/magic/general/skulking_knight.jpg +End \ No newline at end of file diff --git a/res/cardsfolder/tar_pit_warrior.txt b/res/cardsfolder/tar_pit_warrior.txt new file mode 100644 index 00000000000..3e2cd4fc6da --- /dev/null +++ b/res/cardsfolder/tar_pit_warrior.txt @@ -0,0 +1,10 @@ +Name:Tar Pit Warrior +ManaCost:2 B +Types:Creature Cyclops Warrior +Text:no text +PT:3/4 +K:When CARDNAME becomes the target of a spell or ability, sacrifice it. +SVar:RemAIDeck:True +SVar:Rarity:Common +SVar:Picture:http://www.wizards.com/global/images/magic/general/tar_pit_warrior.jpg +End \ No newline at end of file diff --git a/src/forge/CardFactoryUtil.java b/src/forge/CardFactoryUtil.java index 00bf66b21a5..c3b4ce02ebd 100644 --- a/src/forge/CardFactoryUtil.java +++ b/src/forge/CardFactoryUtil.java @@ -4634,6 +4634,49 @@ public class CardFactoryUtil { return ""; } + + //whenever CARDNAME becomes the target of a spell or ability, ... : + public static void checkTargetingEffects(SpellAbility sa, final Card c) + { + + //if (AllZone.GameAction.isCardInPlay(c)) + //{ + if (c.getKeyword().contains("When CARDNAME becomes the target of a spell or ability, return CARDNAME to its owner's hand.")) { + SpellAbility ability = new Ability(c, "0") + { + public void resolve() + { + AllZone.GameAction.moveToHand(c); + } + }; + ability.setStackDescription(c + " - return CARDNAME to its owner's hand."); + AllZone.Stack.add(ability); + } + if (c.getKeyword().contains("When CARDNAME becomes the target of a spell or ability, destroy CARDNAME.")) { + + SpellAbility ability = new Ability(c, "0") + { + public void resolve() + { + AllZone.GameAction.destroy(c); + } + }; + ability.setStackDescription(c + " - destroy CARDNAME."); + AllZone.Stack.add(ability); + } + if (c.getKeyword().contains("When CARDNAME becomes the target of a spell or ability, sacrifice it.")) { + SpellAbility ability = new Ability(c, "0") + { + public void resolve() + { + AllZone.GameAction.sacrifice(c); + } + }; + ability.setStackDescription(c + " - sacrifice CARDNAME."); + AllZone.Stack.add(ability); + } + //} + } public static void main(String[] args) { diff --git a/src/forge/ComputerAI_General.java b/src/forge/ComputerAI_General.java index 0c5e8a85290..69d668a6a0a 100644 --- a/src/forge/ComputerAI_General.java +++ b/src/forge/ComputerAI_General.java @@ -253,7 +253,7 @@ public class ComputerAI_General implements Computer { for(SpellAbility sa:c.getSpellAbility()) //This try/catch should fix the "computer is thinking" bug try { - if(sa.canPlayAI() && ComputerUtil.canPayCost(sa) && + if(ComputerUtil.canPayCost(sa) && sa.canPlayAI() && (sa.isAnyPlayer() || sa.getSourceCard().getController().equals(Constant.Player.Computer))) spellAbility.add(sa); } catch(Exception ex) { diff --git a/src/forge/MagicStack.java b/src/forge/MagicStack.java index 0af39d4ce98..81e5d52eb54 100644 --- a/src/forge/MagicStack.java +++ b/src/forge/MagicStack.java @@ -37,8 +37,11 @@ public class MagicStack extends MyObservable { if(sp instanceof Ability_Mana || sp instanceof Ability_Triggered)//TODO make working triggered abilities! sp.resolve(); - else + else { push(sp); + if (sp.getTargetCard()!= null) + CardFactoryUtil.checkTargetingEffects(sp, sp.getTargetCard()); + } } } @@ -179,13 +182,13 @@ public class MagicStack extends MyObservable Card crd = sa.getSourceCard(); AllZone.InputControl.setInput(new Input_PayManaCost_Ability("Pay X cost for " + crd.getName() + " (X=" +crd.getXManaCostPaid()+")\r\n", ability.getManaCost(), this, unpaidCommand, true)); - } - }; - Card crd = sa.getSourceCard(); - if(sp.getSourceCard().getController().equals(Constant.Player.Human)) { - AllZone.InputControl.setInput(new Input_PayManaCost_Ability("Pay X cost for " + sp.getSourceCard().getName() + " (X=" +crd.getXManaCostPaid()+")\r\n", + } + }; + Card crd = sa.getSourceCard(); + if(sp.getSourceCard().getController().equals(Constant.Player.Human)) { + AllZone.InputControl.setInput(new Input_PayManaCost_Ability("Pay X cost for " + sp.getSourceCard().getName() + " (X=" +crd.getXManaCostPaid()+")\r\n", ability.getManaCost(), paidCommand, unpaidCommand, true)); - } + } else //computer { int neededDamage = CardFactoryUtil.getNeededXDamage(sa); @@ -273,7 +276,9 @@ public class MagicStack extends MyObservable } } - } + } + if (sp.getTargetCard()!= null) + CardFactoryUtil.checkTargetingEffects(sp, sp.getTargetCard()); } public int size() { diff --git a/src/forge/SpellAbility.java b/src/forge/SpellAbility.java index e11c6c09bd6..ae69fe181b8 100644 --- a/src/forge/SpellAbility.java +++ b/src/forge/SpellAbility.java @@ -307,6 +307,8 @@ public abstract class SpellAbility { if(!card.isFaceDown()) desc = getSourceCard().getName() + " - targeting " + card; else desc = getSourceCard().getName() + " - targeting Morph(" + card.getUniqueNumber() + ")"; setStackDescription(desc); + + //System.out.println(card + " has become target of a spell or ability (" +this.getSourceCard() + ")"); } public void setTargetPlayer(String p) {