diff --git a/src/main/java/forge/CCnt.java b/src/main/java/forge/CCnt.java index 39af97fd184..a343b61af9e 100644 --- a/src/main/java/forge/CCnt.java +++ b/src/main/java/forge/CCnt.java @@ -22,7 +22,7 @@ class CCnt { * @param clr a {@link java.lang.String} object. * @param cnt a int. */ - public CCnt(String clr, int cnt) { + public CCnt(final String clr, final int cnt) { Color = clr; Count = cnt; } diff --git a/src/main/java/forge/CardContainer.java b/src/main/java/forge/CardContainer.java index 5f013a03ade..118f7b9da65 100644 --- a/src/main/java/forge/CardContainer.java +++ b/src/main/java/forge/CardContainer.java @@ -19,12 +19,12 @@ public interface CardContainer { * * @param card a {@link forge.Card} object. */ - public void setCard(Card card); + void setCard(Card card); /** *
getCard.
* * @return a {@link forge.Card} object. */ - public Card getCard(); + Card getCard(); } diff --git a/src/main/java/forge/Card_Type.java b/src/main/java/forge/Card_Type.java index 97515d78bb0..fe586fc0e54 100644 --- a/src/main/java/forge/Card_Type.java +++ b/src/main/java/forge/Card_Type.java @@ -11,7 +11,7 @@ import java.util.ArrayList; */ public class Card_Type implements ComparableaddColorChanges.
@@ -17,7 +22,9 @@ public class ColorChanger { * @param bIncrease a boolean. * @return a long. */ - public long addColorChanges(String s, Card c, boolean addToColors, boolean bIncrease) { + public final long addColorChanges(final String s, final Card c, final boolean addToColors, + final boolean bIncrease) + { if (bIncrease) { Card_Color.increaseTimestamp(); } @@ -33,7 +40,7 @@ public class ColorChanger { * @param addTo a boolean. * @param timestamp a long. */ - public final void removeColorChanges(String s, Card c, boolean addTo, long timestamp) { + public final void removeColorChanges(final String s, final Card c, final boolean addTo, final long timestamp) { Card_Color removeCol = null; for (Card_Color cc : globalColorChanges) { if (cc.equals(s, c, addTo, timestamp)) { diff --git a/src/main/java/forge/CommandArgs.java b/src/main/java/forge/CommandArgs.java index 8f90771a884..92ef9df43eb 100644 --- a/src/main/java/forge/CommandArgs.java +++ b/src/main/java/forge/CommandArgs.java @@ -12,5 +12,5 @@ public interface CommandArgs extends java.io.Serializable { * * @param o a {@link java.lang.Object} object. */ - public void execute(Object o); + void execute(Object o); } diff --git a/src/main/java/forge/CommandList.java b/src/main/java/forge/CommandList.java index ee93566e63c..0b0f5011c2c 100644 --- a/src/main/java/forge/CommandList.java +++ b/src/main/java/forge/CommandList.java @@ -10,17 +10,26 @@ import java.util.Iterator; * @version $Id$ */ public class CommandList implements java.io.Serializable, Command, IterableserialVersionUID=-1532687201812613302L */
+ /** Constant serialVersionUID=-1532687201812613302L. */
private static final long serialVersionUID = -1532687201812613302L;
private ArrayListexecute.
*/ - public void execute() { - for (int i = 0; i < size(); i++) + public final void execute() { + for (int i = 0; i < size(); i++) { get(i).execute(); + } } } diff --git a/src/main/java/forge/CommandReturn.java b/src/main/java/forge/CommandReturn.java index ae535e7593a..5d200445ec7 100644 --- a/src/main/java/forge/CommandReturn.java +++ b/src/main/java/forge/CommandReturn.java @@ -12,5 +12,5 @@ public interface CommandReturn { * * @return a {@link java.lang.Object} object. */ - public Object execute(); + Object execute(); } diff --git a/src/main/java/forge/Computer.java b/src/main/java/forge/Computer.java index ba4490aedc3..97597ace871 100644 --- a/src/main/java/forge/Computer.java +++ b/src/main/java/forge/Computer.java @@ -10,51 +10,51 @@ public interface Computer { /** *main1.
*/ - public void main1(); + void main1(); /** *begin_combat.
*/ - public void begin_combat(); + void begin_combat(); /** *declare_attackers.
*/ - public void declare_attackers(); + void declare_attackers(); /** *declare_attackers_after.
*/ - public void declare_attackers_after(); //can play Instants and Abilities + void declare_attackers_after(); //can play Instants and Abilities /** *declare_blockers.
*/ - public void declare_blockers();//this is called after when the Human or Computer blocks + void declare_blockers(); //this is called after when the Human or Computer blocks /** *declare_blockers_after.
*/ - public void declare_blockers_after();//can play Instants and Abilities + void declare_blockers_after(); //can play Instants and Abilities /** *end_of_combat.
*/ - public void end_of_combat(); + void end_of_combat(); /** *main2.
*/ - public void main2(); + void main2(); /** *end_of_turn.
*/ - public void end_of_turn();//end of Human's turn + void end_of_turn();//end of Human's turn /** *stack_not_empty.
*/ - public void stack_not_empty(); + void stack_not_empty(); } diff --git a/src/main/java/forge/ComputerAI_General.java b/src/main/java/forge/ComputerAI_General.java index 13dce50bed3..b700b8b59c2 100644 --- a/src/main/java/forge/ComputerAI_General.java +++ b/src/main/java/forge/ComputerAI_General.java @@ -28,25 +28,27 @@ public class ComputerAI_General implements Computer { /** *main1.
*/ - public void main1() { - ComputerUtil.chooseLandsToPlay(); - - if (AllZone.getStack().size() == 0) - playCards(Constant.Phase.Main1); - else - stackResponse(); - }//main1() + public final void main1() { + ComputerUtil.chooseLandsToPlay(); + + if (AllZone.getStack().size() == 0) { + playCards(Constant.Phase.Main1); + } else { + stackResponse(); + } + } //main1() /** *main2.
*/ - public void main2() { - ComputerUtil.chooseLandsToPlay(); - - if (AllZone.getStack().size() == 0) - playCards(Constant.Phase.Main2); - else - stackResponse(); + public final void main2() { + ComputerUtil.chooseLandsToPlay(); + + if (AllZone.getStack().size() == 0) { + playCards(Constant.Phase.Main2); + } else { + stackResponse(); + } } /** @@ -62,7 +64,7 @@ public class ComputerAI_General implements Computer { if (nextPhase) { AllZone.getPhase().passPriority(); } - }//playCards() + } //playCards() /** *getMain1.
@@ -73,40 +75,52 @@ public class ComputerAI_General implements Computer { //Card list of all cards to consider CardList hand = AllZoneUtil.getPlayerHand(AllZone.getComputerPlayer()); - if (AllZone.getComputerManaPool().isEmpty()) + if (AllZone.getComputerManaPool().isEmpty()) { hand = hand.filter(new CardListFilter() { - public boolean addCard(Card c) { + public boolean addCard(final Card c) { - if (c.getSVar("PlayMain1").equals("TRUE")) + if (c.getSVar("PlayMain1").equals("TRUE")) { return true; + } - if (c.isSorcery() || c.isAura()) //timing should be handled by the AF's + //timing should be handled by the AF's + if (c.isSorcery() || c.isAura()) { return true; + } - if (c.isCreature() - && (c.hasKeyword("Haste")) || c.hasKeyword("Exalted")) return true; + if (c.isCreature() && (c.hasKeyword("Haste")) || c.hasKeyword("Exalted")) { + return true; + } - CardList buffed = AllZoneUtil.getPlayerCardsInPlay(AllZone.getComputerPlayer()); //get all cards the computer controls with BuffedBy + //get all cards the computer controls with BuffedBy + CardList buffed = AllZoneUtil.getPlayerCardsInPlay(AllZone.getComputerPlayer()); for (int j = 0; j < buffed.size(); j++) { Card buffedcard = buffed.get(j); if (buffedcard.getSVar("BuffedBy").length() > 0) { String buffedby = buffedcard.getSVar("BuffedBy"); - String bffdby[] = buffedby.split(","); - if (c.isValidCard(bffdby, c.getController(), c)) return true; + String[] bffdby = buffedby.split(","); + if (c.isValidCard(bffdby, c.getController(), c)) { + return true; + } } - }//BuffedBy + } //BuffedBy - CardList antibuffed = AllZoneUtil.getPlayerCardsInPlay(AllZone.getHumanPlayer()); //get all cards the human controls with AntiBuffedBy + //get all cards the human controls with AntiBuffedBy + CardList antibuffed = AllZoneUtil.getPlayerCardsInPlay(AllZone.getHumanPlayer()); for (int k = 0; k < antibuffed.size(); k++) { Card buffedcard = antibuffed.get(k); if (buffedcard.getSVar("AntiBuffedBy").length() > 0) { String buffedby = buffedcard.getSVar("AntiBuffedBy"); - String bffdby[] = buffedby.split(","); - if (c.isValidCard(bffdby, c.getController(), c)) return true; + String[] bffdby = buffedby.split(","); + if (c.isValidCard(bffdby, c.getController(), c)) { + return true; + } } - }//AntiBuffedBy + } //AntiBuffedBy - if (c.isLand()) return false; + if (c.isLand()) { + return false; + } CardList vengevines = AllZoneUtil.getPlayerGraveyard(AllZone.getComputerPlayer(), "Vengevine"); if (vengevines.size() > 0) { @@ -120,18 +134,21 @@ public class ComputerAI_General implements Computer { } if (creatures2.size() + Phase.getComputerCreatureSpellCount() > 1 && c.isCreature() - && CardUtil.getConvertedManaCost(c.getManaCost()) <= 3) return true; + && CardUtil.getConvertedManaCost(c.getManaCost()) <= 3) { + return true; + } } // AI Improvement for Vengevine // Beached As End return false; } }); + } CardList all = AllZoneUtil.getPlayerCardsInPlay(AllZone.getComputerPlayer()); all.addAll(hand); CardList humanPlayable = AllZoneUtil.getPlayerCardsInPlay(AllZone.getHumanPlayer()); humanPlayable = humanPlayable.filter(new CardListFilter() { - public boolean addCard(Card c) { + public boolean addCard(final Card c) { return (c.canAnyPlayerActivate()); } }); @@ -139,7 +156,7 @@ public class ComputerAI_General implements Computer { all.addAll(humanPlayable); return getPlayable(all); - }//getMain1() + } //getMain1() /** @@ -152,12 +169,14 @@ public class ComputerAI_General implements Computer { CardList all = AllZoneUtil.getPlayerHand(AllZone.getComputerPlayer()); //Don't play permanents with Flash before humans declare attackers step all = all.filter(new CardListFilter() { - public boolean addCard(Card c) { + public boolean addCard(final Card c) { if (c.isPermanent() && c.hasKeyword("Flash") && (AllZone.getPhase().isPlayerTurn(AllZone.getComputerPlayer()) || AllZone.getPhase().isBefore(Constant.Phase.Combat_Declare_Attackers_InstantAbility))) + { return false; + } return true; } }); @@ -168,22 +187,24 @@ public class ComputerAI_General implements Computer { all = all.getNotKeyword("At the beginning of the end step, sacrifice CARDNAME."); all = all.filter(new CardListFilter() { - public boolean addCard(Card c) { - if (c.isLand()) return false; + public boolean addCard(final Card c) { + if (c.isLand()) { + return false; + } return true; } }); CardList humanPlayable = AllZoneUtil.getPlayerCardsInPlay(AllZone.getHumanPlayer()); humanPlayable = humanPlayable.filter(new CardListFilter() { - public boolean addCard(Card c) { + public boolean addCard(final Card c) { return (c.canAnyPlayerActivate()); } }); all.addAll(humanPlayable); return getPlayable(all); - }//getMain2() + } //getMain2() /** *getAvailableSpellAbilities.
@@ -194,12 +215,14 @@ public class ComputerAI_General implements Computer { CardList all = AllZoneUtil.getPlayerHand(AllZone.getComputerPlayer()); //Don't play permanents with Flash before humans declare attackers step all = all.filter(new CardListFilter() { - public boolean addCard(Card c) { + public boolean addCard(final Card c) { if (c.isPermanent() && c.hasKeyword("Flash") && (AllZone.getPhase().isPlayerTurn(AllZone.getComputerPlayer()) || AllZone.getPhase().isBefore(Constant.Phase.Combat_Declare_Attackers_InstantAbility))) + { return false; + } return true; } }); @@ -209,7 +232,7 @@ public class ComputerAI_General implements Computer { CardList humanPlayable = AllZoneUtil.getPlayerCardsInPlay(AllZone.getHumanPlayer()); humanPlayable = humanPlayable.filter(new CardListFilter() { - public boolean addCard(Card c) { + public boolean addCard(final Card c) { return (c.canAnyPlayerActivate()); } }); @@ -245,15 +268,15 @@ public class ComputerAI_General implements Computer { } /** - * Returns the spellAbilities from the card list that the computer is able to play + * Returns the spellAbilities from the card list that the computer is able to play. * * @param l a {@link forge.CardList} object. * @return an array of {@link forge.card.spellability.SpellAbility} objects. */ - private SpellAbility[] getPlayable(CardList l) { + private SpellAbility[] getPlayable(final CardList l) { ArrayListbegin_combat.
*/ - public void begin_combat() { + public final void begin_combat() { stackResponse(); } /** *declare_attackers.
*/ - public void declare_attackers() { + public final void declare_attackers() { // 12/2/10(sol) the decision making here has moved to getAttackers() AllZone.setCombat(ComputerUtil.getAttackers()); Card[] att = AllZone.getCombat().getAttackers(); - if (att.length > 0) + if (att.length > 0) { AllZone.getPhase().setCombat(true); + } for (int i = 0; i < att.length; i++) { // tapping of attackers happens after Propaganda is paid for @@ -341,14 +369,14 @@ public class ComputerAI_General implements Computer { /** *declare_attackers_after.
*/ - public void declare_attackers_after() { + public final void declare_attackers_after() { stackResponse(); } /** *declare_blockers.
*/ - public void declare_blockers() { + public final void declare_blockers() { CardList blockers = AllZoneUtil.getCreaturesInPlay(AllZone.getComputerPlayer()); AllZone.setCombat(ComputerUtil_Block2.getBlockers(AllZone.getCombat(), blockers)); @@ -361,14 +389,14 @@ public class ComputerAI_General implements Computer { /** *declare_blockers_after.
*/ - public void declare_blockers_after() { + public final void declare_blockers_after() { stackResponse(); } /** *end_of_combat.
*/ - public void end_of_combat() { + public final void end_of_combat() { stackResponse(); } @@ -376,35 +404,37 @@ public class ComputerAI_General implements Computer { /** *end_of_turn.
*/ - public void end_of_turn() { + public final void end_of_turn() { stackResponse(); } /** *stack_not_empty.
*/ - public void stack_not_empty() { + public final void stack_not_empty() { stackResponse(); } /** *stackResponse.
*/ - public void stackResponse() { + public final void stackResponse() { // if top of stack is empty SpellAbility[] sas = null; if (AllZone.getStack().size() == 0) { sas = getOtherPhases(); - boolean pass = (sas.length == 0) || AllZone.getPhase().is(Constant.Phase.Upkeep, AllZone.getComputerPlayer()) || - AllZone.getPhase().is(Constant.Phase.Draw, AllZone.getComputerPlayer()) || - AllZone.getPhase().is(Constant.Phase.End_Of_Turn, AllZone.getComputerPlayer()); + boolean pass = (sas.length == 0) + || AllZone.getPhase().is(Constant.Phase.Upkeep, AllZone.getComputerPlayer()) + || AllZone.getPhase().is(Constant.Phase.Draw, AllZone.getComputerPlayer()) + || AllZone.getPhase().is(Constant.Phase.End_Of_Turn, AllZone.getComputerPlayer()); if (!pass) { // Each AF should check the phase individually pass = ComputerUtil.playCards(sas); } - if (pass) + if (pass) { AllZone.getPhase().passPriority(); + } return; } @@ -435,8 +465,9 @@ public class ComputerAI_General implements Computer { sas = getOtherPhases(); if (sas.length > 0) { // Spell not Countered - if (!ComputerUtil.playCards(sas)) + if (!ComputerUtil.playCards(sas)) { return; + } } // if this hasn't been covered above, just PassPriority() AllZone.getPhase().passPriority(); diff --git a/src/main/java/forge/ComputerAI_Input.java b/src/main/java/forge/ComputerAI_Input.java index 3bfd6153b4e..64e66cba85b 100644 --- a/src/main/java/forge/ComputerAI_Input.java +++ b/src/main/java/forge/ComputerAI_Input.java @@ -11,7 +11,7 @@ import forge.gui.input.Input; * @version $Id$ */ public class ComputerAI_Input extends Input { - /** ConstantserialVersionUID=-3091338639571662216L */
+ /** Constant serialVersionUID=-3091338639571662216L. */
private static final long serialVersionUID = -3091338639571662216L;
private final Computer computer;
@@ -19,10 +19,10 @@ public class ComputerAI_Input extends Input {
/**
* Constructor for ComputerAI_Input.
* - * @param i_computer a {@link forge.Computer} object. + * @param iComputer a {@link forge.Computer} object. */ - public ComputerAI_Input(Computer i_computer) { - computer = i_computer; + public ComputerAI_Input(final Computer iComputer) { + computer = iComputer; } //wrapper method that ComputerAI_StackNotEmpty class calls @@ -30,29 +30,30 @@ public class ComputerAI_Input extends Input { /** *stackNotEmpty.
*/ - public void stackNotEmpty() { + public final void stackNotEmpty() { computer.stack_not_empty(); } /** {@inheritDoc} */ @Override - public void showMessage() { + public final void showMessage() { /* * //put this back in ButtonUtil.disableAll(); AllZone.getDisplay().showMessage("Phase: " + AllZone.getPhase().getPhase() - + "\nAn error may have occurred. Please send the \"Stack Report\" and the \"Detailed Error Trace\" to the Forge forum."); + + "\nAn error may have occurred. Please send the \"Stack Report\" and the + \"Detailed Error Trace\" to the Forge forum."); */ think(); - }//getMessage(); + } //getMessage(); /** *Getter for the field computer.
think.
*/ private void think() { - //TODO: instead of setNextPhase, pass priority + //TODO instead of setNextPhase, pass priority final String phase = AllZone.getPhase().getPhase(); - if (AllZone.getStack().size() > 0) + if (AllZone.getStack().size() > 0) { computer.stack_not_empty(); - else if (phase.equals(Constant.Phase.Main1)) { + } else if (phase.equals(Constant.Phase.Main1)) { Log.debug("Computer main1"); computer.main1(); } else if (phase.equals(Constant.Phase.Combat_Begin)) { @@ -81,8 +82,9 @@ public class ComputerAI_Input extends Input { } else if (phase.equals(Constant.Phase.Main2)) { Log.debug("Computer main2"); computer.main2(); - } else + } else { computer.stack_not_empty(); + } - }//think + } //think } diff --git a/src/main/java/forge/ComputerUtil_Attack2.java b/src/main/java/forge/ComputerUtil_Attack2.java index 03efe0531b6..8ce2b60b1f4 100644 --- a/src/main/java/forge/ComputerUtil_Attack2.java +++ b/src/main/java/forge/ComputerUtil_Attack2.java @@ -26,7 +26,7 @@ public class ComputerUtil_Attack2 { private final int randomInt = random.nextInt(); private CardList humanList; //holds human player creatures - private CardList computerList;//holds computer creatures + private CardList computerList; //holds computer creatures private int aiAggression = 0; // added by Masher, how aggressive the ai attack will be depending on circumstances @@ -48,7 +48,7 @@ public class ComputerUtil_Attack2 { * @param possibleBlockers a {@link forge.CardList} object. * @param blockerLife a int. */ - public ComputerUtil_Attack2(CardList possibleAttackers, CardList possibleBlockers, int blockerLife) { + public ComputerUtil_Attack2(final CardList possibleAttackers, CardList possibleBlockers, int blockerLife) { humanList = new CardList(possibleBlockers.toArray()); humanList = humanList.getType("Creature"); @@ -60,7 +60,7 @@ public class ComputerUtil_Attack2 { attackers = getPossibleAttackers(possibleAttackers); blockers = getPossibleBlockers(possibleBlockers, attackers); this.blockerLife = blockerLife; - }//constructor + } //constructor /** *sortAttackers.
@@ -68,7 +68,7 @@ public class ComputerUtil_Attack2 { * @param in a {@link forge.CardList} object. * @return a {@link forge.CardList} object. */ - public CardList sortAttackers(CardList in) { + public final CardList sortAttackers(final CardList in) { CardList list = new CardList(); //Cards with triggers should come first (for Battle Cry) @@ -76,17 +76,20 @@ public class ComputerUtil_Attack2 { ArrayListgetPossibleBlockers.
@@ -136,14 +147,18 @@ public class ComputerUtil_Attack2 { * @param attackers a {@link forge.CardList} object. * @return a {@link forge.CardList} object. */ - public CardList getPossibleBlockers(CardList blockers, CardList attackers) { + public final CardList getPossibleBlockers(CardList blockers, CardList attackers) { CardList possibleBlockers = new CardList(blockers.toArray()); final CardList attackerList = new CardList(attackers.toArray()); possibleBlockers = possibleBlockers.filter(new CardListFilter() { - public boolean addCard(Card c) { - if (!c.isCreature()) return false; + public boolean addCard(final Card c) { + if (!c.isCreature()) { + return false; + } for (Card attacker : attackerList) { - if (CombatUtil.canBlock(attacker, c)) return true; + if (CombatUtil.canBlock(attacker, c)) { + return true; + } } return false; } @@ -161,7 +176,7 @@ public class ComputerUtil_Attack2 { * @param combat a {@link forge.Combat} object. * @return a {@link forge.CardList} object. */ - public CardList notNeededAsBlockers(CardList attackers, Combat combat) { + public final CardList notNeededAsBlockers(CardList attackers, Combat combat) { CardList notNeededAsBlockers = new CardList(attackers.toArray()); CardListUtil.sortAttackLowFirst(attackers); int blockersNeeded = attackers.size(); @@ -173,7 +188,9 @@ public class ComputerUtil_Attack2 { if (!doesHumanAttackAndWin(i)) { blockersNeeded = i; break; - } else notNeededAsBlockers.remove(list.get(i)); + } else { + notNeededAsBlockers.remove(list.get(i)); + } } if (blockersNeeded == list.size()) {