From d2a30ea0493647406606b27bf930e36bf79b99ea Mon Sep 17 00:00:00 2001 From: Agetian Date: Tue, 15 Aug 2017 06:35:08 +0000 Subject: [PATCH] - [C17] Added Shifting Shadow. - One of the hackier/more complicated scripts, so may not be perfect, though was tested in most situations, including stealing the enchanted creature. --- .gitattributes | 1 + .../src/main/java/forge/game/GameAction.java | 14 ++++++++++++++ .../java/forge/game/ability/AbilityFactory.java | 7 ++++++- .../forge/game/ability/effects/EffectEffect.java | 8 ++++++++ .../res/cardsfolder/upcoming/shifting_shadow.txt | 14 ++++++++++++++ 5 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 forge-gui/res/cardsfolder/upcoming/shifting_shadow.txt diff --git a/.gitattributes b/.gitattributes index 99485e588c7..cccc487dfc4 100644 --- a/.gitattributes +++ b/.gitattributes @@ -17193,6 +17193,7 @@ forge-gui/res/cardsfolder/upcoming/patron_of_the_vein.txt -text forge-gui/res/cardsfolder/upcoming/qasali_slingers.txt -text forge-gui/res/cardsfolder/upcoming/ramos_dragon_engine.txt -text forge-gui/res/cardsfolder/upcoming/scalelord_reckoner.txt -text +forge-gui/res/cardsfolder/upcoming/shifting_shadow.txt -text forge-gui/res/cardsfolder/upcoming/taigam_ojutai_master.txt -text forge-gui/res/cardsfolder/upcoming/taigam_sidisis_hand.txt -text forge-gui/res/cardsfolder/upcoming/teferis_protection.txt -text diff --git a/forge-game/src/main/java/forge/game/GameAction.java b/forge-game/src/main/java/forge/game/GameAction.java index e5200630258..27595fc71e7 100644 --- a/forge-game/src/main/java/forge/game/GameAction.java +++ b/forge-game/src/main/java/forge/game/GameAction.java @@ -604,6 +604,20 @@ public class GameAction { c.setTurnInZone(tiz); c.setCameUnderControlSinceLastUpkeep(true); + // check for related effects and correct their controller and zone if necessary + for (Card eff : game.getCardsIn(ZoneType.Command)) { + if (eff.getType().hasSubtype("Effect")) { + boolean moveWithImprinted = eff.hasSVar("MoveWithImprinted") && eff.getImprintedCards().contains(c); + boolean moveWithRemembered = eff.hasSVar("MoveWithRemembered") && (Iterables.contains(eff.getRemembered(), c)); + + if (moveWithImprinted || moveWithRemembered) { + eff.setController(c.getController(), game.getNextTimestamp()); + eff.getZone().remove(eff); + c.getController().getZone(ZoneType.Command).add(eff); + } + } + } + final Map runParams = Maps.newHashMap(); runParams.put("Card", c); runParams.put("OriginalController", original); diff --git a/forge-game/src/main/java/forge/game/ability/AbilityFactory.java b/forge-game/src/main/java/forge/game/ability/AbilityFactory.java index 186922a0196..c19c235bc48 100644 --- a/forge-game/src/main/java/forge/game/ability/AbilityFactory.java +++ b/forge-game/src/main/java/forge/game/ability/AbilityFactory.java @@ -252,7 +252,12 @@ public final class AbilityFactory { } } - if (spellAbility instanceof SpellApiBased && hostCard.isPermanent()) { + // OverrideSpellDescription can be set in case a permanent spell with subs explicitly specifies + // SpellDescription for all its components, potentially in subabilities, which allows to avoid artifacts + // such as splashing the card name in the beginning of the description (e.g. Shifting Shadow) + + if (spellAbility instanceof SpellApiBased && hostCard.isPermanent() + && !mapParams.containsKey("OverrideSpellDescription")) { spellAbility.setDescription(spellAbility.getHostCard().getName()); } else if (mapParams.containsKey("SpellDescription")) { final StringBuilder sb = new StringBuilder(); diff --git a/forge-game/src/main/java/forge/game/ability/effects/EffectEffect.java b/forge-game/src/main/java/forge/game/ability/effects/EffectEffect.java index 74727440305..93db64a5b65 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/EffectEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/EffectEffect.java @@ -112,6 +112,14 @@ public class EffectEffect extends SpellAbilityEffect { final Card eff = createEffect(hostCard, controller, name, image); + // For effects that need to change their controller and zone together with the card remembered/imprinted on them + if (sa.hasParam("MoveWithRemembered")) { + eff.setSVar("MoveWithRemembered", "True"); + } + if (sa.hasParam("MoveWithImprinted")) { + eff.setSVar("MoveWithImprinted", "True"); + } + // Grant SVars first in order to give references to granted abilities if (effectSVars != null) { for (final String s : effectSVars) { diff --git a/forge-gui/res/cardsfolder/upcoming/shifting_shadow.txt b/forge-gui/res/cardsfolder/upcoming/shifting_shadow.txt new file mode 100644 index 00000000000..bc2ee32b646 --- /dev/null +++ b/forge-gui/res/cardsfolder/upcoming/shifting_shadow.txt @@ -0,0 +1,14 @@ +Name:Shifting Shadow +ManaCost:2 R +Types:Enchantment Aura +K:Enchant creature +A:SP$ Attach | Cost$ 2 R | ValidTgts$ Creature | AILogic$ Pump | SubAbility$ DBEffect | OverrideSpellDescription$ True +SVar:DBEffect:DB$ Effect | Triggers$ ShadowUpkeepTrig | RememberObjects$ Enchanted | ImprintCards$ Self | SVars$ ShadowRevealCards,ShadowReattach,ShadowDestroyEnchanted,ShadowForgetDestroyed | ConditionPresent$ Card.Self | Duration$ UntilHostLeavesPlay | ExileOnMoved$ Exile | Name$ Shifting Shadow Effect | MoveWithRemembered$ True | SpellDescription$ Enchanted creature has haste and "At the beginning of your upkeep, destroy this creature. Reveal cards from the top of your library until you reveal a creature card. Put that card onto the battlefield and attach CARDNAME to it, then put all other cards revealed this way on the bottom of your library in a random order." +S:Mode$ Continuous | Affected$ Creature.EnchantedBy | AddKeyword$ Haste +SVar:ShadowUpkeepTrig:Mode$ Phase | Phase$ Upkeep | ValidPlayer$ You | TriggerZones$ Command | TriggerController$ RememberedController | Execute$ ShadowDestroyEnchanted | TriggerDescription$ At the beginning of your upkeep, destroy this creature. Reveal cards from the top of your library until you reveal a creature card. Put that card onto the battlefield and attach EFFECTSOURCE to it, then put all other cards revealed this way on the bottom of your library in a random order. +SVar:ShadowDestroyEnchanted:DB$ Destroy | Defined$ Remembered | SubAbility$ ShadowForgetDestroyed +SVar:ShadowForgetDestroyed:DB$ Pump | ForgetObjects$ Remembered | SubAbility$ ShadowRevealCards +SVar:ShadowRevealCards:DB$ DigUntil | Valid$ Creature | ValidDescription$ creature | FoundDestination$ Battlefield | RevealedDestination$ Library | RevealedLibraryPosition$ -1 | RevealRandomOrder$ True | RememberFound$ True | SubAbility$ ShadowReattach +SVar:ShadowReattach:DB$ Attach | Defined$ Remembered | Object$ Imprinted +SVar:Picture:http://www.wizards.com/global/images/magic/general/shifting_shadow.jpg +Oracle:Enchant creature\nEnchanted creature has haste and "At the beginning of your upkeep, destroy this creature. Reveal cards from the top of your library until you reveal a creature card. Put that card onto the battlefield and attach Shifting Shadow to it, then put all other cards revealed this way on the bottom of your library in a random order." \ No newline at end of file