From 94e50fe39909ccabf6ac451dcdac78fd3374323a Mon Sep 17 00:00:00 2001 From: Sloth Date: Sat, 19 Nov 2011 08:02:15 +0000 Subject: [PATCH] - The keyword "CARDNAME enters the battlefield tapped." will now be checked at runtime. - Added the static ability ETBTapped and converted six cards to script. --- .gitattributes | 1 + res/cardsfolder/f/frozen_aether.txt | 3 +- res/cardsfolder/k/kismet.txt | 3 +- res/cardsfolder/l/loxodon_gatekeeper.txt | 3 +- res/cardsfolder/o/orb_of_dreams.txt | 3 +- res/cardsfolder/r/root_maze.txt | 3 +- res/cardsfolder/u/urabrask_the_hidden.txt | 3 +- .../java/forge/PlayerZoneComesIntoPlay.java | 28 +++++++++------ .../card/cardfactory/CardFactoryUtil.java | 4 +-- .../card/staticability/StaticAbility.java | 18 ++++++++++ .../staticability/StaticAbilityETBTapped.java | 35 +++++++++++++++++++ 11 files changed, 86 insertions(+), 18 deletions(-) create mode 100644 src/main/java/forge/card/staticability/StaticAbilityETBTapped.java diff --git a/.gitattributes b/.gitattributes index 8d9e9396ccd..0b6d739a7ce 100644 --- a/.gitattributes +++ b/.gitattributes @@ -10630,6 +10630,7 @@ src/main/java/forge/card/staticability/StaticAbility.java svneol=native#text/pla src/main/java/forge/card/staticability/StaticAbilityCantBeCast.java svneol=native#text/plain src/main/java/forge/card/staticability/StaticAbilityCantTarget.java -text src/main/java/forge/card/staticability/StaticAbilityContinuous.java svneol=native#text/plain +src/main/java/forge/card/staticability/StaticAbilityETBTapped.java -text src/main/java/forge/card/staticability/StaticAbilityPreventDamage.java -text svneol=native#text/plain src/main/java/forge/card/staticability/package-info.java svneol=native#text/plain src/main/java/forge/card/trigger/Trigger.java svneol=native#text/plain diff --git a/res/cardsfolder/f/frozen_aether.txt b/res/cardsfolder/f/frozen_aether.txt index cb89d82b8d5..352300acddf 100644 --- a/res/cardsfolder/f/frozen_aether.txt +++ b/res/cardsfolder/f/frozen_aether.txt @@ -1,7 +1,8 @@ Name:Frozen AEther ManaCost:3 U Types:Enchantment -Text:Artifacts, creatures, and lands your opponents control enter the battlefield tapped. +Text:no text +S:Mode$ ETBTapped | ValidCard$ Artifact.YouDontCtrl,Creature.YouDontCtrl,Land.YouDontCtrl | Description$ Artifacts, creatures, and lands your opponents control enter the battlefield tapped. SVar:Rarity:Uncommon SVar:Picture:http://www.wizards.com/global/images/magic/general/frozen_aether.jpg SetInfo:PLC|Uncommon|http://magiccards.info/scans/en/pc/54.jpg diff --git a/res/cardsfolder/k/kismet.txt b/res/cardsfolder/k/kismet.txt index 6ee4b238ffa..6082f6707fc 100644 --- a/res/cardsfolder/k/kismet.txt +++ b/res/cardsfolder/k/kismet.txt @@ -1,7 +1,8 @@ Name:Kismet ManaCost:3 W Types:Enchantment -Text:Artifacts, creatures, and lands your opponents control enter the battlefield tapped. +Text:no text +S:Mode$ ETBTapped | ValidCard$ Artifact.YouDontCtrl,Creature.YouDontCtrl,Land.YouDontCtrl | Description$ Artifacts, creatures, and lands your opponents control enter the battlefield tapped. SVar:Rarity:Uncommon SVar:Picture:http://www.wizards.com/global/images/magic/general/kismet.jpg SetInfo:5ED|Uncommon|http://magiccards.info/scans/en/5e/319.jpg diff --git a/res/cardsfolder/l/loxodon_gatekeeper.txt b/res/cardsfolder/l/loxodon_gatekeeper.txt index 83dc59ec2e0..f8998533716 100644 --- a/res/cardsfolder/l/loxodon_gatekeeper.txt +++ b/res/cardsfolder/l/loxodon_gatekeeper.txt @@ -1,8 +1,9 @@ Name:Loxodon Gatekeeper ManaCost:2 W W Types:Creature Elephant Soldier -Text:Artifacts, creatures, and lands your opponents control enter the battlefield tapped. +Text:no text PT:2/3 +S:Mode$ ETBTapped | ValidCard$ Artifact.YouDontCtrl,Creature.YouDontCtrl,Land.YouDontCtrl | Description$ Artifacts, creatures, and lands your opponents control enter the battlefield tapped. SVar:Rarity:Rare SVar:Picture:http://www.wizards.com/global/images/magic/general/loxodon_gatekeeper.jpg SetInfo:RAV|Rare|http://magiccards.info/scans/en/rav/25.jpg diff --git a/res/cardsfolder/o/orb_of_dreams.txt b/res/cardsfolder/o/orb_of_dreams.txt index 69702552c3c..f525afce08e 100644 --- a/res/cardsfolder/o/orb_of_dreams.txt +++ b/res/cardsfolder/o/orb_of_dreams.txt @@ -1,7 +1,8 @@ Name:Orb of Dreams ManaCost:3 Types:Artifact -Text:Permanents enter the battlefield tapped. +Text:no text +S:Mode$ ETBTapped | ValidCard$ Permanent | Description$ Permanents enter the battlefield tapped. SVar:RemRandomDeck:True SVar:Rarity:Rare SVar:Picture:http://www.wizards.com/global/images/magic/general/orb_of_dreams.jpg diff --git a/res/cardsfolder/r/root_maze.txt b/res/cardsfolder/r/root_maze.txt index e4933d7a397..1f31864882f 100644 --- a/res/cardsfolder/r/root_maze.txt +++ b/res/cardsfolder/r/root_maze.txt @@ -1,7 +1,8 @@ Name:Root Maze ManaCost:G Types:Enchantment -Text:Artifacts and lands enter the battlefield tapped. +Text:no text +S:Mode$ ETBTapped | ValidCard$ Artifact,Land | Description$ Artifacts and lands enter the battlefield tapped. SVar:RemRandomDeck:True SVar:Rarity:Rare SVar:Picture:http://www.wizards.com/global/images/magic/general/root_maze.jpg diff --git a/res/cardsfolder/u/urabrask_the_hidden.txt b/res/cardsfolder/u/urabrask_the_hidden.txt index b99acbfe0c5..89dfd4366d0 100644 --- a/res/cardsfolder/u/urabrask_the_hidden.txt +++ b/res/cardsfolder/u/urabrask_the_hidden.txt @@ -1,9 +1,10 @@ Name:Urabrask the Hidden ManaCost:3 R R Types:Legendary Creature Praetor -Text:Creatures your opponents control enter the battlefield tapped. +Text: PT:4/4 S:Mode$ Continuous | Affected$ Creature.YouCtrl | AddKeyword$ Haste | Description$ Creatures you control have haste. +S:Mode$ ETBTapped | ValidCard$ Creature.YouDontCtrl | Description$ Creatures your opponents control enter the battlefield tapped. SVar:PlayMain1:TRUE SVar:BuffedBy:Creature SVar:Rarity:Mythic diff --git a/src/main/java/forge/PlayerZoneComesIntoPlay.java b/src/main/java/forge/PlayerZoneComesIntoPlay.java index 20628546af6..9ee14d1b269 100644 --- a/src/main/java/forge/PlayerZoneComesIntoPlay.java +++ b/src/main/java/forge/PlayerZoneComesIntoPlay.java @@ -4,9 +4,9 @@ import java.util.ArrayList; import java.util.Iterator; import forge.Constant.Zone; -import forge.card.cardfactory.CardFactoryUtil; import forge.card.spellability.Ability; import forge.card.spellability.SpellAbility; +import forge.card.staticability.StaticAbility; /** *

