From 6fb1fd30589c51a76f7b211c3a329863fb296ef9 Mon Sep 17 00:00:00 2001 From: elcnesh Date: Sun, 14 Dec 2014 13:08:26 +0000 Subject: [PATCH] Fix certain planes by triggering once for each plane left when planeswalking. --- .../main/java/forge/game/player/Player.java | 20 +++++++-------- .../game/trigger/TriggerPlaneswalkedFrom.java | 25 +++++++------------ forge-gui/res/cardsfolder/m/mount_keralia.txt | 2 +- 3 files changed, 20 insertions(+), 27 deletions(-) diff --git a/forge-game/src/main/java/forge/game/player/Player.java b/forge-game/src/main/java/forge/game/player/Player.java index f7f637968fe..968acad559f 100644 --- a/forge-game/src/main/java/forge/game/player/Player.java +++ b/forge-game/src/main/java/forge/game/player/Player.java @@ -20,6 +20,7 @@ package forge.game.player; import com.google.common.base.Function; import com.google.common.base.Predicate; import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; @@ -2291,20 +2292,19 @@ public class Player extends GameEntity implements Comparable { * Puts my currently active planes, if any, at the bottom of my planar deck. */ public void leaveCurrentPlane() { - if (!currentPlanes.isEmpty()) { + for (final Card plane : currentPlanes) { //Run PlaneswalkedFrom triggers here. - HashMap runParams = new HashMap(); - runParams.put("Card", new CardCollection(currentPlanes)); + final Map runParams = new ImmutableMap.Builder().put("Card", plane).build(); game.getTriggerHandler().runTrigger(TriggerType.PlaneswalkedFrom, runParams,false); - - for (Card c : currentPlanes) { - game.getZoneOf(c).remove(c); - c.clearControllers(); - getZone(ZoneType.PlanarDeck).add(c); - } - currentPlanes.clear(); } + for (final Card plane : currentPlanes) { + game.getZoneOf(plane).remove(plane); + plane.clearControllers(); + getZone(ZoneType.PlanarDeck).add(plane); + } + currentPlanes.clear(); + //DBG //System.out.println("CurrentPlanes: " + currentPlanes); //System.out.println("ActivePlanes: " + game.getActivePlanes()); diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerPlaneswalkedFrom.java b/forge-game/src/main/java/forge/game/trigger/TriggerPlaneswalkedFrom.java index 33ebb3ca95b..c3904d81fa1 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerPlaneswalkedFrom.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerPlaneswalkedFrom.java @@ -26,37 +26,30 @@ public class TriggerPlaneswalkedFrom extends Trigger { public TriggerPlaneswalkedFrom(final Map params, final Card host, final boolean intrinsic) { super(params, host, intrinsic); } - + /* (non-Javadoc) * @see forge.card.trigger.Trigger#performTest(java.util.Map) */ - @SuppressWarnings("unchecked") @Override - public boolean performTest(Map runParams2) { + public boolean performTest(final Map runParams2) { if (this.mapParams.containsKey("ValidCard")) { - for(Card moved : (Iterable)runParams2.get("Card")) - { - if (moved.isValid(this.mapParams.get("ValidCard").split(","), this.getHostCard().getController(), - this.getHostCard())) { - return true; - } + final Card moved = (Card) runParams2.get("Card"); + if (moved.isValid(this.mapParams.get("ValidCard").split(","), this + .getHostCard().getController(), this.getHostCard())) { + return true; } return false; } - + return true; } - /* (non-Javadoc) * @see forge.card.trigger.Trigger#setTriggeringObjects(forge.card.spellability.SpellAbility) */ @Override - public void setTriggeringObjects(SpellAbility sa) { - sa.setTriggeringObject("Cards", this.getRunParams().get("Card")); - // The 'Card' triggered object above is actually an array list of the current planes being left, - // so the actual source has to be determined differently than usual - sa.setTriggeringObject("Source", this.hostCard); + public void setTriggeringObjects(final SpellAbility sa) { + sa.setTriggeringObject("Card", this.getRunParams().get("Card")); } } diff --git a/forge-gui/res/cardsfolder/m/mount_keralia.txt b/forge-gui/res/cardsfolder/m/mount_keralia.txt index f7ccc6c176b..cd1459e7b11 100644 --- a/forge-gui/res/cardsfolder/m/mount_keralia.txt +++ b/forge-gui/res/cardsfolder/m/mount_keralia.txt @@ -8,7 +8,7 @@ SVar:Eruption:AB$ DamageAll | Cost$ 0 | ValidCards$ Creature,Planeswalker | Vali T:Mode$ PlanarDice | Result$ Chaos | TriggerZones$ Command | Execute$ RolledChaos | TriggerDescription$ Whenever you roll {C}, prevent all damage that planes named CARDNAME would deal this game to permanents you control. SVar:RolledChaos:AB$ Effect | Cost$ 0 | Name$ Mount Keralia Effect | StaticAbilities$ KeraliaProtection | EffectOwner$ You | Duration$ Permanent | SpellDescription$ Prevent all damage that planes named CARDNAME would deal this game to permanents you control. SVar:KeraliaProtection:Mode$ PreventDamage | EffectZone$ Command | Target$ Permanent.YouCtrl | Source$ Plane.namedMount Keralia | Description$ Prevent all damage that planes named Mount Keralia would deal this game to permanents you control. -SVar:KeraliaX:TriggeredSource$CardCounters.PRESSURE +SVar:KeraliaX:TriggeredCard$CardCounters.PRESSURE SVar:AIRollPlanarDieParams:Mode$ Always | LowPriority$ True SVar:Picture:http://www.wizards.com/global/images/magic/general/mount_keralia.jpg Oracle:At the beginning of your end step, put a pressure counter on Mount Keralia.\nWhen you planeswalk away from Mount Keralia, it deals damage equal to the number of pressure counters on it to each creature and each planeswalker.\nWhenever you roll {C}, prevent all damage that planes named Mount Keralia would deal this game to permanents you control.