From 2f45d0050bacd3877bf4676691f2d2899fed42d3 Mon Sep 17 00:00:00 2001 From: Ryan1729 Date: Sun, 8 Sep 2019 21:34:41 -0600 Subject: [PATCH] Find that many methods are always passed null for their params and so start removeing those params since they are getting in the way of my intended refactor. --- .../src/main/java/forge/game/GameAction.java | 48 ++++++++----------- .../ability/effects/ChangeZoneEffect.java | 8 ++-- .../main/java/forge/game/zone/MagicStack.java | 2 +- 3 files changed, 25 insertions(+), 33 deletions(-) diff --git a/forge-game/src/main/java/forge/game/GameAction.java b/forge-game/src/main/java/forge/game/GameAction.java index 8176841ed7f..e243b172934 100644 --- a/forge-game/src/main/java/forge/game/GameAction.java +++ b/forge-game/src/main/java/forge/game/GameAction.java @@ -79,7 +79,7 @@ public class GameAction { return changeZone(zoneFrom, zoneTo, c, position, cause, null); } - public Card changeZone(final Zone zoneFrom, Zone zoneTo, final Card c, Integer position, SpellAbility cause, Map params) { + private Card changeZone(final Zone zoneFrom, Zone zoneTo, final Card c, Integer position, SpellAbility cause, Map params) { if (c.isCopiedSpell() || (c.isImmutable() && zoneTo.is(ZoneType.Exile))) { // Remove Effect from command immediately, this is essential when some replacement // effects happen during the resolving of a spellability ("the next time ..." effect) @@ -528,18 +528,18 @@ public class GameAction { public final Card moveTo(final Zone zoneTo, Card c, SpellAbility cause) { return moveTo(zoneTo, c, cause, null); } - - public final Card moveTo(final Zone zoneTo, Card c, SpellAbility cause, Map params) { - // FThreads.assertExecutedByEdt(false); // This code must never be executed from EDT, - // use FThreads.invokeInNewThread to run code in a pooled thread - return moveTo(zoneTo, c, null, cause, params); - } public final Card moveTo(final Zone zoneTo, Card c, Integer position, SpellAbility cause) { return moveTo(zoneTo, c, position, cause, null); } - - public final Card moveTo(final Zone zoneTo, Card c, Integer position, SpellAbility cause, Map params) { + + private Card moveTo(final Zone zoneTo, Card c, SpellAbility cause, Map params) { + // FThreads.assertExecutedByEdt(false); // This code must never be executed from EDT, + // use FThreads.invokeInNewThread to run code in a pooled thread + return moveTo(zoneTo, c, null, cause, params); + } + + private Card moveTo(final Zone zoneTo, Card c, Integer position, SpellAbility cause, Map params) { // Ideally move to should never be called without a prevZone // Remove card from Current Zone, if it has one final Zone zoneFrom = game.getZoneOf(c); @@ -723,30 +723,22 @@ public class GameAction { } public final Card moveTo(final ZoneType name, final Card c, SpellAbility cause) { - return moveTo(name, c, cause, null); - } - - public final Card moveTo(final ZoneType name, final Card c, SpellAbility cause, Map params) { - return moveTo(name, c, 0, cause, params); - } - - public final Card moveTo(final ZoneType name, final Card c, final int libPosition, SpellAbility cause) { - return moveTo(name, c, libPosition, cause, null); + return moveTo(name, c, 0, cause); } - public final Card moveTo(final ZoneType name, final Card c, final int libPosition, SpellAbility cause, Map params) { + public final Card moveTo(final ZoneType name, final Card c, final int libPosition, SpellAbility cause) { // Call specific functions to set PlayerZone, then move onto moveTo switch(name) { - case Hand: return moveToHand(c, cause, params); - case Library: return moveToLibrary(c, libPosition, cause, params); - case Battlefield: return moveToPlay(c, cause, params); - case Graveyard: return moveToGraveyard(c, cause, params); - case Exile: return exile(c, cause, params); - case Stack: return moveToStack(c, cause, params); - case PlanarDeck: return moveToVariantDeck(c, ZoneType.PlanarDeck, libPosition, cause, params); - case SchemeDeck: return moveToVariantDeck(c, ZoneType.SchemeDeck, libPosition, cause, params); + case Hand: return moveToHand(c, cause, null); + case Library: return moveToLibrary(c, libPosition, cause, null); + case Battlefield: return moveToPlay(c, cause, null); + case Graveyard: return moveToGraveyard(c, cause, null); + case Exile: return exile(c, cause, null); + case Stack: return moveToStack(c, cause, null); + case PlanarDeck: return moveToVariantDeck(c, ZoneType.PlanarDeck, libPosition, cause, null); + case SchemeDeck: return moveToVariantDeck(c, ZoneType.SchemeDeck, libPosition, cause, null); default: // sideboard will also get there - return moveTo(c.getOwner().getZone(name), c, cause, params); + return moveTo(c.getOwner().getZone(name), c, cause, null); } } diff --git a/forge-game/src/main/java/forge/game/ability/effects/ChangeZoneEffect.java b/forge-game/src/main/java/forge/game/ability/effects/ChangeZoneEffect.java index f34202c6a64..01445323772 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/ChangeZoneEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/ChangeZoneEffect.java @@ -534,7 +534,7 @@ public class ChangeZoneEffect extends SpellAbilityEffect { } movedCard = game.getAction().moveTo( - tgtC.getController().getZone(destination), tgtC, sa, null); + tgtC.getController().getZone(destination), tgtC, sa); if (sa.hasParam("Unearth")) { movedCard.setUnearthed(true); movedCard.addChangedCardKeywords(Lists.newArrayList("Haste"), null, false, false, @@ -591,7 +591,7 @@ public class ChangeZoneEffect extends SpellAbilityEffect { } tgtC.setExiledWith(host); } - movedCard = game.getAction().moveTo(destination, tgtC, sa, null); + movedCard = game.getAction().moveTo(destination, tgtC, sa); // If a card is Exiled from the stack, remove its spells from the stack if (sa.hasParam("Fizzle")) { if (tgtC.isInZone(ZoneType.Exile) || tgtC.isInZone(ZoneType.Hand) @@ -1096,7 +1096,7 @@ public class ChangeZoneEffect extends SpellAbilityEffect { c.addFaceupCommand(unanimate); } } - movedCard = game.getAction().moveTo(c.getController().getZone(destination), c, sa, null); + movedCard = game.getAction().moveTo(c.getController().getZone(destination), c, sa); if (sa.hasParam("Tapped")) { movedCard.setTapped(true); } @@ -1121,7 +1121,7 @@ public class ChangeZoneEffect extends SpellAbilityEffect { } } else { - movedCard = game.getAction().moveTo(destination, c, sa, null); + movedCard = game.getAction().moveTo(destination, c, sa); } movedCards.add(movedCard); diff --git a/forge-game/src/main/java/forge/game/zone/MagicStack.java b/forge-game/src/main/java/forge/game/zone/MagicStack.java index 00b0c822de2..30df45a36ae 100644 --- a/forge-game/src/main/java/forge/game/zone/MagicStack.java +++ b/forge-game/src/main/java/forge/game/zone/MagicStack.java @@ -136,7 +136,7 @@ public class MagicStack /* extends MyObservable */ implements Iterable