From 76c68123552d636ddf77c52e2646b01a2b42a306 Mon Sep 17 00:00:00 2001 From: swordshine Date: Sat, 31 May 2014 01:53:13 +0000 Subject: [PATCH] - Added Halfdane --- .gitattributes | 1 + .../game/ability/effects/AnimateEffect.java | 7 ++++ .../src/main/java/forge/game/phase/Phase.java | 32 ++++++++++++++++++- .../java/forge/game/phase/PhaseHandler.java | 2 ++ forge-gui/res/cardsfolder/h/halfdane.txt | 11 +++++++ 5 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 forge-gui/res/cardsfolder/h/halfdane.txt diff --git a/.gitattributes b/.gitattributes index 14ee7dcb84c..7fb33383d2f 100644 --- a/.gitattributes +++ b/.gitattributes @@ -6379,6 +6379,7 @@ forge-gui/res/cardsfolder/h/hakim_loreweaver.txt -text forge-gui/res/cardsfolder/h/halam_djinn.txt -text forge-gui/res/cardsfolder/h/halberdier.txt svneol=native#text/plain forge-gui/res/cardsfolder/h/halcyon_glaze.txt svneol=native#text/plain +forge-gui/res/cardsfolder/h/halfdane.txt -text forge-gui/res/cardsfolder/h/halimar_depths.txt svneol=native#text/plain forge-gui/res/cardsfolder/h/halimar_excavator.txt svneol=native#text/plain forge-gui/res/cardsfolder/h/halimar_wavewatch.txt svneol=native#text/plain diff --git a/forge-game/src/main/java/forge/game/ability/effects/AnimateEffect.java b/forge-game/src/main/java/forge/game/ability/effects/AnimateEffect.java index f61f2ce91f2..057a9f827ba 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/AnimateEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/AnimateEffect.java @@ -7,6 +7,7 @@ import forge.game.ability.AbilityUtils; import forge.game.card.Card; import forge.game.card.CardUtil; import forge.game.event.GameEventCardStatsChanged; +import forge.game.phase.PhaseType; import forge.game.replacement.ReplacementEffect; import forge.game.replacement.ReplacementHandler; import forge.game.spellability.SpellAbility; @@ -290,6 +291,12 @@ public class AnimateEffect extends AnimateEffectBase { source.addLeavesPlayCommand(unanimate); } else if (sa.hasParam("UntilYourNextUpkeep")) { game.getUpkeep().addUntil(source.getController(), unanimate); + } else if (sa.hasParam("UntilTheEndOfYourNextUpkeep")) { + if (game.getPhaseHandler().is(PhaseType.UPKEEP)) { + game.getUpkeep().registerUntilEnd(source.getController(), unanimate); + } else { + game.getUpkeep().addUntilEnd(source.getController(), unanimate); + } } else if (sa.hasParam("UntilControllerNextUntap")) { game.getUntap().addUntil(c.getController(), unanimate); } else if (sa.hasParam("UntilYourNextTurn")) { diff --git a/forge-game/src/main/java/forge/game/phase/Phase.java b/forge-game/src/main/java/forge/game/phase/Phase.java index 1f5dcd59660..37aa4f3340d 100644 --- a/forge-game/src/main/java/forge/game/phase/Phase.java +++ b/forge-game/src/main/java/forge/game/phase/Phase.java @@ -93,7 +93,8 @@ public class Phase implements java.io.Serializable { /** The until map. */ private final HashMap> untilMap = new HashMap>(); - + private final HashMap> untilEndMap = new HashMap>(); + private final HashMap> registerMap = new HashMap>(); /** *

* Add a Command that will terminate an effect with "until next ". @@ -121,6 +122,35 @@ public class Phase implements java.io.Serializable { } } + public final void registerUntilEnd(Player p, final GameCommand c) { + if (this.registerMap.containsKey(p)) { + this.registerMap.get(p).add(0, c); + } else { + this.registerMap.put(p, Lists.newArrayList(c)); + } + } + + public final void addUntilEnd(Player p, final GameCommand c) { + if (this.untilEndMap.containsKey(p)) { + this.untilEndMap.get(p).add(0, c); + } else { + this.untilEndMap.put(p, Lists.newArrayList(c)); + } + } + + public final void RegisterUntilEndCommand(final Player p) { + if (this.registerMap.containsKey(p)) { + this.untilEndMap.put(p, registerMap.get(p)); + registerMap.remove(p); + } + } + + public final void executeUntilEndOfPhase(final Player p) { + if (this.untilEndMap.containsKey(p)) { + this.execute(this.untilEndMap.get(p)); + } + } + /** *

* execute. diff --git a/forge-game/src/main/java/forge/game/phase/PhaseHandler.java b/forge-game/src/main/java/forge/game/phase/PhaseHandler.java index 923411412e5..98736c8cad3 100644 --- a/forge-game/src/main/java/forge/game/phase/PhaseHandler.java +++ b/forge-game/src/main/java/forge/game/phase/PhaseHandler.java @@ -424,6 +424,8 @@ public class PhaseHandler implements java.io.Serializable { c.getDamageHistory().setNotBlockedSinceLastUpkeepOf(this.getPlayerTurn()); c.getDamageHistory().setNotBeenBlockedSinceLastUpkeepOf(this.getPlayerTurn()); } + game.getUpkeep().executeUntilEndOfPhase(this.getPlayerTurn()); + game.getUpkeep().RegisterUntilEndCommand(this.getPlayerTurn()); break; case COMBAT_END: diff --git a/forge-gui/res/cardsfolder/h/halfdane.txt b/forge-gui/res/cardsfolder/h/halfdane.txt new file mode 100644 index 00000000000..565c5382fbd --- /dev/null +++ b/forge-gui/res/cardsfolder/h/halfdane.txt @@ -0,0 +1,11 @@ +Name:Halfdane +ManaCost:1 W U B +Types:Legendary Creature Shapeshifter +PT:3/3 +T:Mode$ Phase | Phase$ Upkeep | ValidPlayer$ You | TriggerZones$ Battlefield | Execute$ TrigAnimate | TriggerDescription$ At the beginning of your upkeep, CARDNAME's power and toughness become equal to the power and toughness of target creature other than CARDNAME until the end of your next upkeep. +SVar:TrigAnimate:AB$ Pump | Cost$ 0 | ValidTgts$ Creature.Other | TgtPrompt$ Select target another creature | AILogic$ HighestPower | SubAbility$ DBAnimate +SVar:DBAnimate:DB$ Animate | Defined$ Self | Power$ X | Toughness$ Y | References$ X,Y | UntilTheEndOfYourNextUpkeep$ True +SVar:X:Targeted$CardPower +SVar:Y:Targeted$CardToughness +SVar:Picture:http://www.wizards.com/global/images/magic/general/halfdane.jpg +Oracle:At the beginning of your upkeep, Halfdane's power and toughness become equal to the power and toughness of target creature other than Halfdane until the end of your next upkeep.