From 1b782a9a23a7072e173c6d115cf2d403609b0402 Mon Sep 17 00:00:00 2001 From: Sloth Date: Sat, 4 Feb 2012 12:29:12 +0000 Subject: [PATCH] - Added the keyword "May be played by your Opponent". - Added Fiend of the Shadows. --- .gitattributes | 1 + res/cardsfolder/c/cone_of_flame.txt | 2 +- res/cardsfolder/f/fiend_of_the_shadows.txt | 17 +++++ src/main/java/forge/GameAction.java | 8 ++- src/main/java/forge/Player.java | 3 +- .../card/cardfactory/CardFactoryUtil.java | 72 +++++++++++-------- .../java/forge/card/spellability/Spell.java | 2 +- .../spellability/SpellAbilityRestriction.java | 3 +- .../card/spellability/SpellPermanent.java | 3 +- 9 files changed, 76 insertions(+), 35 deletions(-) create mode 100644 res/cardsfolder/f/fiend_of_the_shadows.txt diff --git a/.gitattributes b/.gitattributes index 8c3da7d01d9..299f555f326 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2920,6 +2920,7 @@ res/cardsfolder/f/field_of_souls.txt svneol=native#text/plain res/cardsfolder/f/field_surgeon.txt svneol=native#text/plain res/cardsfolder/f/fieldmist_borderpost.txt svneol=native#text/plain res/cardsfolder/f/fiend_hunter.txt -text +res/cardsfolder/f/fiend_of_the_shadows.txt -text res/cardsfolder/f/fierce_empath.txt svneol=native#text/plain res/cardsfolder/f/fiery_conclusion.txt svneol=native#text/plain res/cardsfolder/f/fiery_fall.txt svneol=native#text/plain diff --git a/res/cardsfolder/c/cone_of_flame.txt b/res/cardsfolder/c/cone_of_flame.txt index 99bc7e2c375..074c1b42245 100644 --- a/res/cardsfolder/c/cone_of_flame.txt +++ b/res/cardsfolder/c/cone_of_flame.txt @@ -2,7 +2,7 @@ Name:Cone of Flame ManaCost:3 R R Types:Sorcery Text:no text -A:SP$ DealDamage | Cost$ 3 R | ValidTgts$ Creature,Player,Planeswalker | TgtPrompt$ Select target creature or player | NumDmg$ 1 | SubAbility$ DBDamageTwo | SpellDescription$ CARDNAME deals 1 damage to target creature or player, 2 damage to another target creature or player, and 3 damage to a third target creature or player. +A:SP$ DealDamage | Cost$ 3 R R | ValidTgts$ Creature,Player,Planeswalker | TgtPrompt$ Select target creature or player | NumDmg$ 1 | SubAbility$ DBDamageTwo | SpellDescription$ CARDNAME deals 1 damage to target creature or player, 2 damage to another target creature or player, and 3 damage to a third target creature or player. SVar:DBDamageTwo:DB$ DealDamage | Cost$ 0 | ValidTgts$ Creature,Player,Planeswalker | TgtPrompt$ Select another target creature or player | NumDmg$ 2 | TargetUnique$ True | SubAbility$ DBDamageThree SVar:DBDamageThree:DB$ DealDamage | Cost$ 0 | ValidTgts$ Creature,Player,Planeswalker | TgtPrompt$ Select another target creature or player | NumDmg$ 3 |TargetUnique$ True SVar:Rarity:Uncommon diff --git a/res/cardsfolder/f/fiend_of_the_shadows.txt b/res/cardsfolder/f/fiend_of_the_shadows.txt new file mode 100644 index 00000000000..7d635a15c98 --- /dev/null +++ b/res/cardsfolder/f/fiend_of_the_shadows.txt @@ -0,0 +1,17 @@ +Name:Fiend of the Shadows +ManaCost:3 B B +Types:Creature Vampire Wizard +Text:no text +PT:3/3 +K:Flying +T:Mode$ DamageDone | ValidSource$ Card.Self | ValidTarget$ Player | CombatDamage$ True | Execute$ TrigChangeZone | TriggerZones$ Battlefield | TriggerDescription$ Whenever CARDNAME deals combat damage to a player, that player exiles a card from his or her hand. You may play that card for as long as it remains exiled. +SVar:TrigChangeZone:AB$ ChangeZone | Cost$ 0 | Origin$ Hand | Destination$ Exile | DefinedPlayer$ TriggeredTarget | Chooser$ Opponent | ChangeType$ Card | ChangeNum$ 1 | RememberChanged$ True | SubAbility$ DBPump +SVar:DBPump:DB$ Pump | Defined$ Remembered | KW$ May be played by your Opponent | PumpZone$ Exile | Permanent$ True | SubAbility$ DBCleanup +SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True +A:AB$ Regenerate | Cost$ Sac<1/Human> | SpellDescription$ Regenerate CARDNAME. +SVar:RemAIDeck:True +SVar:Rarity:Rare +SVar:Picture:http://www.wizards.com/global/images/magic/general/fiend_of_the_shadows.jpg +SetInfo:DKA|Rare|http://magiccards.info/scans/en/dka/62.jpg +Oracle:Flying\nWhenever Fiend of the Shadows deals combat damage to a player, that player exiles a card from his or her hand. You may play that card for as long as it remains exiled.\nSacrifice a Human: Regenerate Fiend of the Shadows. +End \ No newline at end of file diff --git a/src/main/java/forge/GameAction.java b/src/main/java/forge/GameAction.java index cd0e735c902..1d5a1616caf 100644 --- a/src/main/java/forge/GameAction.java +++ b/src/main/java/forge/GameAction.java @@ -225,6 +225,11 @@ public class GameAction { } copied.setTimestamp(AllZone.getNextTimestamp()); + for (String s : copied.getKeyword()) { + if (s.startsWith("May be played")) { + copied.removeAllExtrinsicKeyword(s); + } + } return copied; } @@ -1876,7 +1881,6 @@ public class GameAction { // for uncastables like lotus bloom, check if manaCost is blank sa.setActivatingPlayer(human); if (sa.canPlay() && (!sa.isSpell() || !sa.getManaCost().equals(""))) { - boolean flashb = false; // check for flashback keywords @@ -1913,7 +1917,7 @@ public class GameAction { choices.add(newSA.toString()); map.put(newSA.toString(), newSA); } - if (!flashb || c.hasKeyword("May be played")) { + if (!flashb || c.hasKeyword("May be played") || c.hasKeyword("May be played by your Opponent")) { choices.add(sa.toString()); map.put(sa.toString(), sa); } diff --git a/src/main/java/forge/Player.java b/src/main/java/forge/Player.java index 89812061952..561064de787 100644 --- a/src/main/java/forge/Player.java +++ b/src/main/java/forge/Player.java @@ -1780,7 +1780,8 @@ public abstract class Player extends GameEntity { */ public final void playLand(final Card land) { if (this.canPlayLand()) { - AllZone.getGameAction().moveToPlay(land); + land.addController(this); + AllZone.getGameAction().moveTo(this.getZone(Constant.Zone.Battlefield), land); CardFactoryUtil.playLandEffects(land); this.numLandsPlayed++; diff --git a/src/main/java/forge/card/cardfactory/CardFactoryUtil.java b/src/main/java/forge/card/cardfactory/CardFactoryUtil.java index 7058ed0dbef..5fc995330c5 100644 --- a/src/main/java/forge/card/cardfactory/CardFactoryUtil.java +++ b/src/main/java/forge/card/cardfactory/CardFactoryUtil.java @@ -2412,17 +2412,19 @@ public class CardFactoryUtil { * getExternalZoneActivationCards. *