@@ -49,15 +49,23 @@ public class PlayerZoneComesIntoPlay extends DefaultPlayerZone { final Card c = (Card) o; final Player player = c.getController(); - if (trigger - && ((CardFactoryUtil.oppHasKismet(c.getController()) - && (c.isLand() || c.isCreature() || c.isArtifact())) - || (AllZoneUtil.isCardInPlay("Urabrask the Hidden", c.getController().getOpponent()) && c - .isCreature()) - || (AllZoneUtil.isCardInPlay("Root Maze") && (c.isLand() || c.isArtifact())) || (AllZoneUtil - .isCardInPlay("Orb of Dreams") && c.isPermanent()))) { - // it enters the battlefield this way, and should not fire triggers - c.setTapped(true); + if (trigger) { + if (c.hasKeyword("CARDNAME enters the battlefield tapped.")) { + // it enters the battlefield this way, and should not fire triggers + c.setTapped(true); + } else { + // ETBTapped static abilities + final CardList allp = AllZoneUtil.getCardsIn(Zone.Battlefield); + for (final Card ca : allp) { + final ArrayList staticAbilities = ca.getStaticAbilities(); + for (final StaticAbility stAb : staticAbilities) { + if (stAb.applyAbility("ETBTapped", c)) { + // it enters the battlefield this way, and should not fire triggers + c.setTapped(true); + } + } + } + } } // cannot use addComesIntoPlayCommand - trigger might be set to false; diff --git a/src/main/java/forge/card/cardfactory/CardFactoryUtil.java b/src/main/java/forge/card/cardfactory/CardFactoryUtil.java index 308fdcc1f46..a9d08c4f4d1 100644 --- a/src/main/java/forge/card/cardfactory/CardFactoryUtil.java +++ b/src/main/java/forge/card/cardfactory/CardFactoryUtil.java @@ -4932,7 +4932,7 @@ public class CardFactoryUtil { * */ public static final void parseKeywords(final Card card, final String cardName) { - if (card.hasKeyword("CARDNAME enters the battlefield tapped.")) { + /*if (card.hasKeyword("CARDNAME enters the battlefield tapped.")) { card.addComesIntoPlayCommand(new Command() { private static final long serialVersionUID = 203335252453049234L; @@ -4943,7 +4943,7 @@ public class CardFactoryUtil { card.setTapped(true); } }); - } // if "Comes into play tapped." + }*/ // if "Comes into play tapped." if (card.hasKeyword("CARDNAME enters the battlefield tapped unless you control two or fewer other lands.")) { card.addComesIntoPlayCommand(new Command() { private static final long serialVersionUID = 6436821515525468682L; diff --git a/src/main/java/forge/card/staticability/StaticAbility.java b/src/main/java/forge/card/staticability/StaticAbility.java index 3c230e2dccd..c6a5a7d967a 100644 --- a/src/main/java/forge/card/staticability/StaticAbility.java +++ b/src/main/java/forge/card/staticability/StaticAbility.java @@ -318,6 +318,24 @@ public class StaticAbility { return false; } + + public final boolean applyAbility(final String mode, final Card card) { + + // don't apply the ability if it hasn't got the right mode + if (!this.mapParams.get("Mode").equals(mode)) { + return false; + } + + if (this.isSuppressed() || !this.checkConditions()) { + return false; + } + + if (mode.equals("ETBTapped")) { + return StaticAbilityETBTapped.applyETBTappedAbility(this, card); + } + + return false; + } /** * Check conditions. diff --git a/src/main/java/forge/card/staticability/StaticAbilityETBTapped.java b/src/main/java/forge/card/staticability/StaticAbilityETBTapped.java new file mode 100644 index 00000000000..f5ee8741a80 --- /dev/null +++ b/src/main/java/forge/card/staticability/StaticAbilityETBTapped.java @@ -0,0 +1,35 @@ +package forge.card.staticability; + +import java.util.HashMap; + +import forge.Card; + +/** + * The Class StaticAbility_CantBeCast. + */ +public class StaticAbilityETBTapped { + + /** + * TODO Write javadoc for this method. + * + * @param stAb + * a StaticAbility + * @param card + * the card + * @param activator + * the activator + * @return true, if successful + */ + public static boolean applyETBTappedAbility(final StaticAbility stAb, final Card card) { + final HashMap params = stAb.getMapParams(); + final Card hostCard = stAb.getHostCard(); + + if (params.containsKey("ValidCard") + && !card.isValid(params.get("ValidCard").split(","), hostCard.getController(), hostCard)) { + return false; + } + + return true; + } + +}