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 Comparable { // takes care of individual card types - private ArrayList type = new ArrayList(); + private ArrayList type = new ArrayList(); private boolean removeSuperTypes; private boolean removeCardTypes; private boolean removeSubTypes; @@ -23,58 +23,85 @@ public class Card_Type implements Comparable { * * @return a long. */ - public long getTimestamp() { + public final long getTimestamp() { return timeStamp; } /** * - * @param types - * @param removeSuperType - * @param removeCardType - * @param removeSubType - * @param removeCreatureType - * @param stamp + * @param types an ArrayList + * @param removeSuperType a boolean + * @param removeCardType a boolean + * @param removeSubType a boolean + * @param removeCreatureType a boolean + * @param stamp a long */ - Card_Type(ArrayList types, boolean removeSuperType, boolean removeCardType, boolean removeSubType, - boolean removeCreatureType, long stamp) { - type = types; - removeSuperTypes = removeSuperType; + Card_Type(final ArrayList types, final boolean removeSuperType, final boolean removeCardType, + final boolean removeSubType, final boolean removeCreatureType, final long stamp) + { + type = types; + removeSuperTypes = removeSuperType; removeCardTypes = removeCardType; removeSubTypes = removeSubType; removeCreatureTypes = removeCreatureType; - timeStamp = stamp; + timeStamp = stamp; + } + + /** + * + * TODO Write javadoc for this method. + * @return type + */ + public final ArrayList getType() { + return type; } - public ArrayList getType() { - return type; + /** + * + * TODO Write javadoc for this method. + * @return removeSuperTypes + */ + public final boolean isRemoveSuperTypes() { + return removeSuperTypes; } - public boolean isRemoveSuperTypes() { - return removeSuperTypes; + /** + * + * TODO Write javadoc for this method. + * @return removeCardTypes + */ + public final boolean isRemoveCardTypes() { + return removeCardTypes; } - public boolean isRemoveCardTypes() { - return removeCardTypes; + /** + * + * TODO Write javadoc for this method. + * @return removeSubTypes + */ + public final boolean isRemoveSubTypes() { + return removeSubTypes; } - public boolean isRemoveSubTypes() { - return removeSubTypes; - } - - public boolean isRemoveCreatureTypes() { - return removeCreatureTypes; + /** + * + * TODO Write javadoc for this method. + * @return removeCreatureTypes + */ + public final boolean isRemoveCreatureTypes() { + return removeCreatureTypes; } @Override - public int compareTo(final Card_Type anotherCardType) { + public final int compareTo(final Card_Type anotherCardType) { int returnValue = 0; long anotherTimeStamp = anotherCardType.getTimestamp(); - if (this.timeStamp < anotherTimeStamp) + if (this.timeStamp < anotherTimeStamp) { returnValue = -1; - else if (this.timeStamp > anotherTimeStamp) + } else if (this.timeStamp > anotherTimeStamp) { returnValue = 1; - return returnValue; + } + return returnValue; } } diff --git a/src/main/java/forge/Color.java b/src/main/java/forge/Color.java index a70a3cebb69..6bc11058ecd 100644 --- a/src/main/java/forge/Color.java +++ b/src/main/java/forge/Color.java @@ -26,7 +26,7 @@ public enum Color { * * @param c a int. */ - Color(int c) { + Color(final int c) { flag = c; } @@ -53,8 +53,9 @@ public enum Color { colors.add(ConvertFromString(s[i])); } - if (colors.size() > 1) + if (colors.size() > 1) { colors.remove(Color.Colorless); + } return colors; } @@ -67,16 +68,17 @@ public enum Color { */ public static Color ConvertFromString(String s) { { - if (s.equals(Constant.Color.White)) + if (s.equals(Constant.Color.White)) { return Color.White; - else if (s.equals(Constant.Color.Green)) + } else if (s.equals(Constant.Color.Green)) { return Color.Green; - else if (s.equals(Constant.Color.Red)) + } else if (s.equals(Constant.Color.Red)) { return Color.Red; - else if (s.equals(Constant.Color.Black)) + } else if (s.equals(Constant.Color.Black)) { return Color.Black; - else if (s.equals(Constant.Color.Blue)) + } else if (s.equals(Constant.Color.Blue)) { return Color.Blue; + } return Color.Colorless; } @@ -88,22 +90,28 @@ public enum Color { * @param m a {@link forge.card.mana.ManaCost} object. * @return a {@link java.util.EnumSet} object. */ - public static EnumSet ConvertManaCostToColor(ManaCost m) { + public static EnumSet ConvertManaCostToColor(final ManaCost m) { EnumSet colors = EnumSet.of(Color.Colorless); - if (m.isColor("W")) + if (m.isColor("W")) { colors.add(Color.White); - if (m.isColor("G")) + } + if (m.isColor("G")) { colors.add(Color.Green); - if (m.isColor("R")) + } + if (m.isColor("R")) { colors.add(Color.Red); - if (m.isColor("B")) + } + if (m.isColor("B")) { colors.add(Color.Black); - if (m.isColor("U")) + } + if (m.isColor("U")) { colors.add(Color.Blue); + } - if (colors.size() > 1) + if (colors.size() > 1) { colors.remove(Color.Colorless); + } return colors; } @@ -114,17 +122,18 @@ public enum Color { * @return a {@link java.lang.String} object. */ public String toString() { - if (this.equals(Color.White)) + if (this.equals(Color.White)) { return Constant.Color.White; - else if (this.equals(Color.Green)) + } else if (this.equals(Color.Green)) { return Constant.Color.Green; - else if (this.equals(Color.Red)) + } else if (this.equals(Color.Red)) { return Constant.Color.Red; - else if (this.equals(Color.Black)) + } else if (this.equals(Color.Black)) { return Constant.Color.Black; - else if (this.equals(Color.Blue)) + } else if (this.equals(Color.Blue)) { return Constant.Color.Blue; - else + } else { return Constant.Color.Colorless; + } } } diff --git a/src/main/java/forge/ColorChanger.java b/src/main/java/forge/ColorChanger.java index d5addea90aa..bd0d61491d1 100644 --- a/src/main/java/forge/ColorChanger.java +++ b/src/main/java/forge/ColorChanger.java @@ -4,9 +4,14 @@ import java.util.ArrayList; import forge.card.mana.ManaCost; +/** + * class ColorChanger. + * TODO Write javadoc for this type. + * + */ public class ColorChanger { private ArrayList globalColorChanges = new ArrayList(); - + /** *

addColorChanges.

@@ -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, Iterable { - /** Constant serialVersionUID=-1532687201812613302L */ + /** Constant serialVersionUID=-1532687201812613302L. */ private static final long serialVersionUID = -1532687201812613302L; private ArrayList a = new ArrayList(); - + + /** + * default constructor + * TODO Write javadoc for Constructor. + */ public CommandList() { - ; + //nothing to do } - - public CommandList(Command c) { - a.add(c); + + /** + * constructor + * TODO Write javadoc for Constructor. + * @param c a Command + */ + public CommandList(final Command c) { + a.add(c); } /** @@ -28,7 +37,7 @@ public class CommandList implements java.io.Serializable, Command, Iterable iterator() { + public final Iterator iterator() { return a.iterator(); } @@ -40,7 +49,7 @@ public class CommandList implements java.io.Serializable, Command, Iterableclear.

*/ - public void clear() { + public final void clear() { a.clear(); } /** *

execute.

*/ - 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) { ArrayList spellAbility = new ArrayList(); - for (Card c : l) - for (SpellAbility sa : c.getSpellAbility()) + for (Card c : l) { + for (SpellAbility sa : c.getSpellAbility()) { // if SA is from AF_Counter don't add to getPlayable //This try/catch should fix the "computer is thinking" bug try { @@ -264,6 +287,8 @@ public class ComputerAI_General implements Computer { } catch (Exception ex) { showError(ex, "There is an error in the card code for %s:%n", c.getName(), ex.getMessage()); } + } + } return spellAbility.toArray(new SpellAbility[spellAbility.size()]); } @@ -273,13 +298,14 @@ public class ComputerAI_General implements Computer { * @param l a {@link forge.CardList} object. * @return a {@link java.util.ArrayList} object. */ - private ArrayList getPlayableCounters(CardList l) { + private ArrayList getPlayableCounters(final CardList l) { ArrayList spellAbility = new ArrayList(); for (Card c : l) { for (SpellAbility sa : c.getSpellAbility()) { // Check if this AF is a Counterpsell - if (sa.getAbilityFactory() != null && sa.getAbilityFactory().getAPI().equals("Counter")) + if (sa.getAbilityFactory() != null && sa.getAbilityFactory().getAPI().equals("Counter")) { spellAbility.add(sa); + } } } @@ -292,14 +318,15 @@ public class ComputerAI_General implements Computer { * @param l a {@link forge.CardList} object. * @return a {@link java.util.ArrayList} object. */ - private ArrayList getETBCounters(CardList l) { + private ArrayList getETBCounters(final CardList l) { ArrayList spellAbility = new ArrayList(); for (Card c : l) { for (SpellAbility sa : c.getSpellAbility()) { // Or if this Permanent has an ETB ability with Counter if (sa instanceof Spell_Permanent) { - if (Spell_Permanent.checkETBEffects(c, sa, "Counter")) + if (Spell_Permanent.checkETBEffects(c, sa, "Counter")) { spellAbility.add(sa); + } } } } @@ -310,21 +337,22 @@ public class ComputerAI_General implements Computer { /** *

begin_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 { - /** Constant serialVersionUID=-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.

* * @return a {@link forge.Computer} object. */ - public Computer getComputer() { + public final Computer getComputer() { return computer; } @@ -60,12 +61,12 @@ public class ComputerAI_Input extends Input { *

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 { ArrayList registeredTriggers = AllZone.getTriggerHandler().getRegisteredTriggers(); for (Trigger trigger : registeredTriggers) { HashMap trigParams = trigger.getMapParams(); - if (trigParams.get("Mode").equals("Attacks") && trigger.getHostCard().equals(attacker)) + if (trigParams.get("Mode").equals("Attacks") && trigger.getHostCard().equals(attacker)) { list.add(attacker); + } } } for (Card attacker : in) { - if (!list.contains(attacker)) list.add(attacker); + if (!list.contains(attacker)) { + list.add(attacker); + } } return list; - }//sortAttackers() + } //sortAttackers() //Is there any reward for attacking? (for 0/1 creatures there is not) /** @@ -96,19 +99,27 @@ public class ComputerUtil_Attack2 { * @param combat a {@link forge.Combat} object. * @return a boolean. */ - public boolean isEffectiveAttacker(Card attacker, Combat combat) { + public final boolean isEffectiveAttacker(final Card attacker, Combat combat) { //if the attacker will die when attacking don't attack - if (attacker.getNetDefense() + CombatUtil.predictToughnessBonusOfAttacker(attacker, null, combat) <= 0) + if (attacker.getNetDefense() + CombatUtil.predictToughnessBonusOfAttacker(attacker, null, combat) <= 0) { return false; - - if (CombatUtil.damageIfUnblocked(attacker, AllZone.getHumanPlayer(), combat) > 0) return true; - if (CombatUtil.poisonIfUnblocked(attacker, AllZone.getHumanPlayer(), combat) > 0) return true; - + } + + if (CombatUtil.damageIfUnblocked(attacker, AllZone.getHumanPlayer(), combat) > 0) { + return true; + } + if (CombatUtil.poisonIfUnblocked(attacker, AllZone.getHumanPlayer(), combat) > 0) { + return true; + } + ArrayList registeredTriggers = AllZone.getTriggerHandler().getRegisteredTriggers(); - for (Trigger trigger : registeredTriggers) + for (Trigger trigger : registeredTriggers) { if (CombatUtil.combatTriggerWillTrigger(attacker, null, trigger, combat) - && trigger.getHostCard().getController().isComputer()) return true; + && trigger.getHostCard().getController().isComputer()) { + return true; + } + } return false; } @@ -122,12 +133,12 @@ public class ComputerUtil_Attack2 { public CardList getPossibleAttackers(CardList in) { CardList list = new CardList(in.toArray()); list = list.filter(new CardListFilter() { - public boolean addCard(Card c) { + public boolean addCard(final Card c) { return CombatUtil.canAttack(c); } }); return list; - }//getPossibleAttackers() + } //getPossibleAttackers() /** *

getPossibleBlockers.

@@ -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()) {