* - * @param player + * @param activator * a {@link forge.Player} object. * @return a {@link forge.CardList} object. */ - public static CardList getExternalZoneActivationCards(final Player player) { + public static CardList getExternalZoneActivationCards(final Player activator) { CardList cl = new CardList(); + Player opponent = activator.getOpponent(); - cl.addAll(getActivateablesFromZone(player.getZone(Constant.Zone.Graveyard), player)); - cl.addAll(getActivateablesFromZone(player.getZone(Constant.Zone.Exile), player)); - cl.addAll(getActivateablesFromZone(player.getZone(Constant.Zone.Library), player)); - cl.addAll(getActivateablesFromZone(player.getZone(Constant.Zone.Command), player)); + cl.addAll(getActivateablesFromZone(activator.getZone(Constant.Zone.Graveyard), activator)); + cl.addAll(getActivateablesFromZone(activator.getZone(Constant.Zone.Exile), activator)); + cl.addAll(getActivateablesFromZone(activator.getZone(Constant.Zone.Library), activator)); + cl.addAll(getActivateablesFromZone(activator.getZone(Constant.Zone.Command), activator)); + cl.addAll(getActivateablesFromZone(opponent.getZone(Constant.Zone.Exile), activator)); return cl; } @@ -2434,42 +2436,56 @@ public class CardFactoryUtil { * * @param zone * a PlayerZone object. - * @param player + * @param activator * a {@link forge.Player} object. * @return a boolean. */ - public static CardList getActivateablesFromZone(final PlayerZone zone, final Player player) { + public static CardList getActivateablesFromZone(final PlayerZone zone, final Player activator) { CardList cl = new CardList(zone.getCards()); - cl = cl.filter(new CardListFilter() { - @Override - public boolean addCard(final Card c) { - if (zone.is(Constant.Zone.Graveyard)) { - if (c.hasUnearth()) { - return true; + if (activator.isPlayer(zone.getPlayer())) { + cl = cl.filter(new CardListFilter() { + @Override + public boolean addCard(final Card c) { + if (zone.is(Constant.Zone.Graveyard)) { + if (c.hasUnearth()) { + return true; + } } - } - if (c.isLand() && c.hasKeyword("May be played")) { - return true; - } - - for (final SpellAbility sa : c.getSpellAbility()) { - final Zone restrictZone = sa.getRestrictions().getZone(); - if (zone.is(restrictZone)) { + if (c.isLand() && c.hasKeyword("May be played")) { return true; } - if (sa.isSpell() - && (c.hasKeyword("May be played") || (c.hasStartOfKeyword("Flashback") && zone - .is(Zone.Graveyard))) && restrictZone.equals(Zone.Hand)) { + for (final SpellAbility sa : c.getSpellAbility()) { + final Zone restrictZone = sa.getRestrictions().getZone(); + if (zone.is(restrictZone)) { + return true; + } + + if (sa.isSpell() + && (c.hasKeyword("May be played") || (c.hasStartOfKeyword("Flashback") && zone + .is(Zone.Graveyard))) && restrictZone.equals(Zone.Hand)) { + return true; + } + } + return false; + } + }); + } else { + // the activator is not the owner of the card + cl = cl.filter(new CardListFilter() { + @Override + public boolean addCard(final Card c) { + + if (c.hasKeyword("May be played by your Opponent")) { return true; } + return false; } - return false; - } - }); + }); + } return cl; } diff --git a/src/main/java/forge/card/spellability/Spell.java b/src/main/java/forge/card/spellability/Spell.java index 2f423d63298..370eae5b27a 100644 --- a/src/main/java/forge/card/spellability/Spell.java +++ b/src/main/java/forge/card/spellability/Spell.java @@ -117,7 +117,7 @@ public abstract class Spell extends SpellAbility implements java.io.Serializable return false; } - return (card.isInstant() || card.hasKeyword("Flash") || PhaseHandler.canCastSorcery(card.getController())); + return (card.isInstant() || card.hasKeyword("Flash") || PhaseHandler.canCastSorcery(activator)); } // canPlay() /** {@inheritDoc} */ diff --git a/src/main/java/forge/card/spellability/SpellAbilityRestriction.java b/src/main/java/forge/card/spellability/SpellAbilityRestriction.java index 7fb76fcbe44..920dccd97da 100644 --- a/src/main/java/forge/card/spellability/SpellAbilityRestriction.java +++ b/src/main/java/forge/card/spellability/SpellAbilityRestriction.java @@ -228,7 +228,8 @@ public class SpellAbilityRestriction extends SpellAbilityVariables { return false; } - if (!this.isAnyPlayer() && !activator.equals(c.getController())) { + if (!this.isAnyPlayer() && !activator.equals(c.getController()) + && !c.hasKeyword("May be played by your Opponent")) { return false; } diff --git a/src/main/java/forge/card/spellability/SpellPermanent.java b/src/main/java/forge/card/spellability/SpellPermanent.java index 55af6431dad..44db359d838 100644 --- a/src/main/java/forge/card/spellability/SpellPermanent.java +++ b/src/main/java/forge/card/spellability/SpellPermanent.java @@ -412,6 +412,7 @@ public class SpellPermanent extends Spell { @Override public void resolve() { final Card c = this.getSourceCard(); - AllZone.getGameAction().moveToPlay(c); + c.addController(this.getActivatingPlayer()); + AllZone.getGameAction().moveTo(this.getActivatingPlayer().getZone(Constant.Zone.Battlefield), c); } }