From 6120b99ace2f22b94e1cc666b51fb0279b5e86e6 Mon Sep 17 00:00:00 2001 From: jendave Date: Tue, 1 Nov 2011 22:11:41 +0000 Subject: [PATCH] checkstyle and refactoring --- src/main/java/forge/CombatUtil.java | 2 +- src/main/java/forge/GameAction.java | 795 +++++++++--------- src/main/java/forge/HumanPlayer.java | 10 +- src/main/java/forge/PlayerUtil.java | 36 +- src/main/java/forge/Upkeep.java | 4 +- .../AbilityFactory_Sacrifice.java | 2 +- .../cardFactory/CardFactory_Sorceries.java | 4 +- .../java/forge/card/cost/CostDiscard.java | 12 +- src/main/java/forge/card/cost/CostExile.java | 12 +- src/main/java/forge/card/cost/CostMill.java | 8 +- .../forge/card/cost/CostPartWithList.java | 10 +- .../java/forge/card/cost/CostPutCounter.java | 4 +- src/main/java/forge/card/cost/CostReturn.java | 8 +- src/main/java/forge/card/cost/CostReveal.java | 8 +- .../java/forge/card/cost/CostSacrifice.java | 10 +- .../java/forge/card/cost/CostTapType.java | 12 +- src/main/java/forge/card/trigger/Trigger.java | 383 +++++---- .../forge/card/trigger/TriggerHandler.java | 140 ++- .../forge/card/trigger/Trigger_Always.java | 10 +- .../card/trigger/Trigger_AttackerBlocked.java | 26 +- .../trigger/Trigger_AttackerUnblocked.java | 17 +- .../trigger/Trigger_AttackersDeclared.java | 22 +- .../forge/card/trigger/Trigger_Attacks.java | 29 +- .../card/trigger/Trigger_BecomesTarget.java | 35 +- .../forge/card/trigger/Trigger_Blocks.java | 24 +- .../card/trigger/Trigger_Championed.java | 21 +- .../card/trigger/Trigger_ChangesZone.java | 33 +- .../forge/card/trigger/Trigger_Clashed.java | 19 +- .../card/trigger/Trigger_CounterAdded.java | 25 +- .../forge/card/trigger/Trigger_Cycled.java | 17 +- .../card/trigger/Trigger_DamageDone.java | 45 +- .../forge/card/trigger/Trigger_Discarded.java | 27 +- .../forge/card/trigger/Trigger_Drawn.java | 19 +- .../card/trigger/Trigger_LandPlayed.java | 20 +- .../card/trigger/Trigger_LifeGained.java | 19 +- .../forge/card/trigger/Trigger_LifeLost.java | 19 +- .../forge/card/trigger/Trigger_Phase.java | 25 +- .../card/trigger/Trigger_Sacrificed.java | 24 +- .../forge/card/trigger/Trigger_Shuffled.java | 17 +- .../trigger/Trigger_SpellAbilityCast.java | 80 +- .../java/forge/card/trigger/Trigger_Taps.java | 19 +- .../card/trigger/Trigger_TapsForMana.java | 23 +- .../card/trigger/Trigger_TurnFaceUp.java | 17 +- .../forge/card/trigger/Trigger_Unequip.java | 28 +- .../forge/card/trigger/Trigger_Untaps.java | 19 +- .../forge/game/limited/BoosterDraftAI.java | 44 +- .../java/forge/game/limited/DeckColors.java | 74 +- .../forge/quest/data/pet/QuestPetManager.java | 24 +- .../java/forge/quest/gui/QuestMainPanel.java | 2 +- .../forge/quest/gui/QuestWinLoseHandler.java | 36 +- .../forge/view/swing/ApplicationView.java | 8 +- .../java/forge/view/swing/OldGuiNewGame.java | 88 +- .../java/forge/view/swing/WinLoseFrame.java | 134 ++- 53 files changed, 1405 insertions(+), 1144 deletions(-) diff --git a/src/main/java/forge/CombatUtil.java b/src/main/java/forge/CombatUtil.java index 4e1ca346fdf..fb8148d8e34 100644 --- a/src/main/java/forge/CombatUtil.java +++ b/src/main/java/forge/CombatUtil.java @@ -2117,7 +2117,7 @@ public class CombatUtil { CardList list = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); ComputerUtil.sacrificePermanents(a, list); } else { - AllZone.getInputControl().setInput(PlayerUtil.input_sacrificePermanents(a)); + AllZone.getInputControl().setInput(PlayerUtil.inputSacrificePermanents(a)); } } diff --git a/src/main/java/forge/GameAction.java b/src/main/java/forge/GameAction.java index 91092d326ff..f92ee6330f8 100644 --- a/src/main/java/forge/GameAction.java +++ b/src/main/java/forge/GameAction.java @@ -65,16 +65,16 @@ public class GameAction { *

*/ public final void resetActivationsPerTurn() { - CardList all = AllZoneUtil.getCardsInGame(); + final CardList all = AllZoneUtil.getCardsInGame(); // Reset Activations per Turn - for (Card card : all) { - for (SpellAbility sa : card.getSpellAbility()) { + for (final Card card : all) { + for (final SpellAbility sa : card.getSpellAbility()) { sa.getRestrictions().resetTurnActivations(); } if (card.hasAlternateState()) { card.changeState(); - for (SpellAbility sa : card.getSpellAbility()) { + for (final SpellAbility sa : card.getSpellAbility()) { sa.getRestrictions().resetTurnActivations(); } card.changeState(); @@ -96,13 +96,13 @@ public class GameAction { * @return a {@link forge.Card} object. */ public static Card changeZone(final PlayerZone prev, final PlayerZone zone, final Card c) { - if (prev == null && !c.isToken()) { + if ((prev == null) && !c.isToken()) { zone.add(c); return c; } boolean suppress; - if (prev == null && !c.isToken()) { + if ((prev == null) && !c.isToken()) { suppress = true; } else if (c.isToken()) { suppress = false; @@ -130,12 +130,12 @@ public class GameAction { // Stack->Battlefield // these probably can be moved back to SubtractCounters if (c.wasSuspendCast()) { - copied = addSuspendTriggers(c); + copied = GameAction.addSuspendTriggers(c); } copied.setUnearthed(c.isUnearthed()); // this might be unnecessary } - for (Trigger trigger : c.getTriggers()) { + for (final Trigger trigger : c.getTriggers()) { trigger.setHostCard(copied); } @@ -158,7 +158,7 @@ public class GameAction { prev.remove(c); } - HashMap runParams = new HashMap(); + final HashMap runParams = new HashMap(); runParams.put("Card", lastKnownInfo); if (prev != null) { runParams.put("Origin", prev.getZoneType().name()); @@ -206,22 +206,22 @@ public class GameAction { public final Card moveTo(final PlayerZone zone, Card c) { // Ideally move to should never be called without a prevZone // Remove card from Current Zone, if it has one - PlayerZone prev = AllZone.getZoneOf(c); + final PlayerZone prev = AllZone.getZoneOf(c); // String prevName = prev != null ? prev.getZoneName() : ""; if (c.hasKeyword("If CARDNAME would leave the battlefield, exile it instead of putting it anywhere else.") && !zone.is(Constant.Zone.Exile)) { - PlayerZone removed = c.getOwner().getZone(Constant.Zone.Exile); + final PlayerZone removed = c.getOwner().getZone(Constant.Zone.Exile); c.removeExtrinsicKeyword("If CARDNAME would leave the battlefield, " - + "exile it instead of putting it anywhere else."); - return moveTo(removed, c); + + "exile it instead of putting it anywhere else."); + return this.moveTo(removed, c); } // Card lastKnownInfo = c; - c = changeZone(prev, zone, c); + c = GameAction.changeZone(prev, zone, c); - if (c.isAura() && zone.is(Constant.Zone.Battlefield) && (prev == null || !prev.is(Constant.Zone.Stack))) { + if (c.isAura() && zone.is(Constant.Zone.Battlefield) && ((prev == null) || !prev.is(Constant.Zone.Stack))) { // TODO Need a way to override this for Abilities that put Auras // into play attached to things AbilityFactory_Attach.attachAuraOnIndirectEnterBattlefield(c); @@ -242,10 +242,10 @@ public class GameAction { public final Card moveToPlayFromHand(Card c) { // handles the case for Clone, etc where prev was null - PlayerZone hand = c.getOwner().getZone(Constant.Zone.Hand); - PlayerZone play = c.getController().getZone(Constant.Zone.Battlefield); + final PlayerZone hand = c.getOwner().getZone(Constant.Zone.Hand); + final PlayerZone play = c.getController().getZone(Constant.Zone.Battlefield); - c = changeZone(hand, play, c); + c = GameAction.changeZone(hand, play, c); return c; } @@ -289,10 +289,10 @@ public class GameAction { */ public final void controllerChangeZoneCorrection(final Card c) { System.out.println("Correcting zone for " + c.toString()); - PlayerZone oldBattlefield = AllZone.getZoneOf(c); - PlayerZone newBattlefield = c.getController().getZone(oldBattlefield.getZoneType()); + final PlayerZone oldBattlefield = AllZone.getZoneOf(c); + final PlayerZone newBattlefield = c.getController().getZone(oldBattlefield.getZoneType()); - if (oldBattlefield == null || newBattlefield == null) { + if ((oldBattlefield == null) || (newBattlefield == null)) { return; } @@ -300,7 +300,7 @@ public class GameAction { ((PlayerZoneComesIntoPlay) AllZone.getHumanPlayer().getZone(Zone.Battlefield)).setTriggers(false); ((PlayerZoneComesIntoPlay) AllZone.getComputerPlayer().getZone(Zone.Battlefield)).setTriggers(false); - int tiz = c.getTurnInZone(); + final int tiz = c.getTurnInZone(); oldBattlefield.remove(c); newBattlefield.add(c); @@ -322,8 +322,8 @@ public class GameAction { * @return a {@link forge.Card} object. */ public final Card moveToStack(final Card c) { - PlayerZone stack = AllZone.getStackZone(); - return moveTo(stack, c); + final PlayerZone stack = AllZone.getStackZone(); + return this.moveTo(stack, c); } /** @@ -344,24 +344,24 @@ public class GameAction { final CardList opponentsBoard = owner.getOpponent().getCardsIn(Constant.Zone.Battlefield); if (c.getName().equals("Nissa's Chosen") && origZone.is(Constant.Zone.Battlefield)) { - return moveToLibrary(c, -1); + return this.moveToLibrary(c, -1); } - for (Card card : opponentsBoard) { + for (final Card card : opponentsBoard) { if (card.hasKeyword("If a card would be put into an opponent's " - + "graveyard from anywhere, exile it instead.")) { - return moveTo(exile, c); + + "graveyard from anywhere, exile it instead.")) { + return this.moveTo(exile, c); } } - for (Card card : ownerBoard) { + for (final Card card : ownerBoard) { if (card.hasKeyword("If a card would be put into your graveyard from anywhere, exile it instead.")) { - return moveTo(exile, c); + return this.moveTo(exile, c); } } if (c.hasKeyword("If CARDNAME would be put into a graveyard this turn, exile it instead.")) { - return moveTo(exile, c); + return this.moveTo(exile, c); } if (c.hasKeyword("If CARDNAME is put into a graveyard this turn, its controller gets a poison counter.")) { @@ -369,13 +369,13 @@ public class GameAction { } // must put card in OWNER's graveyard not controller's - c = moveTo(grave, c); + c = this.moveTo(grave, c); // Recover keyword if (c.isCreature() && origZone.is(Constant.Zone.Battlefield)) { for (final Card recoverable : c.getOwner().getCardsIn(Zone.Graveyard)) { if (recoverable.hasStartOfKeyword("Recover")) { - SpellAbility abRecover = new Ability(recoverable, "0") { + final SpellAbility abRecover = new Ability(recoverable, "0") { @Override public void resolve() { AllZone.getGameAction().moveToHand(recoverable); @@ -383,16 +383,17 @@ public class GameAction { @Override public String getStackDescription() { - StringBuilder sd = new StringBuilder(recoverable.getName()); + final StringBuilder sd = new StringBuilder(recoverable.getName()); sd.append(" - Recover."); return sd.toString(); } }; - Command notPaid = new Command() { + final Command notPaid = new Command() { private static final long serialVersionUID = 5812397026869965462L; + @Override public void execute() { AllZone.getGameAction().exile(recoverable); } @@ -401,12 +402,12 @@ public class GameAction { abRecover.setCancelCommand(notPaid); abRecover.setTrigger(true); - String recoverCost = recoverable.getKeyword().get(recoverable.getKeywordPosition("Recover")) + final String recoverCost = recoverable.getKeyword().get(recoverable.getKeywordPosition("Recover")) .split(":")[1]; - Cost abCost = new Cost(recoverCost, recoverable.getName(), false); + final Cost abCost = new Cost(recoverCost, recoverable.getName(), false); abRecover.setPayCosts(abCost); - StringBuilder question = new StringBuilder("Recover "); + final StringBuilder question = new StringBuilder("Recover "); question.append(recoverable.getName()); question.append("("); question.append(recoverable.getUniqueNumber()); @@ -450,8 +451,8 @@ public class GameAction { * @return a {@link forge.Card} object. */ public final Card moveToHand(final Card c) { - PlayerZone hand = c.getOwner().getZone(Constant.Zone.Hand); - return moveTo(hand, c); + final PlayerZone hand = c.getOwner().getZone(Constant.Zone.Hand); + return this.moveTo(hand, c); } /** @@ -464,8 +465,8 @@ public class GameAction { * @return a {@link forge.Card} object. */ public final Card moveToPlay(final Card c) { - PlayerZone play = c.getOwner().getZone(Constant.Zone.Battlefield); - return moveTo(play, c); + final PlayerZone play = c.getOwner().getZone(Constant.Zone.Battlefield); + return this.moveTo(play, c); } /** @@ -481,8 +482,8 @@ public class GameAction { */ public final Card moveToPlay(final Card c, final Player p) { // move to a specific player's Battlefield - PlayerZone play = p.getZone(Constant.Zone.Battlefield); - return moveTo(play, c); + final PlayerZone play = p.getZone(Constant.Zone.Battlefield); + return this.moveTo(play, c); } /** @@ -495,7 +496,7 @@ public class GameAction { * @return a {@link forge.Card} object. */ public final Card moveToBottomOfLibrary(final Card c) { - return moveToLibrary(c, -1); + return this.moveToLibrary(c, -1); } /** @@ -508,7 +509,7 @@ public class GameAction { * @return a {@link forge.Card} object. */ public final Card moveToLibrary(final Card c) { - return moveToLibrary(c, 0); + return this.moveToLibrary(c, 0); } /** @@ -523,14 +524,14 @@ public class GameAction { * @return a {@link forge.Card} object. */ public final Card moveToLibrary(Card c, int libPosition) { - PlayerZone p = AllZone.getZoneOf(c); - PlayerZone library = c.getOwner().getZone(Constant.Zone.Library); + final PlayerZone p = AllZone.getZoneOf(c); + final PlayerZone library = c.getOwner().getZone(Constant.Zone.Library); if (c.hasKeyword("If CARDNAME would leave the battlefield, exile it instead of putting it anywhere else.")) { - PlayerZone removed = c.getOwner().getZone(Constant.Zone.Exile); + final PlayerZone removed = c.getOwner().getZone(Constant.Zone.Exile); c.removeExtrinsicKeyword("If CARDNAME would leave the battlefield, " - + "exile it instead of putting it anywhere else."); - return moveTo(removed, c); + + "exile it instead of putting it anywhere else."); + return this.moveTo(removed, c); } if (p != null) { @@ -541,13 +542,13 @@ public class GameAction { return c; } - if (p != null && p.is(Constant.Zone.Battlefield)) { + if ((p != null) && p.is(Constant.Zone.Battlefield)) { c = AllZone.getCardFactory().copyCard(c); } c.clearCounters(); // remove all counters - if (libPosition == -1 || libPosition > library.size()) { + if ((libPosition == -1) || (libPosition > library.size())) { libPosition = library.size(); } @@ -569,7 +570,7 @@ public class GameAction { return c; } - PlayerZone removed = c.getOwner().getZone(Constant.Zone.Exile); + final PlayerZone removed = c.getOwner().getZone(Constant.Zone.Exile); return AllZone.getGameAction().moveTo(removed, c); } @@ -584,7 +585,7 @@ public class GameAction { * @return the card */ public final Card moveTo(final Zone name, final Card c) { - return moveTo(name, c, 0); + return this.moveTo(name, c, 0); } /** @@ -603,17 +604,17 @@ public class GameAction { public final Card moveTo(final Zone name, final Card c, final int libPosition) { // Call specific functions to set PlayerZone, then move onto moveTo if (name.equals(Constant.Zone.Hand)) { - return moveToHand(c); + return this.moveToHand(c); } else if (name.equals(Constant.Zone.Library)) { - return moveToLibrary(c, libPosition); + return this.moveToLibrary(c, libPosition); } else if (name.equals(Constant.Zone.Battlefield)) { - return moveToPlay(c); + return this.moveToPlay(c); } else if (name.equals(Constant.Zone.Graveyard)) { - return moveToGraveyard(c); + return this.moveToGraveyard(c); } else if (name.equals(Constant.Zone.Exile)) { - return exile(c); + return this.exile(c); } else { - return moveToStack(c); + return this.moveToStack(c); } } @@ -626,7 +627,7 @@ public class GameAction { * a {@link forge.Card} object. */ public final void discard_PutIntoPlayInstead(final Card c) { - moveToPlay(c); + this.moveToPlay(c); if (c.getName().equals("Dodecapod")) { c.setCounter(Counters.P1P1, 2, false); @@ -652,12 +653,12 @@ public class GameAction { final Ability cast = new Ability(madness, madness.getMadnessCost()) { @Override public void resolve() { - playCardNoCost(madness); + GameAction.this.playCardNoCost(madness); System.out.println("Madness cost paid"); } }; - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); sb.append(madness.getName()).append(" - Cast via Madness"); cast.setStackDescription(sb.toString()); @@ -681,7 +682,7 @@ public class GameAction { } }; - StringBuilder sbAct = new StringBuilder(); + final StringBuilder sbAct = new StringBuilder(); sbAct.append(madness.getName()).append(" - Discarded. Pay Madness Cost?"); activate.setStackDescription(sbAct.toString()); @@ -697,11 +698,11 @@ public class GameAction { */ public final boolean checkEndGameSate() { // Win / Lose - GameSummary game = AllZone.getGameInfo(); + final GameSummary game = AllZone.getGameInfo(); boolean humanWins = false; boolean computerWins = false; - Player computer = AllZone.getComputerPlayer(); - Player human = AllZone.getHumanPlayer(); + final Player computer = AllZone.getComputerPlayer(); + final Player human = AllZone.getHumanPlayer(); if (human.hasWon() || computer.hasLost()) { // Winning Conditions can be // worth more than losing @@ -732,7 +733,7 @@ public class GameAction { } } - boolean isGameDone = humanWins || computerWins; + final boolean isGameDone = humanWins || computerWins; if (isGameDone) { game.getPlayerRating(computer.getName()).setLossReason(computer.getLossState(), computer.getLossConditionSource()); @@ -749,7 +750,7 @@ public class GameAction { *

*/ public final void checkStateEffects() { - checkStateEffects(false); + this.checkStateEffects(false); } /** @@ -769,15 +770,15 @@ public class GameAction { return; } - boolean refreeze = AllZone.getStack().isFrozen(); + final boolean refreeze = AllZone.getStack().isFrozen(); AllZone.getStack().setFrozen(true); - JFrame frame = (JFrame) AllZone.getDisplay(); + final JFrame frame = (JFrame) AllZone.getDisplay(); if (!frame.isDisplayable()) { return; } - if (canShowWinLose && checkEndGameSate()) { + if (this.canShowWinLose && this.checkEndGameSate()) { AllZone.getDisplay().savePrefs(); frame.setEnabled(false); // frame.dispose(); @@ -798,7 +799,7 @@ public class GameAction { // gwl.setAlwaysOnTop(true); gwl.toFront(); - canShowWinLose = false; + this.canShowWinLose = false; return; } @@ -812,10 +813,10 @@ public class GameAction { AllZone.getStaticEffects().clearStaticEffects(); // search for cards with static abilities - CardList allCards = AllZoneUtil.getCardsInGame(); - CardList cardsWithStAbs = new CardList(); - for (Card card : allCards) { - ArrayList staticAbilities = card.getStaticAbilities(); + final CardList allCards = AllZoneUtil.getCardsInGame(); + final CardList cardsWithStAbs = new CardList(); + for (final Card card : allCards) { + final ArrayList staticAbilities = card.getStaticAbilities(); if (!staticAbilities.isEmpty() && !card.isFaceDown()) { cardsWithStAbs.add(card); } @@ -825,9 +826,9 @@ public class GameAction { // apply continuous effects for (int layer = 4; layer < 11; layer++) { - for (Card card : cardsWithStAbs) { - ArrayList staticAbilities = card.getStaticAbilities(); - for (StaticAbility stAb : staticAbilities) { + for (final Card card : cardsWithStAbs) { + final ArrayList staticAbilities = card.getStaticAbilities(); + for (final StaticAbility stAb : staticAbilities) { if (stAb.getLayer() == layer) { stAb.applyAbility("Continuous"); } @@ -835,26 +836,26 @@ public class GameAction { } } - HashMap runParams = new HashMap(); + final HashMap runParams = new HashMap(); AllZone.getTriggerHandler().runTrigger("Always", runParams); // card state effects like Glorious Anthem - for (String effect : AllZone.getStaticEffects().getStateBasedMap().keySet()) { - Command com = GameActionUtil.getCommands().get(effect); + for (final String effect : AllZone.getStaticEffects().getStateBasedMap().keySet()) { + final Command com = GameActionUtil.getCommands().get(effect); com.execute(); } - CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield); + final CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield); Card c; - Iterator it = list.iterator(); + final Iterator it = list.iterator(); while (it.hasNext()) { c = it.next(); if (c.isEquipped()) { - CardList equipments = new CardList(c.getEquippedBy()); - for (Card equipment : equipments) { + final CardList equipments = new CardList(c.getEquippedBy()); + for (final Card equipment : equipments) { if (!AllZoneUtil.isCardInPlay(equipment)) { equipment.unEquipCard(c); checkAgain = true; @@ -863,7 +864,7 @@ public class GameAction { } // if isEquipped() if (c.isEquipping()) { - Card equippedCreature = c.getEquipping().get(0); + final Card equippedCreature = c.getEquipping().get(0); if (!AllZoneUtil.isCardInPlay(equippedCreature)) { c.unEquipCard(equippedCreature); checkAgain = true; @@ -879,38 +880,37 @@ public class GameAction { if (c.isAura()) { // Check if Card Aura is attached to is a legal target - GameEntity entity = c.getEnchanting(); - SpellAbility sa = c.getSpellPermanent(); + final GameEntity entity = c.getEnchanting(); + final SpellAbility sa = c.getSpellPermanent(); Target tgt = null; if (sa != null) { tgt = sa.getTarget(); } if (entity instanceof Card) { - Card perm = (Card) entity; + final Card perm = (Card) entity; // I think the Keyword checks might be superfluous with // the isValid check - if (!AllZoneUtil.isCardInPlay(perm) - || perm.hasProtectionFrom(c) - || (tgt != null && !perm.isValid(tgt.getValidTgts(), c.getController(), c))) - { + if (!AllZoneUtil.isCardInPlay(perm) || perm.hasProtectionFrom(c) + || ((tgt != null) && !perm.isValid(tgt.getValidTgts(), c.getController(), c))) { c.unEnchantEntity(perm); - moveToGraveyard(c); + this.moveToGraveyard(c); checkAgain = true; } } else { - Player pl = (Player) entity; + final Player pl = (Player) entity; boolean invalid = false; if (tgt.canOnlyTgtOpponent() && !c.getController().getOpponent().isPlayer(pl)) { invalid = true; } else { - if(pl.hasProtectionFrom(c)) + if (pl.hasProtectionFrom(c)) { invalid = true; + } } if (invalid) { c.unEnchantEntity(pl); - moveToGraveyard(c); + this.moveToGraveyard(c); checkAgain = true; } } @@ -918,8 +918,8 @@ public class GameAction { } // if isAura if (c.isCreature()) { - if (c.getNetDefense() <= c.getDamage() && !c.hasKeyword("Indestructible")) { - destroy(c); + if ((c.getNetDefense() <= c.getDamage()) && !c.hasKeyword("Indestructible")) { + this.destroy(c); // this is untested with instants and abilities but // required for First Strike combat phase AllZone.getCombat().removeFromCombat(c); @@ -927,7 +927,7 @@ public class GameAction { } else if (c.getNetDefense() <= 0) { // TODO This shouldn't be a destroy, and should happen // before the damage check probably - destroy(c); + this.destroy(c); AllZone.getCombat().removeFromCombat(c); checkAgain = true; } @@ -941,8 +941,8 @@ public class GameAction { } // for q=0;q<2 - destroyLegendaryCreatures(); - destroyPlaneswalkers(); + this.destroyLegendaryCreatures(); + this.destroyPlaneswalkers(); GameActionUtil.getStLandManaAbilities().execute(); @@ -958,7 +958,7 @@ public class GameAction { */ private void destroyPlaneswalkers() { // get all Planeswalkers - CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield).getType("Planeswalker"); + final CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield).getType("Planeswalker"); Card c; for (int i = 0; i < list.size(); i++) { @@ -968,16 +968,16 @@ public class GameAction { AllZone.getGameAction().moveToGraveyard(c); } - ArrayList types = c.getType(); - for (String type : types) { + final ArrayList types = c.getType(); + for (final String type : types) { if (!CardUtil.isAPlaneswalkerType(type)) { continue; } - CardList cl = list.getType(type); + final CardList cl = list.getType(type); if (cl.size() > 1) { - for (Card crd : cl) { + for (final Card crd : cl) { AllZone.getGameAction().moveToGraveyard(crd); } } @@ -991,12 +991,13 @@ public class GameAction { *

*/ private void destroyLegendaryCreatures() { - CardList a = AllZoneUtil.getCardsIn(Zone.Battlefield).getType("Legendary"); + final CardList a = AllZoneUtil.getCardsIn(Zone.Battlefield).getType("Legendary"); while (!a.isEmpty() && !AllZoneUtil.isCardInPlay("Mirror Gallery")) { CardList b = AllZoneUtil.getCardsIn(Zone.Battlefield, a.get(0).getName()); b = b.getType("Legendary"); b = b.filter(new CardListFilter() { + @Override public boolean addCard(final Card c) { return !c.isFaceDown(); } @@ -1024,10 +1025,10 @@ public class GameAction { System.out.println("Trying to sacrifice mana pool..."); return false; } - sacrificeDestroy(c); + this.sacrificeDestroy(c); // Run triggers - HashMap runParams = new HashMap(); + final HashMap runParams = new HashMap(); runParams.put("Card", c); AllZone.getTriggerHandler().runTrigger("Sacrificed", runParams); @@ -1051,6 +1052,7 @@ public class GameAction { if (c.isEnchanted()) { CardList list = new CardList(c.getEnchantedBy().toArray()); list = list.filter(new CardListFilter() { + @Override public boolean addCard(final Card crd) { return crd.hasKeyword("Totem armor"); } @@ -1070,15 +1072,16 @@ public class GameAction { } final Card card = c; - Ability_Static ability = new Ability_Static(crd, "0") { + final Ability_Static ability = new Ability_Static(crd, "0") { + @Override public void resolve() { - destroy(crd); + GameAction.this.destroy(crd); card.setDamage(0); } }; - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); sb.append(crd).append(" - Totem armor: destroy this aura."); ability.setStackDescription(sb.toString()); @@ -1087,7 +1090,7 @@ public class GameAction { } } // totem armor - return sacrificeDestroy(c); + return this.sacrificeDestroy(c); } /** @@ -1102,9 +1105,10 @@ public class GameAction { public static Card addSuspendTriggers(final Card c) { c.setSVar("HasteFromSuspend", "True"); - Command intoPlay = new Command() { + final Command intoPlay = new Command() { private static final long serialVersionUID = -4514610171270596654L; + @Override public void execute() { if (AllZoneUtil.isCardInPlay(c) && c.isCreature()) { c.addExtrinsicKeyword("Haste"); @@ -1114,9 +1118,10 @@ public class GameAction { c.addComesIntoPlayCommand(intoPlay); - Command loseControl = new Command() { + final Command loseControl = new Command() { private static final long serialVersionUID = -4514610171270596654L; + @Override public void execute() { if (c.getSVar("HasteFromSuspend").equals("True")) { c.setSVar("HasteFromSuspend", "False"); @@ -1144,21 +1149,21 @@ public class GameAction { return false; } - Player owner = c.getOwner(); + final Player owner = c.getOwner(); if (!(owner.isComputer() || owner.isHuman())) { throw new RuntimeException("GameAction : destroy() invalid card.getOwner() - " + c + " " + owner); } - boolean persist = (c.hasKeyword("Persist") && c.getCounters(Counters.M1M1) == 0) && !c.isToken(); + final boolean persist = (c.hasKeyword("Persist") && (c.getCounters(Counters.M1M1) == 0)) && !c.isToken(); - Card newCard = moveToGraveyard(c); + final Card newCard = this.moveToGraveyard(c); // Destroy needs to be called with Last Known Information c.destroy(); // System.out.println("Card " + c.getName() + // " is getting sent to GY, and this turn it got damaged by: "); - for (Card crd : c.getReceivedDamageFromThisTurn().keySet()) { + for (final Card crd : c.getReceivedDamageFromThisTurn().keySet()) { if (c.getReceivedDamageFromThisTurn().get(crd) > 0) { // System.out.println(crd.getName() ); GameActionUtil.executeVampiricEffects(crd); @@ -1167,13 +1172,13 @@ public class GameAction { if (persist) { final Card persistCard = newCard; - Ability persistAb = new Ability(persistCard, "0") { + final Ability persistAb = new Ability(persistCard, "0") { @Override public void resolve() { if (AllZone.getZoneOf(persistCard).is(Constant.Zone.Graveyard)) { - PlayerZone ownerPlay = persistCard.getOwner().getZone(Constant.Zone.Battlefield); - Card card = moveTo(ownerPlay, persistCard); + final PlayerZone ownerPlay = persistCard.getOwner().getZone(Constant.Zone.Battlefield); + final Card card = GameAction.this.moveTo(ownerPlay, persistCard); AllZone.getGameAction().checkStateEffects(true); card.addCounter(Counters.M1M1, 1); } @@ -1196,12 +1201,11 @@ public class GameAction { */ public final boolean destroy(final Card c) { if (!AllZoneUtil.isCardInPlay(c) - || (c.hasKeyword("Indestructible") && (!c.isCreature() || c.getNetDefense() > 0))) - { + || (c.hasKeyword("Indestructible") && (!c.isCreature() || (c.getNetDefense() > 0)))) { return false; } - if (c.canBeShielded() && c.getShield() > 0) { + if (c.canBeShielded() && (c.getShield() > 0)) { c.subtractShield(); c.setDamage(0); c.tap(); @@ -1212,6 +1216,7 @@ public class GameAction { if (c.isEnchanted()) { CardList list = new CardList(c.getEnchantedBy().toArray()); list = list.filter(new CardListFilter() { + @Override public boolean addCard(final Card crd) { return crd.hasKeyword("Totem armor"); } @@ -1231,13 +1236,13 @@ public class GameAction { } c.setDamage(0); - destroy(crd); + this.destroy(crd); System.out.println("Totem armor destroyed instead of original card"); return false; } } // totem armor - return sacrificeDestroy(c); + return this.sacrificeDestroy(c); } /** @@ -1268,13 +1273,13 @@ public class GameAction { AllZone.getComputerPlayer().setLife(computerLife, null); AllZone.getHumanPlayer().setLife(humanLife, null); - for (Card c : human) { + for (final Card c : human) { AllZone.getHumanPlayer().getZone(Zone.Battlefield).add(c); c.setSickness(true); } - for (Card c : computer) { + for (final Card c : computer) { AllZone.getComputerPlayer().getZone(Zone.Battlefield).add(c); c.setSickness(true); @@ -1300,27 +1305,27 @@ public class GameAction { Constant.Quest.FANTASY_QUEST[0] = false; AllZone.newGameCleanup(); - canShowWinLose = true; + this.canShowWinLose = true; forge.card.trigger.Trigger.resetIDs(); AllZone.getTriggerHandler().clearTriggerSettings(); // friendliness - CardFactoryInterface c = AllZone.getCardFactory(); + final CardFactoryInterface c = AllZone.getCardFactory(); Card.resetUniqueNumber(); - boolean canRandomFoil = Constant.Runtime.RANDOM_FOIL[0] + final boolean canRandomFoil = Constant.Runtime.RANDOM_FOIL[0] && Constant.Runtime.getGameType().equals(GameType.Constructed); - Random generator = MyRandom.getRandom(); - for (Entry stackOfCards : humanDeck.getMain()) { - CardPrinted cardPrinted = stackOfCards.getKey(); + final Random generator = MyRandom.getRandom(); + for (final Entry stackOfCards : humanDeck.getMain()) { + final CardPrinted cardPrinted = stackOfCards.getKey(); for (int i = 0; i < stackOfCards.getValue(); i++) { if (cardPrinted.isAlternate()) { continue; } - Card card = c.getCard(cardPrinted.getName(), AllZone.getHumanPlayer()); + final Card card = c.getCard(cardPrinted.getName(), AllZone.getHumanPlayer()); card.setCurSetCode(cardPrinted.getSet()); - int cntVariants = cardPrinted.getCard().getSetInfo(cardPrinted.getSet()).getCopiesCount(); + final int cntVariants = cardPrinted.getCard().getSetInfo(cardPrinted.getSet()).getCopiesCount(); if (cntVariants > 1) { card.setRandomPicture(generator.nextInt(cntVariants - 1) + 1); } @@ -1329,7 +1334,7 @@ public class GameAction { // Assign random foiling on approximately 1:20 cards if (cardPrinted.isFoil() || (canRandomFoil && MyRandom.percentTrue(5))) { - int iFoil = MyRandom.getRandom().nextInt(9) + 1; + final int iFoil = MyRandom.getRandom().nextInt(9) + 1; card.setFoil(iFoil); } @@ -1342,15 +1347,15 @@ public class GameAction { } } } - ArrayList RAICards = new ArrayList(); - for (Entry stackOfCards : computerDeck.getMain()) { - CardPrinted cardPrinted = stackOfCards.getKey(); + final ArrayList RAICards = new ArrayList(); + for (final Entry stackOfCards : computerDeck.getMain()) { + final CardPrinted cardPrinted = stackOfCards.getKey(); for (int i = 0; i < stackOfCards.getValue(); i++) { - Card card = c.getCard(cardPrinted.getName(), AllZone.getComputerPlayer()); + final Card card = c.getCard(cardPrinted.getName(), AllZone.getComputerPlayer()); card.setCurSetCode(cardPrinted.getSet()); - int cntVariants = cardPrinted.getCard().getSetInfo(cardPrinted.getSet()).getCopiesCount(); + final int cntVariants = cardPrinted.getCard().getSetInfo(cardPrinted.getSet()).getCopiesCount(); if (cntVariants > 1) { card.setRandomPicture(generator.nextInt(cntVariants - 1) + 1); } @@ -1359,7 +1364,7 @@ public class GameAction { // Assign random foiling on approximately 1:20 cards if (cardPrinted.isFoil() || (canRandomFoil && MyRandom.percentTrue(5))) { - int iFoil = MyRandom.getRandom().nextInt(9) + 1; + final int iFoil = MyRandom.getRandom().nextInt(9) + 1; card.setFoil(iFoil); } @@ -1370,7 +1375,7 @@ public class GameAction { // get card picture so that it is in the image cache // ImageCache.getImage(card); } - + if (card.hasAlternateState()) { card.changeState(); card.setImageFilename(CardUtil.buildFilename(card)); @@ -1379,7 +1384,7 @@ public class GameAction { } } if (RAICards.size() > 0) { - StringBuilder sb = new StringBuilder( + final StringBuilder sb = new StringBuilder( "AI deck contains the following cards that it can't play or may be buggy:\n"); for (int i = 0; i < RAICards.size(); i++) { sb.append(RAICards.get(i)); @@ -1398,10 +1403,11 @@ public class GameAction { } // do this instead of shuffling Computer's deck - boolean smoothLand = Constant.Runtime.SMOOTH[0]; + final boolean smoothLand = Constant.Runtime.SMOOTH[0]; if (smoothLand) { - Card[] c1 = smoothComputerManaCurve(AllZone.getComputerPlayer().getCardsIn(Zone.Library).toArray()); + final Card[] c1 = this.smoothComputerManaCurve(AllZone.getComputerPlayer().getCardsIn(Zone.Library) + .toArray()); AllZone.getComputerPlayer().getZone(Zone.Library).setCards(c1); } else { // WTF? (it was so before refactor) @@ -1414,14 +1420,14 @@ public class GameAction { if (AllZone.getMatchState().getGamesPlayedCount() == 0) { // New code to determine who goes first. Delete this if it doesn't // work properly - if (isStartCut()) { - seeWhoPlaysFirst(); + if (this.isStartCut()) { + this.seeWhoPlaysFirst(); } else { - seeWhoPlaysFirst_CoinToss(); + this.seeWhoPlaysFirst_CoinToss(); } } else if (AllZone.getMatchState().hasWonLastGame(AllZone.getHumanPlayer().getName())) { // if player won last, AI starts - computerStartsGame(); + this.computerStartsGame(); } for (int i = 0; i < 7; i++) { @@ -1431,7 +1437,7 @@ public class GameAction { // TODO ManaPool should be moved to Player and be represented in the // player panel - ManaPool mp = AllZone.getHumanPlayer().getManaPool(); + final ManaPool mp = AllZone.getHumanPlayer().getManaPool(); mp.setImageFilename("mana_pool"); AllZone.getHumanPlayer().getZone(Zone.Battlefield).add(mp); @@ -1452,7 +1458,7 @@ public class GameAction { * @return an array of {@link forge.Card} objects. */ final Card[] smoothComputerManaCurve(final Card[] in) { - CardList library = new CardList(in); + final CardList library = new CardList(in); library.shuffle(); // remove all land, keep non-basicland in there, shuffled @@ -1465,7 +1471,7 @@ public class GameAction { // non-basic lands are removed, because the computer doesn't seem to // effectively use them very well - land = threadLand(land); + land = this.threadLand(land); try { // mana weave, total of 7 land @@ -1479,7 +1485,7 @@ public class GameAction { library.add(12, land.get(5)); library.add(15, land.get(6)); - } catch (IndexOutOfBoundsException e) { + } catch (final IndexOutOfBoundsException e) { System.err.println("Error: cannot smooth mana curve, not enough land"); return in; } @@ -1516,22 +1522,22 @@ public class GameAction { // "Plains"}; //unused // Thread stuff with as large a spread of colors as possible: - String[] allLand = {"Bayou", "Volcanic Island", "Savannah", "Badlands", "Tundra", "Taiga", "Underground Sea", - "Plateau", "Tropical Island", "Scrubland", "Overgrown Tomb", "Steam Vents", "Temple Garden", - "Blood Crypt", "Hallowed Fountain", "Stomping Ground", "Watery Grave", "Sacred Foundry", - "Breeding Pool", "Godless Shrine", "Pendelhaven", "Flagstones of Trokair", "Forest", "Swamp", - "Mountain", "Island", "Plains", "Tree of Tales", "Vault of Whispers", "Great Furnace", + final String[] allLand = { "Bayou", "Volcanic Island", "Savannah", "Badlands", "Tundra", "Taiga", + "Underground Sea", "Plateau", "Tropical Island", "Scrubland", "Overgrown Tomb", "Steam Vents", + "Temple Garden", "Blood Crypt", "Hallowed Fountain", "Stomping Ground", "Watery Grave", + "Sacred Foundry", "Breeding Pool", "Godless Shrine", "Pendelhaven", "Flagstones of Trokair", "Forest", + "Swamp", "Mountain", "Island", "Plains", "Tree of Tales", "Vault of Whispers", "Great Furnace", "Seat of the Synod", "Ancient Den", "Treetop Village", "Ghitu Encampment", "Faerie Conclave", "Forbidding Watchtower", "Savage Lands", "Arcane Sanctum", "Jungle Shrine", "Crumbling Necropolis", "Seaside Citadel", "Elfhame Palace", "Coastal Tower", "Salt Marsh", "Kher Keep", - "Library of Alexandria", "Dryad Arbor"}; + "Library of Alexandria", "Dryad Arbor" }; - ArrayList land = new ArrayList(); + final ArrayList land = new ArrayList(); // get different CardList of all Forest, Swamps, etc... CardList check; - for (int i = 0; i < allLand.length; i++) { - check = in.getName(allLand[i]); + for (final String element : allLand) { + check = in.getName(element); if (!check.isEmpty()) { land.add(check); @@ -1545,7 +1551,7 @@ public class GameAction { // thread all separate CardList's of land together to get something like // Mountain, Plains, Island, Mountain, Plains, Island - CardList out = new CardList(); + final CardList out = new CardList(); int i = 0; while (!land.isEmpty()) { @@ -1580,7 +1586,7 @@ public class GameAction { @SuppressWarnings("unused") // getDifferentLand private int getDifferentLand(final CardList list, final String land) { - int out = 0; + final int out = 0; return out; } @@ -1593,13 +1599,13 @@ public class GameAction { *

*/ public final void seeWhoPlaysFirst_CoinToss() { - Object[] possibleValues = { ForgeProps.getLocalized(GameActionText.HEADS), + final Object[] possibleValues = { ForgeProps.getLocalized(GameActionText.HEADS), ForgeProps.getLocalized(GameActionText.TAILS) }; - Object q = JOptionPane.showOptionDialog(null, ForgeProps.getLocalized(GameActionText.HEADS_OR_TAILS), + final Object q = JOptionPane.showOptionDialog(null, ForgeProps.getLocalized(GameActionText.HEADS_OR_TAILS), ForgeProps.getLocalized(GameActionText.COIN_TOSS), JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, null, possibleValues, possibleValues[0]); - int Flip = MyRandom.getRandom().nextInt(2); + final int Flip = MyRandom.getRandom().nextInt(2); String Human_Flip = " "; String Computer_Flip = " "; // JOptionPane.showMessageDialog(null, q, "", @@ -1612,12 +1618,12 @@ public class GameAction { Computer_Flip = ForgeProps.getLocalized(GameActionText.HEADS); } - if ((Flip == 0 && q.equals(0)) || (Flip == 1 && q.equals(1))) { + if (((Flip == 0) && q.equals(0)) || ((Flip == 1) && q.equals(1))) { JOptionPane.showMessageDialog(null, Human_Flip + "\r\n" + ForgeProps.getLocalized(GameActionText.HUMAN_WIN), "", JOptionPane.INFORMATION_MESSAGE); } else { - computerStartsGame(); + this.computerStartsGame(); JOptionPane.showMessageDialog(null, Computer_Flip + "\r\n" + ForgeProps.getLocalized(GameActionText.COMPUTER_WIN), "", JOptionPane.INFORMATION_MESSAGE); @@ -1639,31 +1645,28 @@ public class GameAction { CardList CLibrary = AllZone.getComputerPlayer().getCardsIn(Zone.Library); CLibrary = CLibrary.filter(CardListFilter.NON_LANDS); - boolean Starter_Determined = false; + final boolean Starter_Determined = false; int Cut_Count = 0; - int Cut_CountMax = 20; + final int Cut_CountMax = 20; for (int i = 0; i < Cut_CountMax; i++) { if (Starter_Determined) { break; } if (HLibrary.size() > 0) { - setHumanCut(HLibrary.get(MyRandom.getRandom().nextInt(HLibrary.size()))); + this.setHumanCut(HLibrary.get(MyRandom.getRandom().nextInt(HLibrary.size()))); } else { - computerStartsGame(); - JOptionPane - .showMessageDialog(null, ForgeProps.getLocalized(GameActionText.HUMAN_MANA_COST) + "\r\n" - + ForgeProps.getLocalized(GameActionText.COMPUTER_STARTS), "", - JOptionPane.INFORMATION_MESSAGE); + this.computerStartsGame(); + JOptionPane.showMessageDialog(null, ForgeProps.getLocalized(GameActionText.HUMAN_MANA_COST) + "\r\n" + + ForgeProps.getLocalized(GameActionText.COMPUTER_STARTS), "", JOptionPane.INFORMATION_MESSAGE); return; } if (CLibrary.size() > 0) { - setComputerCut(CLibrary.get(MyRandom.getRandom().nextInt(CLibrary.size()))); + this.setComputerCut(CLibrary.get(MyRandom.getRandom().nextInt(CLibrary.size()))); } else { - JOptionPane.showMessageDialog(null, ForgeProps.getLocalized(GameActionText.COMPUTER_MANA_COST) - + "\r\n" + ForgeProps.getLocalized(GameActionText.HUMAN_STARTS), "", - JOptionPane.INFORMATION_MESSAGE); + JOptionPane.showMessageDialog(null, ForgeProps.getLocalized(GameActionText.COMPUTER_MANA_COST) + "\r\n" + + ForgeProps.getLocalized(GameActionText.HUMAN_STARTS), "", JOptionPane.INFORMATION_MESSAGE); return; } @@ -1673,32 +1676,32 @@ public class GameAction { AllZone.getGameAction().moveTo(AllZone.getComputerPlayer().getZone(Constant.Zone.Library), AllZone.getGameAction().getComputerCut()); - StringBuilder sb = new StringBuilder(); - sb.append(ForgeProps.getLocalized(GameActionText.HUMAN_CUT) + getHumanCut().getName() + " (" - + getHumanCut().getManaCost() + ")" + "\r\n"); - sb.append(ForgeProps.getLocalized(GameActionText.COMPUTER_CUT) + getComputerCut().getName() + " (" - + getComputerCut().getManaCost() + ")" + "\r\n"); + final StringBuilder sb = new StringBuilder(); + sb.append(ForgeProps.getLocalized(GameActionText.HUMAN_CUT) + this.getHumanCut().getName() + " (" + + this.getHumanCut().getManaCost() + ")" + "\r\n"); + sb.append(ForgeProps.getLocalized(GameActionText.COMPUTER_CUT) + this.getComputerCut().getName() + " (" + + this.getComputerCut().getManaCost() + ")" + "\r\n"); sb.append("\r\n" + "Number of times the deck has been cut: " + Cut_Count + "\r\n"); - if (CardUtil.getConvertedManaCost(getComputerCut().getManaCost()) > CardUtil - .getConvertedManaCost(getHumanCut().getManaCost())) { - computerStartsGame(); + if (CardUtil.getConvertedManaCost(this.getComputerCut().getManaCost()) > CardUtil.getConvertedManaCost(this + .getHumanCut().getManaCost())) { + this.computerStartsGame(); JOptionPane.showMessageDialog(null, sb + ForgeProps.getLocalized(GameActionText.COMPUTER_STARTS), "", JOptionPane.INFORMATION_MESSAGE); return; - } else if (CardUtil.getConvertedManaCost(getComputerCut().getManaCost()) < CardUtil - .getConvertedManaCost(getHumanCut().getManaCost())) { + } else if (CardUtil.getConvertedManaCost(this.getComputerCut().getManaCost()) < CardUtil + .getConvertedManaCost(this.getHumanCut().getManaCost())) { JOptionPane.showMessageDialog(null, sb + ForgeProps.getLocalized(GameActionText.HUMAN_STARTS), "", JOptionPane.INFORMATION_MESSAGE); return; } else { sb.append(ForgeProps.getLocalized(GameActionText.EQUAL_CONVERTED_MANA) + "\r\n"); - if (i == Cut_CountMax - 1) { + if (i == (Cut_CountMax - 1)) { sb.append(ForgeProps.getLocalized(GameActionText.RESOLVE_STARTER)); if (MyRandom.getRandom().nextInt(2) == 1) { - JOptionPane.showMessageDialog(null, sb + ForgeProps.getLocalized(GameActionText.HUMAN_WIN), - "", JOptionPane.INFORMATION_MESSAGE); + JOptionPane.showMessageDialog(null, sb + ForgeProps.getLocalized(GameActionText.HUMAN_WIN), "", + JOptionPane.INFORMATION_MESSAGE); } else { - computerStartsGame(); + this.computerStartsGame(); JOptionPane.showMessageDialog(null, sb + ForgeProps.getLocalized(GameActionText.COMPUTER_WIN), "", JOptionPane.INFORMATION_MESSAGE); } @@ -1718,7 +1721,7 @@ public class GameAction { *

*/ public final void computerStartsGame() { - Player computer = AllZone.getComputerPlayer(); + final Player computer = AllZone.getComputerPlayer(); AllZone.getPhase().setPlayerTurn(computer); AllZone.getGameInfo().setPlayerWhoGotFirstTurn(computer.getName()); } @@ -1737,10 +1740,10 @@ public class GameAction { * @return a boolean. */ public final boolean isAttacheeByMindsDesire(final Card c) { - CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield); + final CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield); for (int i = 0; i < list.size(); i++) { - Card[] cc = list.getCard(i).getAttachedCardsByMindsDesire(); + final Card[] cc = list.getCard(i).getAttachedCardsByMindsDesire(); if (Arrays.binarySearch(cc, c) >= 0) { return true; } @@ -1760,20 +1763,20 @@ public class GameAction { */ public final boolean playCard(final Card c) { // this can only be called by the Human - HashMap map = new HashMap(); - SpellAbility[] abilities = canPlaySpellAbility(c.getSpellAbility()); - ArrayList choices = new ArrayList(); - Player human = AllZone.getHumanPlayer(); + final HashMap map = new HashMap(); + final SpellAbility[] abilities = this.canPlaySpellAbility(c.getSpellAbility()); + final ArrayList choices = new ArrayList(); + final Player human = AllZone.getHumanPlayer(); if (c.isLand() && human.canPlayLand()) { - PlayerZone zone = AllZone.getZoneOf(c); + final PlayerZone zone = AllZone.getZoneOf(c); - if (zone.is(Zone.Hand) || (!zone.is(Zone.Battlefield)) && c.hasStartOfKeyword("May be played")) { + if (zone.is(Zone.Hand) || ((!zone.is(Zone.Battlefield)) && c.hasStartOfKeyword("May be played"))) { choices.add("Play land"); } } - for (SpellAbility sa : abilities) { + for (final SpellAbility sa : abilities) { // for uncastables like lotus bloom, check if manaCost is blank sa.setActivatingPlayer(human); if (sa.canPlay() && (!sa.isSpell() || !sa.getManaCost().equals(""))) { @@ -1800,9 +1803,9 @@ public class GameAction { return true; } - SpellAbility ability = map.get(choice); + final SpellAbility ability = map.get(choice); if (ability != null) { - playSpellAbility(ability); + this.playSpellAbility(ability); return true; } return false; @@ -1817,7 +1820,7 @@ public class GameAction { * a {@link forge.Card} object. */ public final void playCardNoCost(final Card c) { - ArrayList choices = c.getBasicSpells(); + final ArrayList choices = c.getBasicSpells(); SpellAbility sa; // TODO add Buyback, Kicker, ... , spells here @@ -1838,7 +1841,7 @@ public class GameAction { if (sa.getActivatingPlayer() == null) { sa.setActivatingPlayer(AllZone.getHumanPlayer()); } - playSpellAbilityForFree(sa); + this.playSpellAbilityForFree(sa); } /** @@ -1851,15 +1854,15 @@ public class GameAction { */ public final void playSpellAbilityForFree(final SpellAbility sa) { if (sa.getPayCosts() != null) { - Target_Selection ts = new Target_Selection(sa.getTarget(), sa); - Cost_Payment payment = new Cost_Payment(sa.getPayCosts(), sa); + final Target_Selection ts = new Target_Selection(sa.getTarget(), sa); + final Cost_Payment payment = new Cost_Payment(sa.getPayCosts(), sa); - SpellAbility_Requirements req = new SpellAbility_Requirements(sa, ts, payment); + final SpellAbility_Requirements req = new SpellAbility_Requirements(sa, ts, payment); req.setFree(true); req.fillRequirements(); } else if (sa.getBeforePayMana() == null) { if (sa.isSpell()) { - Card c = sa.getSourceCard(); + final Card c = sa.getSourceCard(); if (!c.isCopiedSpell()) { sa.setSourceCard(AllZone.getGameAction().moveToStack(c)); } @@ -1870,9 +1873,10 @@ public class GameAction { } if (sa.isKickerAbility()) { - Command paid1 = new Command() { + final Command paid1 = new Command() { private static final long serialVersionUID = -6531785460264284794L; + @Override public void execute() { AllZone.getStack().add(sa); } @@ -1912,9 +1916,9 @@ public class GameAction { */ public final ManaCost getSpellCostChange(final SpellAbility sa, final ManaCost originalCost) { // Beached - Card originalCard = sa.getSourceCard(); - Player controller = originalCard.getController(); - SpellAbility spell = sa; + final Card originalCard = sa.getSourceCard(); + final Player controller = originalCard.getController(); + final SpellAbility spell = sa; String mana = originalCost.toString(); ManaCost manaCost = new ManaCost(mana); if (sa.isXCost() && !originalCard.isCopiedSpell()) { @@ -1927,53 +1931,54 @@ public class GameAction { if (spell.isSpell()) { if (originalCard.getName().equals("Avatar of Woe")) { - Player player = AllZone.getPhase().getPlayerTurn(); - Player opponent = player.getOpponent(); - CardList PlayerCreatureList = player.getCardsIn(Zone.Graveyard); - PlayerCreatureList = PlayerCreatureList.getType("Creature"); - CardList OpponentCreatureList = opponent.getCardsIn(Zone.Graveyard); - OpponentCreatureList = OpponentCreatureList.getType("Creature"); - if ((PlayerCreatureList.size() + OpponentCreatureList.size()) >= 10) { + final Player player = AllZone.getPhase().getPlayerTurn(); + final Player opponent = player.getOpponent(); + CardList playerCreatureList = player.getCardsIn(Zone.Graveyard); + playerCreatureList = playerCreatureList.getType("Creature"); + CardList opponentCreatureList = opponent.getCardsIn(Zone.Graveyard); + opponentCreatureList = opponentCreatureList.getType("Creature"); + if ((playerCreatureList.size() + opponentCreatureList.size()) >= 10) { manaCost = new ManaCost("B B"); } // Avatar of Woe } else if (originalCard.getName().equals("Avatar of Will")) { - Player opponent = AllZone.getPhase().getPlayerTurn().getOpponent(); - CardList opponentHandList = opponent.getCardsIn(Zone.Hand); + final Player opponent = AllZone.getPhase().getPlayerTurn().getOpponent(); + final CardList opponentHandList = opponent.getCardsIn(Zone.Hand); if (opponentHandList.size() == 0) { manaCost = new ManaCost("U U"); } // Avatar of Will } else if (originalCard.getName().equals("Avatar of Fury")) { - Player opponent = AllZone.getPhase().getPlayerTurn().getOpponent(); - CardList opponentLand = AllZoneUtil.getPlayerLandsInPlay(opponent); + final Player opponent = AllZone.getPhase().getPlayerTurn().getOpponent(); + final CardList opponentLand = AllZoneUtil.getPlayerLandsInPlay(opponent); if (opponentLand.size() >= 7) { manaCost = new ManaCost("R R"); } // Avatar of Fury } else if (originalCard.getName().equals("Avatar of Might")) { - Player player = AllZone.getPhase().getPlayerTurn(); - Player opponent = player.getOpponent(); - CardList playerCreature = AllZoneUtil.getCreaturesInPlay(player); - CardList opponentCreature = AllZoneUtil.getCreaturesInPlay(opponent); - if (opponentCreature.size() - playerCreature.size() >= 4) { + final Player player = AllZone.getPhase().getPlayerTurn(); + final Player opponent = player.getOpponent(); + final CardList playerCreature = AllZoneUtil.getCreaturesInPlay(player); + final CardList opponentCreature = AllZoneUtil.getCreaturesInPlay(opponent); + if ((opponentCreature.size() - playerCreature.size()) >= 4) { manaCost = new ManaCost("G G"); } // Avatar of Might } else if (spell.getIsDelve()) { - int cardsInGrave = originalCard.getController().getCardsIn(Zone.Graveyard).size(); - ArrayList choiceList = new ArrayList(); + final int cardsInGrave = originalCard.getController().getCardsIn(Zone.Graveyard).size(); + final ArrayList choiceList = new ArrayList(); for (int i = 0; i <= cardsInGrave; i++) { choiceList.add(i); } if (originalCard.getController().isHuman()) { - int chosenAmount = (Integer) GuiUtils.getChoice("Exile how many cards?", choiceList.toArray()); + final int chosenAmount = (Integer) GuiUtils + .getChoice("Exile how many cards?", choiceList.toArray()); System.out.println("Delve for " + chosenAmount); - CardList choices = AllZone.getHumanPlayer().getCardsIn(Zone.Graveyard); - CardList chosen = new CardList(); + final CardList choices = AllZone.getHumanPlayer().getCardsIn(Zone.Graveyard); + final CardList chosen = new CardList(); for (int i = 0; i < chosenAmount; i++) { - Card nowChosen = (Card) GuiUtils.getChoiceOptional("Exile which card?", choices.toArray()); + final Card nowChosen = GuiUtils.getChoiceOptional("Exile which card?", choices.toArray()); if (nowChosen == null) { - // User canceled,abort delving. + // User canceled,abort delving. chosen.clear(); break; } @@ -1982,8 +1987,8 @@ public class GameAction { chosen.add(nowChosen); } - for (Card c : chosen) { - exile(c); + for (final Card c : chosen) { + this.exile(c); } manaCost = new ManaCost(originalCost.toString()); @@ -1991,7 +1996,7 @@ public class GameAction { } else { // AI int numToExile = 0; - int colorlessCost = originalCost.getColorlessManaAmount(); + final int colorlessCost = originalCost.getColorlessManaAmount(); if (cardsInGrave <= colorlessCost) { numToExile = cardsInGrave; @@ -2000,13 +2005,15 @@ public class GameAction { } for (int i = 0; i < numToExile; i++) { - CardList grave = new CardList(AllZone.getComputerPlayer().getZone(Zone.Graveyard).getCards()); + final CardList grave = new CardList(AllZone.getComputerPlayer().getZone(Zone.Graveyard) + .getCards()); Card chosen = null; - for (Card c : grave) { // Exile noncreatures first in - // case we can revive. Might - // wanna do some additional - // checking here for Flashback - // and the like. + for (final Card c : grave) { // Exile noncreatures first + // in + // case we can revive. Might + // wanna do some additional + // checking here for Flashback + // and the like. if (!c.isCreature()) { chosen = c; break; @@ -2021,15 +2028,16 @@ public class GameAction { chosen = grave.get(0); } - exile(chosen); + this.exile(chosen); } } } } // isSpell // Get Cost Reduction - CardList Cards_In_Play = AllZoneUtil.getCardsIn(Zone.Battlefield); - Cards_In_Play = Cards_In_Play.filter(new CardListFilter() { + CardList cardsInPlay = AllZoneUtil.getCardsIn(Zone.Battlefield); + cardsInPlay = cardsInPlay.filter(new CardListFilter() { + @Override public boolean addCard(final Card c) { if (c.getKeyword().toString().contains("CostChange")) { return true; @@ -2037,32 +2045,32 @@ public class GameAction { return false; } }); - Cards_In_Play.add(originalCard); - CardList Player_Play = controller.getCardsIn(Zone.Battlefield); - CardList Player_Hand = controller.getCardsIn(Zone.Hand); - int XBonus = 0; - int Max = 25; + cardsInPlay.add(originalCard); + final CardList playerPlay = controller.getCardsIn(Zone.Battlefield); + final CardList playerHand = controller.getCardsIn(Zone.Hand); + int xBonus = 0; + final int max = 25; if (sa.isMultiKicker()) { - CostCutting_GetMultiMickerManaCostPaid_Colored = ""; + this.CostCutting_GetMultiMickerManaCostPaid_Colored = ""; } if (mana.toString().length() == 0) { mana = "0"; } - for (int i = 0; i < Cards_In_Play.size(); i++) { - Card card = Cards_In_Play.get(i); - ArrayList a = card.getKeyword(); - int CostKeywords = 0; - int[] CostKeyword_Number = new int[a.size()]; + for (int i = 0; i < cardsInPlay.size(); i++) { + final Card card = cardsInPlay.get(i); + final ArrayList a = card.getKeyword(); + int costKeywords = 0; + final int[] costKeywordNumber = new int[a.size()]; for (int x = 0; x < a.size(); x++) { if (a.get(x).toString().startsWith("CostChange")) { - CostKeyword_Number[CostKeywords] = x; - CostKeywords = CostKeywords + 1; + costKeywordNumber[costKeywords] = x; + costKeywords = costKeywords + 1; } } - for (int CKeywords = 0; CKeywords < CostKeywords; CKeywords++) { - String parse = card.getKeyword().get(CostKeyword_Number[CKeywords]).toString(); - String[] k = parse.split(":"); + for (int cKeywords = 0; cKeywords < costKeywords; cKeywords++) { + final String parse = card.getKeyword().get(costKeywordNumber[cKeywords]).toString(); + final String[] k = parse.split(":"); if (card.equals(originalCard)) { if (!k[4].equals("Self")) { k[2] = "Owned"; @@ -2074,16 +2082,16 @@ public class GameAction { if (k[2].equals("More")) { if (k[7].equals("OnlyOneBonus")) { // Only Works for Color // and Type - for (int string_no = 5; string_no < 7; string_no++) { - String spilt = k[string_no]; - String[] color_spilt = spilt.split("/"); + for (int stringNo = 5; stringNo < 7; stringNo++) { + final String spilt = k[stringNo]; + final String[] colorSpilt = spilt.split("/"); - for (int cs_num = 0; cs_num < color_spilt.length; cs_num++) { - k[string_no] = color_spilt[cs_num]; - if (string_no == 5 && CardUtil.getColors(originalCard).contains(k[5])) { + for (final String element : colorSpilt) { + k[stringNo] = element; + if ((stringNo == 5) && CardUtil.getColors(originalCard).contains(k[5])) { break; } - if (string_no == 6 && (originalCard.isType(k[6]))) { + if ((stringNo == 6) && (originalCard.isType(k[6]))) { break; } } @@ -2091,19 +2099,19 @@ public class GameAction { } if (k[7].contains("All Conditions")) { // Only Works for // Color and Type - for (int string_no = 5; string_no < 7; string_no++) { - String spilt = k[string_no]; - String[] color_spilt = spilt.split("/"); - for (int cs_num = 0; cs_num < color_spilt.length; cs_num++) { - k[string_no] = color_spilt[cs_num]; - if (string_no == 5) { + for (int stringNo = 5; stringNo < 7; stringNo++) { + final String spilt = k[stringNo]; + final String[] colorSpilt = spilt.split("/"); + for (final String element : colorSpilt) { + k[stringNo] = element; + if (stringNo == 5) { if (CardUtil.getColors(originalCard).contains(k[5]) || k[5].equals("All")) { } else { k[5] = "Nullified"; break; } } - if (string_no == 6) { + if (stringNo == 6) { if (originalCard.isType(k[6]) || k[6].equals("All")) { } else { k[6] = "Nullified"; @@ -2119,12 +2127,11 @@ public class GameAction { k[6] = "All"; } } - if ((k[1].equals("Player") && card.getController().equals(controller) - || (k[1].equals("Opponent") - && card.getController().equals(controller.getOpponent())) || k[1] + if (((k[1].equals("Player") && card.getController().equals(controller)) + || (k[1].equals("Opponent") && card.getController().equals(controller.getOpponent())) || k[1] .equals("All")) - && ((k[4].equals("Spell") && sa.isSpell() == true) - || (k[4].equals("Ability") && sa.isAbility() == true) + && ((k[4].equals("Spell") && (sa.isSpell())) + || (k[4].equals("Ability") && (sa.isAbility())) || (k[4].startsWith("Ability_Cycling") && sa.isCycling()) || (k[4].equals("Self") && originalCard.equals(card)) || (k[4].equals("Enchanted") && originalCard.getEnchantedBy().contains(card)) || k[4] @@ -2133,17 +2140,17 @@ public class GameAction { && ((originalCard.isType(k[6])) || (!(originalCard.isType(k[6])) && k[7].contains("NonType")) || k[6].equals("All"))) { if (k[7].contains("CardIsTapped")) { - if (card.isTapped() == false) { + if (!card.isTapped()) { k[3] = "0"; } } if (k[7].contains("TargetInPlay")) { - if (!Player_Play.contains(originalCard)) { + if (!playerPlay.contains(originalCard)) { k[3] = "0"; } } if (k[7].contains("TargetInHand")) { - if (!Player_Hand.contains(originalCard)) { + if (!playerHand.contains(originalCard)) { k[3] = "0"; } } @@ -2158,30 +2165,30 @@ public class GameAction { } } if (k[7].contains("Affinity")) { - String spilt = k[7]; - String[] color_spilt = spilt.split("/"); + final String spilt = k[7]; + final String[] color_spilt = spilt.split("/"); k[7] = color_spilt[1]; - CardList PlayerList = controller.getCardsIn(Zone.Battlefield); - PlayerList = PlayerList.getType(k[7]); - k[3] = String.valueOf(PlayerList.size()); + CardList playerList = controller.getCardsIn(Zone.Battlefield); + playerList = playerList.getType(k[7]); + k[3] = String.valueOf(playerList.size()); } - String[] Numbers = new String[Max]; + final String[] numbers = new String[max]; if ("X".equals(k[3])) { - for (int no = 0; no < Max; no++) { - Numbers[no] = String.valueOf(no); + for (int no = 0; no < max; no++) { + numbers[no] = String.valueOf(no); } - String Number_ManaCost = " "; + String numberManaCost = " "; if (mana.toString().length() == 1) { - Number_ManaCost = mana.toString().substring(0, 1); + numberManaCost = mana.toString().substring(0, 1); } else if (mana.toString().length() == 0) { - Number_ManaCost = "0"; // Should Never Occur + numberManaCost = "0"; // Should Never Occur } else { - Number_ManaCost = mana.toString().substring(0, 2); + numberManaCost = mana.toString().substring(0, 2); } - Number_ManaCost = Number_ManaCost.trim(); - for (int check = 0; check < Max; check++) { - if (Number_ManaCost.equals(Numbers[check])) { - int xValue = CardFactoryUtil.xCount(card, card.getSVar("X")); + numberManaCost = numberManaCost.trim(); + for (int check = 0; check < max; check++) { + if (numberManaCost.equals(numbers[check])) { + final int xValue = CardFactoryUtil.xCount(card, card.getSVar("X")); // if((spell.isXCost()) || // (spell.isMultiKicker()) && (check - // Integer.valueOf(k[3])) < 0) XBonus = @@ -2194,8 +2201,8 @@ public class GameAction { manaCost = new ManaCost(mana); } } else if (!"WUGRB".contains(k[3])) { - for (int no = 0; no < Max; no++) { - Numbers[no] = String.valueOf(no); + for (int no = 0; no < max; no++) { + numbers[no] = String.valueOf(no); } String Number_ManaCost = " "; if (mana.toString().length() == 1) { @@ -2207,8 +2214,8 @@ public class GameAction { } Number_ManaCost = Number_ManaCost.trim(); - for (int check = 0; check < Max; check++) { - if (Number_ManaCost.equals(Numbers[check])) { + for (int check = 0; check < max; check++) { + if (Number_ManaCost.equals(numbers[check])) { mana = mana.replaceFirst(String.valueOf(check), String.valueOf(check + Integer.valueOf(k[3]))); } @@ -2236,20 +2243,20 @@ public class GameAction { if (mana.equals("0") && spell.isAbility()) { } else { - for (int i = 0; i < Cards_In_Play.size(); i++) { - Card card = Cards_In_Play.get(i); - ArrayList a = card.getKeyword(); - int CostKeywords = 0; - int[] CostKeyword_Number = new int[a.size()]; + for (int i = 0; i < cardsInPlay.size(); i++) { + final Card card = cardsInPlay.get(i); + final ArrayList a = card.getKeyword(); + int costKeywords = 0; + final int[] costKeyword_Number = new int[a.size()]; for (int x = 0; x < a.size(); x++) { if (a.get(x).toString().startsWith("CostChange")) { - CostKeyword_Number[CostKeywords] = x; - CostKeywords = CostKeywords + 1; + costKeyword_Number[costKeywords] = x; + costKeywords = costKeywords + 1; } } - for (int CKeywords = 0; CKeywords < CostKeywords; CKeywords++) { - String parse = card.getKeyword().get(CostKeyword_Number[CKeywords]).toString(); - String[] k = parse.split(":"); + for (int cKeywords = 0; cKeywords < costKeywords; cKeywords++) { + final String parse = card.getKeyword().get(costKeyword_Number[cKeywords]).toString(); + final String[] k = parse.split(":"); if (card.equals(originalCard)) { if (!k[4].equals("Self")) { k[2] = "Owned"; @@ -2261,16 +2268,16 @@ public class GameAction { if (k[2].equals("Less")) { if (k[7].equals("OnlyOneBonus")) { // Only Works for // Color and Type - for (int string_no = 5; string_no < 7; string_no++) { - String spilt = k[string_no]; - String[] color_spilt = spilt.split("/"); + for (int stringNo = 5; stringNo < 7; stringNo++) { + final String spilt = k[stringNo]; + final String[] colorSpilt = spilt.split("/"); - for (int cs_num = 0; cs_num < color_spilt.length; cs_num++) { - k[string_no] = color_spilt[cs_num]; - if (string_no == 5 && CardUtil.getColors(originalCard).contains(k[5])) { + for (final String element : colorSpilt) { + k[stringNo] = element; + if ((stringNo == 5) && CardUtil.getColors(originalCard).contains(k[5])) { break; } - if (string_no == 6 && (originalCard.isType(k[6]))) { + if ((stringNo == 6) && (originalCard.isType(k[6]))) { break; } } @@ -2278,19 +2285,19 @@ public class GameAction { } if (k[7].contains("All Conditions")) { // Only Works for // Color and Type - for (int string_no = 5; string_no < 7; string_no++) { - String spilt = k[string_no]; - String[] color_spilt = spilt.split("/"); - for (int cs_num = 0; cs_num < color_spilt.length; cs_num++) { - k[string_no] = color_spilt[cs_num]; - if (string_no == 5) { + for (int stringNo = 5; stringNo < 7; stringNo++) { + final String spilt = k[stringNo]; + final String[] colorSpilt = spilt.split("/"); + for (final String element : colorSpilt) { + k[stringNo] = element; + if (stringNo == 5) { if (CardUtil.getColors(originalCard).contains(k[5]) || k[5].equals("All")) { } else { k[5] = "Nullified"; break; } } - if (string_no == 6) { + if (stringNo == 6) { if (originalCard.isType(k[6]) || k[6].equals("All")) { } else { k[6] = "Nullified"; @@ -2306,9 +2313,8 @@ public class GameAction { k[6] = "All"; } } - if ((k[1].equals("Player") && card.getController().equals(controller) - || (k[1].equals("Opponent") - && card.getController().equals(controller.getOpponent())) || k[1] + if (((k[1].equals("Player") && card.getController().equals(controller)) + || (k[1].equals("Opponent") && card.getController().equals(controller.getOpponent())) || k[1] .equals("All")) && ((k[4].equals("Spell") && sa.isSpell()) || (k[4].equals("Ability") && sa.isAbility()) @@ -2326,12 +2332,12 @@ public class GameAction { } } if (k[7].contains("TargetInPlay")) { - if (!Player_Play.contains(originalCard)) { + if (!playerPlay.contains(originalCard)) { k[3] = "0"; } } if (k[7].contains("TargetInHand")) { - if (!Player_Hand.contains(originalCard)) { + if (!playerHand.contains(originalCard)) { k[3] = "0"; } } @@ -2346,15 +2352,15 @@ public class GameAction { } } if (k[7].contains("Affinity")) { - String spilt = k[7]; - String[] color_spilt = spilt.split("/"); - k[7] = color_spilt[1]; - CardList PlayerList = controller.getCardsIn(Zone.Battlefield); - PlayerList = PlayerList.getType(k[7]); - k[3] = String.valueOf(PlayerList.size()); + final String spilt = k[7]; + final String[] colorSpilt = spilt.split("/"); + k[7] = colorSpilt[1]; + CardList playerList = controller.getCardsIn(Zone.Battlefield); + playerList = playerList.getType(k[7]); + k[3] = String.valueOf(playerList.size()); } - String[] Numbers = new String[Max]; + final String[] numbers = new String[max]; if (!"WUGRB".contains(k[3])) { int value = 0; @@ -2364,8 +2370,8 @@ public class GameAction { value = Integer.valueOf(k[3]); } - for (int no = 0; no < Max; no++) { - Numbers[no] = String.valueOf(no); + for (int no = 0; no < max; no++) { + numbers[no] = String.valueOf(no); } String Number_ManaCost = " "; if (mana.toString().length() == 1) { @@ -2377,12 +2383,12 @@ public class GameAction { } Number_ManaCost = Number_ManaCost.trim(); - for (int check = 0; check < Max; check++) { - if (Number_ManaCost.equals(Numbers[check])) { - if ((spell.isXCost()) || (spell.isMultiKicker()) && (check - value) < 0) { - XBonus = XBonus - check + value; + for (int check = 0; check < max; check++) { + if (Number_ManaCost.equals(numbers[check])) { + if ((spell.isXCost()) || ((spell.isMultiKicker()) && ((check - value) < 0))) { + xBonus = (xBonus - check) + value; } - if (check - value < 0) { + if ((check - value) < 0) { value = check; } mana = mana.replaceFirst(String.valueOf(check), String.valueOf(check - value)); @@ -2402,12 +2408,11 @@ public class GameAction { // Not Included as X Costs are not in // Colored Mana if (sa.isMultiKicker()) { - CostCutting_GetMultiMickerManaCostPaid_Colored - = CostCutting_GetMultiMickerManaCostPaid_Colored + this.CostCutting_GetMultiMickerManaCostPaid_Colored = this.CostCutting_GetMultiMickerManaCostPaid_Colored + k[3]; - // JOptionPane.showMessageDialog(null, - // CostCutting_GetMultiMickerManaCostPaid_Colored, - // "", JOptionPane.INFORMATION_MESSAGE); + // JOptionPane.showMessageDialog(null, + // CostCutting_GetMultiMickerManaCostPaid_Colored, + // "", JOptionPane.INFORMATION_MESSAGE); } } else { mana = mana.replaceFirst(k[3], ""); @@ -2420,7 +2425,7 @@ public class GameAction { } } mana = mana.trim(); - if (mana.length() == 0 || mana.equals("0")) { + if ((mana.length() == 0) || mana.equals("0")) { if (sa.isSpell() || sa.isCycling()) { mana = "0"; } else { @@ -2433,19 +2438,19 @@ public class GameAction { } } if (sa.isXCost()) { - for (int XPaid = 0; XPaid < XBonus; XPaid++) { + for (int XPaid = 0; XPaid < xBonus; XPaid++) { originalCard.addXManaCostPaid(1); } } if (sa.isMultiKicker()) { - CostCutting_GetMultiMickerManaCostPaid = 0; - for (int XPaid = 0; XPaid < XBonus; XPaid++) { - CostCutting_GetMultiMickerManaCostPaid = CostCutting_GetMultiMickerManaCostPaid + 1; + this.CostCutting_GetMultiMickerManaCostPaid = 0; + for (int XPaid = 0; XPaid < xBonus; XPaid++) { + this.CostCutting_GetMultiMickerManaCostPaid = this.CostCutting_GetMultiMickerManaCostPaid + 1; } } if (originalCard.getName().equals("Khalni Hydra") && spell.isSpell()) { - Player player = AllZone.getPhase().getPlayerTurn(); + final Player player = AllZone.getPhase().getPlayerTurn(); CardList playerCreature = AllZoneUtil.getCreaturesInPlay(player); playerCreature = playerCreature.filter(CardListFilter.GREEN); String manaC = manaCost + " "; @@ -2479,15 +2484,15 @@ public class GameAction { // Need to check PayCosts, and Ability + All SubAbilities for Target boolean newAbility = sa.getPayCosts() != null; SpellAbility ability = sa; - while (ability != null && !newAbility) { - Target tgt = ability.getTarget(); + while ((ability != null) && !newAbility) { + final Target tgt = ability.getTarget(); newAbility |= tgt != null; ability = ability.getSubAbility(); } if (newAbility) { - Target_Selection ts = new Target_Selection(sa.getTarget(), sa); + final Target_Selection ts = new Target_Selection(sa.getTarget(), sa); Cost_Payment payment = null; if (sa.getPayCosts() == null) { payment = new Cost_Payment(new Cost("0", sa.getSourceCard().getName(), sa.isAbility()), sa); @@ -2499,7 +2504,7 @@ public class GameAction { payment.changeCost(); } - SpellAbility_Requirements req = new SpellAbility_Requirements(sa, ts, payment); + final SpellAbility_Requirements req = new SpellAbility_Requirements(sa, ts, payment); req.fillRequirements(); } else { ManaCost manaCost = new ManaCost(sa.getManaCost()); @@ -2507,11 +2512,11 @@ public class GameAction { manaCost = new ManaCost("0"); } else { - manaCost = getSpellCostChange(sa, new ManaCost(sa.getManaCost())); + manaCost = this.getSpellCostChange(sa, new ManaCost(sa.getManaCost())); } - if (manaCost.isPaid() && sa.getBeforePayMana() == null) { + if (manaCost.isPaid() && (sa.getBeforePayMana() == null)) { if (sa.getAfterPayMana() == null) { - Card source = sa.getSourceCard(); + final Card source = sa.getSourceCard(); if (sa.isSpell() && !source.isCopiedSpell()) { sa.setSourceCard(AllZone.getGameAction().moveToStack(source)); } @@ -2549,14 +2554,14 @@ public class GameAction { sa.setActivatingPlayer(AllZone.getHumanPlayer()); if (sa.getPayCosts() != null) { - Target_Selection ts = new Target_Selection(sa.getTarget(), sa); - Cost_Payment payment = new Cost_Payment(sa.getPayCosts(), sa); + final Target_Selection ts = new Target_Selection(sa.getTarget(), sa); + final Cost_Payment payment = new Cost_Payment(sa.getPayCosts(), sa); if (!sa.isTrigger()) { payment.changeCost(); } - SpellAbility_Requirements req = new SpellAbility_Requirements(sa, ts, payment); + final SpellAbility_Requirements req = new SpellAbility_Requirements(sa, ts, payment); req.setSkipStack(true); req.fillRequirements(skipTargeting); } else { @@ -2565,9 +2570,9 @@ public class GameAction { manaCost = new ManaCost("0"); } else { - manaCost = getSpellCostChange(sa, new ManaCost(sa.getManaCost())); + manaCost = this.getSpellCostChange(sa, new ManaCost(sa.getManaCost())); } - if (manaCost.isPaid() && sa.getBeforePayMana() == null) { + if (manaCost.isPaid() && (sa.getBeforePayMana() == null)) { if (sa.getAfterPayMana() == null) { AbilityFactory.resolve(sa, false); if (sa.isTapAbility() && !sa.wasCancelled()) { @@ -2599,16 +2604,16 @@ public class GameAction { * @return an array of {@link forge.card.spellability.SpellAbility} objects. */ public final SpellAbility[] canPlaySpellAbility(final SpellAbility[] sa) { - ArrayList list = new ArrayList(); + final ArrayList list = new ArrayList(); - for (int i = 0; i < sa.length; i++) { - sa[i].setActivatingPlayer(AllZone.getHumanPlayer()); - if (sa[i].canPlay()) { - list.add(sa[i]); + for (final SpellAbility element : sa) { + element.setActivatingPlayer(AllZone.getHumanPlayer()); + if (element.canPlay()) { + list.add(element); } } - SpellAbility[] array = new SpellAbility[list.size()]; + final SpellAbility[] array = new SpellAbility[list.size()]; list.toArray(array); return array; } // canPlaySpellAbility() @@ -2622,7 +2627,7 @@ public class GameAction { * a {@link forge.Card} object. */ public final void setComputerCut(final Card computerCut) { - ComputerCut = computerCut; + this.ComputerCut = computerCut; } /** @@ -2633,7 +2638,7 @@ public class GameAction { * @return a {@link forge.Card} object. */ public final Card getComputerCut() { - return ComputerCut; + return this.ComputerCut; } /** @@ -2645,7 +2650,7 @@ public class GameAction { * a boolean. */ public final void setStartCut(final boolean startCutIn) { - Start_Cut = startCutIn; + this.Start_Cut = startCutIn; } /** @@ -2656,7 +2661,7 @@ public class GameAction { * @return a boolean. */ public final boolean isStartCut() { - return Start_Cut; + return this.Start_Cut; } /** @@ -2668,7 +2673,7 @@ public class GameAction { * a {@link forge.Card} object. */ public final void setHumanCut(final Card humanCut) { - HumanCut = humanCut; + this.HumanCut = humanCut; } /** @@ -2679,6 +2684,6 @@ public class GameAction { * @return a {@link forge.Card} object. */ public final Card getHumanCut() { - return HumanCut; + return this.HumanCut; } } diff --git a/src/main/java/forge/HumanPlayer.java b/src/main/java/forge/HumanPlayer.java index 412bd3036fa..12d10b60098 100644 --- a/src/main/java/forge/HumanPlayer.java +++ b/src/main/java/forge/HumanPlayer.java @@ -136,7 +136,7 @@ public class HumanPlayer extends Player { /** {@inheritDoc} */ public final CardList discard(final int num, final SpellAbility sa, final boolean duringResolution) { - AllZone.getInputControl().setInput(PlayerUtil.input_discard(num, sa), duringResolution); + AllZone.getInputControl().setInput(PlayerUtil.inputDiscard(num, sa), duringResolution); // why is CardList returned? return new CardList(); @@ -144,7 +144,7 @@ public class HumanPlayer extends Player { /** {@inheritDoc} */ public final void discardUnless(final int num, final String uType, final SpellAbility sa) { - AllZone.getInputControl().setInput(PlayerUtil.input_discardNumUnless(num, uType, sa)); + AllZone.getInputControl().setInput(PlayerUtil.inputDiscardNumUnless(num, uType, sa)); } /* @@ -156,7 +156,7 @@ public class HumanPlayer extends Player { * */ protected final void discardChainsOfMephistopheles() { - AllZone.getInputControl().setInput(PlayerUtil.input_chainsDiscard(), true); + AllZone.getInputControl().setInput(PlayerUtil.inputChainsDiscard(), true); } /** {@inheritDoc} */ @@ -173,7 +173,7 @@ public class HumanPlayer extends Player { new Object[] { "top", "bottom" }); libPos = o.toString(); } - AllZone.getInputControl().setInput(PlayerUtil.input_putFromHandToLibrary(libPos, numToLibrary)); + AllZone.getInputControl().setInput(PlayerUtil.inputPutFromHandToLibrary(libPos, numToLibrary)); } /** {@inheritDoc} */ @@ -205,7 +205,7 @@ public class HumanPlayer extends Player { /** {@inheritDoc} */ public final void sacrificePermanent(final String prompt, final CardList choices) { - Input in = PlayerUtil.input_sacrificePermanent(choices, prompt); + Input in = PlayerUtil.inputSacrificePermanent(choices, prompt); AllZone.getInputControl().setInput(in); } diff --git a/src/main/java/forge/PlayerUtil.java b/src/main/java/forge/PlayerUtil.java index db84cfb375d..073f56892ac 100644 --- a/src/main/java/forge/PlayerUtil.java +++ b/src/main/java/forge/PlayerUtil.java @@ -54,12 +54,12 @@ public final class PlayerUtil { * @return a {@link forge.gui.input.Input} object. * @since 1.0.15 */ - public static Input input_discardNumUnless(final int nCards, final String uType, final SpellAbility sa) { + public static Input inputDiscardNumUnless(final int nCards, final String uType, final SpellAbility sa) { final SpellAbility sp = sa; Input target = new Input() { private static final long serialVersionUID = 8822292413831640944L; - int n = 0; + private int n = 0; @Override public void showMessage() { @@ -110,12 +110,12 @@ public final class PlayerUtil { * @return a {@link forge.gui.input.Input} object. * @since 1.0.15 */ - public static Input input_discard(final int nCards, final SpellAbility sa) { + public static Input inputDiscard(final int nCards, final SpellAbility sa) { final SpellAbility sp = sa; Input target = new Input() { private static final long serialVersionUID = -329993322080934435L; - int n = 0; + private int n = 0; @Override public void showMessage() { @@ -155,7 +155,7 @@ public final class PlayerUtil { * * @return a {@link forge.gui.input.Input} object. */ - public static Input input_chainsDiscard() { + public static Input inputChainsDiscard() { Input target = new Input() { private static final long serialVersionUID = 2856894846224546303L; @@ -198,8 +198,8 @@ public final class PlayerUtil { * @return a {@link forge.gui.input.Input} object. * @since 1.0.15 */ - public static Input input_sacrificePermanent(final CardList choices, final String message) { - return input_sacrificePermanentsFromList(1, choices, message); + public static Input inputSacrificePermanent(final CardList choices, final String message) { + return inputSacrificePermanentsFromList(1, choices, message); } // input_sacrifice() /** @@ -212,10 +212,10 @@ public final class PlayerUtil { * @return a {@link forge.gui.input.Input} object. * @since 1.0.15 */ - public static Input input_sacrificePermanents(final int nCards) { + public static Input inputSacrificePermanents(final int nCards) { CardList list = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield); list.remove("Mana Pool"); // is this needed? - return input_sacrificePermanentsFromList(nCards, list, "Select a permanent to sacrifice"); + return inputSacrificePermanentsFromList(nCards, list, "Select a permanent to sacrifice"); } // input_sacrificePermanents() /** @@ -230,12 +230,12 @@ public final class PlayerUtil { * @return a {@link forge.gui.input.Input} object. * @since 1.0.15 */ - public static Input input_sacrificePermanents(final int nCards, final String type) { + public static Input inputSacrificePermanents(final int nCards, final String type) { CardList list = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield); list.remove("Mana Pool"); // is this needed? list = list.getType(type); - return input_sacrificePermanentsFromList(nCards, list, "Select a " + type + " to sacrifice"); + return inputSacrificePermanentsFromList(nCards, list, "Select a " + type + " to sacrifice"); } // input_sacrificePermanents() /** @@ -252,10 +252,10 @@ public final class PlayerUtil { * @return a {@link forge.gui.input.Input} object. * @since 1.0.15 */ - public static Input input_sacrificePermanentsFromList(final int nCards, final CardList list, final String message) { + public static Input inputSacrificePermanentsFromList(final int nCards, final CardList list, final String message) { Input target = new Input() { private static final long serialVersionUID = 1981791992623774490L; - int n = 0; + private int n = 0; @Override public void showMessage() { @@ -294,21 +294,21 @@ public final class PlayerUtil { * input_putFromHandToLibrary. *

* - * @param TopOrBottom + * @param topOrBottom * a {@link java.lang.String} object. * @param num * a int. * @return a {@link forge.gui.input.Input} object. * @since 1.0.15 */ - public static Input input_putFromHandToLibrary(final String TopOrBottom, final int num) { + public static Input inputPutFromHandToLibrary(final String topOrBottom, final int num) { Input target = new Input() { private static final long serialVersionUID = 5178077952030689103L; - public int n = 0; + private int n = 0; @Override public void showMessage() { - AllZone.getDisplay().showMessage("Select a card to put on the " + TopOrBottom + " of your library."); + AllZone.getDisplay().showMessage("Select a card to put on the " + topOrBottom + " of your library."); ButtonUtil.disableAll(); if (n == num || AllZone.getHumanPlayer().getZone(Zone.Hand).size() == 0) { @@ -325,7 +325,7 @@ public final class PlayerUtil { public void selectCard(final Card card, final PlayerZone zone) { if (zone.is(Constant.Zone.Hand)) { int position = 0; - if (TopOrBottom.equalsIgnoreCase("bottom")) { + if (topOrBottom.equalsIgnoreCase("bottom")) { position = -1; } diff --git a/src/main/java/forge/Upkeep.java b/src/main/java/forge/Upkeep.java index ff0df3595f0..3f4aeac9a1e 100644 --- a/src/main/java/forge/Upkeep.java +++ b/src/main/java/forge/Upkeep.java @@ -680,7 +680,7 @@ public class Upkeep implements java.io.Serializable { creatures.remove(c); if (player.isHuman()) { AllZone.getInputControl().setInput( - PlayerUtil.input_sacrificePermanent(creatures, c.getName() + PlayerUtil.inputSacrificePermanent(creatures, c.getName() + " - Select a creature to sacrifice.")); } else { // computer final Card target = CardFactoryUtil.getWorstCreatureAI(creatures); @@ -823,7 +823,7 @@ public class Upkeep implements java.io.Serializable { if (c.getController().isComputer()) { if (playerLand.size() > 0) { AllZone.getInputControl().setInput( - PlayerUtil.input_sacrificePermanent(playerLand, c.getName() + PlayerUtil.inputSacrificePermanent(playerLand, c.getName() + " - Select a land to sacrifice.")); } } else { diff --git a/src/main/java/forge/card/abilityFactory/AbilityFactory_Sacrifice.java b/src/main/java/forge/card/abilityFactory/AbilityFactory_Sacrifice.java index 8bc420ebf2b..410f5c6fbc8 100644 --- a/src/main/java/forge/card/abilityFactory/AbilityFactory_Sacrifice.java +++ b/src/main/java/forge/card/abilityFactory/AbilityFactory_Sacrifice.java @@ -534,7 +534,7 @@ public class AbilityFactory_Sacrifice { // TODO: Wait for Input to finish before moving on with the rest of // Resolution - AllZone.getInputControl().setInput(PlayerUtil.input_sacrificePermanentsFromList(amount, list, message), true); + AllZone.getInputControl().setInput(PlayerUtil.inputSacrificePermanentsFromList(amount, list, message), true); } // ************************************************************** diff --git a/src/main/java/forge/card/cardFactory/CardFactory_Sorceries.java b/src/main/java/forge/card/cardFactory/CardFactory_Sorceries.java index 3a5b94a346e..916bfa265c8 100644 --- a/src/main/java/forge/card/cardFactory/CardFactory_Sorceries.java +++ b/src/main/java/forge/card/cardFactory/CardFactory_Sorceries.java @@ -1424,7 +1424,7 @@ public class CardFactory_Sorceries { } } else if (humLand.size() > compLand.size()) { final int diff = humLand.size() - compLand.size(); - AllZone.getInputControl().setInput(PlayerUtil.input_sacrificePermanents(diff, "Land")); + AllZone.getInputControl().setInput(PlayerUtil.inputSacrificePermanents(diff, "Land")); } // Hand @@ -1451,7 +1451,7 @@ public class CardFactory_Sorceries { } } else if (humCreats.size() > compCreats.size()) { final int diff = humCreats.size() - compCreats.size(); - AllZone.getInputControl().setInput(PlayerUtil.input_sacrificePermanents(diff, "Creature")); + AllZone.getInputControl().setInput(PlayerUtil.inputSacrificePermanents(diff, "Creature")); } } diff --git a/src/main/java/forge/card/cost/CostDiscard.java b/src/main/java/forge/card/cost/CostDiscard.java index 1e6ed392de7..a7ed9b0214e 100644 --- a/src/main/java/forge/card/cost/CostDiscard.java +++ b/src/main/java/forge/card/cost/CostDiscard.java @@ -154,7 +154,7 @@ public class CostDiscard extends CostPartWithList { payment.setPaidManaPart(this, true); this.addToList(source); } else if (discType.equals("Hand")) { - this.list = handList; + this.setList(handList); activator.discardHand(ability); payment.setPaidManaPart(this, true); } else if (discType.equals("LastDrawn")) { @@ -179,7 +179,7 @@ public class CostDiscard extends CostPartWithList { } } - this.list = activator.discardRandom(c, ability); + this.setList(activator.discardRandom(c, ability)); payment.setPaidManaPart(this, true); } else { final String[] validType = discType.split(";"); @@ -232,7 +232,7 @@ public class CostDiscard extends CostPartWithList { } else if (type.equals("Hand")) { - this.list.addAll(hand); + this.getList().addAll(hand); } else { @@ -246,12 +246,12 @@ public class CostDiscard extends CostPartWithList { } if (type.equals("Random")) { - this.list = CardListUtil.getRandomSubList(hand, c); + this.setList(CardListUtil.getRandomSubList(hand, c)); } else { - this.list = ComputerUtil.discardNumTypeAI(c, type.split(";"), ability); + this.setList(ComputerUtil.discardNumTypeAI(c, type.split(";"), ability)); } } - return this.list != null; + return this.getList() != null; } // Inputs diff --git a/src/main/java/forge/card/cost/CostExile.java b/src/main/java/forge/card/cost/CostExile.java index 1d276c60767..61162b21722 100644 --- a/src/main/java/forge/card/cost/CostExile.java +++ b/src/main/java/forge/card/cost/CostExile.java @@ -147,7 +147,7 @@ public class CostExile extends CostPartWithList { */ @Override public final void payAI(final SpellAbility ability, final Card source, final Cost_Payment payment) { - for (final Card c : this.list) { + for (final Card c : this.getList()) { AllZone.getGameAction().exile(c); } } @@ -198,7 +198,7 @@ public class CostExile extends CostPartWithList { public final boolean decideAIPayment(final SpellAbility ability, final Card source, final Cost_Payment payment) { this.resetList(); if (this.getThis()) { - this.list.add(source); + this.getList().add(source); } else { Integer c = this.convertAmount(); if (c == null) { @@ -212,12 +212,12 @@ public class CostExile extends CostPartWithList { } if (this.from.equals(Constant.Zone.Library)) { - this.list = AllZone.getComputerPlayer().getCardsIn(Zone.Library, c); + this.setList(AllZone.getComputerPlayer().getCardsIn(Zone.Library, c)); } else { - this.list = ComputerUtil.chooseExileFrom(this.getFrom(), this.getType(), source, - ability.getTargetCard(), c); + this.setList(ComputerUtil.chooseExileFrom(this.getFrom(), this.getType(), source, + ability.getTargetCard(), c)); } - if ((this.list == null) || (this.list.size() < c)) { + if ((this.getList() == null) || (this.getList().size() < c)) { return false; } } diff --git a/src/main/java/forge/card/cost/CostMill.java b/src/main/java/forge/card/cost/CostMill.java index db18f58d6d8..ebbdaf07a90 100644 --- a/src/main/java/forge/card/cost/CostMill.java +++ b/src/main/java/forge/card/cost/CostMill.java @@ -77,9 +77,9 @@ public class CostMill extends CostPartWithList { c = AbilityFactory.calculateAmount(source, this.getAmount(), ability); } - this.list = AllZone.getComputerPlayer().getCardsIn(Zone.Library, c); + this.setList(AllZone.getComputerPlayer().getCardsIn(Zone.Library, c)); - if ((this.list == null) || (this.list.size() < c)) { + if ((this.getList() == null) || (this.getList().size() < c)) { return false; } @@ -94,7 +94,7 @@ public class CostMill extends CostPartWithList { */ @Override public final void payAI(final SpellAbility ability, final Card source, final Cost_Payment payment) { - for (final Card c : this.list) { + for (final Card c : this.getList()) { AllZone.getGameAction().moveToGraveyard(c); } } @@ -116,7 +116,7 @@ public class CostMill extends CostPartWithList { final String sVar = source.getSVar(amount); // Generalize this if (sVar.equals("XChoice")) { - c = CostUtil.chooseXValue(source, this.list.size()); + c = CostUtil.chooseXValue(source, this.getList().size()); } else { c = AbilityFactory.calculateAmount(source, amount, ability); } diff --git a/src/main/java/forge/card/cost/CostPartWithList.java b/src/main/java/forge/card/cost/CostPartWithList.java index 2f8fdb93869..d5569ed7c84 100644 --- a/src/main/java/forge/card/cost/CostPartWithList.java +++ b/src/main/java/forge/card/cost/CostPartWithList.java @@ -10,7 +10,7 @@ import forge.card.spellability.SpellAbility; public abstract class CostPartWithList extends CostPart { /** The list. */ - protected CardList list = null; + private CardList list = null; /** * Gets the list. @@ -35,7 +35,7 @@ public abstract class CostPartWithList extends CostPart { * Reset list. */ public final void resetList() { - this.list = new CardList(); + this.setList(new CardList()); } /** @@ -45,10 +45,10 @@ public abstract class CostPartWithList extends CostPart { * the c */ public final void addToList(final Card c) { - if (this.list == null) { + if (this.getList() == null) { this.resetList(); } - this.list.add(c); + this.getList().add(c); } /** @@ -60,7 +60,7 @@ public abstract class CostPartWithList extends CostPart { * the hash */ public final void addListToHash(final SpellAbility sa, final String hash) { - for (final Card card : this.list) { + for (final Card card : this.getList()) { sa.addCostToHashList(card, hash); } } diff --git a/src/main/java/forge/card/cost/CostPutCounter.java b/src/main/java/forge/card/cost/CostPutCounter.java index 45dc23ad300..9a462215edb 100644 --- a/src/main/java/forge/card/cost/CostPutCounter.java +++ b/src/main/java/forge/card/cost/CostPutCounter.java @@ -94,7 +94,7 @@ public class CostPutCounter extends CostPartWithList { */ @Override public final void refund(final Card source) { - for (final Card c : this.list) { + for (final Card c : this.getList()) { c.subtractCounter(this.counter, this.lastPaidAmount); } } @@ -146,7 +146,7 @@ public class CostPutCounter extends CostPartWithList { source.addCounterFromNonEffect(this.getCounter(), c); } else { // Put counter on chosen card - for (final Card card : this.list) { + for (final Card card : this.getList()) { card.addCounterFromNonEffect(this.getCounter(), 1); } } diff --git a/src/main/java/forge/card/cost/CostReturn.java b/src/main/java/forge/card/cost/CostReturn.java index 70983137f5b..78d5fddaf50 100644 --- a/src/main/java/forge/card/cost/CostReturn.java +++ b/src/main/java/forge/card/cost/CostReturn.java @@ -110,7 +110,7 @@ public class CostReturn extends CostPartWithList { */ @Override public final void payAI(final SpellAbility ability, final Card source, final Cost_Payment payment) { - for (final Card c : this.list) { + for (final Card c : this.getList()) { AllZone.getGameAction().moveToHand(c); } } @@ -156,15 +156,15 @@ public class CostReturn extends CostPartWithList { public final boolean decideAIPayment(final SpellAbility ability, final Card source, final Cost_Payment payment) { this.resetList(); if (this.getThis()) { - this.list.add(source); + this.getList().add(source); } else { Integer c = this.convertAmount(); if (c == null) { c = AbilityFactory.calculateAmount(source, this.getAmount(), ability); } - this.list = ComputerUtil.chooseReturnType(this.getType(), source, ability.getTargetCard(), c); - if (this.list == null) { + this.setList(ComputerUtil.chooseReturnType(this.getType(), source, ability.getTargetCard(), c)); + if (this.getList() == null) { return false; } } diff --git a/src/main/java/forge/card/cost/CostReveal.java b/src/main/java/forge/card/cost/CostReveal.java index 92f8a82338f..f6c776f49d4 100644 --- a/src/main/java/forge/card/cost/CostReveal.java +++ b/src/main/java/forge/card/cost/CostReveal.java @@ -81,7 +81,7 @@ public class CostReveal extends CostPartWithList { return false; } - this.list.add(source); + this.getList().add(source); } else { hand = hand.getValidCards(type.split(";"), activator, source); Integer c = this.convertAmount(); @@ -94,9 +94,9 @@ public class CostReveal extends CostPartWithList { } } - this.list = ComputerUtil.discardNumTypeAI(c, type.split(";"), ability); + this.setList(ComputerUtil.discardNumTypeAI(c, type.split(";"), ability)); } - return this.list != null; + return this.getList() != null; } /* @@ -107,7 +107,7 @@ public class CostReveal extends CostPartWithList { */ @Override public final void payAI(final SpellAbility ability, final Card source, final Cost_Payment payment) { - GuiUtils.getChoiceOptional("Revealed cards:", this.list.toArray()); + GuiUtils.getChoiceOptional("Revealed cards:", this.getList().toArray()); } /* diff --git a/src/main/java/forge/card/cost/CostSacrifice.java b/src/main/java/forge/card/cost/CostSacrifice.java index f756077ee8b..c40b64569c1 100644 --- a/src/main/java/forge/card/cost/CostSacrifice.java +++ b/src/main/java/forge/card/cost/CostSacrifice.java @@ -108,7 +108,7 @@ public class CostSacrifice extends CostPartWithList { */ @Override public final void payAI(final SpellAbility ability, final Card source, final Cost_Payment payment) { - for (final Card c : this.list) { + for (final Card c : this.getList()) { AllZone.getGameAction().sacrifice(c); } } @@ -131,7 +131,7 @@ public class CostSacrifice extends CostPartWithList { if (this.getThis()) { CostUtil.setInput(CostSacrifice.sacrificeThis(ability, payment, this)); } else if (amount.equals("All")) { - this.list = list; + this.setList(list); CostSacrifice.sacrificeAll(ability, payment, this, list); this.addListToHash(ability, "Sacrificed"); return true; @@ -165,7 +165,7 @@ public class CostSacrifice extends CostPartWithList { this.resetList(); final Player activator = ability.getActivatingPlayer(); if (this.getThis()) { - this.list.add(source); + this.getList().add(source); } else if (this.getAmount().equals("All")) { CardList typeList = activator.getCardsIn(Zone.Battlefield); typeList = typeList.getValidCards(this.getType().split(","), activator, source); @@ -180,8 +180,8 @@ public class CostSacrifice extends CostPartWithList { c = AbilityFactory.calculateAmount(source, this.getAmount(), ability); } - this.list = ComputerUtil.chooseSacrificeType(this.getType(), source, ability.getTargetCard(), c); - if (this.list == null) { + this.setList(ComputerUtil.chooseSacrificeType(this.getType(), source, ability.getTargetCard(), c)); + if (this.getList() == null) { return false; } } diff --git a/src/main/java/forge/card/cost/CostTapType.java b/src/main/java/forge/card/cost/CostTapType.java index cb7e36dbcd4..6cb7a8890d0 100644 --- a/src/main/java/forge/card/cost/CostTapType.java +++ b/src/main/java/forge/card/cost/CostTapType.java @@ -70,7 +70,7 @@ public class CostTapType extends CostPartWithList { * the c */ public final void addToTappedList(final Card c) { - this.list.add(c); + this.getList().add(c); } /* @@ -80,11 +80,11 @@ public class CostTapType extends CostPartWithList { */ @Override public final void refund(final Card source) { - for (final Card c : this.list) { + for (final Card c : this.getList()) { c.untap(); } - this.list.clear(); + this.getList().clear(); } /* @@ -121,7 +121,7 @@ public class CostTapType extends CostPartWithList { */ @Override public final void payAI(final SpellAbility ability, final Card source, final Cost_Payment payment) { - for (final Card c : this.list) { + for (final Card c : this.getList()) { c.tap(); } } @@ -170,9 +170,9 @@ public class CostTapType extends CostPartWithList { // Determine Amount } - this.list = ComputerUtil.chooseTapType(this.getType(), source, tap, c); + this.setList(ComputerUtil.chooseTapType(this.getType(), source, tap, c)); - if (this.list == null) { + if (this.getList() == null) { System.out.println("Couldn't find a valid card to tap for: " + source.getName()); return false; } diff --git a/src/main/java/forge/card/trigger/Trigger.java b/src/main/java/forge/card/trigger/Trigger.java index 66ed71cddc3..5508d4a7d26 100644 --- a/src/main/java/forge/card/trigger/Trigger.java +++ b/src/main/java/forge/card/trigger/Trigger.java @@ -36,14 +36,14 @@ public abstract class Trigger { *

*/ public static void resetIDs() { - nextID = 50000; + Trigger.nextID = 50000; } /** The ID. */ - protected int ID = nextID++; + private int id = Trigger.nextID++; /** The name. */ - protected String name; + private String name; /** *

@@ -53,7 +53,7 @@ public abstract class Trigger { * @return a {@link java.lang.String} object. */ public final String getName() { - return name; + return this.name; } /** @@ -65,7 +65,7 @@ public abstract class Trigger { * a {@link java.lang.String} object. */ public final void setName(final String n) { - name = n; + this.name = n; } /** @@ -77,11 +77,11 @@ public abstract class Trigger { * a int. */ public final void setID(final int id) { - ID = id; + this.id = id; } /** The map params. */ - protected HashMap mapParams = new HashMap(); + private HashMap mapParams = new HashMap(); /** *

@@ -91,60 +91,23 @@ public abstract class Trigger { * @return a {@link java.util.HashMap} object. */ public final HashMap getMapParams() { - return mapParams; + return this.mapParams; + } + + /** + * Sets the map params. + * + * @param mapParams the mapParams to set + */ + public final void setMapParams(final HashMap mapParams) { + this.mapParams = mapParams; // TODO: Add 0 to parameter's name. } /** The run params. */ - protected Map runParams; - - /** - *

- * Setter for the field runParams. - *

- * - * @param runParams2 - * a {@link java.util.Map} object. - */ - public final void setRunParams(final Map runParams2) { - runParams = runParams2; - } - - /** - *

- * Getter for the field runParams. - *

- * - * @return a {@link java.util.Map} object. - */ - public final Map getRunParams() { - return runParams; - } + private Map runParams; /** The overriding ability. */ - protected SpellAbility overridingAbility = null; - - /** - *

- * Getter for the field overridingAbility. - *

- * - * @return a {@link forge.card.spellability.SpellAbility} object. - */ - public final SpellAbility getOverridingAbility() { - return overridingAbility; - } - - /** - *

- * Setter for the field overridingAbility. - *

- * - * @param sa - * a {@link forge.card.spellability.SpellAbility} object. - */ - public final void setOverridingAbility(final SpellAbility sa) { - overridingAbility = sa; - } + private SpellAbility overridingAbility = null; private HashMap storedTriggeredObjects = null; @@ -170,11 +133,11 @@ public abstract class Trigger { * @since 1.0.15 */ public final HashMap getStoredTriggeredObjects() { - return storedTriggeredObjects; + return this.storedTriggeredObjects; } /** The host card. */ - protected Card hostCard; + private Card hostCard; /** *

@@ -184,7 +147,7 @@ public abstract class Trigger { * @return a {@link forge.Card} object. */ public final Card getHostCard() { - return hostCard; + return this.hostCard; } /** @@ -196,11 +159,11 @@ public abstract class Trigger { * a {@link forge.Card} object. */ public final void setHostCard(final Card c) { - hostCard = c; + this.hostCard = c; } /** The is intrinsic. */ - protected boolean isIntrinsic; + private boolean isIntrinsic; /** * Gets the checks if is intrinsic. @@ -208,7 +171,7 @@ public abstract class Trigger { * @return the checks if is intrinsic */ public final boolean getIsIntrinsic() { - return isIntrinsic; + return this.isIntrinsic(); } /** @@ -218,7 +181,7 @@ public abstract class Trigger { * the new checks if is intrinsic */ public final void setIsIntrinsic(final boolean b) { - isIntrinsic = b; + this.setIntrinsic(b); } /** @@ -236,14 +199,14 @@ public abstract class Trigger { * the intrinsic */ public Trigger(final String n, final HashMap params, final Card host, final boolean intrinsic) { - name = n; - mapParams = new HashMap(); - for (Map.Entry entry : params.entrySet()) { - mapParams.put(entry.getKey(), entry.getValue()); + this.name = n; + this.setRunParams(new HashMap()); + for (final Map.Entry entry : params.entrySet()) { + this.getMapParams().put(entry.getKey(), entry.getValue()); } - hostCard = host; + this.setHostCard(host); - isIntrinsic = intrinsic; + this.setIntrinsic(intrinsic); } /** @@ -259,13 +222,13 @@ public abstract class Trigger { * the intrinsic */ public Trigger(final HashMap params, final Card host, final boolean intrinsic) { - mapParams = new HashMap(); - for (Map.Entry entry : params.entrySet()) { - mapParams.put(entry.getKey(), entry.getValue()); + this.setRunParams(new HashMap()); + for (final Map.Entry entry : params.entrySet()) { + this.getMapParams().put(entry.getKey(), entry.getValue()); } - hostCard = host; + this.setHostCard(host); - isIntrinsic = intrinsic; + this.setIntrinsic(intrinsic); } /** @@ -275,9 +238,10 @@ public abstract class Trigger { * * @return a {@link java.lang.String} object. */ + @Override public final String toString() { - if (mapParams.containsKey("TriggerDescription") && !isSuppressed()) { - return mapParams.get("TriggerDescription").replace("CARDNAME", hostCard.getName()); + if (this.getMapParams().containsKey("TriggerDescription") && !this.isSuppressed()) { + return this.getMapParams().get("TriggerDescription").replace("CARDNAME", this.getHostCard().getName()); } else { return ""; } @@ -291,16 +255,16 @@ public abstract class Trigger { * @return a boolean. */ public final boolean zonesCheck() { - if (mapParams.containsKey("TriggerZones")) { - List triggerZones = new ArrayList(); - PlayerZone zone = AllZone.getZoneOf(hostCard); - for (String s : mapParams.get("TriggerZones").split(",")) { + if (this.getMapParams().containsKey("TriggerZones")) { + final List triggerZones = new ArrayList(); + final PlayerZone zone = AllZone.getZoneOf(this.getHostCard()); + for (final String s : this.getMapParams().get("TriggerZones").split(",")) { triggerZones.add(Zone.smartValueOf(s)); } if (zone == null) { return false; } - if (!triggerZones.contains(zone.getZoneType()) || hostCard.isPhasedOut()) { + if (!triggerZones.contains(zone.getZoneType()) || this.getHostCard().isPhasedOut()) { return false; } } @@ -316,8 +280,8 @@ public abstract class Trigger { * @return a boolean. */ public final boolean phasesCheck() { - if (mapParams.containsKey("TriggerPhases")) { - String phases = mapParams.get("TriggerPhases"); + if (this.getMapParams().containsKey("TriggerPhases")) { + String phases = this.getMapParams().get("TriggerPhases"); if (phases.contains("->")) { // If phases lists a Range, split and Build Activate String @@ -325,11 +289,11 @@ public abstract class Trigger { // Draw-> (After Upkeep) // Upkeep->Combat_Begin (Before Declare Attackers) - String[] split = phases.split("->", 2); + final String[] split = phases.split("->", 2); phases = AllZone.getPhase().buildActivateString(split[0], split[1]); } - ArrayList triggerPhases = new ArrayList(); - for (String s : phases.split(",")) { + final ArrayList triggerPhases = new ArrayList(); + for (final String s : phases.split(",")) { triggerPhases.add(s); } if (!triggerPhases.contains(AllZone.getPhase().getPhase())) { @@ -337,14 +301,14 @@ public abstract class Trigger { } } - if (mapParams.containsKey("PlayerTurn")) { - if (!AllZone.getPhase().isPlayerTurn(hostCard.getController())) { + if (this.getMapParams().containsKey("PlayerTurn")) { + if (!AllZone.getPhase().isPlayerTurn(this.getHostCard().getController())) { return false; } } - if (mapParams.containsKey("OpponentTurn")) { - if (AllZone.getPhase().isPlayerTurn(hostCard.getController())) { + if (this.getMapParams().containsKey("OpponentTurn")) { + if (AllZone.getPhase().isPlayerTurn(this.getHostCard().getController())) { return false; } } @@ -360,59 +324,62 @@ public abstract class Trigger { * @return a boolean. */ public final boolean requirementsCheck() { - if (mapParams.containsKey("Metalcraft")) { - if (mapParams.get("Metalcraft").equals("True") && !hostCard.getController().hasMetalcraft()) { + if (this.getMapParams().containsKey("Metalcraft")) { + if (this.getMapParams().get("Metalcraft").equals("True") + && !this.getHostCard().getController().hasMetalcraft()) { return false; } } - if (mapParams.containsKey("Threshold")) { - if (mapParams.get("Threshold").equals("True") && !hostCard.getController().hasThreshold()) { + if (this.getMapParams().containsKey("Threshold")) { + if (this.getMapParams().get("Threshold").equals("True") + && !this.getHostCard().getController().hasThreshold()) { return false; } } - if (mapParams.containsKey("Hellbent")) { - if (mapParams.get("Hellbent").equals("True") && !hostCard.getController().hasHellbent()) { + if (this.getMapParams().containsKey("Hellbent")) { + if (this.getMapParams().get("Hellbent").equals("True") && !this.getHostCard().getController().hasHellbent()) { return false; } } - if (mapParams.containsKey("PlayersPoisoned")) { - if (mapParams.get("PlayersPoisoned").equals("You") && hostCard.getController().getPoisonCounters() == 0) { + if (this.getMapParams().containsKey("PlayersPoisoned")) { + if (this.getMapParams().get("PlayersPoisoned").equals("You") + && (this.getHostCard().getController().getPoisonCounters() == 0)) { return false; - } else if (mapParams.get("PlayersPoisoned").equals("Opponent") - && hostCard.getController().getOpponent().getPoisonCounters() == 0) { + } else if (this.getMapParams().get("PlayersPoisoned").equals("Opponent") + && (this.getHostCard().getController().getOpponent().getPoisonCounters() == 0)) { return false; - } else if (mapParams.get("PlayersPoisoned").equals("Each") - && !(hostCard.getController().getPoisonCounters() != 0 && hostCard.getController() - .getPoisonCounters() != 0)) { + } else if (this.getMapParams().get("PlayersPoisoned").equals("Each") + && !((this.getHostCard().getController().getPoisonCounters() != 0) && (this.getHostCard() + .getController().getPoisonCounters() != 0))) { return false; } } - if (mapParams.containsKey("LifeTotal")) { - String player = mapParams.get("LifeTotal"); + if (this.getMapParams().containsKey("LifeTotal")) { + final String player = this.getMapParams().get("LifeTotal"); String lifeCompare = "GE1"; int life = 1; if (player.equals("You")) { - life = hostCard.getController().getLife(); + life = this.getHostCard().getController().getLife(); } if (player.equals("Opponent")) { - life = hostCard.getController().getOpponent().getLife(); + life = this.getHostCard().getController().getOpponent().getLife(); } - if (mapParams.containsKey("LifeAmount")) { - lifeCompare = mapParams.get("LifeAmount"); + if (this.getMapParams().containsKey("LifeAmount")) { + lifeCompare = this.getMapParams().get("LifeAmount"); } int right = 1; - String rightString = lifeCompare.substring(2); + final String rightString = lifeCompare.substring(2); try { right = Integer.parseInt(rightString); - } catch (NumberFormatException nfe) { - right = CardFactoryUtil.xCount(hostCard, hostCard.getSVar(rightString)); + } catch (final NumberFormatException nfe) { + right = CardFactoryUtil.xCount(this.getHostCard(), this.getHostCard().getSVar(rightString)); } if (!AllZoneUtil.compare(life, lifeCompare, right)) { @@ -421,38 +388,38 @@ public abstract class Trigger { } - if (mapParams.containsKey("IsPresent")) { - String sIsPresent = mapParams.get("IsPresent"); + if (this.getMapParams().containsKey("IsPresent")) { + final String sIsPresent = this.getMapParams().get("IsPresent"); String presentCompare = "GE1"; Zone presentZone = Zone.Battlefield; String presentPlayer = "Any"; - if (mapParams.containsKey("PresentCompare")) { - presentCompare = mapParams.get("PresentCompare"); + if (this.getMapParams().containsKey("PresentCompare")) { + presentCompare = this.getMapParams().get("PresentCompare"); } - if (mapParams.containsKey("PresentZone")) { - presentZone = Zone.smartValueOf(mapParams.get("PresentZone")); + if (this.getMapParams().containsKey("PresentZone")) { + presentZone = Zone.smartValueOf(this.getMapParams().get("PresentZone")); } - if (mapParams.containsKey("PresentPlayer")) { - presentPlayer = mapParams.get("PresentPlayer"); + if (this.getMapParams().containsKey("PresentPlayer")) { + presentPlayer = this.getMapParams().get("PresentPlayer"); } CardList list = new CardList(); if (presentPlayer.equals("You") || presentPlayer.equals("Any")) { - list.addAll(hostCard.getController().getCardsIn(presentZone)); + list.addAll(this.getHostCard().getController().getCardsIn(presentZone)); } if (presentPlayer.equals("Opponent") || presentPlayer.equals("Any")) { - list.addAll(hostCard.getController().getOpponent().getCardsIn(presentZone)); + list.addAll(this.getHostCard().getController().getOpponent().getCardsIn(presentZone)); } - list = list.getValidCards(sIsPresent.split(","), hostCard.getController(), hostCard); + list = list.getValidCards(sIsPresent.split(","), this.getHostCard().getController(), this.getHostCard()); int right = 1; - String rightString = presentCompare.substring(2); + final String rightString = presentCompare.substring(2); if (rightString.equals("X")) { - right = CardFactoryUtil.xCount(hostCard, hostCard.getSVar("X")); + right = CardFactoryUtil.xCount(this.getHostCard(), this.getHostCard().getSVar("X")); } else { right = Integer.parseInt(presentCompare.substring(2)); } - int left = list.size(); + final int left = list.size(); if (!AllZoneUtil.compare(left, presentCompare, right)) { return false; @@ -460,38 +427,38 @@ public abstract class Trigger { } - if (mapParams.containsKey("IsPresent2")) { - String sIsPresent = mapParams.get("IsPresent2"); + if (this.getMapParams().containsKey("IsPresent2")) { + final String sIsPresent = this.getMapParams().get("IsPresent2"); String presentCompare = "GE1"; Zone presentZone = Zone.Battlefield; String presentPlayer = "Any"; - if (mapParams.containsKey("PresentCompare2")) { - presentCompare = mapParams.get("PresentCompare2"); + if (this.getMapParams().containsKey("PresentCompare2")) { + presentCompare = this.getMapParams().get("PresentCompare2"); } - if (mapParams.containsKey("PresentZone2")) { - presentZone = Zone.smartValueOf(mapParams.get("PresentZone2")); + if (this.getMapParams().containsKey("PresentZone2")) { + presentZone = Zone.smartValueOf(this.getMapParams().get("PresentZone2")); } - if (mapParams.containsKey("PresentPlayer2")) { - presentPlayer = mapParams.get("PresentPlayer2"); + if (this.getMapParams().containsKey("PresentPlayer2")) { + presentPlayer = this.getMapParams().get("PresentPlayer2"); } CardList list = new CardList(); if (presentPlayer.equals("You") || presentPlayer.equals("Any")) { - list.addAll(hostCard.getController().getCardsIn(presentZone)); + list.addAll(this.getHostCard().getController().getCardsIn(presentZone)); } if (presentPlayer.equals("Opponent") || presentPlayer.equals("Any")) { - list.addAll(hostCard.getController().getOpponent().getCardsIn(presentZone)); + list.addAll(this.getHostCard().getController().getOpponent().getCardsIn(presentZone)); } - list = list.getValidCards(sIsPresent.split(","), hostCard.getController(), hostCard); + list = list.getValidCards(sIsPresent.split(","), this.getHostCard().getController(), this.getHostCard()); int right = 1; - String rightString = presentCompare.substring(2); + final String rightString = presentCompare.substring(2); if (rightString.equals("X")) { - right = CardFactoryUtil.xCount(hostCard, hostCard.getSVar("X")); + right = CardFactoryUtil.xCount(this.getHostCard(), this.getHostCard().getSVar("X")); } else { right = Integer.parseInt(presentCompare.substring(2)); } - int left = list.size(); + final int left = list.size(); if (!AllZoneUtil.compare(left, presentCompare, right)) { return false; @@ -499,43 +466,44 @@ public abstract class Trigger { } - if (mapParams.containsKey("CheckSVar")) { - int sVar = AbilityFactory.calculateAmount(AllZoneUtil.getCardState(hostCard), mapParams.get("CheckSVar"), - null); + if (this.getMapParams().containsKey("CheckSVar")) { + final int sVar = AbilityFactory.calculateAmount(AllZoneUtil.getCardState(this.getHostCard()), this + .getMapParams().get("CheckSVar"), null); String comparator = "GE1"; - if (mapParams.containsKey("SVarCompare")) { - comparator = mapParams.get("SVarCompare"); + if (this.getMapParams().containsKey("SVarCompare")) { + comparator = this.getMapParams().get("SVarCompare"); } - String svarOperator = comparator.substring(0, 2); - String svarOperand = comparator.substring(2); - int operandValue = AbilityFactory.calculateAmount(AllZoneUtil.getCardState(hostCard), svarOperand, null); + final String svarOperator = comparator.substring(0, 2); + final String svarOperand = comparator.substring(2); + final int operandValue = AbilityFactory.calculateAmount(AllZoneUtil.getCardState(this.getHostCard()), + svarOperand, null); if (!AllZoneUtil.compare(sVar, svarOperator, operandValue)) { return false; } } - if (mapParams.containsKey("ManaSpent")) { - if (!hostCard.getColorsPaid().contains(mapParams.get("ManaSpent"))) { + if (this.getMapParams().containsKey("ManaSpent")) { + if (!this.getHostCard().getColorsPaid().contains(this.getMapParams().get("ManaSpent"))) { return false; } } - if (mapParams.containsKey("ManaNotSpent")) { - if (hostCard.getColorsPaid().contains(mapParams.get("ManaNotSpent"))) { + if (this.getMapParams().containsKey("ManaNotSpent")) { + if (this.getHostCard().getColorsPaid().contains(this.getMapParams().get("ManaNotSpent"))) { return false; } } - if (mapParams.containsKey("WerewolfTransformCondition")) { - if (CardUtil.getLastTurnCast("Card", hostCard).size() > 0) { + if (this.getMapParams().containsKey("WerewolfTransformCondition")) { + if (CardUtil.getLastTurnCast("Card", this.getHostCard()).size() > 0) { return false; } } - if (mapParams.containsKey("WerewolfUntransformCondition")) { - CardList you = CardUtil.getLastTurnCast("Card.YouCtrl", hostCard); - CardList opp = CardUtil.getLastTurnCast("Card.YouDontCtrl", hostCard); - if (!(you.size() > 1 || opp.size() > 1)) { + if (this.getMapParams().containsKey("WerewolfUntransformCondition")) { + final CardList you = CardUtil.getLastTurnCast("Card.YouCtrl", this.getHostCard()); + final CardList opp = CardUtil.getLastTurnCast("Card.YouDontCtrl", this.getHostCard()); + if (!((you.size() > 1) || (opp.size() > 1))) { return false; } } @@ -558,12 +526,12 @@ public abstract class Trigger { */ public final boolean matchesValid(final Object o, final String[] valids, final Card srcCard) { if (o instanceof Card) { - Card c = (Card) o; + final Card c = (Card) o; return c.isValid(valids, srcCard.getController(), srcCard); } if (o instanceof Player) { - for (String v : valids) { + for (final String v : valids) { if (v.equalsIgnoreCase("Player") || v.equalsIgnoreCase("Each")) { return true; } @@ -595,8 +563,8 @@ public abstract class Trigger { * @return a boolean. */ public final boolean isSecondary() { - if (mapParams.containsKey("Secondary")) { - if (mapParams.get("Secondary").equals("True")) { + if (this.getMapParams().containsKey("Secondary")) { + if (this.getMapParams().get("Secondary").equals("True")) { return true; } } @@ -610,7 +578,7 @@ public abstract class Trigger { return false; } - return this.ID == ((Trigger) o).ID; + return this.getId() == ((Trigger) o).getId(); } /** @@ -644,7 +612,7 @@ public abstract class Trigger { public abstract void setTriggeringObjects(SpellAbility sa); /** The temporary. */ - protected boolean temporary = false; + private boolean temporary = false; /** * Sets the temporary. @@ -653,7 +621,7 @@ public abstract class Trigger { * the new temporary */ public final void setTemporary(final boolean temp) { - temporary = temp; + this.temporary = temp; } /** @@ -662,14 +630,14 @@ public abstract class Trigger { * @return true, if is temporary */ public final boolean isTemporary() { - return temporary; + return this.temporary; } /** The suppressed. */ - protected boolean suppressed = false; + private boolean suppressed = false; /** The temporarily suppressed. */ - protected boolean temporarilySuppressed = false; + private boolean temporarilySuppressed = false; /** * Sets the suppressed. @@ -678,7 +646,7 @@ public abstract class Trigger { * the new suppressed */ public final void setSuppressed(final boolean supp) { - suppressed = supp; + this.suppressed = supp; } /** @@ -688,7 +656,7 @@ public abstract class Trigger { * the new temporarily suppressed */ public final void setTemporarilySuppressed(final boolean supp) { - temporarilySuppressed = supp; + this.temporarilySuppressed = supp; } /** @@ -697,6 +665,79 @@ public abstract class Trigger { * @return true, if is suppressed */ public final boolean isSuppressed() { - return (suppressed || temporarilySuppressed); + return (this.suppressed || this.temporarilySuppressed); + } + + /** + * Checks if is intrinsic. + * + * @return the isIntrinsic + */ + public boolean isIntrinsic() { + return this.isIntrinsic; + } + + /** + * Sets the intrinsic. + * + * @param isIntrinsic the isIntrinsic to set + */ + public void setIntrinsic(final boolean isIntrinsic) { + this.isIntrinsic = isIntrinsic; // TODO: Add 0 to parameter's name. + } + + /** + * Gets the run params. + * + * @return the runParams + */ + public Map getRunParams() { + return this.runParams; + } + + /** + * Sets the run params. + * + * @param runParams the runParams to set + */ + public void setRunParams(final Map runParams) { + this.runParams = runParams; // TODO: Add 0 to parameter's name. + } + + /** + * Gets the overriding ability. + * + * @return the overridingAbility + */ + public SpellAbility getOverridingAbility() { + return this.overridingAbility; + } + + /** + * Sets the overriding ability. + * + * @param overridingAbility the overridingAbility to set + */ + public void setOverridingAbility(final SpellAbility overridingAbility) { + this.overridingAbility = overridingAbility; // TODO: Add 0 to + // parameter's name. + } + + /** + * Gets the id. + * + * @return the id + */ + public int getId() { + return this.id; + } + + /** + * Sets the id. + * + * @param id the id to set + */ + public void setId(final int id) { + this.id = id; // TODO: Add 0 to parameter's name. } } diff --git a/src/main/java/forge/card/trigger/TriggerHandler.java b/src/main/java/forge/card/trigger/TriggerHandler.java index 8e576cc1271..e01989b8be0 100644 --- a/src/main/java/forge/card/trigger/TriggerHandler.java +++ b/src/main/java/forge/card/trigger/TriggerHandler.java @@ -36,19 +36,19 @@ import forge.gui.input.Input; */ public class TriggerHandler { - private ArrayList suppressedModes = new ArrayList(); + private final ArrayList suppressedModes = new ArrayList(); - private ArrayList delayedTriggers = new ArrayList(); + private final ArrayList delayedTriggers = new ArrayList(); /** * Clean up temporary triggers. */ public final void cleanUpTemporaryTriggers() { - CardList absolutelyAllCards = new CardList(); + final CardList absolutelyAllCards = new CardList(); absolutelyAllCards.addAll(AllZone.getHumanPlayer().getAllCards()); absolutelyAllCards.addAll(AllZone.getComputerPlayer().getAllCards()); - for (Card c : absolutelyAllCards) { + for (final Card c : absolutelyAllCards) { for (int i = 0; i < c.getTriggers().size(); i++) { if (c.getTriggers().get(i).isTemporary()) { c.getTriggers().remove(i); @@ -56,7 +56,7 @@ public class TriggerHandler { } } } - for (Card c : absolutelyAllCards) { + for (final Card c : absolutelyAllCards) { for (int i = 0; i < c.getTriggers().size(); i++) { c.getTriggers().get(i).setTemporarilySuppressed(false); } @@ -73,7 +73,7 @@ public class TriggerHandler { * a {@link forge.card.trigger.Trigger} object. */ public final void registerDelayedTrigger(final Trigger trig) { - delayedTriggers.add(trig); + this.delayedTriggers.add(trig); } /** @@ -85,7 +85,7 @@ public class TriggerHandler { * a {@link java.lang.String} object. */ public final void suppressMode(final String mode) { - suppressedModes.add(mode); + this.suppressedModes.add(mode); } /** @@ -97,7 +97,7 @@ public class TriggerHandler { * a {@link java.lang.String} object. */ public final void clearSuppression(final String mode) { - suppressedModes.remove(mode); + this.suppressedModes.remove(mode); } /** @@ -117,7 +117,7 @@ public class TriggerHandler { */ public static Trigger parseTrigger(final String name, final String trigParse, final Card host, final boolean intrinsic) { - Trigger ret = TriggerHandler.parseTrigger(trigParse, host, intrinsic); + final Trigger ret = TriggerHandler.parseTrigger(trigParse, host, intrinsic); ret.setName(name); return ret; } @@ -136,8 +136,8 @@ public class TriggerHandler { * @return a {@link forge.card.trigger.Trigger} object. */ public static Trigger parseTrigger(final String trigParse, final Card host, final boolean intrinsic) { - HashMap mapParams = parseParams(trigParse); - return parseTrigger(mapParams, host, intrinsic); + final HashMap mapParams = TriggerHandler.parseParams(trigParse); + return TriggerHandler.parseTrigger(mapParams, host, intrinsic); } /** @@ -153,11 +153,10 @@ public class TriggerHandler { * a boolean. * @return a {@link forge.card.trigger.Trigger} object. */ - public static Trigger parseTrigger(final HashMap mapParams, - final Card host, final boolean intrinsic) { + public static Trigger parseTrigger(final HashMap mapParams, final Card host, final boolean intrinsic) { Trigger ret = null; - String mode = mapParams.get("Mode"); + final String mode = mapParams.get("Mode"); if (mode.equals("AbilityCast")) { ret = new Trigger_SpellAbilityCast(mapParams, host, intrinsic); } else if (mode.equals("Always")) { @@ -231,26 +230,26 @@ public class TriggerHandler { * @return a {@link java.util.HashMap} object. */ private static HashMap parseParams(final String trigParse) { - HashMap mapParams = new HashMap(); + final HashMap mapParams = new HashMap(); if (trigParse.length() == 0) { throw new RuntimeException("TriggerFactory : registerTrigger -- trigParse too short"); } - String[] params = trigParse.split("\\|"); + final String[] params = trigParse.split("\\|"); for (int i = 0; i < params.length; i++) { params[i] = params[i].trim(); } - for (String param : params) { - String[] splitParam = param.split("\\$"); + for (final String param : params) { + final String[] splitParam = param.split("\\$"); for (int i = 0; i < splitParam.length; i++) { splitParam[i] = splitParam[i].trim(); } if (splitParam.length != 2) { - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); sb.append("TriggerFactory Parsing Error in registerTrigger() : Split length of "); sb.append(param).append(" is not 2."); throw new RuntimeException(sb.toString()); @@ -273,31 +272,31 @@ public class TriggerHandler { * a {@link java.util.Map} object. */ public final void runTrigger(final String mode, final Map runParams) { - if (suppressedModes.contains(mode)) { + if (this.suppressedModes.contains(mode)) { return; } - Player playerAP = AllZone.getPhase().getPlayerTurn(); + final Player playerAP = AllZone.getPhase().getPlayerTurn(); // This is done to allow the list of triggers to be modified while // triggers are running. - ArrayList delayedTriggersWorkingCopy = new ArrayList(delayedTriggers); + final ArrayList delayedTriggersWorkingCopy = new ArrayList(this.delayedTriggers); CardList allCards; // AP allCards = playerAP.getAllCards(); allCards.addAll(AllZoneUtil.getCardsIn(Constant.Zone.Stack).getController(playerAP)); - for (Card c : allCards) { - for (Trigger t : c.getTriggers()) { - runSingleTrigger(t, mode, runParams); + for (final Card c : allCards) { + for (final Trigger t : c.getTriggers()) { + this.runSingleTrigger(t, mode, runParams); } } for (int i = 0; i < delayedTriggersWorkingCopy.size(); i++) { - Trigger deltrig = delayedTriggersWorkingCopy.get(i); + final Trigger deltrig = delayedTriggersWorkingCopy.get(i); if (deltrig.getHostCard().getController().equals(playerAP)) { - if (runSingleTrigger(deltrig, mode, runParams)) { + if (this.runSingleTrigger(deltrig, mode, runParams)) { delayedTriggersWorkingCopy.remove(deltrig); - delayedTriggers.remove(deltrig); + this.delayedTriggers.remove(deltrig); i--; } } @@ -306,17 +305,17 @@ public class TriggerHandler { // NAP allCards = playerAP.getOpponent().getAllCards(); allCards.addAll(AllZoneUtil.getCardsIn(Constant.Zone.Stack).getController(playerAP.getOpponent())); - for (Card c : allCards) { - for (Trigger t : c.getTriggers()) { - runSingleTrigger(t, mode, runParams); + for (final Card c : allCards) { + for (final Trigger t : c.getTriggers()) { + this.runSingleTrigger(t, mode, runParams); } } for (int i = 0; i < delayedTriggersWorkingCopy.size(); i++) { - Trigger deltrig = delayedTriggersWorkingCopy.get(i); + final Trigger deltrig = delayedTriggersWorkingCopy.get(i); if (deltrig.getHostCard().getController().equals(playerAP.getOpponent())) { - if (runSingleTrigger(deltrig, mode, runParams)) { + if (this.runSingleTrigger(deltrig, mode, runParams)) { delayedTriggersWorkingCopy.remove(deltrig); - delayedTriggers.remove(deltrig); + this.delayedTriggers.remove(deltrig); i--; } } @@ -339,8 +338,7 @@ public class TriggerHandler { * a {@link java.util.HashMap} object. * @return a boolean. */ - private boolean runSingleTrigger(final Trigger regtrig, - final String mode, final Map runParams) { + private boolean runSingleTrigger(final Trigger regtrig, final String mode, final Map runParams) { final Map params = regtrig.getMapParams(); if (!params.get("Mode").equals(mode)) { @@ -359,7 +357,7 @@ public class TriggerHandler { return false; // Morphed cards only have pumped triggers go off. } if (regtrig instanceof Trigger_Always) { - if (AllZone.getStack().hasStateTrigger(regtrig.ID)) { + if (AllZone.getStack().hasStateTrigger(regtrig.getId())) { return false; // State triggers that are already on the stack // don't trigger again. } @@ -372,21 +370,19 @@ public class TriggerHandler { } // Torpor Orb check - CardList torporOrbs = AllZoneUtil.getCardsIn(Zone.Battlefield, "Torpor Orb"); + final CardList torporOrbs = AllZoneUtil.getCardsIn(Zone.Battlefield, "Torpor Orb"); if (torporOrbs.size() != 0) { if (params.containsKey("Destination")) { if ((params.get("Destination").equals("Battlefield") || params.get("Destination").equals("Any")) && mode.equals("ChangesZone") - && ((params.get("ValidCard").contains("Creature")) - || (params.get("ValidCard").contains("Self") && regtrig + && ((params.get("ValidCard").contains("Creature")) || (params.get("ValidCard").contains("Self") && regtrig .getHostCard().isCreature()))) { return false; } } else { if (mode.equals("ChangesZone") - && ((params.get("ValidCard").contains("Creature")) - || (params.get("ValidCard").contains("Self") && regtrig + && ((params.get("ValidCard").contains("Creature")) || (params.get("ValidCard").contains("Self") && regtrig .getHostCard().isCreature()))) { return false; } @@ -403,13 +399,13 @@ public class TriggerHandler { // All tests passed, execute ability. if (regtrig instanceof Trigger_TapsForMana) { - Ability_Mana abMana = (Ability_Mana) runParams.get("Ability_Mana"); + final Ability_Mana abMana = (Ability_Mana) runParams.get("Ability_Mana"); if (null != abMana) { abMana.setUndoable(false); } } - AbilityFactory abilityFactory = new AbilityFactory(); + final AbilityFactory abilityFactory = new AbilityFactory(); final SpellAbility[] sa = new SpellAbility[1]; Card host = AllZoneUtil.getCardState(regtrig.getHostCard()); @@ -431,7 +427,7 @@ public class TriggerHandler { } } sa[0].setTrigger(true); - sa[0].setSourceTrigger(regtrig.ID); + sa[0].setSourceTrigger(regtrig.getId()); regtrig.setTriggeringObjects(sa[0]); if (regtrig.getStoredTriggeredObjects() != null) { sa[0].setAllTriggeringObjects(regtrig.getStoredTriggeredObjects()); @@ -453,7 +449,7 @@ public class TriggerHandler { SpellAbility ability = sa[0]; while (ability != null) { - Target tgt = ability.getTarget(); + final Target tgt = ability.getTarget(); if (tgt != null) { tgt.setMandatory(true); @@ -628,10 +624,10 @@ public class TriggerHandler { @Override public String getStackDescription() { - StringBuilder sb = new StringBuilder(regtrig.toString()); - if (getTarget() != null) { + final StringBuilder sb = new StringBuilder(regtrig.toString()); + if (this.getTarget() != null) { sb.append(" (Targeting "); - for (Object o : getTarget().getTargets()) { + for (final Object o : this.getTarget().getTargets()) { sb.append(o.toString()); sb.append(", "); } @@ -908,8 +904,8 @@ public class TriggerHandler { } @Override - public void setSourceTrigger(final int ID) { - sa[0].setSourceTrigger(ID); + public void setSourceTrigger(final int id) { + sa[0].setSourceTrigger(id); } @Override @@ -933,7 +929,7 @@ public class TriggerHandler { @Override public void resolve() { if (!(regtrig instanceof Trigger_Always)) { - // State triggers + // State triggers // don't do the whole // "Intervening If" // thing. @@ -944,12 +940,12 @@ public class TriggerHandler { if (decider[0] != null) { if (decider[0].isHuman()) { - if (triggersAlwaysAccept.contains(getSourceTrigger())) { + if (TriggerHandler.this.triggersAlwaysAccept.contains(this.getSourceTrigger())) { // No need to do anything. - } else if (triggersAlwaysDecline.contains(getSourceTrigger())) { + } else if (TriggerHandler.this.triggersAlwaysDecline.contains(this.getSourceTrigger())) { return; } else { - StringBuilder buildQuestion = new StringBuilder("Use triggered ability of "); + final StringBuilder buildQuestion = new StringBuilder("Use triggered ability of "); buildQuestion.append(regtrig.getHostCard().getName()).append("(") .append(regtrig.getHostCard().getUniqueNumber()).append(")?"); buildQuestion.append("\r\n("); @@ -982,11 +978,11 @@ public class TriggerHandler { // Add eventual delayed trigger. if (params.containsKey("DelayedTrigger")) { - String sVarName = params.get("DelayedTrigger"); - Trigger deltrig = parseTrigger(regtrig.getHostCard().getSVar(sVarName), + final String sVarName = params.get("DelayedTrigger"); + final Trigger deltrig = TriggerHandler.parseTrigger(regtrig.getHostCard().getSVar(sVarName), regtrig.getHostCard(), true); deltrig.setStoredTriggeredObjects(this.getTriggeringObjects()); - registerDelayedTrigger(deltrig); + TriggerHandler.this.registerDelayedTrigger(deltrig); } } }; @@ -1021,12 +1017,12 @@ public class TriggerHandler { * the new always accept trigger */ public final void setAlwaysAcceptTrigger(final int trigID) { - if (triggersAlwaysDecline.contains(trigID)) { - triggersAlwaysDecline.remove((Object) trigID); + if (this.triggersAlwaysDecline.contains(trigID)) { + this.triggersAlwaysDecline.remove((Object) trigID); } - if (!triggersAlwaysAccept.contains(trigID)) { - triggersAlwaysAccept.add(trigID); + if (!this.triggersAlwaysAccept.contains(trigID)) { + this.triggersAlwaysAccept.add(trigID); } } @@ -1037,12 +1033,12 @@ public class TriggerHandler { * the new always decline trigger */ public final void setAlwaysDeclineTrigger(final int trigID) { - if (triggersAlwaysAccept.contains(trigID)) { - triggersAlwaysAccept.remove((Object) trigID); + if (this.triggersAlwaysAccept.contains(trigID)) { + this.triggersAlwaysAccept.remove((Object) trigID); } - if (!triggersAlwaysDecline.contains(trigID)) { - triggersAlwaysDecline.add(trigID); + if (!this.triggersAlwaysDecline.contains(trigID)) { + this.triggersAlwaysDecline.add(trigID); } } @@ -1053,8 +1049,8 @@ public class TriggerHandler { * the new always ask trigger */ public final void setAlwaysAskTrigger(final int trigID) { - triggersAlwaysAccept.remove((Object) trigID); - triggersAlwaysDecline.remove((Object) trigID); + this.triggersAlwaysAccept.remove((Object) trigID); + this.triggersAlwaysDecline.remove((Object) trigID); } /** @@ -1065,7 +1061,7 @@ public class TriggerHandler { * @return true, if is always accepted */ public final boolean isAlwaysAccepted(final int trigID) { - return triggersAlwaysAccept.contains(trigID); + return this.triggersAlwaysAccept.contains(trigID); } /** @@ -1076,14 +1072,14 @@ public class TriggerHandler { * @return true, if is always declined */ public final boolean isAlwaysDeclined(final int trigID) { - return triggersAlwaysDecline.contains(trigID); + return this.triggersAlwaysDecline.contains(trigID); } /** * Clear trigger settings. */ public final void clearTriggerSettings() { - triggersAlwaysAccept.clear(); - triggersAlwaysDecline.clear(); + this.triggersAlwaysAccept.clear(); + this.triggersAlwaysDecline.clear(); } } diff --git a/src/main/java/forge/card/trigger/Trigger_Always.java b/src/main/java/forge/card/trigger/Trigger_Always.java index 48e729d1ae1..61ccf8cf341 100644 --- a/src/main/java/forge/card/trigger/Trigger_Always.java +++ b/src/main/java/forge/card/trigger/Trigger_Always.java @@ -41,12 +41,12 @@ public class Trigger_Always extends Trigger { /** {@inheritDoc} */ @Override public final Trigger getCopy() { - Trigger copy = new Trigger_Always(mapParams, hostCard, isIntrinsic); - if (overridingAbility != null) { - copy.setOverridingAbility(overridingAbility); + final Trigger copy = new Trigger_Always(this.getMapParams(), this.getHostCard(), this.isIntrinsic()); + if (this.getOverridingAbility() != null) { + copy.setOverridingAbility(this.getOverridingAbility()); } - copy.setName(name); - copy.setID(ID); + copy.setName(this.getName()); + copy.setID(this.getId()); return copy; } diff --git a/src/main/java/forge/card/trigger/Trigger_AttackerBlocked.java b/src/main/java/forge/card/trigger/Trigger_AttackerBlocked.java index b70f870bc58..418281d1967 100644 --- a/src/main/java/forge/card/trigger/Trigger_AttackerBlocked.java +++ b/src/main/java/forge/card/trigger/Trigger_AttackerBlocked.java @@ -35,13 +35,15 @@ public class Trigger_AttackerBlocked extends Trigger { /** {@inheritDoc} */ @Override public final boolean performTest(final Map runParams2) { - if (mapParams.containsKey("ValidCard")) { - if (!matchesValid(runParams2.get("Attacker"), mapParams.get("ValidCard").split(","), hostCard)) { + if (this.getMapParams().containsKey("ValidCard")) { + if (!this.matchesValid(runParams2.get("Attacker"), this.getMapParams().get("ValidCard").split(","), + this.getHostCard())) { return false; } } - if (mapParams.containsKey("ValidBlocker")) { - if (!matchesValid(runParams2.get("Blocker"), mapParams.get("ValidBlocker").split(","), hostCard)) { + if (this.getMapParams().containsKey("ValidBlocker")) { + if (!this.matchesValid(runParams2.get("Blocker"), this.getMapParams().get("ValidBlocker").split(","), + this.getHostCard())) { return false; } } @@ -52,12 +54,12 @@ public class Trigger_AttackerBlocked extends Trigger { /** {@inheritDoc} */ @Override public final Trigger getCopy() { - Trigger copy = new Trigger_AttackerBlocked(mapParams, hostCard, isIntrinsic); - if (overridingAbility != null) { - copy.setOverridingAbility(overridingAbility); + final Trigger copy = new Trigger_AttackerBlocked(this.getMapParams(), this.getHostCard(), this.isIntrinsic()); + if (this.getOverridingAbility() != null) { + copy.setOverridingAbility(this.getOverridingAbility()); } - copy.setName(name); - copy.setID(ID); + copy.setName(this.getName()); + copy.setID(this.getId()); return copy; } @@ -65,8 +67,8 @@ public class Trigger_AttackerBlocked extends Trigger { /** {@inheritDoc} */ @Override public final void setTriggeringObjects(final SpellAbility sa) { - sa.setTriggeringObject("Attacker", runParams.get("Attacker")); - sa.setTriggeringObject("Blocker", runParams.get("Blocker")); - sa.setTriggeringObject("NumBlockers", runParams.get("NumBlockers")); + sa.setTriggeringObject("Attacker", this.getRunParams().get("Attacker")); + sa.setTriggeringObject("Blocker", this.getRunParams().get("Blocker")); + sa.setTriggeringObject("NumBlockers", this.getRunParams().get("NumBlockers")); } } diff --git a/src/main/java/forge/card/trigger/Trigger_AttackerUnblocked.java b/src/main/java/forge/card/trigger/Trigger_AttackerUnblocked.java index d881f2e58be..2dca35710aa 100644 --- a/src/main/java/forge/card/trigger/Trigger_AttackerUnblocked.java +++ b/src/main/java/forge/card/trigger/Trigger_AttackerUnblocked.java @@ -35,8 +35,9 @@ public class Trigger_AttackerUnblocked extends Trigger { /** {@inheritDoc} */ @Override public final boolean performTest(final Map runParams2) { - if (mapParams.containsKey("ValidCard")) { - if (!matchesValid(runParams2.get("Attacker"), mapParams.get("ValidCard").split(","), hostCard)) { + if (this.getMapParams().containsKey("ValidCard")) { + if (!this.matchesValid(runParams2.get("Attacker"), this.getMapParams().get("ValidCard").split(","), + this.getHostCard())) { return false; } } @@ -47,12 +48,12 @@ public class Trigger_AttackerUnblocked extends Trigger { /** {@inheritDoc} */ @Override public final Trigger getCopy() { - Trigger copy = new Trigger_AttackerUnblocked(mapParams, hostCard, isIntrinsic); - if (overridingAbility != null) { - copy.setOverridingAbility(overridingAbility); + final Trigger copy = new Trigger_AttackerUnblocked(this.getMapParams(), this.getHostCard(), this.isIntrinsic()); + if (this.getOverridingAbility() != null) { + copy.setOverridingAbility(this.getOverridingAbility()); } - copy.setName(name); - copy.setID(ID); + copy.setName(this.getName()); + copy.setID(this.getId()); return copy; } @@ -60,6 +61,6 @@ public class Trigger_AttackerUnblocked extends Trigger { /** {@inheritDoc} */ @Override public final void setTriggeringObjects(final SpellAbility sa) { - sa.setTriggeringObject("Attacker", runParams.get("Attacker")); + sa.setTriggeringObject("Attacker", this.getRunParams().get("Attacker")); } } diff --git a/src/main/java/forge/card/trigger/Trigger_AttackersDeclared.java b/src/main/java/forge/card/trigger/Trigger_AttackersDeclared.java index 67794c8cadd..1333e37a4c9 100644 --- a/src/main/java/forge/card/trigger/Trigger_AttackersDeclared.java +++ b/src/main/java/forge/card/trigger/Trigger_AttackersDeclared.java @@ -30,15 +30,15 @@ public class Trigger_AttackersDeclared extends Trigger { /** {@inheritDoc} */ @Override public final boolean performTest(final Map runParams2) { - if (mapParams.containsKey("SingleAttacker")) { - CardList attackers = (CardList) runParams2.get("Attackers"); + if (this.getMapParams().containsKey("SingleAttacker")) { + final CardList attackers = (CardList) runParams2.get("Attackers"); if (attackers.size() != 1) { return false; } } - if (mapParams.containsKey("AttackingPlayer")) { - if (!matchesValid(runParams2.get("AttackingPlayer"), - mapParams.get("AttackingPlayer").split(","), hostCard)) { + if (this.getMapParams().containsKey("AttackingPlayer")) { + if (!this.matchesValid(runParams2.get("AttackingPlayer"), + this.getMapParams().get("AttackingPlayer").split(","), this.getHostCard())) { return false; } } @@ -48,13 +48,13 @@ public class Trigger_AttackersDeclared extends Trigger { /** {@inheritDoc} */ @Override public final Trigger getCopy() { - Trigger copy = new Trigger_AttackersDeclared(this.mapParams, this.hostCard, this.isIntrinsic); + final Trigger copy = new Trigger_AttackersDeclared(this.getMapParams(), this.getHostCard(), this.isIntrinsic()); - if (overridingAbility != null) { - copy.setOverridingAbility(overridingAbility); + if (this.getOverridingAbility() != null) { + copy.setOverridingAbility(this.getOverridingAbility()); } - copy.setName(name); - copy.setID(ID); + copy.setName(this.getName()); + copy.setID(this.getId()); return copy; } @@ -62,6 +62,6 @@ public class Trigger_AttackersDeclared extends Trigger { /** {@inheritDoc} */ @Override public final void setTriggeringObjects(final SpellAbility sa) { - sa.setTriggeringObject("Attackers", runParams.get("Attackers")); + sa.setTriggeringObject("Attackers", this.getRunParams().get("Attackers")); } } diff --git a/src/main/java/forge/card/trigger/Trigger_Attacks.java b/src/main/java/forge/card/trigger/Trigger_Attacks.java index 2ac6c8e6df6..98893ad664f 100644 --- a/src/main/java/forge/card/trigger/Trigger_Attacks.java +++ b/src/main/java/forge/card/trigger/Trigger_Attacks.java @@ -38,26 +38,27 @@ public class Trigger_Attacks extends Trigger { /** {@inheritDoc} */ @Override public final boolean performTest(final Map runParams2) { - if (mapParams.containsKey("ValidCard")) { - if (!matchesValid(runParams2.get("Attacker"), mapParams.get("ValidCard").split(","), hostCard)) { + if (this.getMapParams().containsKey("ValidCard")) { + if (!this.matchesValid(runParams2.get("Attacker"), this.getMapParams().get("ValidCard").split(","), + this.getHostCard())) { return false; } } - if (mapParams.containsKey("Attacked")) { - if (mapParams.get("Attacked").equals("Player") + if (this.getMapParams().containsKey("Attacked")) { + if (this.getMapParams().get("Attacked").equals("Player") && StringUtils.isNumeric(runParams2.get("Attacked").toString()) - && Integer.parseInt(runParams2.get("Attacked").toString()) > 0) { + && (Integer.parseInt(runParams2.get("Attacked").toString()) > 0)) { return false; } } - if (mapParams.containsKey("Alone")) { - CardList otherAttackers = (CardList) runParams2.get("OtherAttackers"); + if (this.getMapParams().containsKey("Alone")) { + final CardList otherAttackers = (CardList) runParams2.get("OtherAttackers"); if (otherAttackers == null) { return false; } - if (mapParams.get("Alone").equals("True")) { + if (this.getMapParams().get("Alone").equals("True")) { if (otherAttackers.size() != 0) { return false; } @@ -74,12 +75,12 @@ public class Trigger_Attacks extends Trigger { /** {@inheritDoc} */ @Override public final Trigger getCopy() { - Trigger copy = new Trigger_Attacks(mapParams, hostCard, isIntrinsic); - if (overridingAbility != null) { - copy.setOverridingAbility(overridingAbility); + final Trigger copy = new Trigger_Attacks(this.getMapParams(), this.getHostCard(), this.isIntrinsic()); + if (this.getOverridingAbility() != null) { + copy.setOverridingAbility(this.getOverridingAbility()); } - copy.setName(name); - copy.setID(ID); + copy.setName(this.getName()); + copy.setID(this.getId()); return copy; } @@ -87,6 +88,6 @@ public class Trigger_Attacks extends Trigger { /** {@inheritDoc} */ @Override public final void setTriggeringObjects(final SpellAbility sa) { - sa.setTriggeringObject("Attacker", runParams.get("Attacker")); + sa.setTriggeringObject("Attacker", this.getRunParams().get("Attacker")); } } diff --git a/src/main/java/forge/card/trigger/Trigger_BecomesTarget.java b/src/main/java/forge/card/trigger/Trigger_BecomesTarget.java index 65c5df3971c..942876f09ff 100644 --- a/src/main/java/forge/card/trigger/Trigger_BecomesTarget.java +++ b/src/main/java/forge/card/trigger/Trigger_BecomesTarget.java @@ -36,26 +36,27 @@ public class Trigger_BecomesTarget extends Trigger { /** {@inheritDoc} */ @Override public final boolean performTest(final Map runParams2) { - if (mapParams.containsKey("SourceType")) { - SpellAbility sa = (SpellAbility) runParams2.get("SourceSA"); - if (mapParams.get("SourceType").equalsIgnoreCase("spell")) { + if (this.getMapParams().containsKey("SourceType")) { + final SpellAbility sa = (SpellAbility) runParams2.get("SourceSA"); + if (this.getMapParams().get("SourceType").equalsIgnoreCase("spell")) { if (!sa.isSpell()) { return false; } - } else if (mapParams.get("SourceType").equalsIgnoreCase("ability")) { + } else if (this.getMapParams().get("SourceType").equalsIgnoreCase("ability")) { if (!sa.isAbility()) { return false; } } } - if (mapParams.containsKey("ValidSource")) { - if (!matchesValid(((SpellAbility) runParams2.get("SourceSA")).getSourceCard(), mapParams.get("ValidSource") - .split(","), hostCard)) { + if (this.getMapParams().containsKey("ValidSource")) { + if (!this.matchesValid(((SpellAbility) runParams2.get("SourceSA")).getSourceCard(), this.getMapParams() + .get("ValidSource").split(","), this.getHostCard())) { return false; } } - if (mapParams.containsKey("ValidTarget")) { - if (!matchesValid(runParams2.get("Target"), mapParams.get("ValidTarget").split(","), hostCard)) { + if (this.getMapParams().containsKey("ValidTarget")) { + if (!this.matchesValid(runParams2.get("Target"), this.getMapParams().get("ValidTarget").split(","), + this.getHostCard())) { return false; } } @@ -66,12 +67,12 @@ public class Trigger_BecomesTarget extends Trigger { /** {@inheritDoc} */ @Override public final Trigger getCopy() { - Trigger copy = new Trigger_BecomesTarget(mapParams, hostCard, isIntrinsic); - if (overridingAbility != null) { - copy.setOverridingAbility(overridingAbility); + final Trigger copy = new Trigger_BecomesTarget(this.getMapParams(), this.getHostCard(), this.isIntrinsic()); + if (this.getOverridingAbility() != null) { + copy.setOverridingAbility(this.getOverridingAbility()); } - copy.setName(name); - copy.setID(ID); + copy.setName(this.getName()); + copy.setID(this.getId()); return copy; } @@ -79,8 +80,8 @@ public class Trigger_BecomesTarget extends Trigger { /** {@inheritDoc} */ @Override public final void setTriggeringObjects(final SpellAbility sa) { - sa.setTriggeringObject("SourceSA", runParams.get("SourceSA")); - sa.setTriggeringObject("Source", ((SpellAbility) runParams.get("SourceSA")).getSourceCard()); - sa.setTriggeringObject("Target", runParams.get("Target")); + sa.setTriggeringObject("SourceSA", this.getRunParams().get("SourceSA")); + sa.setTriggeringObject("Source", ((SpellAbility) this.getRunParams().get("SourceSA")).getSourceCard()); + sa.setTriggeringObject("Target", this.getRunParams().get("Target")); } } diff --git a/src/main/java/forge/card/trigger/Trigger_Blocks.java b/src/main/java/forge/card/trigger/Trigger_Blocks.java index 0b6353ab183..68ef65425bc 100644 --- a/src/main/java/forge/card/trigger/Trigger_Blocks.java +++ b/src/main/java/forge/card/trigger/Trigger_Blocks.java @@ -35,13 +35,15 @@ public class Trigger_Blocks extends Trigger { /** {@inheritDoc} */ @Override public final boolean performTest(final Map runParams2) { - if (mapParams.containsKey("ValidCard")) { - if (!matchesValid(runParams2.get("Blocker"), mapParams.get("ValidCard").split(","), hostCard)) { + if (this.getMapParams().containsKey("ValidCard")) { + if (!this.matchesValid(runParams2.get("Blocker"), this.getMapParams().get("ValidCard").split(","), + this.getHostCard())) { return false; } } - if (mapParams.containsKey("ValidBlocked")) { - if (!matchesValid(runParams2.get("Attacker"), mapParams.get("ValidBlocked").split(","), hostCard)) { + if (this.getMapParams().containsKey("ValidBlocked")) { + if (!this.matchesValid(runParams2.get("Attacker"), this.getMapParams().get("ValidBlocked").split(","), + this.getHostCard())) { return false; } } @@ -52,12 +54,12 @@ public class Trigger_Blocks extends Trigger { /** {@inheritDoc} */ @Override public final Trigger getCopy() { - Trigger copy = new Trigger_Blocks(mapParams, hostCard, isIntrinsic); - if (overridingAbility != null) { - copy.setOverridingAbility(overridingAbility); + final Trigger copy = new Trigger_Blocks(this.getMapParams(), this.getHostCard(), this.isIntrinsic()); + if (this.getOverridingAbility() != null) { + copy.setOverridingAbility(this.getOverridingAbility()); } - copy.setName(name); - copy.setID(ID); + copy.setName(this.getName()); + copy.setID(this.getId()); return copy; } @@ -65,7 +67,7 @@ public class Trigger_Blocks extends Trigger { /** {@inheritDoc} */ @Override public final void setTriggeringObjects(final SpellAbility sa) { - sa.setTriggeringObject("Blocker", runParams.get("Blocker")); - sa.setTriggeringObject("Attacker", runParams.get("Attacker")); + sa.setTriggeringObject("Blocker", this.getRunParams().get("Blocker")); + sa.setTriggeringObject("Attacker", this.getRunParams().get("Attacker")); } } diff --git a/src/main/java/forge/card/trigger/Trigger_Championed.java b/src/main/java/forge/card/trigger/Trigger_Championed.java index 2bc3ee1db2a..70bb6e72c16 100644 --- a/src/main/java/forge/card/trigger/Trigger_Championed.java +++ b/src/main/java/forge/card/trigger/Trigger_Championed.java @@ -35,10 +35,11 @@ public class Trigger_Championed extends Trigger { /** {@inheritDoc} */ @Override public final boolean performTest(final java.util.Map runParams2) { - Card championed = (Card) runParams2.get("Championed"); + final Card championed = (Card) runParams2.get("Championed"); - if (mapParams.containsKey("ValidCard")) { - if (!championed.isValid(mapParams.get("ValidCard").split(","), hostCard.getController(), hostCard)) { + if (this.getMapParams().containsKey("ValidCard")) { + if (!championed.isValid(this.getMapParams().get("ValidCard").split(","), + this.getHostCard().getController(), this.getHostCard())) { return false; } } @@ -49,12 +50,12 @@ public class Trigger_Championed extends Trigger { /** {@inheritDoc} */ @Override public final Trigger getCopy() { - Trigger copy = new Trigger_Championed(mapParams, hostCard, isIntrinsic); - if (overridingAbility != null) { - copy.setOverridingAbility(overridingAbility); + final Trigger copy = new Trigger_Championed(this.getMapParams(), this.getHostCard(), this.isIntrinsic()); + if (this.getOverridingAbility() != null) { + copy.setOverridingAbility(this.getOverridingAbility()); } - copy.setName(name); - copy.setID(ID); + copy.setName(this.getName()); + copy.setID(this.getId()); return copy; } @@ -62,7 +63,7 @@ public class Trigger_Championed extends Trigger { /** {@inheritDoc} */ @Override public final void setTriggeringObjects(final SpellAbility sa) { - sa.setTriggeringObject("Championed", runParams.get("Championed")); - sa.setTriggeringObject("Card", runParams.get("Card")); + sa.setTriggeringObject("Championed", this.getRunParams().get("Championed")); + sa.setTriggeringObject("Card", this.getRunParams().get("Card")); } } diff --git a/src/main/java/forge/card/trigger/Trigger_ChangesZone.java b/src/main/java/forge/card/trigger/Trigger_ChangesZone.java index 8bcccd13b48..724ca9b53a5 100644 --- a/src/main/java/forge/card/trigger/Trigger_ChangesZone.java +++ b/src/main/java/forge/card/trigger/Trigger_ChangesZone.java @@ -34,28 +34,29 @@ public class Trigger_ChangesZone extends Trigger { /** {@inheritDoc} */ @Override public final boolean performTest(final java.util.Map runParams2) { - if (mapParams.containsKey("Origin")) { - if (!mapParams.get("Origin").equals("Any")) { - if (mapParams.get("Origin") == null) { + if (this.getMapParams().containsKey("Origin")) { + if (!this.getMapParams().get("Origin").equals("Any")) { + if (this.getMapParams().get("Origin") == null) { return false; } - if (!mapParams.get("Origin").equals((String) runParams2.get("Origin"))) { + if (!this.getMapParams().get("Origin").equals(runParams2.get("Origin"))) { return false; } } } - if (mapParams.containsKey("Destination")) { - if (!mapParams.get("Destination").equals("Any")) { - if (!mapParams.get("Destination").equals((String) runParams2.get("Destination"))) { + if (this.getMapParams().containsKey("Destination")) { + if (!this.getMapParams().get("Destination").equals("Any")) { + if (!this.getMapParams().get("Destination").equals(runParams2.get("Destination"))) { return false; } } } - if (mapParams.containsKey("ValidCard")) { - Card moved = (Card) runParams2.get("Card"); - if (!moved.isValid(mapParams.get("ValidCard").split(","), hostCard.getController(), hostCard)) { + if (this.getMapParams().containsKey("ValidCard")) { + final Card moved = (Card) runParams2.get("Card"); + if (!moved.isValid(this.getMapParams().get("ValidCard").split(","), this.getHostCard().getController(), + this.getHostCard())) { return false; } } @@ -66,12 +67,12 @@ public class Trigger_ChangesZone extends Trigger { /** {@inheritDoc} */ @Override public final Trigger getCopy() { - Trigger copy = new Trigger_ChangesZone(mapParams, hostCard, isIntrinsic); - if (overridingAbility != null) { - copy.setOverridingAbility(overridingAbility); + final Trigger copy = new Trigger_ChangesZone(this.getMapParams(), this.getHostCard(), this.isIntrinsic()); + if (this.getOverridingAbility() != null) { + copy.setOverridingAbility(this.getOverridingAbility()); } - copy.setName(name); - copy.setID(ID); + copy.setName(this.getName()); + copy.setID(this.getId()); return copy; } @@ -79,6 +80,6 @@ public class Trigger_ChangesZone extends Trigger { /** {@inheritDoc} */ @Override public final void setTriggeringObjects(final SpellAbility sa) { - sa.setTriggeringObject("Card", runParams.get("Card")); + sa.setTriggeringObject("Card", this.getRunParams().get("Card")); } } diff --git a/src/main/java/forge/card/trigger/Trigger_Clashed.java b/src/main/java/forge/card/trigger/Trigger_Clashed.java index d8b62e45f6e..7eec7cfdade 100644 --- a/src/main/java/forge/card/trigger/Trigger_Clashed.java +++ b/src/main/java/forge/card/trigger/Trigger_Clashed.java @@ -34,14 +34,15 @@ public class Trigger_Clashed extends Trigger { /** {@inheritDoc} */ @Override public final boolean performTest(final java.util.Map runParams2) { - if (mapParams.containsKey("ValidPlayer")) { - if (!matchesValid(runParams2.get("Player"), mapParams.get("ValidPlayer").split(","), hostCard)) { + if (this.getMapParams().containsKey("ValidPlayer")) { + if (!this.matchesValid(runParams2.get("Player"), this.getMapParams().get("ValidPlayer").split(","), + this.getHostCard())) { return false; } } - if (mapParams.containsKey("Won")) { - if (!mapParams.get("Won").equals(runParams2.get("Won"))) { + if (this.getMapParams().containsKey("Won")) { + if (!this.getMapParams().get("Won").equals(runParams2.get("Won"))) { return false; } } @@ -52,12 +53,12 @@ public class Trigger_Clashed extends Trigger { /** {@inheritDoc} */ @Override public final Trigger getCopy() { - Trigger copy = new Trigger_Clashed(mapParams, hostCard, isIntrinsic); - if (overridingAbility != null) { - copy.setOverridingAbility(overridingAbility); + final Trigger copy = new Trigger_Clashed(this.getMapParams(), this.getHostCard(), this.isIntrinsic()); + if (this.getOverridingAbility() != null) { + copy.setOverridingAbility(this.getOverridingAbility()); } - copy.setName(name); - copy.setID(ID); + copy.setName(this.getName()); + copy.setID(this.getId()); return copy; } diff --git a/src/main/java/forge/card/trigger/Trigger_CounterAdded.java b/src/main/java/forge/card/trigger/Trigger_CounterAdded.java index d40085cca8e..fb6290d8536 100644 --- a/src/main/java/forge/card/trigger/Trigger_CounterAdded.java +++ b/src/main/java/forge/card/trigger/Trigger_CounterAdded.java @@ -35,17 +35,18 @@ public class Trigger_CounterAdded extends Trigger { /** {@inheritDoc} */ @Override public final boolean performTest(final java.util.Map runParams2) { - Card addedTo = (Card) runParams2.get("Card"); - Counters addedType = (Counters) runParams2.get("CounterType"); + final Card addedTo = (Card) runParams2.get("Card"); + final Counters addedType = (Counters) runParams2.get("CounterType"); - if (mapParams.containsKey("ValidCard")) { - if (!addedTo.isValid(mapParams.get("ValidCard").split(","), hostCard.getController(), hostCard)) { + if (this.getMapParams().containsKey("ValidCard")) { + if (!addedTo.isValid(this.getMapParams().get("ValidCard").split(","), this.getHostCard().getController(), + this.getHostCard())) { return false; } } - if (mapParams.containsKey("CounterType")) { - String type = mapParams.get("CounterType"); + if (this.getMapParams().containsKey("CounterType")) { + final String type = this.getMapParams().get("CounterType"); if (!type.equals(addedType.toString())) { return false; } @@ -57,12 +58,12 @@ public class Trigger_CounterAdded extends Trigger { /** {@inheritDoc} */ @Override public final Trigger getCopy() { - Trigger copy = new Trigger_CounterAdded(mapParams, hostCard, isIntrinsic); - if (overridingAbility != null) { - copy.setOverridingAbility(overridingAbility); + final Trigger copy = new Trigger_CounterAdded(this.getMapParams(), this.getHostCard(), this.isIntrinsic()); + if (this.getOverridingAbility() != null) { + copy.setOverridingAbility(this.getOverridingAbility()); } - copy.setName(name); - copy.setID(ID); + copy.setName(this.getName()); + copy.setID(this.getId()); return copy; } @@ -70,6 +71,6 @@ public class Trigger_CounterAdded extends Trigger { /** {@inheritDoc} */ @Override public final void setTriggeringObjects(final SpellAbility sa) { - sa.setTriggeringObject("Card", runParams.get("Card")); + sa.setTriggeringObject("Card", this.getRunParams().get("Card")); } } diff --git a/src/main/java/forge/card/trigger/Trigger_Cycled.java b/src/main/java/forge/card/trigger/Trigger_Cycled.java index d5658be3314..65c5ae2118e 100644 --- a/src/main/java/forge/card/trigger/Trigger_Cycled.java +++ b/src/main/java/forge/card/trigger/Trigger_Cycled.java @@ -34,12 +34,12 @@ public class Trigger_Cycled extends Trigger { /** {@inheritDoc} */ @Override public final Trigger getCopy() { - Trigger copy = new Trigger_Cycled(mapParams, hostCard, isIntrinsic); - if (overridingAbility != null) { - copy.setOverridingAbility(overridingAbility); + final Trigger copy = new Trigger_Cycled(this.getMapParams(), this.getHostCard(), this.isIntrinsic()); + if (this.getOverridingAbility() != null) { + copy.setOverridingAbility(this.getOverridingAbility()); } - copy.setName(name); - copy.setID(ID); + copy.setName(this.getName()); + copy.setID(this.getId()); return copy; } @@ -47,14 +47,15 @@ public class Trigger_Cycled extends Trigger { /** {@inheritDoc} */ @Override public final void setTriggeringObjects(final SpellAbility sa) { - sa.setTriggeringObject("Card", runParams.get("Card")); + sa.setTriggeringObject("Card", this.getRunParams().get("Card")); } /** {@inheritDoc} */ @Override public final boolean performTest(final java.util.Map runParams2) { - if (mapParams.containsKey("ValidCard")) { - if (!matchesValid(runParams2.get("Card"), mapParams.get("ValidCard").split(","), hostCard)) { + if (this.getMapParams().containsKey("ValidCard")) { + if (!this.matchesValid(runParams2.get("Card"), this.getMapParams().get("ValidCard").split(","), + this.getHostCard())) { return false; } } diff --git a/src/main/java/forge/card/trigger/Trigger_DamageDone.java b/src/main/java/forge/card/trigger/Trigger_DamageDone.java index fd51b83aec7..b58049cc9b7 100644 --- a/src/main/java/forge/card/trigger/Trigger_DamageDone.java +++ b/src/main/java/forge/card/trigger/Trigger_DamageDone.java @@ -35,39 +35,40 @@ public class Trigger_DamageDone extends Trigger { /** {@inheritDoc} */ @Override public final boolean performTest(final java.util.Map runParams2) { - Card src = (Card) runParams2.get("DamageSource"); - Object tgt = runParams2.get("DamageTarget"); + final Card src = (Card) runParams2.get("DamageSource"); + final Object tgt = runParams2.get("DamageTarget"); - if (mapParams.containsKey("ValidSource")) { - if (!src.isValid(mapParams.get("ValidSource").split(","), hostCard.getController(), hostCard)) { + if (this.getMapParams().containsKey("ValidSource")) { + if (!src.isValid(this.getMapParams().get("ValidSource").split(","), this.getHostCard().getController(), + this.getHostCard())) { return false; } } - if (mapParams.containsKey("ValidTarget")) { - if (!matchesValid(tgt, mapParams.get("ValidTarget").split(","), hostCard)) { + if (this.getMapParams().containsKey("ValidTarget")) { + if (!this.matchesValid(tgt, this.getMapParams().get("ValidTarget").split(","), this.getHostCard())) { return false; } } - if (mapParams.containsKey("CombatDamage")) { - if (mapParams.get("CombatDamage").equals("True")) { + if (this.getMapParams().containsKey("CombatDamage")) { + if (this.getMapParams().get("CombatDamage").equals("True")) { if (!((Boolean) runParams2.get("IsCombatDamage"))) { return false; } - } else if (mapParams.get("CombatDamage").equals("False")) { + } else if (this.getMapParams().get("CombatDamage").equals("False")) { if (((Boolean) runParams2.get("IsCombatDamage"))) { return false; } } } - if (mapParams.containsKey("DamageAmount")) { - String fullParam = mapParams.get("DamageAmount"); + if (this.getMapParams().containsKey("DamageAmount")) { + final String fullParam = this.getMapParams().get("DamageAmount"); - String operator = fullParam.substring(0, 2); - int operand = Integer.parseInt(fullParam.substring(2)); - int actualAmount = (Integer) runParams2.get("DamageAmount"); + final String operator = fullParam.substring(0, 2); + final int operand = Integer.parseInt(fullParam.substring(2)); + final int actualAmount = (Integer) runParams2.get("DamageAmount"); if (!AllZoneUtil.compare(actualAmount, operator, operand)) { return false; @@ -85,12 +86,12 @@ public class Trigger_DamageDone extends Trigger { /** {@inheritDoc} */ @Override public final Trigger getCopy() { - Trigger copy = new Trigger_DamageDone(mapParams, hostCard, isIntrinsic); - if (overridingAbility != null) { - copy.setOverridingAbility(overridingAbility); + final Trigger copy = new Trigger_DamageDone(this.getMapParams(), this.getHostCard(), this.isIntrinsic()); + if (this.getOverridingAbility() != null) { + copy.setOverridingAbility(this.getOverridingAbility()); } - copy.setName(name); - copy.setID(ID); + copy.setName(this.getName()); + copy.setID(this.getId()); return copy; } @@ -98,8 +99,8 @@ public class Trigger_DamageDone extends Trigger { /** {@inheritDoc} */ @Override public final void setTriggeringObjects(final SpellAbility sa) { - sa.setTriggeringObject("Source", runParams.get("DamageSource")); - sa.setTriggeringObject("Target", runParams.get("DamageTarget")); - sa.setTriggeringObject("DamageAmount", runParams.get("DamageAmount")); + sa.setTriggeringObject("Source", this.getRunParams().get("DamageSource")); + sa.setTriggeringObject("Target", this.getRunParams().get("DamageTarget")); + sa.setTriggeringObject("DamageAmount", this.getRunParams().get("DamageAmount")); } } diff --git a/src/main/java/forge/card/trigger/Trigger_Discarded.java b/src/main/java/forge/card/trigger/Trigger_Discarded.java index 47f97db016e..3e69cca1d34 100644 --- a/src/main/java/forge/card/trigger/Trigger_Discarded.java +++ b/src/main/java/forge/card/trigger/Trigger_Discarded.java @@ -34,23 +34,26 @@ public class Trigger_Discarded extends Trigger { /** {@inheritDoc} */ @Override public final boolean performTest(final java.util.Map runParams2) { - if (mapParams.containsKey("ValidCard")) { - if (!matchesValid(runParams2.get("Card"), mapParams.get("ValidCard").split(","), hostCard)) { + if (this.getMapParams().containsKey("ValidCard")) { + if (!this.matchesValid(runParams2.get("Card"), this.getMapParams().get("ValidCard").split(","), + this.getHostCard())) { return false; } } - if (mapParams.containsKey("ValidPlayer")) { - if (!matchesValid(runParams2.get("Player"), mapParams.get("ValidPlayer").split(","), hostCard)) { + if (this.getMapParams().containsKey("ValidPlayer")) { + if (!this.matchesValid(runParams2.get("Player"), this.getMapParams().get("ValidPlayer").split(","), + this.getHostCard())) { return false; } } - if (mapParams.containsKey("ValidCause")) { + if (this.getMapParams().containsKey("ValidCause")) { if (runParams2.get("Cause") == null) { return false; } - if (!matchesValid(runParams2.get("Cause"), mapParams.get("ValidCause").split(","), hostCard)) { + if (!this.matchesValid(runParams2.get("Cause"), this.getMapParams().get("ValidCause").split(","), + this.getHostCard())) { return false; } } @@ -60,12 +63,12 @@ public class Trigger_Discarded extends Trigger { /** {@inheritDoc} */ @Override public final Trigger getCopy() { - Trigger copy = new Trigger_Discarded(mapParams, hostCard, isIntrinsic); - if (overridingAbility != null) { - copy.setOverridingAbility(overridingAbility); + final Trigger copy = new Trigger_Discarded(this.getMapParams(), this.getHostCard(), this.isIntrinsic()); + if (this.getOverridingAbility() != null) { + copy.setOverridingAbility(this.getOverridingAbility()); } - copy.setName(name); - copy.setID(ID); + copy.setName(this.getName()); + copy.setID(this.getId()); return copy; } @@ -73,6 +76,6 @@ public class Trigger_Discarded extends Trigger { /** {@inheritDoc} */ @Override public final void setTriggeringObjects(final SpellAbility sa) { - sa.setTriggeringObject("Card", runParams.get("Card")); + sa.setTriggeringObject("Card", this.getRunParams().get("Card")); } } diff --git a/src/main/java/forge/card/trigger/Trigger_Drawn.java b/src/main/java/forge/card/trigger/Trigger_Drawn.java index ce2764c30aa..3572921281d 100644 --- a/src/main/java/forge/card/trigger/Trigger_Drawn.java +++ b/src/main/java/forge/card/trigger/Trigger_Drawn.java @@ -34,10 +34,11 @@ public class Trigger_Drawn extends Trigger { /** {@inheritDoc} */ @Override public final boolean performTest(final java.util.Map runParams2) { - Card draw = ((Card) runParams2.get("Card")); + final Card draw = ((Card) runParams2.get("Card")); - if (mapParams.containsKey("ValidCard")) { - if (!draw.isValid(mapParams.get("ValidCard").split(","), hostCard.getController(), hostCard)) { + if (this.getMapParams().containsKey("ValidCard")) { + if (!draw.isValid(this.getMapParams().get("ValidCard").split(","), this.getHostCard().getController(), + this.getHostCard())) { return false; } } @@ -47,12 +48,12 @@ public class Trigger_Drawn extends Trigger { /** {@inheritDoc} */ @Override public final Trigger getCopy() { - Trigger copy = new Trigger_Drawn(mapParams, hostCard, isIntrinsic); - if (overridingAbility != null) { - copy.setOverridingAbility(overridingAbility); + final Trigger copy = new Trigger_Drawn(this.getMapParams(), this.getHostCard(), this.isIntrinsic()); + if (this.getOverridingAbility() != null) { + copy.setOverridingAbility(this.getOverridingAbility()); } - copy.setName(name); - copy.setID(ID); + copy.setName(this.getName()); + copy.setID(this.getId()); return copy; } @@ -60,6 +61,6 @@ public class Trigger_Drawn extends Trigger { /** {@inheritDoc} */ @Override public final void setTriggeringObjects(final SpellAbility sa) { - sa.setTriggeringObject("Card", runParams.get("Card")); + sa.setTriggeringObject("Card", this.getRunParams().get("Card")); } } diff --git a/src/main/java/forge/card/trigger/Trigger_LandPlayed.java b/src/main/java/forge/card/trigger/Trigger_LandPlayed.java index f7b6ca7a7f0..ba46d216ba7 100644 --- a/src/main/java/forge/card/trigger/Trigger_LandPlayed.java +++ b/src/main/java/forge/card/trigger/Trigger_LandPlayed.java @@ -29,8 +29,8 @@ public class Trigger_LandPlayed extends Trigger { * @param intrinsic * the intrinsic */ - public Trigger_LandPlayed(final String n, - final HashMap params, final Card host, final boolean intrinsic) { + public Trigger_LandPlayed(final String n, final HashMap params, final Card host, + final boolean intrinsic) { super(n, params, host, intrinsic); } @@ -53,11 +53,12 @@ public class Trigger_LandPlayed extends Trigger { /** {@inheritDoc} */ @Override public final Trigger getCopy() { - Trigger copy = new Trigger_LandPlayed(name, mapParams, hostCard, isIntrinsic); - copy.setID(ID); + final Trigger copy = new Trigger_LandPlayed(this.getName(), this.getMapParams(), this.getHostCard(), + this.isIntrinsic()); + copy.setID(this.getId()); - if (this.overridingAbility != null) { - copy.setOverridingAbility(overridingAbility); + if (this.getOverridingAbility() != null) { + copy.setOverridingAbility(this.getOverridingAbility()); } return copy; @@ -66,14 +67,15 @@ public class Trigger_LandPlayed extends Trigger { /** {@inheritDoc} */ @Override public final void setTriggeringObjects(final SpellAbility sa) { - sa.setTriggeringObject("Card", runParams.get("Card")); + sa.setTriggeringObject("Card", this.getRunParams().get("Card")); } /** {@inheritDoc} */ @Override public final boolean performTest(final java.util.Map runParams2) { - if (mapParams.containsKey("ValidCard")) { - if (!matchesValid(runParams2.get("Card"), mapParams.get("ValidCard").split(","), hostCard)) { + if (this.getMapParams().containsKey("ValidCard")) { + if (!this.matchesValid(runParams2.get("Card"), this.getMapParams().get("ValidCard").split(","), + this.getHostCard())) { return false; } } diff --git a/src/main/java/forge/card/trigger/Trigger_LifeGained.java b/src/main/java/forge/card/trigger/Trigger_LifeGained.java index 51086819872..4c0e2aa29ee 100644 --- a/src/main/java/forge/card/trigger/Trigger_LifeGained.java +++ b/src/main/java/forge/card/trigger/Trigger_LifeGained.java @@ -34,8 +34,9 @@ public class Trigger_LifeGained extends Trigger { /** {@inheritDoc} */ @Override public final boolean performTest(final java.util.Map runParams2) { - if (mapParams.containsKey("ValidPlayer")) { - if (!matchesValid(runParams2.get("Player"), mapParams.get("ValidPlayer").split(","), hostCard)) { + if (this.getMapParams().containsKey("ValidPlayer")) { + if (!this.matchesValid(runParams2.get("Player"), this.getMapParams().get("ValidPlayer").split(","), + this.getHostCard())) { return false; } } @@ -46,12 +47,12 @@ public class Trigger_LifeGained extends Trigger { /** {@inheritDoc} */ @Override public final Trigger getCopy() { - Trigger copy = new Trigger_LifeGained(mapParams, hostCard, isIntrinsic); - if (overridingAbility != null) { - copy.setOverridingAbility(overridingAbility); + final Trigger copy = new Trigger_LifeGained(this.getMapParams(), this.getHostCard(), this.isIntrinsic()); + if (this.getOverridingAbility() != null) { + copy.setOverridingAbility(this.getOverridingAbility()); } - copy.setName(name); - copy.setID(ID); + copy.setName(this.getName()); + copy.setID(this.getId()); return copy; } @@ -59,7 +60,7 @@ public class Trigger_LifeGained extends Trigger { /** {@inheritDoc} */ @Override public final void setTriggeringObjects(final SpellAbility sa) { - sa.setTriggeringObject("LifeAmount", runParams.get("LifeAmount")); - sa.setTriggeringObject("Player", runParams.get("Player")); + sa.setTriggeringObject("LifeAmount", this.getRunParams().get("LifeAmount")); + sa.setTriggeringObject("Player", this.getRunParams().get("Player")); } } diff --git a/src/main/java/forge/card/trigger/Trigger_LifeLost.java b/src/main/java/forge/card/trigger/Trigger_LifeLost.java index 068525308a8..009377a5133 100644 --- a/src/main/java/forge/card/trigger/Trigger_LifeLost.java +++ b/src/main/java/forge/card/trigger/Trigger_LifeLost.java @@ -34,8 +34,9 @@ public class Trigger_LifeLost extends Trigger { /** {@inheritDoc} */ @Override public final boolean performTest(final java.util.Map runParams2) { - if (mapParams.containsKey("ValidPlayer")) { - if (!matchesValid(runParams2.get("Player"), mapParams.get("ValidPlayer").split(","), hostCard)) { + if (this.getMapParams().containsKey("ValidPlayer")) { + if (!this.matchesValid(runParams2.get("Player"), this.getMapParams().get("ValidPlayer").split(","), + this.getHostCard())) { return false; } } @@ -46,12 +47,12 @@ public class Trigger_LifeLost extends Trigger { /** {@inheritDoc} */ @Override public final Trigger getCopy() { - Trigger copy = new Trigger_LifeLost(mapParams, hostCard, isIntrinsic); - if (overridingAbility != null) { - copy.setOverridingAbility(overridingAbility); + final Trigger copy = new Trigger_LifeLost(this.getMapParams(), this.getHostCard(), this.isIntrinsic()); + if (this.getOverridingAbility() != null) { + copy.setOverridingAbility(this.getOverridingAbility()); } - copy.setName(name); - copy.setID(ID); + copy.setName(this.getName()); + copy.setID(this.getId()); return copy; } @@ -59,7 +60,7 @@ public class Trigger_LifeLost extends Trigger { /** {@inheritDoc} */ @Override public final void setTriggeringObjects(final SpellAbility sa) { - sa.setTriggeringObject("LifeAmount", runParams.get("LifeAmount")); - sa.setTriggeringObject("Player", runParams.get("Player")); + sa.setTriggeringObject("LifeAmount", this.getRunParams().get("LifeAmount")); + sa.setTriggeringObject("Player", this.getRunParams().get("Player")); } } diff --git a/src/main/java/forge/card/trigger/Trigger_Phase.java b/src/main/java/forge/card/trigger/Trigger_Phase.java index 74df6330f49..9d67b941341 100644 --- a/src/main/java/forge/card/trigger/Trigger_Phase.java +++ b/src/main/java/forge/card/trigger/Trigger_Phase.java @@ -34,10 +34,10 @@ public class Trigger_Phase extends Trigger { /** {@inheritDoc} */ @Override public final boolean performTest(final java.util.Map runParams2) { - if (mapParams.containsKey("Phase")) { - if (mapParams.get("Phase").contains(",")) { + if (this.getMapParams().containsKey("Phase")) { + if (this.getMapParams().get("Phase").contains(",")) { boolean found = false; - for (String s : mapParams.get("Phase").split(",")) { + for (final String s : this.getMapParams().get("Phase").split(",")) { if (s.equals(runParams2.get("Phase"))) { found = true; break; @@ -48,13 +48,14 @@ public class Trigger_Phase extends Trigger { return false; } } else { - if (!mapParams.get("Phase").equals(runParams2.get("Phase"))) { + if (!this.getMapParams().get("Phase").equals(runParams2.get("Phase"))) { return false; } } } - if (mapParams.containsKey("ValidPlayer")) { - if (!matchesValid(runParams2.get("Player"), mapParams.get("ValidPlayer").split(","), hostCard)) { + if (this.getMapParams().containsKey("ValidPlayer")) { + if (!this.matchesValid(runParams2.get("Player"), this.getMapParams().get("ValidPlayer").split(","), + this.getHostCard())) { return false; } } @@ -64,12 +65,12 @@ public class Trigger_Phase extends Trigger { /** {@inheritDoc} */ @Override public final Trigger getCopy() { - Trigger copy = new Trigger_Phase(mapParams, hostCard, isIntrinsic); - if (overridingAbility != null) { - copy.setOverridingAbility(overridingAbility); + final Trigger copy = new Trigger_Phase(this.getMapParams(), this.getHostCard(), this.isIntrinsic()); + if (this.getOverridingAbility() != null) { + copy.setOverridingAbility(this.getOverridingAbility()); } - copy.setName(name); - copy.setID(ID); + copy.setName(this.getName()); + copy.setID(this.getId()); return copy; } @@ -77,6 +78,6 @@ public class Trigger_Phase extends Trigger { /** {@inheritDoc} */ @Override public final void setTriggeringObjects(final SpellAbility sa) { - sa.setTriggeringObject("Player", runParams.get("Player")); + sa.setTriggeringObject("Player", this.getRunParams().get("Player")); } } diff --git a/src/main/java/forge/card/trigger/Trigger_Sacrificed.java b/src/main/java/forge/card/trigger/Trigger_Sacrificed.java index bfe1dc9bd2d..1a4f48a7418 100644 --- a/src/main/java/forge/card/trigger/Trigger_Sacrificed.java +++ b/src/main/java/forge/card/trigger/Trigger_Sacrificed.java @@ -34,14 +34,16 @@ public class Trigger_Sacrificed extends Trigger { /** {@inheritDoc} */ @Override public final boolean performTest(final java.util.Map runParams2) { - Card sac = (Card) runParams2.get("Card"); - if (mapParams.containsKey("ValidPlayer")) { - if (!matchesValid(sac.getController(), mapParams.get("ValidPlayer").split(","), hostCard)) { + final Card sac = (Card) runParams2.get("Card"); + if (this.getMapParams().containsKey("ValidPlayer")) { + if (!this.matchesValid(sac.getController(), this.getMapParams().get("ValidPlayer").split(","), + this.getHostCard())) { return false; } } - if (mapParams.containsKey("ValidCard")) { - if (!sac.isValid(mapParams.get("ValidCard").split(","), hostCard.getController(), hostCard)) { + if (this.getMapParams().containsKey("ValidCard")) { + if (!sac.isValid(this.getMapParams().get("ValidCard").split(","), this.getHostCard().getController(), + this.getHostCard())) { return false; } } @@ -51,12 +53,12 @@ public class Trigger_Sacrificed extends Trigger { /** {@inheritDoc} */ @Override public final Trigger getCopy() { - Trigger copy = new Trigger_Sacrificed(mapParams, hostCard, isIntrinsic); - if (overridingAbility != null) { - copy.setOverridingAbility(overridingAbility); + final Trigger copy = new Trigger_Sacrificed(this.getMapParams(), this.getHostCard(), this.isIntrinsic()); + if (this.getOverridingAbility() != null) { + copy.setOverridingAbility(this.getOverridingAbility()); } - copy.setName(name); - copy.setID(ID); + copy.setName(this.getName()); + copy.setID(this.getId()); return copy; } @@ -64,6 +66,6 @@ public class Trigger_Sacrificed extends Trigger { /** {@inheritDoc} */ @Override public final void setTriggeringObjects(final SpellAbility sa) { - sa.setTriggeringObject("Card", runParams.get("Card")); + sa.setTriggeringObject("Card", this.getRunParams().get("Card")); } } diff --git a/src/main/java/forge/card/trigger/Trigger_Shuffled.java b/src/main/java/forge/card/trigger/Trigger_Shuffled.java index f4276d78f45..13fe9e4dcea 100644 --- a/src/main/java/forge/card/trigger/Trigger_Shuffled.java +++ b/src/main/java/forge/card/trigger/Trigger_Shuffled.java @@ -34,8 +34,9 @@ public class Trigger_Shuffled extends Trigger { /** {@inheritDoc} */ @Override public final boolean performTest(final java.util.Map runParams2) { - if (mapParams.containsKey("ValidPlayer")) { - if (!matchesValid(runParams2.get("Player"), mapParams.get("ValidPlayer").split(","), hostCard)) { + if (this.getMapParams().containsKey("ValidPlayer")) { + if (!this.matchesValid(runParams2.get("Player"), this.getMapParams().get("ValidPlayer").split(","), + this.getHostCard())) { return false; } } @@ -46,12 +47,12 @@ public class Trigger_Shuffled extends Trigger { /** {@inheritDoc} */ @Override public final Trigger getCopy() { - Trigger copy = new Trigger_Shuffled(mapParams, hostCard, isIntrinsic); - if (overridingAbility != null) { - copy.setOverridingAbility(overridingAbility); + final Trigger copy = new Trigger_Shuffled(this.getMapParams(), this.getHostCard(), this.isIntrinsic()); + if (this.getOverridingAbility() != null) { + copy.setOverridingAbility(this.getOverridingAbility()); } - copy.setName(name); - copy.setID(ID); + copy.setName(this.getName()); + copy.setID(this.getId()); return copy; } @@ -59,6 +60,6 @@ public class Trigger_Shuffled extends Trigger { /** {@inheritDoc} */ @Override public final void setTriggeringObjects(final SpellAbility sa) { - sa.setTriggeringObject("Player", runParams.get("Player")); + sa.setTriggeringObject("Player", this.getRunParams().get("Player")); } } diff --git a/src/main/java/forge/card/trigger/Trigger_SpellAbilityCast.java b/src/main/java/forge/card/trigger/Trigger_SpellAbilityCast.java index 5cf391754c6..df37776f7c9 100644 --- a/src/main/java/forge/card/trigger/Trigger_SpellAbilityCast.java +++ b/src/main/java/forge/card/trigger/Trigger_SpellAbilityCast.java @@ -38,62 +38,66 @@ public class Trigger_SpellAbilityCast extends Trigger { /** {@inheritDoc} */ @Override public final boolean performTest(final java.util.Map runParams2) { - SpellAbility SA = (SpellAbility) runParams2.get("CastSA"); - Card cast = SA.getSourceCard(); - SpellAbility_StackInstance si = AllZone.getStack().getInstanceFromSpellAbility(SA); + final SpellAbility spellAbility = (SpellAbility) runParams2.get("CastSA"); + final Card cast = spellAbility.getSourceCard(); + final SpellAbility_StackInstance si = AllZone.getStack().getInstanceFromSpellAbility(spellAbility); - if (mapParams.get("Mode").equals("SpellCast")) { - if (!SA.isSpell()) { + if (this.getMapParams().get("Mode").equals("SpellCast")) { + if (!spellAbility.isSpell()) { return false; } - } else if (mapParams.get("Mode").equals("AbilityCast")) { - if (!SA.isAbility()) { + } else if (this.getMapParams().get("Mode").equals("AbilityCast")) { + if (!spellAbility.isAbility()) { return false; } - } else if (mapParams.get("Mode").equals("SpellAbilityCast")) { + } else if (this.getMapParams().get("Mode").equals("SpellAbilityCast")) { // Empty block for readability. } - if (mapParams.containsKey("ActivatedOnly")) { - if (SA.isTrigger()) { + if (this.getMapParams().containsKey("ActivatedOnly")) { + if (spellAbility.isTrigger()) { return false; } } - if (mapParams.containsKey("ValidControllingPlayer")) { - if (!matchesValid(cast.getController(), mapParams.get("ValidControllingPlayer").split(","), hostCard)) { + if (this.getMapParams().containsKey("ValidControllingPlayer")) { + if (!this.matchesValid(cast.getController(), this.getMapParams().get("ValidControllingPlayer").split(","), + this.getHostCard())) { return false; } } - if (mapParams.containsKey("ValidActivatingPlayer")) { - if (!matchesValid(si.getActivatingPlayer(), mapParams.get("ValidActivatingPlayer").split(","), hostCard)) { + if (this.getMapParams().containsKey("ValidActivatingPlayer")) { + if (!this.matchesValid(si.getActivatingPlayer(), this.getMapParams().get("ValidActivatingPlayer") + .split(","), this.getHostCard())) { return false; } } - if (mapParams.containsKey("ValidCard")) { - if (!matchesValid(cast, mapParams.get("ValidCard").split(","), hostCard)) { + if (this.getMapParams().containsKey("ValidCard")) { + if (!this.matchesValid(cast, this.getMapParams().get("ValidCard").split(","), this.getHostCard())) { return false; } } - if (mapParams.containsKey("TargetsValid")) { - SpellAbility sa = si.getSpellAbility(); + if (this.getMapParams().containsKey("TargetsValid")) { + final SpellAbility sa = si.getSpellAbility(); if (sa.getTarget() == null) { if (sa.getTargetCard() == null) { if (sa.getTargetList() == null) { if (sa.getTargetPlayer() == null) { return false; } else { - if (!matchesValid(sa.getTargetPlayer(), mapParams.get("TargetsValid").split(","), hostCard)) { + if (!this.matchesValid(sa.getTargetPlayer(), + this.getMapParams().get("TargetsValid").split(","), this.getHostCard())) { return false; } } } else { boolean validTgtFound = false; - for (Card tgt : sa.getTargetList()) { - if (matchesValid(tgt, mapParams.get("TargetsValid").split(","), hostCard)) { + for (final Card tgt : sa.getTargetList()) { + if (this.matchesValid(tgt, this.getMapParams().get("TargetsValid").split(","), + this.getHostCard())) { validTgtFound = true; break; } @@ -103,22 +107,24 @@ public class Trigger_SpellAbilityCast extends Trigger { } } } else { - if (!matchesValid(sa.getTargetCard(), mapParams.get("TargetsValid").split(","), hostCard)) { + if (!this.matchesValid(sa.getTargetCard(), this.getMapParams().get("TargetsValid").split(","), + this.getHostCard())) { return false; } } } else { if (sa.getTarget().doesTarget()) { boolean validTgtFound = false; - for (Card tgt : sa.getTarget().getTargetCards()) { - if (tgt.isValid(mapParams.get("TargetsValid").split(","), hostCard.getController(), hostCard)) { + for (final Card tgt : sa.getTarget().getTargetCards()) { + if (tgt.isValid(this.getMapParams().get("TargetsValid").split(","), this.getHostCard() + .getController(), this.getHostCard())) { validTgtFound = true; break; } } - for (Player p : sa.getTarget().getTargetPlayers()) { - if (matchesValid(p, mapParams.get("TargetsValid").split(","), hostCard)) { + for (final Player p : sa.getTarget().getTargetPlayers()) { + if (this.matchesValid(p, this.getMapParams().get("TargetsValid").split(","), this.getHostCard())) { validTgtFound = true; break; } @@ -133,8 +139,8 @@ public class Trigger_SpellAbilityCast extends Trigger { } } - if (mapParams.containsKey("NonTapCost")) { - Cost cost = (Cost) (runParams2.get("Cost")); + if (this.getMapParams().containsKey("NonTapCost")) { + final Cost cost = (Cost) (runParams2.get("Cost")); if (cost.getTap()) { return false; } @@ -146,12 +152,12 @@ public class Trigger_SpellAbilityCast extends Trigger { /** {@inheritDoc} */ @Override public final Trigger getCopy() { - Trigger copy = new Trigger_SpellAbilityCast(mapParams, hostCard, isIntrinsic); - if (overridingAbility != null) { - copy.setOverridingAbility(overridingAbility); + final Trigger copy = new Trigger_SpellAbilityCast(this.getMapParams(), this.getHostCard(), this.isIntrinsic()); + if (this.getOverridingAbility() != null) { + copy.setOverridingAbility(this.getOverridingAbility()); } - copy.setName(name); - copy.setID(ID); + copy.setName(this.getName()); + copy.setID(this.getId()); return copy; } @@ -159,9 +165,9 @@ public class Trigger_SpellAbilityCast extends Trigger { /** {@inheritDoc} */ @Override public final void setTriggeringObjects(final SpellAbility sa) { - sa.setTriggeringObject("Card", ((SpellAbility) runParams.get("CastSA")).getSourceCard()); - sa.setTriggeringObject("SpellAbility", runParams.get("CastSA")); - sa.setTriggeringObject("Player", runParams.get("Player")); - sa.setTriggeringObject("Activator", runParams.get("Activator")); + sa.setTriggeringObject("Card", ((SpellAbility) this.getRunParams().get("CastSA")).getSourceCard()); + sa.setTriggeringObject("SpellAbility", this.getRunParams().get("CastSA")); + sa.setTriggeringObject("Player", this.getRunParams().get("Player")); + sa.setTriggeringObject("Activator", this.getRunParams().get("Activator")); } } diff --git a/src/main/java/forge/card/trigger/Trigger_Taps.java b/src/main/java/forge/card/trigger/Trigger_Taps.java index 8d15bfdcffb..cb4646ce6ee 100644 --- a/src/main/java/forge/card/trigger/Trigger_Taps.java +++ b/src/main/java/forge/card/trigger/Trigger_Taps.java @@ -34,10 +34,11 @@ public class Trigger_Taps extends Trigger { /** {@inheritDoc} */ @Override public final boolean performTest(final java.util.Map runParams2) { - Card tapper = (Card) runParams2.get("Card"); + final Card tapper = (Card) runParams2.get("Card"); - if (mapParams.containsKey("ValidCard")) { - if (!tapper.isValid(mapParams.get("ValidCard").split(","), hostCard.getController(), hostCard)) { + if (this.getMapParams().containsKey("ValidCard")) { + if (!tapper.isValid(this.getMapParams().get("ValidCard").split(","), this.getHostCard().getController(), + this.getHostCard())) { return false; } } @@ -48,12 +49,12 @@ public class Trigger_Taps extends Trigger { /** {@inheritDoc} */ @Override public final Trigger getCopy() { - Trigger copy = new Trigger_Taps(mapParams, hostCard, isIntrinsic); - if (overridingAbility != null) { - copy.setOverridingAbility(overridingAbility); + final Trigger copy = new Trigger_Taps(this.getMapParams(), this.getHostCard(), this.isIntrinsic()); + if (this.getOverridingAbility() != null) { + copy.setOverridingAbility(this.getOverridingAbility()); } - copy.setName(name); - copy.setID(ID); + copy.setName(this.getName()); + copy.setID(this.getId()); return copy; } @@ -61,6 +62,6 @@ public class Trigger_Taps extends Trigger { /** {@inheritDoc} */ @Override public final void setTriggeringObjects(final SpellAbility sa) { - sa.setTriggeringObject("Card", runParams.get("Card")); + sa.setTriggeringObject("Card", this.getRunParams().get("Card")); } } diff --git a/src/main/java/forge/card/trigger/Trigger_TapsForMana.java b/src/main/java/forge/card/trigger/Trigger_TapsForMana.java index 27efb00cb70..a65f9473857 100644 --- a/src/main/java/forge/card/trigger/Trigger_TapsForMana.java +++ b/src/main/java/forge/card/trigger/Trigger_TapsForMana.java @@ -34,10 +34,11 @@ public class Trigger_TapsForMana extends Trigger { /** {@inheritDoc} */ @Override public final boolean performTest(final java.util.Map runParams2) { - Card tapper = (Card) runParams2.get("Card"); + final Card tapper = (Card) runParams2.get("Card"); - if (mapParams.containsKey("ValidCard")) { - if (!tapper.isValid(mapParams.get("ValidCard").split(","), hostCard.getController(), hostCard)) { + if (this.getMapParams().containsKey("ValidCard")) { + if (!tapper.isValid(this.getMapParams().get("ValidCard").split(","), this.getHostCard().getController(), + this.getHostCard())) { return false; } } @@ -48,12 +49,12 @@ public class Trigger_TapsForMana extends Trigger { /** {@inheritDoc} */ @Override public final Trigger getCopy() { - Trigger copy = new Trigger_TapsForMana(mapParams, hostCard, isIntrinsic); - if (overridingAbility != null) { - copy.setOverridingAbility(overridingAbility); + final Trigger copy = new Trigger_TapsForMana(this.getMapParams(), this.getHostCard(), this.isIntrinsic()); + if (this.getOverridingAbility() != null) { + copy.setOverridingAbility(this.getOverridingAbility()); } - copy.setName(name); - copy.setID(ID); + copy.setName(this.getName()); + copy.setID(this.getId()); return copy; } @@ -61,8 +62,8 @@ public class Trigger_TapsForMana extends Trigger { /** {@inheritDoc} */ @Override public final void setTriggeringObjects(final SpellAbility sa) { - sa.setTriggeringObject("Card", runParams.get("Card")); - sa.setTriggeringObject("Player", runParams.get("Player")); - sa.setTriggeringObject("Produced", runParams.get("Produced")); + sa.setTriggeringObject("Card", this.getRunParams().get("Card")); + sa.setTriggeringObject("Player", this.getRunParams().get("Player")); + sa.setTriggeringObject("Produced", this.getRunParams().get("Produced")); } } diff --git a/src/main/java/forge/card/trigger/Trigger_TurnFaceUp.java b/src/main/java/forge/card/trigger/Trigger_TurnFaceUp.java index 819900d37b3..3e80f39c77f 100644 --- a/src/main/java/forge/card/trigger/Trigger_TurnFaceUp.java +++ b/src/main/java/forge/card/trigger/Trigger_TurnFaceUp.java @@ -34,8 +34,9 @@ public class Trigger_TurnFaceUp extends Trigger { /** {@inheritDoc} */ @Override public final boolean performTest(final java.util.Map runParams2) { - if (mapParams.containsKey("ValidCard")) { - if (!matchesValid(runParams2.get("Card"), mapParams.get("ValidCard").split(","), hostCard)) { + if (this.getMapParams().containsKey("ValidCard")) { + if (!this.matchesValid(runParams2.get("Card"), this.getMapParams().get("ValidCard").split(","), + this.getHostCard())) { return false; } } @@ -46,12 +47,12 @@ public class Trigger_TurnFaceUp extends Trigger { /** {@inheritDoc} */ @Override public final Trigger getCopy() { - Trigger copy = new Trigger_TurnFaceUp(mapParams, hostCard, isIntrinsic); - if (overridingAbility != null) { - copy.setOverridingAbility(overridingAbility); + final Trigger copy = new Trigger_TurnFaceUp(this.getMapParams(), this.getHostCard(), this.isIntrinsic()); + if (this.getOverridingAbility() != null) { + copy.setOverridingAbility(this.getOverridingAbility()); } - copy.setName(name); - copy.setID(ID); + copy.setName(this.getName()); + copy.setID(this.getId()); return copy; } @@ -59,6 +60,6 @@ public class Trigger_TurnFaceUp extends Trigger { /** {@inheritDoc} */ @Override public final void setTriggeringObjects(final SpellAbility sa) { - sa.setTriggeringObject("Card", runParams.get("Card")); + sa.setTriggeringObject("Card", this.getRunParams().get("Card")); } } diff --git a/src/main/java/forge/card/trigger/Trigger_Unequip.java b/src/main/java/forge/card/trigger/Trigger_Unequip.java index a11cd4da0d5..4f4c4520bd2 100644 --- a/src/main/java/forge/card/trigger/Trigger_Unequip.java +++ b/src/main/java/forge/card/trigger/Trigger_Unequip.java @@ -34,17 +34,19 @@ public class Trigger_Unequip extends Trigger { /** {@inheritDoc} */ @Override public final boolean performTest(final java.util.Map runParams2) { - Card equipped = (Card) runParams2.get("Card"); - Card equipment = (Card) runParams2.get("Equipment"); + final Card equipped = (Card) runParams2.get("Card"); + final Card equipment = (Card) runParams2.get("Equipment"); - if (mapParams.containsKey("ValidCard")) { - if (!equipped.isValid(mapParams.get("ValidCard").split(","), hostCard.getController(), hostCard)) { + if (this.getMapParams().containsKey("ValidCard")) { + if (!equipped.isValid(this.getMapParams().get("ValidCard").split(","), this.getHostCard().getController(), + this.getHostCard())) { return false; } } - if (mapParams.containsKey("ValidEquipment")) { - if (!equipment.isValid(mapParams.get("ValidEquipment").split(","), hostCard.getController(), hostCard)) { + if (this.getMapParams().containsKey("ValidEquipment")) { + if (!equipment.isValid(this.getMapParams().get("ValidEquipment").split(","), this.getHostCard() + .getController(), this.getHostCard())) { return false; } } @@ -55,12 +57,12 @@ public class Trigger_Unequip extends Trigger { /** {@inheritDoc} */ @Override public final Trigger getCopy() { - Trigger copy = new Trigger_Unequip(mapParams, hostCard, isIntrinsic); - if (overridingAbility != null) { - copy.setOverridingAbility(overridingAbility); + final Trigger copy = new Trigger_Unequip(this.getMapParams(), this.getHostCard(), this.isIntrinsic()); + if (this.getOverridingAbility() != null) { + copy.setOverridingAbility(this.getOverridingAbility()); } - copy.setName(name); - copy.setID(ID); + copy.setName(this.getName()); + copy.setID(this.getId()); return copy; } @@ -68,7 +70,7 @@ public class Trigger_Unequip extends Trigger { /** {@inheritDoc} */ @Override public final void setTriggeringObjects(final SpellAbility sa) { - sa.setTriggeringObject("Card", runParams.get("Card")); - sa.setTriggeringObject("Equipment", runParams.get("Equipment")); + sa.setTriggeringObject("Card", this.getRunParams().get("Card")); + sa.setTriggeringObject("Equipment", this.getRunParams().get("Equipment")); } } diff --git a/src/main/java/forge/card/trigger/Trigger_Untaps.java b/src/main/java/forge/card/trigger/Trigger_Untaps.java index e3c3fcd79ce..fdbfe2dd0e9 100644 --- a/src/main/java/forge/card/trigger/Trigger_Untaps.java +++ b/src/main/java/forge/card/trigger/Trigger_Untaps.java @@ -34,10 +34,11 @@ public class Trigger_Untaps extends Trigger { /** {@inheritDoc} */ @Override public final boolean performTest(final java.util.Map runParams2) { - Card untapper = (Card) runParams2.get("Card"); + final Card untapper = (Card) runParams2.get("Card"); - if (mapParams.containsKey("ValidCard")) { - if (!untapper.isValid(mapParams.get("ValidCard").split(","), hostCard.getController(), hostCard)) { + if (this.getMapParams().containsKey("ValidCard")) { + if (!untapper.isValid(this.getMapParams().get("ValidCard").split(","), this.getHostCard().getController(), + this.getHostCard())) { return false; } } @@ -48,12 +49,12 @@ public class Trigger_Untaps extends Trigger { /** {@inheritDoc} */ @Override public final Trigger getCopy() { - Trigger copy = new Trigger_Untaps(mapParams, hostCard, isIntrinsic); - if (overridingAbility != null) { - copy.setOverridingAbility(overridingAbility); + final Trigger copy = new Trigger_Untaps(this.getMapParams(), this.getHostCard(), this.isIntrinsic()); + if (this.getOverridingAbility() != null) { + copy.setOverridingAbility(this.getOverridingAbility()); } - copy.setName(name); - copy.setID(ID); + copy.setName(this.getName()); + copy.setID(this.getId()); return copy; } @@ -61,7 +62,7 @@ public class Trigger_Untaps extends Trigger { /** {@inheritDoc} */ @Override public final void setTriggeringObjects(final SpellAbility sa) { - sa.setTriggeringObject("Card", runParams.get("Card")); + sa.setTriggeringObject("Card", this.getRunParams().get("Card")); } } diff --git a/src/main/java/forge/game/limited/BoosterDraftAI.java b/src/main/java/forge/game/limited/BoosterDraftAI.java index b6dae8ecde9..e97e88f2da4 100644 --- a/src/main/java/forge/game/limited/BoosterDraftAI.java +++ b/src/main/java/forge/game/limited/BoosterDraftAI.java @@ -85,7 +85,7 @@ public class BoosterDraftAI { } }); - if (this.playerColors.get(player).Color1.equals("none") && this.playerColors.get(player).Color2.equals("none")) { + if (this.playerColors.get(player).getColor1().equals("none") && this.playerColors.get(player).getColor2().equals("none")) { // final CardList creatures = aiPlayables.getType("Creature").getColored(); creatures.sort(this.bestCreature); @@ -95,30 +95,30 @@ public class BoosterDraftAI { if (creatures.size() > 0) { pickedCard = creatures.get(creatures.size() - 1); - this.playerColors.get(player).Color1 = pickedCard.getColor().get(0).toStringArray().get(0); + this.playerColors.get(player).setColor1(pickedCard.getColor().get(0).toStringArray().get(0)); if (Constant.Runtime.DEV_MODE[0]) { - System.out.println("Player[" + player + "] Color1: " + this.playerColors.get(player).Color1); + System.out.println("Player[" + player + "] Color1: " + this.playerColors.get(player).getColor1()); } - this.playerColors.get(player).Mana1 = this.playerColors.get(player).ColorToMana( - this.playerColors.get(player).Color1); + this.playerColors.get(player).setMana1(this.playerColors.get(player).colorToMana( + this.playerColors.get(player).getColor1())); // if the first pick has more than one color add the second as // second color to draft if (pickedCard.getColor().get(0).toStringArray().size() > 1) { - this.playerColors.get(player).Color2 = pickedCard.getColor().get(0).toStringArray().get(1); + this.playerColors.get(player).setColor2(pickedCard.getColor().get(0).toStringArray().get(1)); if (Constant.Runtime.DEV_MODE[0]) { - System.out.println("Player[" + player + "] Color2: " + this.playerColors.get(player).Color2); + System.out.println("Player[" + player + "] Color2: " + this.playerColors.get(player).getColor2()); } - this.playerColors.get(player).Mana2 = this.playerColors.get(player).ColorToMana( - this.playerColors.get(player).Color2); + this.playerColors.get(player).setMana2(this.playerColors.get(player).colorToMana( + this.playerColors.get(player).getColor2())); } hasPicked = true; } - } else if (!this.playerColors.get(player).Color1.equals("none") - && this.playerColors.get(player).Color2.equals("none")) { + } else if (!this.playerColors.get(player).getColor1().equals("none") + && this.playerColors.get(player).getColor2().equals("none")) { final CardList creatures = aiPlayables.getType("Creature").getColored(); creatures.sort(this.bestCreature); // for (int i=0; i 0) { pickedCard = creatures.get(creatures.size() - 1); - this.playerColors.get(player).Color2 = pickedCard.getColor().get(0).toStringArray().get(0); + this.playerColors.get(player).setColor2(pickedCard.getColor().get(0).toStringArray().get(0)); if (Constant.Runtime.DEV_MODE[0]) { - System.out.println("Player[" + player + "] Color2: " + this.playerColors.get(player).Color2); + System.out.println("Player[" + player + "] Color2: " + this.playerColors.get(player).getColor2()); } - this.playerColors.get(player).Mana2 = this.playerColors.get(player).ColorToMana( - this.playerColors.get(player).Color2); + this.playerColors.get(player).setMana2(this.playerColors.get(player).colorToMana( + this.playerColors.get(player).getColor2())); hasPicked = true; } } else { CardList typeList; CardList colorList; - colorList = aiPlayables.getOnly2Colors(this.playerColors.get(player).Color1, - this.playerColors.get(player).Color2); + colorList = aiPlayables.getOnly2Colors(this.playerColors.get(player).getColor1(), + this.playerColors.get(player).getColor2()); if (colorList.size() > 0) { typeList = colorList.getType("Creature"); @@ -211,8 +211,8 @@ public class BoosterDraftAI { for (int i = 0; i < typeList.size(); i++) { final ArrayList maList = typeList.get(i).getManaAbility(); for (int j = 0; j < maList.size(); j++) { - if (maList.get(j).canProduce(this.playerColors.get(player).Mana1) - || maList.get(j).canProduce(this.playerColors.get(player).Mana2)) { + if (maList.get(j).canProduce(this.playerColors.get(player).getMana1()) + || maList.get(j).canProduce(this.playerColors.get(player).getMana2())) { wouldPick.add(typeList.get(i)); } } @@ -356,7 +356,7 @@ public class BoosterDraftAI { dList.remove(aiPlayables.get(i)); } - final CardList creatures = aiPlayables.getType("Creature").getOnly2Colors(pClrs.Color1, pClrs.Color2); + final CardList creatures = aiPlayables.getType("Creature").getOnly2Colors(pClrs.getColor1(), pClrs.getColor2()); int nCreatures = 15; @@ -395,7 +395,7 @@ public class BoosterDraftAI { } CardList others = aiPlayables.getNotType("Creature").getNotType("Land") - .getOnly2Colors(pClrs.Color1, pClrs.Color2); + .getOnly2Colors(pClrs.getColor1(), pClrs.getColor2()); int ii = 0; while ((cardsNeeded > 0) && (others.size() > 1)) { @@ -406,7 +406,7 @@ public class BoosterDraftAI { cardsNeeded--; aiPlayables.remove(c); - others = aiPlayables.getNotType("Creature").getNotType("Land").getOnly2Colors(pClrs.Color1, pClrs.Color2); + others = aiPlayables.getNotType("Creature").getNotType("Land").getOnly2Colors(pClrs.getColor1(), pClrs.getColor2()); if (Constant.Runtime.DEV_MODE[0]) { System.out.println("Others[" + ii++ + "]:" + c.getName() + " (" + c.getManaCost() + ")"); diff --git a/src/main/java/forge/game/limited/DeckColors.java b/src/main/java/forge/game/limited/DeckColors.java index ea7d2708896..2116e7ebee9 100644 --- a/src/main/java/forge/game/limited/DeckColors.java +++ b/src/main/java/forge/game/limited/DeckColors.java @@ -9,16 +9,16 @@ import forge.Constant; class DeckColors { /** The Color1. */ - public String Color1 = "none"; + private String color1 = "none"; /** The Color2. */ - public String Color2 = "none"; + private String color2 = "none"; // public String Splash = "none"; /** The Mana1. */ - public String Mana1 = ""; + private String mana1 = ""; /** The Mana2. */ - public String Mana2 = ""; + private String mana2 = ""; // public String ManaS = ""; @@ -35,8 +35,8 @@ class DeckColors { * a {@link java.lang.String} object. */ public DeckColors(final String c1, final String c2, final String sp) { - this.Color1 = c1; - this.Color2 = c2; + this.setColor1(c1); + this.setColor2(c2); // Splash = sp; } @@ -58,16 +58,72 @@ class DeckColors { * a {@link java.lang.String} object. * @return a {@link java.lang.String} object. */ - public String ColorToMana(final String color) { - final String Mana[] = { "W", "U", "B", "R", "G" }; + public String colorToMana(final String color) { + final String[] mana = { "W", "U", "B", "R", "G" }; for (int i = 0; i < Constant.Color.ONLY_COLORS.length; i++) { if (Constant.Color.ONLY_COLORS[i].equals(color)) { - return Mana[i]; + return mana[i]; } } return ""; } + /** + * @return the color1 + */ + public String getColor1() { + return color1; + } + + /** + * @param color1 the color1 to set + */ + public void setColor1(String color1) { + this.color1 = color1; // TODO: Add 0 to parameter's name. + } + + /** + * @return the mana1 + */ + public String getMana1() { + return mana1; + } + + /** + * @param mana1 the mana1 to set + */ + public void setMana1(String mana1) { + this.mana1 = mana1; // TODO: Add 0 to parameter's name. + } + + /** + * @return the mana2 + */ + public String getMana2() { + return mana2; + } + + /** + * @param mana2 the mana2 to set + */ + public void setMana2(String mana2) { + this.mana2 = mana2; // TODO: Add 0 to parameter's name. + } + + /** + * @return the color2 + */ + public String getColor2() { + return color2; + } + + /** + * @param color2 the color2 to set + */ + public void setColor2(String color2) { + this.color2 = color2; // TODO: Add 0 to parameter's name. + } + } diff --git a/src/main/java/forge/quest/data/pet/QuestPetManager.java b/src/main/java/forge/quest/data/pet/QuestPetManager.java index a292d1fffbc..4f3ead92052 100644 --- a/src/main/java/forge/quest/data/pet/QuestPetManager.java +++ b/src/main/java/forge/quest/data/pet/QuestPetManager.java @@ -19,16 +19,16 @@ import java.util.TreeSet; public class QuestPetManager { /** The pets. */ - public Map pets = new HashMap(); + private Map pets = new HashMap(); /** The selected pet. */ - public QuestPetAbstract selectedPet; + private QuestPetAbstract selectedPet; /** The plant. */ - public QuestPetAbstract plant; + private QuestPetAbstract plant; /** The use plant. */ - public boolean usePlant; + private boolean usePlant; /** *

@@ -146,7 +146,7 @@ public class QuestPetManager { * @return a boolean. */ public final boolean shouldPlantBeUsed() { - return this.usePlant; + return this.isUsePlant(); } /** @@ -225,4 +225,18 @@ public class QuestPetManager { } return this; } + + /** + * @return the usePlant + */ + public boolean isUsePlant() { + return usePlant; + } + + /** + * @param usePlant the usePlant to set + */ + public void setUsePlant(boolean usePlant) { + this.usePlant = usePlant; // TODO: Add 0 to parameter's name. + } } diff --git a/src/main/java/forge/quest/gui/QuestMainPanel.java b/src/main/java/forge/quest/gui/QuestMainPanel.java index 95739da8be8..9f313be4b05 100644 --- a/src/main/java/forge/quest/gui/QuestMainPanel.java +++ b/src/main/java/forge/quest/gui/QuestMainPanel.java @@ -422,7 +422,7 @@ public class QuestMainPanel extends QuestAbstractPanel { this.plantBox.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent actionEvent) { - QuestMainPanel.this.questData.getPetManager().usePlant = QuestMainPanel.this.plantBox.isSelected(); + QuestMainPanel.this.questData.getPetManager().setUsePlant(QuestMainPanel.this.plantBox.isSelected()); } }); diff --git a/src/main/java/forge/quest/gui/QuestWinLoseHandler.java b/src/main/java/forge/quest/gui/QuestWinLoseHandler.java index b2a5e2c7897..7cbc83dbfcf 100644 --- a/src/main/java/forge/quest/gui/QuestWinLoseHandler.java +++ b/src/main/java/forge/quest/gui/QuestWinLoseHandler.java @@ -117,18 +117,18 @@ public class QuestWinLoseHandler extends WinLoseModeHandler { */ @Override public final boolean populateCustomPanel() { - this.getView().btnRestart.setVisible(false); + this.getView().getBtnRestart().setVisible(false); this.model.qData.getCards().resetNewList(); if (!this.model.qMatchState.isMatchOver()) { - this.getView().btnQuit.setText("Quit (15 Credits)"); + this.getView().getBtnQuit().setText("Quit (15 Credits)"); return false; } else { - this.getView().btnContinue.setVisible(false); + this.getView().getBtnContinue().setVisible(false); if (this.wonMatch) { - this.getView().btnQuit.setText("Great!"); + this.getView().getBtnQuit().setText("Great!"); } else { - this.getView().btnQuit.setText("OK"); + this.getView().getBtnQuit().setText("OK"); } } @@ -371,8 +371,8 @@ public class QuestWinLoseHandler extends WinLoseModeHandler { this.lblTemp2.setIcon(this.icoTemp); this.lblTemp2.setIconTextGap(50); - this.getView().pnlCustom.add(this.lblTemp1, "align center, width 95%!"); - this.getView().pnlCustom.add(this.lblTemp2, "align center, width 95%!, gaptop 10"); + this.getView().getPnlCustom().add(this.lblTemp1, "align center, width 95%!"); + this.getView().getPnlCustom().add(this.lblTemp2, "align center, width 95%!, gaptop 10"); } /** @@ -392,9 +392,9 @@ public class QuestWinLoseHandler extends WinLoseModeHandler { final QuestWinLoseCardViewer cv = new QuestWinLoseCardViewer(cardsWon); - this.getView().pnlCustom.add(this.lblTemp1, "align center, width 95%!, " + "gaptop " + this.spacer + this.getView().getPnlCustom().add(this.lblTemp1, "align center, width 95%!, " + "gaptop " + this.spacer + ", gapbottom 10"); - this.getView().pnlCustom.add(cv, "align center, width 95%!"); + this.getView().getPnlCustom().add(cv, "align center, width 95%!"); } /** @@ -411,9 +411,9 @@ public class QuestWinLoseHandler extends WinLoseModeHandler { this.lblTemp1 = new TitleLabel("You just won 10 random rares!"); final QuestWinLoseCardViewer cv = new QuestWinLoseCardViewer(cardsWon); - this.getView().pnlCustom.add(this.lblTemp1, "align center, width 95%!, " + "gaptop " + this.spacer + this.getView().getPnlCustom().add(this.lblTemp1, "align center, width 95%!, " + "gaptop " + this.spacer + ", gapbottom 10"); - this.getView().pnlCustom.add(cv, "align center, width 95%!"); + this.getView().getPnlCustom().add(cv, "align center, width 95%!"); } /** @@ -436,9 +436,9 @@ public class QuestWinLoseHandler extends WinLoseModeHandler { this.lblTemp1 = new TitleLabel("Bonus booster pack from the \"" + selected.getName() + "\" format!"); final QuestWinLoseCardViewer cv = new QuestWinLoseCardViewer(cardsWon); - this.getView().pnlCustom.add(this.lblTemp1, "align center, width 95%!, " + "gaptop " + this.spacer + this.getView().getPnlCustom().add(this.lblTemp1, "align center, width 95%!, " + "gaptop " + this.spacer + ", gapbottom 10"); - this.getView().pnlCustom.add(cv, "align center, width 95%!"); + this.getView().getPnlCustom().add(cv, "align center, width 95%!"); } /** @@ -478,12 +478,12 @@ public class QuestWinLoseHandler extends WinLoseModeHandler { this.lblTemp2.setIconTextGap(50); this.lblTemp2.setIcon(this.icoTemp); - this.getView().pnlCustom.add(this.lblTemp1, "align center, width 95%!, " + "gaptop " + this.spacer); - this.getView().pnlCustom.add(this.lblTemp2, "align center, width 95%!, height 80!, gapbottom 10"); + this.getView().getPnlCustom().add(this.lblTemp1, "align center, width 95%!, " + "gaptop " + this.spacer); + this.getView().getPnlCustom().add(this.lblTemp2, "align center, width 95%!, height 80!, gapbottom 10"); if (cardsWon != null) { final QuestWinLoseCardViewer cv = new QuestWinLoseCardViewer(cardsWon); - this.getView().pnlCustom.add(cv, "align center, width 95%!"); + this.getView().getPnlCustom().add(cv, "align center, width 95%!"); this.model.qData.getCards().addAllCards(cardsWon); } } @@ -500,8 +500,8 @@ public class QuestWinLoseHandler extends WinLoseModeHandler { this.lblTemp2.setIconTextGap(50); this.lblTemp2.setIcon(this.icoTemp); - this.getView().pnlCustom.add(this.lblTemp1, "align center, width 95%!"); - this.getView().pnlCustom.add(this.lblTemp2, "align center, width 95%!, height 80!"); + this.getView().getPnlCustom().add(this.lblTemp1, "align center, width 95%!"); + this.getView().getPnlCustom().add(this.lblTemp2, "align center, width 95%!, height 80!"); } /** diff --git a/src/main/java/forge/view/swing/ApplicationView.java b/src/main/java/forge/view/swing/ApplicationView.java index 9a7fd8dfe08..840089b714f 100644 --- a/src/main/java/forge/view/swing/ApplicationView.java +++ b/src/main/java/forge/view/swing/ApplicationView.java @@ -96,16 +96,16 @@ public class ApplicationView implements FView { final ForgePreferences preferences = model.getPreferences(); - OldGuiNewGame.useLAFFonts.setSelected(preferences.isLafFonts()); + OldGuiNewGame.getUseLAFFonts().setSelected(preferences.isLafFonts()); // newGuiCheckBox.setSelected(preferences.newGui); - OldGuiNewGame.smoothLandCheckBox.setSelected(preferences.isStackAiLand()); + OldGuiNewGame.getSmoothLandCheckBox().setSelected(preferences.isStackAiLand()); OldGuiNewGame.devModeCheckBox.setSelected(preferences.isDeveloperMode()); - OldGuiNewGame.cardOverlay.setSelected(preferences.isCardOverlay()); + OldGuiNewGame.getCardOverlay().setSelected(preferences.isCardOverlay()); // FindBugs doesn't like the next line. ImageCache.setScaleLargerThanOriginal(preferences.isScaleLargerThanOriginal()); - OldGuiNewGame.cardScale.setSelected(preferences.isScaleLargerThanOriginal()); + OldGuiNewGame.getCardScale().setSelected(preferences.isScaleLargerThanOriginal()); CardStackOffsetAction.set(preferences.getStackOffset()); CardStackAction.setVal(preferences.getMaxStackSize()); CardSizesAction.set(preferences.getCardSize()); diff --git a/src/main/java/forge/view/swing/OldGuiNewGame.java b/src/main/java/forge/view/swing/OldGuiNewGame.java index de7a99c783b..b409e1d20db 100644 --- a/src/main/java/forge/view/swing/OldGuiNewGame.java +++ b/src/main/java/forge/view/swing/OldGuiNewGame.java @@ -127,7 +127,7 @@ public class OldGuiNewGame extends JFrame implements NewConstants, NewConstants. /** Constant newGuiCheckBox. */ // private static JCheckBox newGuiCheckBox = new JCheckBox("", true); /** Constant smoothLandCheckBox. */ - static JCheckBox smoothLandCheckBox = new JCheckBox("", false); + private static JCheckBox smoothLandCheckBox = new JCheckBox("", false); /** Constant devModeCheckBox. */ static JCheckBox devModeCheckBox = new JCheckBox("", true); @@ -147,12 +147,12 @@ public class OldGuiNewGame extends JFrame implements NewConstants, NewConstants. public static JCheckBoxMenuItem removeArtifacts = new JCheckBoxMenuItem( ForgeProps.getLocalized(MenuBar.Options.Generate.REMOVE_ARTIFACTS)); /** Constant useLAFFonts. */ - public static JCheckBoxMenuItem useLAFFonts = new JCheckBoxMenuItem(ForgeProps.getLocalized(MenuBar.Options.FONT)); + private static JCheckBoxMenuItem useLAFFonts = new JCheckBoxMenuItem(ForgeProps.getLocalized(MenuBar.Options.FONT)); /** Constant cardOverlay. */ - public static JCheckBoxMenuItem cardOverlay = new JCheckBoxMenuItem( + private static JCheckBoxMenuItem cardOverlay = new JCheckBoxMenuItem( ForgeProps.getLocalized(MenuBar.Options.CARD_OVERLAY)); /** Constant cardScale. */ - public static JCheckBoxMenuItem cardScale = new JCheckBoxMenuItem( + private static JCheckBoxMenuItem cardScale = new JCheckBoxMenuItem( ForgeProps.getLocalized(MenuBar.Options.CARD_SCALE)); private final JButton questButton = new JButton(); @@ -281,15 +281,15 @@ public class OldGuiNewGame extends JFrame implements NewConstants, NewConstants. final JMenu optionsMenu = new JMenu(ForgeProps.getLocalized(Options.TITLE)); optionsMenu.add(generatedDeck); - optionsMenu.add(OldGuiNewGame.useLAFFonts); + optionsMenu.add(OldGuiNewGame.getUseLAFFonts()); optionsMenu.addSeparator(); - optionsMenu.add(OldGuiNewGame.cardOverlay); - optionsMenu.add(OldGuiNewGame.cardScale); + optionsMenu.add(OldGuiNewGame.getCardOverlay()); + optionsMenu.add(OldGuiNewGame.getCardScale()); - OldGuiNewGame.cardScale.addActionListener(new ActionListener() { + OldGuiNewGame.getCardScale().addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent arg0) { - ImageCache.setScaleLargerThanOriginal(OldGuiNewGame.cardScale.isSelected()); + ImageCache.setScaleLargerThanOriginal(OldGuiNewGame.getCardScale().isSelected()); } }); @@ -537,7 +537,7 @@ public class OldGuiNewGame extends JFrame implements NewConstants, NewConstants. this.jPanel3.setLayout(new MigLayout("align center")); // newGuiCheckBox.setText(ForgeProps.getLocalized(NEW_GAME_TEXT.NEW_GUI)); - OldGuiNewGame.smoothLandCheckBox.setText(ForgeProps.getLocalized(NewGameText.AI_LAND)); + OldGuiNewGame.getSmoothLandCheckBox().setText(ForgeProps.getLocalized(NewGameText.AI_LAND)); OldGuiNewGame.devModeCheckBox.setText(ForgeProps.getLocalized(NewGameText.DEV_MODE)); OldGuiNewGame.devModeCheckBox.addActionListener(new java.awt.event.ActionListener() { @@ -619,7 +619,7 @@ public class OldGuiNewGame extends JFrame implements NewConstants, NewConstants. this.getContentPane().add(this.jPanel3, "span 2, grow"); // jPanel3.add(newGuiCheckBox, "wrap"); - this.jPanel3.add(OldGuiNewGame.smoothLandCheckBox, "wrap"); + this.jPanel3.add(OldGuiNewGame.getSmoothLandCheckBox(), "wrap"); this.jPanel3.add(OldGuiNewGame.devModeCheckBox, "wrap"); this.jPanel3.add(OldGuiNewGame.upldDrftCheckBox, "wrap"); this.jPanel3.add(OldGuiNewGame.foilRandomCheckBox, "wrap"); @@ -852,7 +852,7 @@ public class OldGuiNewGame extends JFrame implements NewConstants, NewConstants. AllZone.setDisplay(new GuiDisplay4()); // else AllZone.setDisplay(new GuiDisplay3()); - Constant.Runtime.SMOOTH[0] = OldGuiNewGame.smoothLandCheckBox.isSelected(); + Constant.Runtime.SMOOTH[0] = OldGuiNewGame.getSmoothLandCheckBox().isSelected(); AllZone.getGameAction().newGame(Constant.Runtime.HUMAN_DECK[0], Constant.Runtime.COMPUTER_DECK[0]); AllZone.getDisplay().setVisible(true); @@ -1626,7 +1626,7 @@ public class OldGuiNewGame extends JFrame implements NewConstants, NewConstants. public final void actionPerformed(final ActionEvent e) { final JTextArea area = new JTextArea(12, 25); - if (OldGuiNewGame.useLAFFonts.isSelected()) { + if (OldGuiNewGame.getUseLAFFonts().isSelected()) { final Font f = new Font(area.getFont().getName(), Font.PLAIN, 13); area.setFont(f); } @@ -1692,12 +1692,12 @@ public class OldGuiNewGame extends JFrame implements NewConstants, NewConstants. try { final ForgePreferences preferences = Singletons.getModel().getPreferences(); preferences.setLaf(UIManager.getLookAndFeel().getClass().getName()); - preferences.setLafFonts(OldGuiNewGame.useLAFFonts.isSelected()); + preferences.setLafFonts(OldGuiNewGame.getUseLAFFonts().isSelected()); // preferences.newGui = newGuiCheckBox.isSelected(); - preferences.setStackAiLand(OldGuiNewGame.smoothLandCheckBox.isSelected()); + preferences.setStackAiLand(OldGuiNewGame.getSmoothLandCheckBox().isSelected()); preferences.setMillingLossCondition(Constant.Runtime.MILL[0]); preferences.setDeveloperMode(Constant.Runtime.DEV_MODE[0]); - preferences.setCardOverlay(OldGuiNewGame.cardOverlay.isSelected()); + preferences.setCardOverlay(OldGuiNewGame.getCardOverlay().isSelected()); preferences.setScaleLargerThanOriginal(ImageCache.isScaleLargerThanOriginal()); preferences.setUploadDraftAI(Constant.Runtime.UPLOAD_DRAFT[0]); preferences.save(); @@ -1866,4 +1866,60 @@ public class OldGuiNewGame extends JFrame implements NewConstants, NewConstants. */ } + /** + * @return the cardOverlay + */ + public static JCheckBoxMenuItem getCardOverlay() { + return cardOverlay; + } + + /** + * @param cardOverlay the cardOverlay to set + */ + public static void setCardOverlay(JCheckBoxMenuItem cardOverlay) { + OldGuiNewGame.cardOverlay = cardOverlay; // TODO: Add 0 to parameter's name. + } + + /** + * @return the cardScale + */ + public static JCheckBoxMenuItem getCardScale() { + return cardScale; + } + + /** + * @param cardScale the cardScale to set + */ + public static void setCardScale(JCheckBoxMenuItem cardScale) { + OldGuiNewGame.cardScale = cardScale; // TODO: Add 0 to parameter's name. + } + + /** + * @return the useLAFFonts + */ + public static JCheckBoxMenuItem getUseLAFFonts() { + return useLAFFonts; + } + + /** + * @param useLAFFonts the useLAFFonts to set + */ + public static void setUseLAFFonts(JCheckBoxMenuItem useLAFFonts) { + OldGuiNewGame.useLAFFonts = useLAFFonts; // TODO: Add 0 to parameter's name. + } + + /** + * @return the smoothLandCheckBox + */ + static JCheckBox getSmoothLandCheckBox() { + return smoothLandCheckBox; + } + + /** + * @param smoothLandCheckBox the smoothLandCheckBox to set + */ + static void setSmoothLandCheckBox(JCheckBox smoothLandCheckBox) { + OldGuiNewGame.smoothLandCheckBox = smoothLandCheckBox; // TODO: Add 0 to parameter's name. + } + } diff --git a/src/main/java/forge/view/swing/WinLoseFrame.java b/src/main/java/forge/view/swing/WinLoseFrame.java index 1ce043eedcf..cdb95e17ea1 100644 --- a/src/main/java/forge/view/swing/WinLoseFrame.java +++ b/src/main/java/forge/view/swing/WinLoseFrame.java @@ -40,22 +40,22 @@ public class WinLoseFrame extends JFrame { private final WinLoseModeHandler modeHandler; /** The btn continue. */ - public FButton btnContinue; + private FButton btnContinue; /** The btn quit. */ - public FButton btnQuit; + private FButton btnQuit; /** The btn restart. */ - public FButton btnRestart; + private FButton btnRestart; /** The lbl title. */ - public JLabel lblTitle; + private JLabel lblTitle; /** The lbl stats. */ - public JLabel lblStats; + private JLabel lblStats; /** The pnl custom. */ - public JPanel pnlCustom; + private JPanel pnlCustom; /** *

@@ -94,15 +94,15 @@ public class WinLoseFrame extends JFrame { // Footer should be at least 150 to keep buttons in-pane on Mac OS X // it needs to be > 175 now that skinning is used - final int HEAD_HEIGHT = 150; - final int FOOT_HEIGHT = 182; - final int FRAME_WIDTH_SMALL = 300; - final int FRAME_WIDTH_BIG = 600; + final int headHeight = 150; + final int footHeight = 182; + final int frameWidthSmall = 300; + final int frameWidthBig = 600; // Head panel final JPanel pnlHead = new JPanel(new MigLayout("wrap, fill")); pnlHead.setOpaque(false); - contentPanel.add(pnlHead, "width " + FRAME_WIDTH_SMALL + "!, align center"); + contentPanel.add(pnlHead, "width " + frameWidthSmall + "!, align center"); this.lblTitle = new JLabel("WinLoseFrame > lblTitle is broken."); this.lblTitle.setForeground(Color.white); @@ -120,44 +120,44 @@ public class WinLoseFrame extends JFrame { // Custom display panel in center; populated later by mode handler. final JScrollPane scroller = new JScrollPane(); scroller.getVerticalScrollBar().setUnitIncrement(16); - this.pnlCustom = new JPanel(new MigLayout("wrap, fillx")); - this.pnlCustom.setBackground(new Color(111, 87, 59)); - this.pnlCustom.setForeground(Color.white); + this.setPnlCustom(new JPanel(new MigLayout("wrap, fillx"))); + this.getPnlCustom().setBackground(new Color(111, 87, 59)); + this.getPnlCustom().setForeground(Color.white); contentPanel.add(scroller, "w 96%!, align center, gapleft 2%"); - scroller.getViewport().add(this.pnlCustom); + scroller.getViewport().add(this.getPnlCustom()); // Foot panel final JPanel pnlFoot = new JPanel(new MigLayout("wrap, fill, hidemode 3")); pnlFoot.setOpaque(false); - contentPanel.add(pnlFoot, "width " + FRAME_WIDTH_SMALL + "!, align center"); + contentPanel.add(pnlFoot, "width " + frameWidthSmall + "!, align center"); - this.btnContinue = new FButton("Continue"); - this.btnRestart = new FButton("Restart"); - this.btnQuit = new FButton("Quit"); + this.setBtnContinue(new FButton("Continue")); + this.setBtnRestart(new FButton("Restart")); + this.setBtnQuit(new FButton("Quit")); - pnlFoot.add(this.btnContinue, "h 36:36, w 200!, gap 0 0 5 5, align center"); - pnlFoot.add(this.btnRestart, "h 36:36, w 200!, gap 0 0 5 5, align center"); - pnlFoot.add(this.btnQuit, "h 36:36, w 200!, gap 0 0 5 5, align center"); + pnlFoot.add(this.getBtnContinue(), "h 36:36, w 200!, gap 0 0 5 5, align center"); + pnlFoot.add(this.getBtnRestart(), "h 36:36, w 200!, gap 0 0 5 5, align center"); + pnlFoot.add(this.getBtnQuit(), "h 36:36, w 200!, gap 0 0 5 5, align center"); // Button actions - this.btnQuit.addActionListener(new java.awt.event.ActionListener() { + this.getBtnQuit().addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(final ActionEvent e) { - WinLoseFrame.this.btnQuit_actionPerformed(e); + WinLoseFrame.this.btnQuitActionPerformed(e); } }); - this.btnContinue.addActionListener(new java.awt.event.ActionListener() { + this.getBtnContinue().addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(final ActionEvent e) { - WinLoseFrame.this.btnContinue_actionPerformed(e); + WinLoseFrame.this.btnContinueActionPerformed(e); } }); - this.btnRestart.addActionListener(new java.awt.event.ActionListener() { + this.getBtnRestart().addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(final ActionEvent e) { - WinLoseFrame.this.btnRestart_actionPerformed(e); + WinLoseFrame.this.btnRestartActionPerformed(e); } }); @@ -165,8 +165,8 @@ public class WinLoseFrame extends JFrame { Phase.setGameBegins(0); if (this.matchState.isMatchOver()) { - this.btnContinue.setEnabled(false); - this.btnQuit.grabFocus(); + this.getBtnContinue().setEnabled(false); + this.getBtnQuit().grabFocus(); } // Show Wins and Loses @@ -196,14 +196,14 @@ public class WinLoseFrame extends JFrame { if (hasContents) { bounds.height = screen.height - 150; - scroller.setPreferredSize(new Dimension(FRAME_WIDTH_BIG, screen.height - HEAD_HEIGHT - FOOT_HEIGHT)); - bounds.width = FRAME_WIDTH_BIG; - bounds.x = (screen.width - FRAME_WIDTH_BIG) / 2; + scroller.setPreferredSize(new Dimension(frameWidthBig, screen.height - headHeight - footHeight)); + bounds.width = frameWidthBig; + bounds.x = (screen.width - frameWidthBig) / 2; bounds.y = (screen.height - bounds.height) / 2; } else { - bounds.height = HEAD_HEIGHT + FOOT_HEIGHT; - bounds.width = FRAME_WIDTH_SMALL; - bounds.x = (screen.width - FRAME_WIDTH_SMALL) / 2; + bounds.height = headHeight + footHeight; + bounds.width = frameWidthSmall; + bounds.x = (screen.width - frameWidthSmall) / 2; bounds.y = (screen.height - bounds.height) / 2; } @@ -222,7 +222,7 @@ public class WinLoseFrame extends JFrame { * @param e * a {@link java.awt.event.ActionEvent} object. */ - final void btnContinue_actionPerformed(final ActionEvent e) { + final void btnContinueActionPerformed(final ActionEvent e) { this.closeWinLoseFrame(); AllZone.getDisplay().setVisible(true); this.modeHandler.startNextRound(); @@ -236,7 +236,7 @@ public class WinLoseFrame extends JFrame { * @param e * a {@link java.awt.event.ActionEvent} object. */ - final void btnRestart_actionPerformed(final ActionEvent e) { + final void btnRestartActionPerformed(final ActionEvent e) { this.closeWinLoseFrame(); AllZone.getDisplay().setVisible(true); this.matchState.reset(); @@ -251,7 +251,7 @@ public class WinLoseFrame extends JFrame { * @param e * a {@link java.awt.event.ActionEvent} object. */ - final void btnQuit_actionPerformed(final ActionEvent e) { + final void btnQuitActionPerformed(final ActionEvent e) { this.closeWinLoseFrame(); this.matchState.reset(); this.modeHandler.actionOnQuit(); @@ -279,6 +279,62 @@ public class WinLoseFrame extends JFrame { return frame; } + /** + * @return the btnContinue + */ + public FButton getBtnContinue() { + return btnContinue; + } + + /** + * @param btnContinue the btnContinue to set + */ + public void setBtnContinue(FButton btnContinue) { + this.btnContinue = btnContinue; // TODO: Add 0 to parameter's name. + } + + /** + * @return the btnRestart + */ + public FButton getBtnRestart() { + return btnRestart; + } + + /** + * @param btnRestart the btnRestart to set + */ + public void setBtnRestart(FButton btnRestart) { + this.btnRestart = btnRestart; // TODO: Add 0 to parameter's name. + } + + /** + * @return the btnQuit + */ + public FButton getBtnQuit() { + return btnQuit; + } + + /** + * @param btnQuit the btnQuit to set + */ + public void setBtnQuit(FButton btnQuit) { + this.btnQuit = btnQuit; // TODO: Add 0 to parameter's name. + } + + /** + * @return the pnlCustom + */ + public JPanel getPnlCustom() { + return pnlCustom; + } + + /** + * @param pnlCustom the pnlCustom to set + */ + public void setPnlCustom(JPanel pnlCustom) { + this.pnlCustom = pnlCustom; // TODO: Add 0 to parameter's name. + } + private class WinLoseBorder extends AbstractBorder { @Override public void paintBorder(final Component c, final Graphics g, final int x, final int y, final int width,