diff --git a/src/main/java/forge/control/FControl.java b/src/main/java/forge/control/FControl.java index d1b4928be16..c22859c2f2e 100644 --- a/src/main/java/forge/control/FControl.java +++ b/src/main/java/forge/control/FControl.java @@ -87,7 +87,7 @@ public enum FControl { public static final int DRAFTING_PROCESS = 7; private final SoundSystem soundSystem = new SoundSystem(); - + /** *

* FControl. @@ -282,8 +282,9 @@ public enum FControl { */ private Lobby lobby = null; public Lobby getLobby() { - if( lobby == null ) + if (lobby == null) { lobby = new Lobby(); + } return lobby; } diff --git a/src/main/java/forge/control/Lobby.java b/src/main/java/forge/control/Lobby.java index 5d3b3cf8349..22afea2c727 100644 --- a/src/main/java/forge/control/Lobby.java +++ b/src/main/java/forge/control/Lobby.java @@ -53,16 +53,15 @@ public class Lobby { "Roger", "Roland", "Ronald", "Roy", "Sam", "Sebastian", "Simon", "Stanley", "Stephen", "Stuart", "Terence", "Thomas", "Tim", "Tom", "Tony", "Victor", "Vincent", "Wallace", "Walter", "Wilfred", "William", "Winston" - }; - + }; + /** * TODO: Write javadoc for this method. * @param human * @return */ public LobbyPlayer findLocalPlayer(PlayerType type, String name) { - - + return new LobbyPlayer(type, name); } @@ -72,10 +71,11 @@ public class Lobby { * @return */ public LobbyPlayer findLocalPlayer(PlayerType type) { - if ( type == PlayerType.HUMAN ) + if (type == PlayerType.HUMAN) { return new LobbyPlayer(type, "Human"); // need to get name! - - LobbyPlayer player = findLocalPlayer(type, getRandomName()); + } + + LobbyPlayer player = findLocalPlayer(type, getRandomName()); player.setAvatarIndex(MyRandom.getRandom().nextInt(FSkin.getAvatars().size())); return player; } @@ -88,7 +88,7 @@ public class Lobby { private String getRandomName() { Random my = MyRandom.getRandom(); return opponentNames[my.nextInt(opponentNames.length)]; - + } /** @@ -99,6 +99,5 @@ public class Lobby { return new LobbyPlayer(PlayerType.HUMAN, "Human"); // need to get name! } - - + } diff --git a/src/main/java/forge/control/input/Input.java b/src/main/java/forge/control/input/Input.java index d93021b7d0a..0491a22212e 100644 --- a/src/main/java/forge/control/input/Input.java +++ b/src/main/java/forge/control/input/Input.java @@ -116,12 +116,13 @@ public abstract class Input implements java.io.Serializable { public String toString() { return "blank"; } // returns the Input name like "EmptyStack" - - + + /** * This method is used to mark old descendants of Input * TODO: Write javadoc for this method. */ - public /*abstract */void isClassUpdated() {}//; + public /*abstract */void isClassUpdated() { + } //; } diff --git a/src/main/java/forge/control/input/InputBlock.java b/src/main/java/forge/control/input/InputBlock.java index 0e113d8a0ff..220dc6af385 100644 --- a/src/main/java/forge/control/input/InputBlock.java +++ b/src/main/java/forge/control/input/InputBlock.java @@ -46,9 +46,9 @@ public class InputBlock extends Input { private static final long serialVersionUID = 6120743598368928128L; private Card currentAttacker = null; - private final HashMap> allBlocking = new HashMap>(); + private final HashMap> allBlocking = new HashMap>(); private final Player defender; - + /** * TODO: Write javadoc for Constructor. * @param priority @@ -110,34 +110,34 @@ public class InputBlock extends Input { public final void selectCard(final Card card) { // is attacking? boolean reminder = true; - + if (Singletons.getModel().getGame().getCombat().getAttackers().contains(card)) { this.currentAttacker = card; reminder = false; } else { Zone zone = Singletons.getModel().getGame().getZoneOf(card); // Make sure this card is valid to even be a blocker - if (this.currentAttacker != null && card.isCreature() && card.getController().equals(defender) + if (this.currentAttacker != null && card.isCreature() && card.getController().equals(defender) && zone.is(ZoneType.Battlefield, defender)) { // Create a new blockedBy list if it doesn't exist if (!this.allBlocking.containsKey(card)) { this.allBlocking.put(card, new ArrayList()); } - + List attackersBlocked = this.allBlocking.get(card); - if (!attackersBlocked.contains(this.currentAttacker) && - CombatUtil.canBlock(this.currentAttacker, card, Singletons.getModel().getGame().getCombat())) { + if (!attackersBlocked.contains(this.currentAttacker) + && CombatUtil.canBlock(this.currentAttacker, card, Singletons.getModel().getGame().getCombat())) { attackersBlocked.add(this.currentAttacker); Singletons.getModel().getGame().getCombat().addBlocker(this.currentAttacker, card); reminder = false; } - } + } } - + if (reminder) { SDisplayUtil.remind(VMessage.SINGLETON_INSTANCE); } - + this.showMessage(); } // selectCard() diff --git a/src/main/java/forge/control/input/InputCleanup.java b/src/main/java/forge/control/input/InputCleanup.java index 78df3e77608..1d1dc4becdd 100644 --- a/src/main/java/forge/control/input/InputCleanup.java +++ b/src/main/java/forge/control/input/InputCleanup.java @@ -40,7 +40,7 @@ public class InputCleanup extends Input { /** {@inheritDoc} */ @Override public final void showMessage() { - final Player active = Singletons.getModel().getGame().getPhaseHandler().getPlayerTurn(); + final Player active = Singletons.getModel().getGame().getPhaseHandler().getPlayerTurn(); if (active.isComputer()) { this.aiCleanupDiscard(active); Singletons.getModel().getGame().getPhaseHandler().passPriority(); diff --git a/src/main/java/forge/control/input/InputControl.java b/src/main/java/forge/control/input/InputControl.java index fd1f5a348d7..efff6426fb6 100644 --- a/src/main/java/forge/control/input/InputControl.java +++ b/src/main/java/forge/control/input/InputControl.java @@ -68,7 +68,7 @@ public class InputControl extends MyObservable implements java.io.Serializable { if (!this.game.getStack().isResolving() && isInputEmpty) { this.input = in; } else { - this.inputStack.add(in); + this.inputStack.add(in); } this.updateObservers(); } @@ -202,7 +202,7 @@ public class InputControl extends MyObservable implements java.io.Serializable { return new InputAttack(); } break; - + case COMBAT_DECLARE_BLOCKERS: stack.freezeStack(); boolean isUnderAttack = game.getCombat().isPlayerAttacked(priority); @@ -210,14 +210,15 @@ public class InputControl extends MyObservable implements java.io.Serializable { handler.passPriority(); return null; } - - if ( priority.isHuman() ) + + if (priority.isHuman()) { return new InputBlock(priority); - + } + // ai is under attack priority.getController().getAiInput().getComputer().declareBlockers(); return null; - + case CLEANUP: // discard if (stack.isEmpty()) { @@ -236,9 +237,9 @@ public class InputControl extends MyObservable implements java.io.Serializable { if (priority == null) { return null; } else if (priority.isHuman()) { - boolean prioritySkip = priority.getController().mayAutoPass(phase) - || priority.getController().isUiSetToSkipPhase(playerTurn, phase); - if (this.game.getStack().isEmpty() && prioritySkip ) { + boolean prioritySkip = priority.getController().mayAutoPass(phase) + || priority.getController().isUiSetToSkipPhase(playerTurn, phase); + if (this.game.getStack().isEmpty() && prioritySkip) { handler.passPriority(); return null; } else { diff --git a/src/main/java/forge/control/input/InputMulligan.java b/src/main/java/forge/control/input/InputMulligan.java index e027b8c36fa..9cbf98fe605 100644 --- a/src/main/java/forge/control/input/InputMulligan.java +++ b/src/main/java/forge/control/input/InputMulligan.java @@ -80,7 +80,7 @@ public class InputMulligan extends Input { @Override public final void selectButtonCancel() { final Player humanPlayer = Singletons.getControl().getPlayer(); - + final int newHand = humanPlayer.doMulligan(); @@ -90,22 +90,24 @@ public class InputMulligan extends Input { } // selectButtonOK() final void end() { - GameState game = Singletons.getModel().getGame(); + GameState game = Singletons.getModel().getGame(); // Computer mulligan for (Player ai : game.getPlayers()) { - if ( ai.isHuman() ) continue; - + if (ai.isHuman()) { + continue; + } + boolean aiTakesMulligan = true; - + // Computer mulligans if there are no cards with converted mana cost of // 0 in its hand while (aiTakesMulligan) { - + final List handList = ai.getCardsIn(ZoneType.Hand); final boolean hasLittleCmc0Cards = CardLists.getValidCards(handList, "Card.cmcEQ0", ai, null).size() < 2; aiTakesMulligan = (handList.size() > InputMulligan.AI_MULLIGAN_THRESHOLD) && hasLittleCmc0Cards; - + if (aiTakesMulligan) { ai.doMulligan(); } @@ -119,16 +121,16 @@ public class InputMulligan extends Input { final GameAction ga = game.getAction(); for (Player p : game.getPlayers()) { final List openingHand = new ArrayList(p.getCardsIn(ZoneType.Hand)); - + for (final Card c : openingHand) { - if ( p.isHuman() ) { + if (p.isHuman()) { final ArrayList kws = c.getKeyword(); for (int i = 0; i < kws.size(); i++) { final String kw = kws.get(i); - + if (kw.startsWith("MayEffectFromOpeningHand")) { final String effName = kw.split(":")[1]; - + final SpellAbility effect = af.getAbility(c.getSVar(effName), c); if (GameActionUtil.showYesNoDialog(c, "Use this card's ability?")) { // If we ever let the AI memorize cards in the players @@ -147,12 +149,12 @@ public class InputMulligan extends Input { final ArrayList kws = c.getKeyword(); for (int i = 0; i < kws.size(); i++) { final String kw = kws.get(i); - + if (kw.startsWith("MayEffectFromOpeningHand")) { final String effName = kw.split(":")[1]; - + final SpellAbility effect = af.getAbility(c.getSVar(effName), c); - + // Is there a better way for the AI to decide this? if (effect.doTrigger(false)) { GameActionUtil.showInfoDialg("Computer reveals " + c.getName() + "(" + c.getUniqueNumber() + ")."); @@ -161,8 +163,9 @@ public class InputMulligan extends Input { } } } - if (c.getName().startsWith("Leyline") && !(c.getName().startsWith("Leyline of Singularity") && - (Iterables.any(game.getCardsIn(ZoneType.Battlefield), CardPredicates.nameEquals("Leyline of Singularity"))))) { + if (c.getName().startsWith("Leyline") + && !(c.getName().startsWith("Leyline of Singularity") + && (Iterables.any(game.getCardsIn(ZoneType.Battlefield), CardPredicates.nameEquals("Leyline of Singularity"))))) { ga.moveToPlay(c); //ga.checkStateEffects(); } @@ -190,7 +193,7 @@ public class InputMulligan extends Input { SDisplayUtil.remind(VMessage.SINGLETON_INSTANCE); } } - + @Override public void isClassUpdated() { } diff --git a/src/main/java/forge/control/input/InputPassPriority.java b/src/main/java/forge/control/input/InputPassPriority.java index d721a4ed1c3..3ecc02976b0 100644 --- a/src/main/java/forge/control/input/InputPassPriority.java +++ b/src/main/java/forge/control/input/InputPassPriority.java @@ -85,6 +85,7 @@ public class InputPassPriority extends Input { SDisplayUtil.remind(VMessage.SINGLETON_INSTANCE); } } // selectCard() - - @Override public void isClassUpdated() {} + + @Override public void isClassUpdated() { + } } diff --git a/src/main/java/forge/control/input/InputPayDiscardCost.java b/src/main/java/forge/control/input/InputPayDiscardCost.java index ae46f22e3ca..8c4eac36cb7 100644 --- a/src/main/java/forge/control/input/InputPayDiscardCost.java +++ b/src/main/java/forge/control/input/InputPayDiscardCost.java @@ -186,5 +186,6 @@ public class InputPayDiscardCost extends Input { this.unpaid.execute(); } - @Override public void isClassUpdated() {} + @Override public void isClassUpdated() { + } } diff --git a/src/main/java/forge/control/input/InputPayManaCost.java b/src/main/java/forge/control/input/InputPayManaCost.java index 49a8a2d630a..5c43a5f3277 100644 --- a/src/main/java/forge/control/input/InputPayManaCost.java +++ b/src/main/java/forge/control/input/InputPayManaCost.java @@ -117,7 +117,7 @@ public class InputPayManaCost extends InputPayMana { this.spell = sa; - if (Singletons.getModel().getGame() != null ) { + if (Singletons.getModel().getGame() != null) { if (sa.getSourceCard().isCopiedSpell() && sa.isSpell()) { if (this.spell.getAfterPayMana() != null) { this.stopSetNext(this.spell.getAfterPayMana()); @@ -290,6 +290,7 @@ public class InputPayManaCost extends InputPayMana { this.done(); } } - - @Override public void isClassUpdated() {} + + @Override public void isClassUpdated() { + } } diff --git a/src/main/java/forge/control/input/InputPayManaCost2.java b/src/main/java/forge/control/input/InputPayManaCost2.java index f8b47e8c510..20605cbb44e 100644 --- a/src/main/java/forge/control/input/InputPayManaCost2.java +++ b/src/main/java/forge/control/input/InputPayManaCost2.java @@ -12,15 +12,15 @@ import forge.gui.match.CMatchUI; import forge.view.ButtonUtil; public class InputPayManaCost2 extends InputPayMana { - + private ManaCost manaCost; private final CostMana costMana; // I would kill the one who made 2 classes like above private final String originalManaCost; - private final SpellAbility sa; + private final SpellAbility sa; private final int manaToAdd; private final CostPayment payment; - + public InputPayManaCost2(CostMana costMana, SpellAbility spellAbility, final CostPayment payment, int toAdd) { manaCost = new ManaCost(costMana.getManaToPay()); manaCost.increaseColorlessMana(toAdd); @@ -30,12 +30,12 @@ public class InputPayManaCost2 extends InputPayMana { sa = spellAbility; manaToAdd = toAdd; this.payment = payment; - + } private static final long serialVersionUID = 3467312982164195091L; - + private int phyLifeToLose = 0; @@ -155,6 +155,7 @@ public class InputPayManaCost2 extends InputPayMana { this.showMessage(); } } - - @Override public void isClassUpdated() {} -} \ No newline at end of file + + @Override public void isClassUpdated() { + } +} diff --git a/src/main/java/forge/control/input/InputPayManaCostAbility.java b/src/main/java/forge/control/input/InputPayManaCostAbility.java index fbd3f726195..f4e97b8d99d 100644 --- a/src/main/java/forge/control/input/InputPayManaCostAbility.java +++ b/src/main/java/forge/control/input/InputPayManaCostAbility.java @@ -184,7 +184,7 @@ public class InputPayManaCostAbility extends InputPayMana { this.showMessage(); } } - + private void done() { if (this.phyLifeToLose > 0) { Singletons.getControl().getPlayer().payLife(this.phyLifeToLose, null); @@ -247,7 +247,8 @@ public class InputPayManaCostAbility extends InputPayMana { this.showMessage(); } } - - @Override public void isClassUpdated() {} + + @Override public void isClassUpdated() { + } } diff --git a/src/main/java/forge/control/input/InputPayManaCostUtil.java b/src/main/java/forge/control/input/InputPayManaCostUtil.java index a904c8f5289..c6bdb6c9cad 100644 --- a/src/main/java/forge/control/input/InputPayManaCostUtil.java +++ b/src/main/java/forge/control/input/InputPayManaCostUtil.java @@ -62,7 +62,6 @@ public class InputPayManaCostUtil { return manaCost; } - final StringBuilder cneeded = new StringBuilder(); final StringBuilder colorRequired = new StringBuilder(); boolean choice = true; @@ -80,8 +79,8 @@ public class InputPayManaCostUtil { List abilities = new ArrayList(); // you can't remove unneeded abilities inside a for(am:abilities) loop :( - - for(SpellAbility ma : card.getManaAbility()) { + + for (SpellAbility ma : card.getManaAbility()) { ma.setActivatingPlayer(Singletons.getControl().getPlayer()); AbilityManaPart m = ma.getManaPart(); if (!ma.canPlay()) { @@ -95,7 +94,7 @@ public class InputPayManaCostUtil { } abilities.add(ma); - + if (!skipExpress) { // skip express mana if the ability is not undoable if (!ma.isUndoable()) { diff --git a/src/main/java/forge/control/input/InputPayManaX.java b/src/main/java/forge/control/input/InputPayManaX.java index dd17b1ed433..f24d22262c0 100644 --- a/src/main/java/forge/control/input/InputPayManaX.java +++ b/src/main/java/forge/control/input/InputPayManaX.java @@ -22,7 +22,7 @@ public class InputPayManaX extends InputPayMana { private final SpellAbility sa; - public InputPayManaX(final SpellAbility sa0, final CostPayment payment0, final CostMana costMana0) + public InputPayManaX(final SpellAbility sa0, final CostPayment payment0, final CostMana costMana0) { sa = sa0; payment = payment0; @@ -110,5 +110,6 @@ public class InputPayManaX extends InputPayMana { * @see forge.control.input.Input#isClassUpdated() */ @Override - public void isClassUpdated() {} -} \ No newline at end of file + public void isClassUpdated() { + } +} diff --git a/src/main/java/forge/control/input/InputPayReturnCost.java b/src/main/java/forge/control/input/InputPayReturnCost.java index 632c8a2d264..d6ff9cbd4c8 100644 --- a/src/main/java/forge/control/input/InputPayReturnCost.java +++ b/src/main/java/forge/control/input/InputPayReturnCost.java @@ -185,9 +185,8 @@ public class InputPayReturnCost extends Input { } this.unpaid.execute(); } - - - @Override public void isClassUpdated() {} + @Override public void isClassUpdated() { + } } diff --git a/src/main/java/forge/control/input/InputPaySacCost.java b/src/main/java/forge/control/input/InputPaySacCost.java index 4747efab0ef..7651e35864b 100644 --- a/src/main/java/forge/control/input/InputPaySacCost.java +++ b/src/main/java/forge/control/input/InputPaySacCost.java @@ -187,5 +187,6 @@ public class InputPaySacCost extends Input { this.unpaid.execute(); } - @Override public void isClassUpdated() {} + @Override public void isClassUpdated() { + } } diff --git a/src/main/java/forge/control/input/InputSelectMany.java b/src/main/java/forge/control/input/InputSelectMany.java index 0b4c37eb0cd..3377426d5a0 100644 --- a/src/main/java/forge/control/input/InputSelectMany.java +++ b/src/main/java/forge/control/input/InputSelectMany.java @@ -14,42 +14,52 @@ import forge.view.ButtonUtil; public abstract class InputSelectMany extends Input { private static final long serialVersionUID = -2305549394512889450L; - + protected final List selected = new ArrayList(); protected final int min; protected final int max; - + private String message = "Source-Card-Name - Select %d more card(s)"; - - protected InputSelectMany(int min, int max) - { - if( min > max ) throw new IllegalArgumentException("Min must not be greater than Max"); + + protected InputSelectMany(int min, int max) { + + if (min > max) { + throw new IllegalArgumentException("Min must not be greater than Max"); + } this.min = min; this.max = max; } - + @Override public final void showMessage() { - String msgToShow = getMessage(); + String msgToShow = getMessage(); CMatchUI.SINGLETON_INSTANCE.showMessage(msgToShow); boolean canCancel = (min == 0 && selected.isEmpty()) || canCancelWithSomethingSelected(); boolean canOk = hasEnoughTargets(); - - if (canOk && canCancel) ButtonUtil.enableAll(); - if (!canOk && canCancel) ButtonUtil.enableOnlyCancel(); - if (canOk && !canCancel) ButtonUtil.enableOnlyOK(); - if (!canOk && !canCancel) ButtonUtil.disableAll(); + + if (canOk && canCancel) { + ButtonUtil.enableAll(); + } + if (!canOk && canCancel) { + ButtonUtil.enableOnlyCancel(); + } + if (canOk && !canCancel) { + ButtonUtil.enableOnlyOK(); + } + if (!canOk && !canCancel) { + ButtonUtil.disableAll(); + } } - + /** * TODO: Write javadoc for this method. * @return */ protected String getMessage() { return max == Integer.MAX_VALUE - ? String.format(message, selected.size()) + ? String.format(message, selected.size()) : String.format(message, max - selected.size()); } @@ -60,68 +70,69 @@ public abstract class InputSelectMany extends Input { // if ( next != null ) { // Singletons.getModel().getMatch().getInput().setInput(next); // } - - if ( null == next ) + + if (null == next) { this.stop(); - else + } else { this.stopSetNext(next); - + } + // for a next use selected.clear(); } @Override public final void selectButtonOK() { - // should check here if it still gets into an infinite loop + // should check here if it still gets into an infinite loop // if an ability is put on stack before this input is stopped; // if it does, uncomment the 5 lines below, use them as method body - + // this.stop(); Input next = onDone(); // might add ability to stack from here // if ( next != null ) { // Singletons.getModel().getMatch().getInput().setInput(next); // } - - if ( null == next ) + + if (null == next) { this.stop(); - else + } else { this.stopSetNext(next); - + } + // for a next use selected.clear(); } @Override - public void isClassUpdated() {} + public void isClassUpdated() { + } public void setMessage(String message0) { this.message = message0; // TODO: Add 0 to parameter's name. } - - + // must define these protected abstract Input onDone(); protected abstract boolean isValidChoice(T choice); - + // might re-define later protected Input onCancel() { return null; } protected boolean canCancelWithSomethingSelected() { return false; } protected boolean hasEnoughTargets() { return selected.size() >= min; } protected boolean hasAllTargets() { return selected.size() >= max; } - - - protected void selectEntity(T c) - { - if ( selected.contains(c) || !isValidChoice(c) ) return; - + + protected void selectEntity(T c) { + + if (selected.contains(c) || !isValidChoice(c)) { + return; + } + this.selected.add(c); this.showMessage(); - - if ( hasAllTargets() ) + + if (hasAllTargets()) { selectButtonOK(); + } } - - - - + } diff --git a/src/main/java/forge/control/input/InputSelectManyCards.java b/src/main/java/forge/control/input/InputSelectManyCards.java index 5078ee71cce..792ed5555a7 100644 --- a/src/main/java/forge/control/input/InputSelectManyCards.java +++ b/src/main/java/forge/control/input/InputSelectManyCards.java @@ -4,14 +4,14 @@ import forge.Card; public abstract class InputSelectManyCards extends InputSelectMany { private static final long serialVersionUID = -6609493252672573139L; - - protected InputSelectManyCards(int min, int max) - { + + protected InputSelectManyCards(int min, int max) { + super(min, max); } - + @Override public final void selectCard(final Card c) { selectEntity(c); } -} \ No newline at end of file +} diff --git a/src/main/java/forge/control/input/InputSelectManyPlayers.java b/src/main/java/forge/control/input/InputSelectManyPlayers.java index b0a3c039ee9..e0a8634f07e 100644 --- a/src/main/java/forge/control/input/InputSelectManyPlayers.java +++ b/src/main/java/forge/control/input/InputSelectManyPlayers.java @@ -9,12 +9,12 @@ import forge.game.player.Player; public class InputSelectManyPlayers extends InputSelectMany { private static final long serialVersionUID = -8209690791522735L; - - protected final Function, Input> onComplete; + + protected final Function, Input> onComplete; private final Predicate allowedFilter; - public InputSelectManyPlayers(final Predicate allowedRule, int min, int max, final Function, Input> onDone) - { + public InputSelectManyPlayers(final Predicate allowedRule, int min, int max, final Function, Input> onDone) { + super(min, max); allowedFilter = allowedRule; onComplete = onDone; @@ -25,9 +25,11 @@ public class InputSelectManyPlayers extends InputSelectMany { public void selectPlayer(final Player p) { selectEntity(p); } - + protected boolean isValidChoice(Player choice) { - if ( allowedFilter != null && !allowedFilter.apply(choice)) return false; + if (allowedFilter != null && !allowedFilter.apply(choice)) { + return false; + } return true; } @@ -35,4 +37,4 @@ public class InputSelectManyPlayers extends InputSelectMany { protected Input onDone() { return onComplete.apply(selected); } -} \ No newline at end of file +}