diff --git a/pom.xml b/pom.xml index 8e113672479..8ea94976d96 100644 --- a/pom.xml +++ b/pom.xml @@ -469,7 +469,7 @@ org.apache.maven.plugins maven-pmd-plugin - 2.5 + 2.6 true utf-8 diff --git a/src/main/config/forge_checks.xml b/src/main/config/forge_checks.xml index 067a4f586fb..f299dac2d1e 100644 --- a/src/main/config/forge_checks.xml +++ b/src/main/config/forge_checks.xml @@ -53,7 +53,7 @@ - + @@ -131,11 +131,11 @@ - + diff --git a/src/main/java/forge/Card.java b/src/main/java/forge/Card.java index 7fe53d882d8..8d1e3dfdbce 100644 --- a/src/main/java/forge/Card.java +++ b/src/main/java/forge/Card.java @@ -40,100 +40,147 @@ import forge.item.CardDb; */ public class Card extends GameEntity implements Comparable { private static int nextUniqueNumber = 1; - private int uniqueNumber = nextUniqueNumber++; + private int uniqueNumber = Card.nextUniqueNumber++; private long value; - - private Map characteristicsMap = new HashMap(); + + private final Map characteristicsMap = new HashMap(); private String curCharacteristics = "Original"; private String preTFDCharacteristic = "Original"; private boolean isDoubleFaced = false; private boolean isFlip = false; - + + /** + * Instantiates a new card. + */ public Card() { - characteristicsMap.put("Original", new CardCharacteristics()); - characteristicsMap.put("FaceDown", CardUtil.getFaceDownCharacteristic()); + this.characteristicsMap.put("Original", new CardCharacteristics()); + this.characteristicsMap.put("FaceDown", CardUtil.getFaceDownCharacteristic()); } - - public boolean setState(String state) { - if(state.equals("FaceDown") && isDoubleFaced) { - return false; //Doublefaced cards can't be turned face-down. + + /** + * Sets the state. + * + * @param state the state + * @return true, if successful + */ + public boolean setState(final String state) { + if (state.equals("FaceDown") && this.isDoubleFaced) { + return false; // Doublefaced cards can't be turned face-down. } - - if(!characteristicsMap.containsKey(state)) { - System.out.println(getName() + " tried to switch to non-existant state \"" + state + "\"!"); - return false; //Nonexistant state. + + if (!this.characteristicsMap.containsKey(state)) { + System.out.println(this.getName() + " tried to switch to non-existant state \"" + state + "\"!"); + return false; // Nonexistant state. } - - if(state.equals(curCharacteristics)) { + + if (state.equals(this.curCharacteristics)) { return false; } - - curCharacteristics = state; + + this.curCharacteristics = state; return true; } - + + /** + * Gets the states. + * + * @return the states + */ public Set getStates() { - return characteristicsMap.keySet(); + return this.characteristicsMap.keySet(); } - + + /** + * Gets the cur state. + * + * @return the cur state + */ public String getCurState() { - return curCharacteristics; + return this.curCharacteristics; } - - public void switchStates(String from,String to) - { - CardCharacteristics tmp = characteristicsMap.get(from); - characteristicsMap.put(from, characteristicsMap.get(to)); - characteristicsMap.put(to, tmp); + + /** + * Switch states. + * + * @param from the from + * @param to the to + */ + public void switchStates(final String from, final String to) { + final CardCharacteristics tmp = this.characteristicsMap.get(from); + this.characteristicsMap.put(from, this.characteristicsMap.get(to)); + this.characteristicsMap.put(to, tmp); } - - public void clearStates(String state) { - characteristicsMap.remove(state); + + /** + * Clear states. + * + * @param state the state + */ + public void clearStates(final String state) { + this.characteristicsMap.remove(state); } - + + /** + * Turn face down. + */ public void turnFaceDown() { - if(!isDoubleFaced) { - preTFDCharacteristic = curCharacteristics; - curCharacteristics = "FaceDown"; + if (!this.isDoubleFaced) { + this.preTFDCharacteristic = this.curCharacteristics; + this.curCharacteristics = "FaceDown"; } } - + + /** + * Turn face up. + */ public void turnFaceUp() { - if(curCharacteristics.equals("FaceDown")) { - curCharacteristics = preTFDCharacteristic; + if (this.curCharacteristics.equals("FaceDown")) { + this.curCharacteristics = this.preTFDCharacteristic; } } - + + /** + * Checks if is cloned. + * + * @return true, if is cloned + */ public boolean isCloned() { - for(String state : characteristicsMap.keySet()) { - if(state.equals("Cloner")) { + for (final String state : this.characteristicsMap.keySet()) { + if (state.equals("Cloner")) { return true; } } return false; } - - public CardCharacteristics getState(String state) { - return characteristicsMap.get(state); + + /** + * Gets the state. + * + * @param state the state + * @return the state + */ + public CardCharacteristics getState(final String state) { + return this.characteristicsMap.get(state); } - + /** * Gets the characteristics. * * @return the characteristics */ public CardCharacteristics getCharacteristics() { - return characteristicsMap.get(curCharacteristics); + return this.characteristicsMap.get(this.curCharacteristics); } /** - * * addAlternateState. + * + * @param state the state */ - public final void addAlternateState(String state) { - characteristicsMap.put(state,new CardCharacteristics()); + public final void addAlternateState(final String state) { + this.characteristicsMap.put(state, new CardCharacteristics()); } /* @@ -143,7 +190,7 @@ public class Card extends GameEntity implements Comparable { */ @Override public final String getName() { - return getCharacteristics().getName(); + return this.getCharacteristics().getName(); } /* @@ -153,7 +200,7 @@ public class Card extends GameEntity implements Comparable { */ @Override public final void setName(final String name0) { - getCharacteristics().setName(name0); + this.getCharacteristics().setName(name0); } /** @@ -163,7 +210,7 @@ public class Card extends GameEntity implements Comparable { * @return boolean */ public final boolean isInAlternateState() { - return !(curCharacteristics.equals("Original") || curCharacteristics.equals("Cloned")); + return !(this.curCharacteristics.equals("Original") || this.curCharacteristics.equals("Cloned")); } /** @@ -173,7 +220,7 @@ public class Card extends GameEntity implements Comparable { * @return boolean */ public final boolean hasAlternateState() { - return characteristicsMap.keySet().size() > 2; + return this.characteristicsMap.keySet().size() > 2; } /** @@ -182,7 +229,7 @@ public class Card extends GameEntity implements Comparable { * @return the isDoubleFaced */ public final boolean isDoubleFaced() { - return isDoubleFaced; + return this.isDoubleFaced; } /** @@ -202,7 +249,7 @@ public class Card extends GameEntity implements Comparable { * @return the isFlip */ public final boolean isFlip() { - return isFlip; + return this.isFlip; } /** @@ -217,12 +264,12 @@ public class Card extends GameEntity implements Comparable { } private Map counters = new TreeMap(); - private Map triggeringObjects = new TreeMap(); + private final Map triggeringObjects = new TreeMap(); private ArrayList extrinsicKeyword = new ArrayList(); // Hidden keywords won't be displayed on the card - private ArrayList hiddenExtrinsicKeyword = new ArrayList(); + private final ArrayList hiddenExtrinsicKeyword = new ArrayList(); private ArrayList prevIntrinsicKeyword = new ArrayList(); - private ArrayList attachedByMindsDesire = new ArrayList(); + private final ArrayList attachedByMindsDesire = new ArrayList(); // which equipment cards are equipping this card? private ArrayList equippedBy = new ArrayList(); // equipping size will always be 0 or 1 @@ -234,21 +281,21 @@ public class Card extends GameEntity implements Comparable { // if this card is an Aura, what Entity is it enchanting? private GameEntity enchanting = null; private ArrayList prevType = new ArrayList(); - private ArrayList choicesMade = new ArrayList(); - private ArrayList targetsForChoices = new ArrayList(); + private final ArrayList choicesMade = new ArrayList(); + private final ArrayList targetsForChoices = new ArrayList(); // changes by AF animate and continuous static effects private ArrayList changedCardTypes = new ArrayList(); private ArrayList changedCardKeywords = new ArrayList(); - private ArrayList rememberedObjects = new ArrayList(); - private ArrayList imprintedCards = new ArrayList(); + private final ArrayList rememberedObjects = new ArrayList(); + private final ArrayList imprintedCards = new ArrayList(); private Card championedCard = null; - private CardList devouredCards = new CardList(); + private final CardList devouredCards = new CardList(); private Map receivedDamageFromThisTurn = new TreeMap(); private Map dealtDamageToThisTurn = new TreeMap(); - private Map assignedDamageMap = new TreeMap(); + private final Map assignedDamageMap = new TreeMap(); private boolean drawnThisTurn = false; private boolean tapped; @@ -265,7 +312,7 @@ public class Card extends GameEntity implements Comparable { private boolean dealtDmgToHumanThisTurn = false; private boolean dealtDmgToComputerThisTurn = false; private boolean sirenAttackOrDestroy = false; - private ArrayList mustBlockCards = new ArrayList(); + private final ArrayList mustBlockCards = new ArrayList(); private boolean canMorph = false; private boolean kicked = false; @@ -339,21 +386,21 @@ public class Card extends GameEntity implements Comparable { private Player chosenPlayer; private Card cloneOrigin = null; - private ArrayList clones = new ArrayList(); - private ArrayList gainControlTargets = new ArrayList(); - private ArrayList gainControlReleaseCommands = new ArrayList(); + private final ArrayList clones = new ArrayList(); + private final ArrayList gainControlTargets = new ArrayList(); + private final ArrayList gainControlReleaseCommands = new ArrayList(); - private ArrayList zcTriggers = new ArrayList(); - private ArrayList equipCommandList = new ArrayList(); - private ArrayList unEquipCommandList = new ArrayList(); - private ArrayList enchantCommandList = new ArrayList(); - private ArrayList unEnchantCommandList = new ArrayList(); - private ArrayList untapCommandList = new ArrayList(); - private ArrayList changeControllerCommandList = new ArrayList(); + private final ArrayList zcTriggers = new ArrayList(); + private final ArrayList equipCommandList = new ArrayList(); + private final ArrayList unEquipCommandList = new ArrayList(); + private final ArrayList enchantCommandList = new ArrayList(); + private final ArrayList unEnchantCommandList = new ArrayList(); + private final ArrayList untapCommandList = new ArrayList(); + private final ArrayList changeControllerCommandList = new ArrayList(); private static String[] storableSVars = { "ChosenX" }; - private ArrayList hauntedBy = new ArrayList(); + private final ArrayList hauntedBy = new ArrayList(); private Card haunting = null; /** @@ -363,7 +410,7 @@ public class Card extends GameEntity implements Comparable { * @return a String array */ public static String[] getStorableSVars() { - return storableSVars; + return Card.storableSVars; } // hacky code below, used to limit the number of times an ability @@ -382,7 +429,7 @@ public class Card extends GameEntity implements Comparable { * TODO Write javadoc for this method. */ public static void resetUniqueNumber() { - nextUniqueNumber = 1; + Card.nextUniqueNumber = 1; } /** @@ -393,7 +440,7 @@ public class Card extends GameEntity implements Comparable { * a Card object */ public final void addDevoured(final Card c) { - devouredCards.add(c); + this.devouredCards.add(c); } /** @@ -401,7 +448,7 @@ public class Card extends GameEntity implements Comparable { * TODO Write javadoc for this method. */ public final void clearDevoured() { - devouredCards.clear(); + this.devouredCards.clear(); } /** @@ -411,7 +458,7 @@ public class Card extends GameEntity implements Comparable { * @return a CardList object */ public final CardList getDevoured() { - return devouredCards; + return this.devouredCards; } /** @@ -423,7 +470,7 @@ public class Card extends GameEntity implements Comparable { * a {@link java.lang.Object} object. */ public final void addRemembered(final Object o) { - rememberedObjects.add(o); + this.rememberedObjects.add(o); } /** @@ -434,7 +481,7 @@ public class Card extends GameEntity implements Comparable { * @return a {@link java.util.ArrayList} object. */ public final ArrayList getRemembered() { - return rememberedObjects; + return this.rememberedObjects; } /** @@ -443,7 +490,7 @@ public class Card extends GameEntity implements Comparable { *

*/ public final void clearRemembered() { - rememberedObjects.clear(); + this.rememberedObjects.clear(); } /** @@ -455,7 +502,7 @@ public class Card extends GameEntity implements Comparable { * a {@link forge.Card} object. */ public final void addImprinted(final Card c) { - imprintedCards.add(c); + this.imprintedCards.add(c); } /** @@ -467,7 +514,7 @@ public class Card extends GameEntity implements Comparable { * a {@link java.util.ArrayList} object. */ public final void addImprinted(final ArrayList list) { - imprintedCards.addAll(list); + this.imprintedCards.addAll(list); } /** @@ -478,7 +525,7 @@ public class Card extends GameEntity implements Comparable { * @return a {@link java.util.ArrayList} object. */ public final ArrayList getImprinted() { - return imprintedCards; + return this.imprintedCards; } /** @@ -487,7 +534,7 @@ public class Card extends GameEntity implements Comparable { *

*/ public final void clearImprinted() { - imprintedCards.clear(); + this.imprintedCards.clear(); } /** @@ -500,7 +547,7 @@ public class Card extends GameEntity implements Comparable { * @since 1.0.15 */ public final void setChampionedCard(final Card c) { - championedCard = c; + this.championedCard = c; } /** @@ -512,7 +559,7 @@ public class Card extends GameEntity implements Comparable { * @since 1.0.15 */ public final Card getChampionedCard() { - return championedCard; + return this.championedCard; } /** @@ -525,9 +572,9 @@ public class Card extends GameEntity implements Comparable { * @return a {@link forge.card.trigger.Trigger} object. */ public final Trigger addTrigger(final Trigger t) { - Trigger newtrig = t.getCopy(); + final Trigger newtrig = t.getCopy(); newtrig.setHostCard(this); - getCharacteristics().getTriggers().add(newtrig); + this.getCharacteristics().getTriggers().add(newtrig); return newtrig; } @@ -540,8 +587,8 @@ public class Card extends GameEntity implements Comparable { */ public final void moveTrigger(final Trigger t) { t.setHostCard(this); - if (!getCharacteristics().getTriggers().contains(t)) { - getCharacteristics().getTriggers().add(t); + if (!this.getCharacteristics().getTriggers().contains(t)) { + this.getCharacteristics().getTriggers().add(t); } } @@ -554,7 +601,7 @@ public class Card extends GameEntity implements Comparable { * a {@link forge.card.trigger.Trigger} object. */ public final void removeTrigger(final Trigger t) { - getCharacteristics().getTriggers().remove(t); + this.getCharacteristics().getTriggers().remove(t); } /** @@ -565,7 +612,7 @@ public class Card extends GameEntity implements Comparable { * @return a {@link java.util.ArrayList} object. */ public final ArrayList getTriggers() { - return getCharacteristics().getTriggers(); + return this.getCharacteristics().getTriggers(); } /** @@ -578,8 +625,8 @@ public class Card extends GameEntity implements Comparable { * @return a {@link forge.card.trigger.Trigger} object. */ public final Trigger getNamedTrigger(final String name) { - for (Trigger t : getCharacteristics().getTriggers()) { - if (t.getName() != null && t.getName().equals(name)) { + for (final Trigger t : this.getCharacteristics().getTriggers()) { + if ((t.getName() != null) && t.getName().equals(name)) { return t; } } @@ -596,16 +643,16 @@ public class Card extends GameEntity implements Comparable { * a {@link java.util.ArrayList} object. */ public final void setTriggers(final ArrayList trigs) { - ArrayList copyList = new ArrayList(); - for (Trigger t : trigs) { + final ArrayList copyList = new ArrayList(); + for (final Trigger t : trigs) { if (t.getIsIntrinsic()) { - Trigger newtrig = t.getCopy(); + final Trigger newtrig = t.getCopy(); newtrig.setHostCard(this); copyList.add(newtrig); } } - getCharacteristics().setTriggers(copyList); + this.getCharacteristics().setTriggers(copyList); } /** @@ -614,7 +661,7 @@ public class Card extends GameEntity implements Comparable { *

*/ public final void clearTriggersNew() { - getCharacteristics().getTriggers().clear(); + this.getCharacteristics().getTriggers().clear(); } /** @@ -627,7 +674,7 @@ public class Card extends GameEntity implements Comparable { * @return a {@link java.lang.Object} object. */ public final Object getTriggeringObject(final String typeIn) { - return triggeringObjects.get(typeIn); + return this.triggeringObjects.get(typeIn); } /** @@ -637,7 +684,7 @@ public class Card extends GameEntity implements Comparable { * a int. */ public final void setAbilityUsed(final int i) { - abilityUsed = i; + this.abilityUsed = i; } /** @@ -648,7 +695,7 @@ public class Card extends GameEntity implements Comparable { * @return a int. */ public final int getAbilityUsed() { - return abilityUsed; + return this.abilityUsed; } /** @@ -659,7 +706,7 @@ public class Card extends GameEntity implements Comparable { * @return a int. */ public final int getSunburstValue() { - return sunburstValue; + return this.sunburstValue; } /** @@ -671,7 +718,7 @@ public class Card extends GameEntity implements Comparable { * a String */ public final void setColorsPaid(final String s) { - colorsPaid = s; + this.colorsPaid = s; } /** @@ -682,7 +729,7 @@ public class Card extends GameEntity implements Comparable { * @return a String. */ public final String getColorsPaid() { - return colorsPaid; + return this.colorsPaid; } /** @@ -694,7 +741,7 @@ public class Card extends GameEntity implements Comparable { * a int. */ public final void setSunburstValue(final int valueIn) { - sunburstValue = valueIn; + this.sunburstValue = valueIn; } /** @@ -706,7 +753,7 @@ public class Card extends GameEntity implements Comparable { * a int. */ public final void addXManaCostPaid(final int n) { - xManaCostPaid += n; + this.xManaCostPaid += n; } /** @@ -718,7 +765,7 @@ public class Card extends GameEntity implements Comparable { * a int. */ public final void setXManaCostPaid(final int n) { - xManaCostPaid = n; + this.xManaCostPaid = n; } /** @@ -729,7 +776,7 @@ public class Card extends GameEntity implements Comparable { * @return a int. */ public final int getXManaCostPaid() { - return xManaCostPaid; + return this.xManaCostPaid; } /** @@ -741,7 +788,7 @@ public class Card extends GameEntity implements Comparable { * a int. */ public final void setXLifePaid(final int n) { - xLifePaid = n; + this.xLifePaid = n; } /** @@ -752,7 +799,7 @@ public class Card extends GameEntity implements Comparable { * @return a int. */ public final int getXLifePaid() { - return xLifePaid; + return this.xLifePaid; } // used to see if an attacking creature with a triggering attack ability @@ -766,9 +813,9 @@ public class Card extends GameEntity implements Comparable { * a boolean. */ public final void setCreatureAttackedThisCombat(final boolean b) { - creatureAttackedThisCombat = b; + this.creatureAttackedThisCombat = b; if (b) { - setCreatureAttackedThisTurn(true); + this.setCreatureAttackedThisTurn(true); } } @@ -780,7 +827,7 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean getCreatureAttackedThisCombat() { - return creatureAttackedThisCombat; + return this.creatureAttackedThisCombat; } /** @@ -792,7 +839,7 @@ public class Card extends GameEntity implements Comparable { * a boolean. */ public final void setCreatureAttackedThisTurn(final boolean b) { - creatureAttackedThisTurn = b; + this.creatureAttackedThisTurn = b; } /** @@ -803,7 +850,7 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean getCreatureAttackedThisTurn() { - return creatureAttackedThisTurn; + return this.creatureAttackedThisTurn; } /** @@ -815,7 +862,7 @@ public class Card extends GameEntity implements Comparable { * a boolean. */ public final void setCreatureBlockedThisCombat(final boolean b) { - creatureBlockedThisCombat = b; + this.creatureBlockedThisCombat = b; } /** @@ -826,7 +873,7 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean getCreatureBlockedThisCombat() { - return creatureBlockedThisCombat; + return this.creatureBlockedThisCombat; } /** @@ -838,7 +885,7 @@ public class Card extends GameEntity implements Comparable { * a boolean. */ public final void setCreatureGotBlockedThisCombat(final boolean b) { - creatureGotBlockedThisCombat = b; + this.creatureGotBlockedThisCombat = b; } /** @@ -849,7 +896,7 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean getCreatureGotBlockedThisCombat() { - return creatureGotBlockedThisCombat; + return this.creatureGotBlockedThisCombat; } /** @@ -860,7 +907,7 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean canAnyPlayerActivate() { - for (SpellAbility s : getCharacteristics().getSpellAbility()) { + for (final SpellAbility s : this.getCharacteristics().getSpellAbility()) { if (s.getRestrictions().isAnyPlayer()) { return true; } @@ -877,7 +924,7 @@ public class Card extends GameEntity implements Comparable { * a boolean. */ public final void setDealtDmgToHumanThisTurn(final boolean b) { - dealtDmgToHumanThisTurn = b; + this.dealtDmgToHumanThisTurn = b; } /** @@ -888,7 +935,7 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean getDealtDmgToHumanThisTurn() { - return dealtDmgToHumanThisTurn; + return this.dealtDmgToHumanThisTurn; } /** @@ -900,7 +947,7 @@ public class Card extends GameEntity implements Comparable { * a boolean. */ public final void setDealtDmgToComputerThisTurn(final boolean b) { - dealtDmgToComputerThisTurn = b; + this.dealtDmgToComputerThisTurn = b; } /** @@ -911,7 +958,7 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean getDealtDmgToComputerThisTurn() { - return dealtDmgToComputerThisTurn; + return this.dealtDmgToComputerThisTurn; } /** @@ -923,7 +970,7 @@ public class Card extends GameEntity implements Comparable { * a boolean. */ public final void setSirenAttackOrDestroy(final boolean b) { - sirenAttackOrDestroy = b; + this.sirenAttackOrDestroy = b; } /** @@ -934,7 +981,7 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean getSirenAttackOrDestroy() { - return sirenAttackOrDestroy; + return this.sirenAttackOrDestroy; } /** @@ -947,7 +994,7 @@ public class Card extends GameEntity implements Comparable { * @since 1.1.6 */ public final void addMustBlockCard(final Card c) { - mustBlockCards.add(c); + this.mustBlockCards.add(c); } /** @@ -958,7 +1005,7 @@ public class Card extends GameEntity implements Comparable { * @since 1.1.6 */ public final ArrayList getMustBlockCards() { - return mustBlockCards; + return this.mustBlockCards; } /** @@ -967,7 +1014,7 @@ public class Card extends GameEntity implements Comparable { * @since 1.1.6 */ public final void clearMustBlockCards() { - mustBlockCards.clear(); + this.mustBlockCards.clear(); } /** @@ -978,7 +1025,7 @@ public class Card extends GameEntity implements Comparable { * @return a {@link java.util.ArrayList} object. */ public final ArrayList getClones() { - return clones; + return this.clones; } /** @@ -990,8 +1037,8 @@ public class Card extends GameEntity implements Comparable { * a {@link java.util.ArrayList} object. */ public final void setClones(final ArrayList c) { - clones.clear(); - clones.addAll(c); + this.clones.clear(); + this.clones.addAll(c); } /** @@ -1003,7 +1050,7 @@ public class Card extends GameEntity implements Comparable { * a {@link forge.Card} object. */ public final void addClone(final Card c) { - clones.add(c); + this.clones.add(c); } /** @@ -1015,7 +1062,7 @@ public class Card extends GameEntity implements Comparable { * a {@link java.util.ArrayList} object. */ public final void addClones(final ArrayList c) { - clones.addAll(c); + this.clones.addAll(c); } /** @@ -1024,7 +1071,7 @@ public class Card extends GameEntity implements Comparable { *

*/ public final void clearClones() { - clones.clear(); + this.clones.clear(); } /** @@ -1035,7 +1082,7 @@ public class Card extends GameEntity implements Comparable { * @return a {@link forge.Card} object. */ public final Card getCloneOrigin() { - return cloneOrigin; + return this.cloneOrigin; } /** @@ -1047,7 +1094,7 @@ public class Card extends GameEntity implements Comparable { * a {@link forge.Card} object. */ public final void setCloneOrigin(final Card name) { - cloneOrigin = name; + this.cloneOrigin = name; } /** @@ -1058,7 +1105,7 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean getSacrificeAtEOT() { - return hasKeyword("At the beginning of the end step, sacrifice CARDNAME."); + return this.hasKeyword("At the beginning of the end step, sacrifice CARDNAME."); } /** @@ -1069,7 +1116,7 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean getBounceAtUntap() { - return bounceAtUntap; + return this.bounceAtUntap; } /** @@ -1092,7 +1139,7 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean getFinishedEnteringBF() { - return finishedEnteringBF; + return this.finishedEnteringBF; } /** @@ -1115,7 +1162,7 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean hasFirstStrike() { - return hasKeyword("First Strike"); + return this.hasKeyword("First Strike"); } /** @@ -1126,7 +1173,7 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean hasDoubleStrike() { - return hasKeyword("Double Strike"); + return this.hasKeyword("Double Strike"); } /** @@ -1137,7 +1184,7 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean hasSecondStrike() { - return hasDoubleStrike() || !hasFirstStrike(); + return this.hasDoubleStrike() || !this.hasFirstStrike(); } // for costs (like Planeswalker abilities) Doubling Season gets ignored. @@ -1158,11 +1205,11 @@ public class Card extends GameEntity implements Comparable { if (this.hasKeyword("CARDNAME can't have -1/-1 counters placed on it.") && counterName.equals(Counters.M1M1)) { return; } - if (counters.containsKey(counterName)) { - Integer aux = counters.get(counterName) + n; - counters.put(counterName, aux); + if (this.counters.containsKey(counterName)) { + final Integer aux = this.counters.get(counterName) + n; + this.counters.put(counterName, aux); } else { - counters.put(counterName, Integer.valueOf(n)); + this.counters.put(counterName, Integer.valueOf(n)); } if (counterName.equals(Counters.P1P1) || counterName.equals(Counters.M1M1)) { @@ -1170,25 +1217,25 @@ public class Card extends GameEntity implements Comparable { int plusOneCounters = 0; int minusOneCounters = 0; - Counters p1Counter = Counters.P1P1; - Counters m1Counter = Counters.M1M1; - if (counters.containsKey(p1Counter)) { - plusOneCounters = counters.get(p1Counter); + final Counters p1Counter = Counters.P1P1; + final Counters m1Counter = Counters.M1M1; + if (this.counters.containsKey(p1Counter)) { + plusOneCounters = this.counters.get(p1Counter); } - if (counters.containsKey(m1Counter)) { - minusOneCounters = counters.get(m1Counter); + if (this.counters.containsKey(m1Counter)) { + minusOneCounters = this.counters.get(m1Counter); } if (plusOneCounters == minusOneCounters) { - counters.remove(m1Counter); - counters.remove(p1Counter); + this.counters.remove(m1Counter); + this.counters.remove(p1Counter); } if (plusOneCounters > minusOneCounters) { - counters.remove(m1Counter); - counters.put(p1Counter, (Integer) (plusOneCounters - minusOneCounters)); + this.counters.remove(m1Counter); + this.counters.put(p1Counter, (plusOneCounters - minusOneCounters)); } else { - counters.put(m1Counter, (Integer) (minusOneCounters - plusOneCounters)); - counters.remove(p1Counter); + this.counters.put(m1Counter, (minusOneCounters - plusOneCounters)); + this.counters.remove(p1Counter); } } @@ -1224,16 +1271,16 @@ public class Card extends GameEntity implements Comparable { if (this.hasKeyword("CARDNAME can't have -1/-1 counters placed on it.") && counterName.equals(Counters.M1M1)) { return; } - int multiplier = AllZoneUtil.getDoublingSeasonMagnitude(this.getController()); - if (counters.containsKey(counterName)) { - Integer aux = counters.get(counterName) + (multiplier * n); - counters.put(counterName, aux); + final int multiplier = AllZoneUtil.getDoublingSeasonMagnitude(this.getController()); + if (this.counters.containsKey(counterName)) { + final Integer aux = this.counters.get(counterName) + (multiplier * n); + this.counters.put(counterName, aux); } else { - counters.put(counterName, Integer.valueOf(multiplier * n)); + this.counters.put(counterName, Integer.valueOf(multiplier * n)); } // Run triggers - Map runParams = new TreeMap(); + final Map runParams = new TreeMap(); runParams.put("Card", this); runParams.put("CounterType", counterName); for (int i = 0; i < (multiplier * n); i++) { @@ -1245,25 +1292,25 @@ public class Card extends GameEntity implements Comparable { int plusOneCounters = 0; int minusOneCounters = 0; - Counters p1Counter = Counters.P1P1; - Counters m1Counter = Counters.M1M1; - if (counters.containsKey(p1Counter)) { - plusOneCounters = counters.get(p1Counter); + final Counters p1Counter = Counters.P1P1; + final Counters m1Counter = Counters.M1M1; + if (this.counters.containsKey(p1Counter)) { + plusOneCounters = this.counters.get(p1Counter); } - if (counters.containsKey(m1Counter)) { - minusOneCounters = counters.get(m1Counter); + if (this.counters.containsKey(m1Counter)) { + minusOneCounters = this.counters.get(m1Counter); } if (plusOneCounters == minusOneCounters) { - counters.remove(m1Counter); - counters.remove(p1Counter); + this.counters.remove(m1Counter); + this.counters.remove(p1Counter); } if (plusOneCounters > minusOneCounters) { - counters.remove(m1Counter); - counters.put(p1Counter, (Integer) (plusOneCounters - minusOneCounters)); + this.counters.remove(m1Counter); + this.counters.put(p1Counter, (plusOneCounters - minusOneCounters)); } else { - counters.put(m1Counter, (Integer) (minusOneCounters - plusOneCounters)); - counters.remove(p1Counter); + this.counters.put(m1Counter, (minusOneCounters - plusOneCounters)); + this.counters.remove(p1Counter); } } @@ -1283,20 +1330,20 @@ public class Card extends GameEntity implements Comparable { * a int. */ public final void subtractCounter(final Counters counterName, final int n) { - if (counters.containsKey(counterName)) { - Integer aux = counters.get(counterName) - n; + if (this.counters.containsKey(counterName)) { + Integer aux = this.counters.get(counterName) - n; if (aux < 0) { aux = 0; } - counters.put(counterName, aux); - if (counterName.equals(Counters.TIME) && aux == 0) { - boolean hasVanish = CardFactoryUtil.hasKeyword(this, "Vanishing") != -1; + this.counters.put(counterName, aux); + if (counterName.equals(Counters.TIME) && (aux == 0)) { + final boolean hasVanish = CardFactoryUtil.hasKeyword(this, "Vanishing") != -1; if (hasVanish && AllZoneUtil.isCardInPlay(this)) { AllZone.getGameAction().sacrifice(this); } - if (hasSuspend() && AllZoneUtil.isCardExiled(this)) { + if (this.hasSuspend() && AllZoneUtil.isCardExiled(this)) { final Card c = this; c.setSuspendCast(true); @@ -1324,8 +1371,8 @@ public class Card extends GameEntity implements Comparable { * @return a int. */ public final int getCounters(final Counters counterName) { - if (counters.containsKey(counterName)) { - return counters.get(counterName); + if (this.counters.containsKey(counterName)) { + return this.counters.get(counterName); } else { return 0; } @@ -1341,7 +1388,7 @@ public class Card extends GameEntity implements Comparable { * @since 1.0.15 */ public final Map getCounters() { - return counters; + return this.counters; } /** @@ -1352,7 +1399,7 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean hasCounters() { - return counters.size() > 0; + return this.counters.size() > 0; } /** @@ -1363,7 +1410,7 @@ public class Card extends GameEntity implements Comparable { */ public final int getNumberOfCounters() { int number = 0; - for (Integer i : counters.values()) { + for (final Integer i : this.counters.values()) { number += i.intValue(); } return number; @@ -1391,14 +1438,14 @@ public class Card extends GameEntity implements Comparable { // sometimes you just need to set the value without being affected by // DoublingSeason if (bSetValue) { - counters.put(counterName, Integer.valueOf(n)); + this.counters.put(counterName, Integer.valueOf(n)); } else { - int num = getCounters(counterName); + final int num = this.getCounters(counterName); // if counters on card is less than the setting value, addCounters if (num < n) { - addCounter(counterName, n - num); + this.addCounter(counterName, n - num); } else { - subtractCounter(counterName, num - n); + this.subtractCounter(counterName, num - n); } } this.updateObservers(); @@ -1415,7 +1462,7 @@ public class Card extends GameEntity implements Comparable { * @since 1.0.15 */ public final void setCounters(final Map allCounters) { - counters = allCounters; + this.counters = allCounters; } // get all counters from a card @@ -1427,7 +1474,7 @@ public class Card extends GameEntity implements Comparable { * @since 1.0.15 */ public final void clearCounters() { - counters = new TreeMap(); + this.counters = new TreeMap(); } /** @@ -1437,7 +1484,7 @@ public class Card extends GameEntity implements Comparable { * @return true if this creature can "Level up", false otherwise */ public final boolean hasLevelUp() { - return levelUp; + return this.levelUp; } /** @@ -1449,7 +1496,7 @@ public class Card extends GameEntity implements Comparable { * a boolean. */ public final void setLevelUp(final boolean b) { - levelUp = b; + this.levelUp = b; } /** @@ -1462,8 +1509,8 @@ public class Card extends GameEntity implements Comparable { * @return a {@link java.lang.String} object. */ public final String getSVar(final String var) { - if (getCharacteristics().getsVars().containsKey(var)) { - return getCharacteristics().getsVars().get(var); + if (this.getCharacteristics().getsVars().containsKey(var)) { + return this.getCharacteristics().getsVars().get(var); } else { return ""; } @@ -1480,11 +1527,11 @@ public class Card extends GameEntity implements Comparable { * a {@link java.lang.String} object. */ public final void setSVar(final String var, final String str) { - if (getCharacteristics().getsVars().containsKey(var)) { - getCharacteristics().getsVars().remove(var); + if (this.getCharacteristics().getsVars().containsKey(var)) { + this.getCharacteristics().getsVars().remove(var); } - getCharacteristics().getsVars().put(var, str); + this.getCharacteristics().getsVars().put(var, str); } /** @@ -1495,7 +1542,7 @@ public class Card extends GameEntity implements Comparable { * @return a Map object. */ public final Map getSVars() { - return getCharacteristics().getsVars(); + return this.getCharacteristics().getsVars(); } /** @@ -1507,7 +1554,7 @@ public class Card extends GameEntity implements Comparable { * a Map object. */ public final void setSVars(final Map newSVars) { - getCharacteristics().setsVars(newSVars); + this.getCharacteristics().setsVars(newSVars); } /** @@ -1518,11 +1565,11 @@ public class Card extends GameEntity implements Comparable { * @return a int. */ public final int sumAllCounters() { - Object[] values = counters.values().toArray(); + final Object[] values = this.counters.values().toArray(); int count = 0; int num = 0; - for (int i = 0; i < values.length; i++) { - num = (Integer) values[i]; + for (final Object value2 : values) { + num = (Integer) value2; count += num; } return count; @@ -1536,7 +1583,7 @@ public class Card extends GameEntity implements Comparable { * @return a int. */ public final int getNetPTCounters() { - return getCounters(Counters.P1P1) - getCounters(Counters.M1M1); + return this.getCounters(Counters.P1P1) - this.getCounters(Counters.M1M1); } /** @@ -1547,7 +1594,7 @@ public class Card extends GameEntity implements Comparable { * @return a int. */ public final int getTurnInZone() { - return turnInZone; + return this.turnInZone; } /** @@ -1559,7 +1606,7 @@ public class Card extends GameEntity implements Comparable { * a int. */ public final void setTurnInZone(final int turn) { - turnInZone = turn; + this.turnInZone = turn; } /** @@ -1571,7 +1618,7 @@ public class Card extends GameEntity implements Comparable { * a {@link java.lang.String} object. */ public final void setEchoCost(final String s) { - echoCost = s; + this.echoCost = s; } /** @@ -1582,7 +1629,7 @@ public class Card extends GameEntity implements Comparable { * @return a {@link java.lang.String} object. */ public final String getEchoCost() { - return echoCost; + return this.echoCost; } /** @@ -1594,7 +1641,7 @@ public class Card extends GameEntity implements Comparable { * a {@link java.lang.String} object. */ public final void setManaCost(final String s) { - getCharacteristics().setManaCost(s); + this.getCharacteristics().setManaCost(s); } /** @@ -1605,7 +1652,7 @@ public class Card extends GameEntity implements Comparable { * @return a {@link java.lang.String} object. */ public final String getManaCost() { - return getCharacteristics().getManaCost(); + return this.getCharacteristics().getManaCost(); } /** @@ -1620,7 +1667,7 @@ public class Card extends GameEntity implements Comparable { if (s.equals("")) { s = "0"; } - getCharacteristics().getCardColor().add(new CardColor(new ManaCost(s), this, false, true)); + this.getCharacteristics().getCardColor().add(new CardColor(new ManaCost(s), this, false, true)); } /** @@ -1642,7 +1689,7 @@ public class Card extends GameEntity implements Comparable { if (bIncrease) { CardColor.increaseTimestamp(); } - getCharacteristics().getCardColor().add(new CardColor(new ManaCost(s), c, addToColors, false)); + this.getCharacteristics().getCardColor().add(new CardColor(new ManaCost(s), c, addToColors, false)); return CardColor.getTimestamp(); } @@ -1662,14 +1709,14 @@ public class Card extends GameEntity implements Comparable { */ public final void removeColor(final String s, final Card c, final boolean addTo, final long timestampIn) { CardColor removeCol = null; - for (CardColor cc : getCharacteristics().getCardColor()) { + for (final CardColor cc : this.getCharacteristics().getCardColor()) { if (cc.equals(s, c, addTo, timestampIn)) { removeCol = cc; } } if (removeCol != null) { - getCharacteristics().getCardColor().remove(removeCol); + this.getCharacteristics().getCardColor().remove(removeCol); } } @@ -1685,8 +1732,8 @@ public class Card extends GameEntity implements Comparable { return new CardColor(this); } CardColor colors = null; - ArrayList globalChanges = AllZone.getColorChanger().getColorChanges(); - colors = determineColor(globalChanges); + final ArrayList globalChanges = AllZone.getColorChanger().getColorChanges(); + colors = this.determineColor(globalChanges); colors.fixColorless(); return colors; } @@ -1700,7 +1747,7 @@ public class Card extends GameEntity implements Comparable { * a {@link java.util.ArrayList} object. */ public final void setColor(final ArrayList colors) { - getCharacteristics().setCardColor(colors); + this.getCharacteristics().setCardColor(colors); } /** @@ -1711,7 +1758,7 @@ public class Card extends GameEntity implements Comparable { * @return a {@link java.util.ArrayList} object. */ public final ArrayList getColor() { - return getCharacteristics().getCardColor(); + return this.getCharacteristics().getCardColor(); } /** @@ -1723,18 +1770,18 @@ public class Card extends GameEntity implements Comparable { * @return a Card_Color */ final CardColor determineColor(final ArrayList globalChanges) { - CardColor colors = new CardColor(this); - int i = getCharacteristics().getCardColor().size() - 1; + final CardColor colors = new CardColor(this); + int i = this.getCharacteristics().getCardColor().size() - 1; int j = -1; if (globalChanges != null) { j = globalChanges.size() - 1; } // if both have changes, see which one is most recent - while (i >= 0 && j >= 0) { + while ((i >= 0) && (j >= 0)) { CardColor cc = null; - if (getCharacteristics().getCardColor().get(i).getStamp() > globalChanges.get(j).getStamp()) { + if (this.getCharacteristics().getCardColor().get(i).getStamp() > globalChanges.get(j).getStamp()) { // Card has a more recent color stamp - cc = getCharacteristics().getCardColor().get(i); + cc = this.getCharacteristics().getCardColor().get(i); i--; } else { // Global effect has a more recent color stamp @@ -1742,7 +1789,7 @@ public class Card extends GameEntity implements Comparable { j--; } - for (String s : cc.toStringArray()) { + for (final String s : cc.toStringArray()) { colors.addToCardColor(s); } if (!cc.getAdditional()) { @@ -1750,9 +1797,9 @@ public class Card extends GameEntity implements Comparable { } } while (i >= 0) { - CardColor cc = getCharacteristics().getCardColor().get(i); + final CardColor cc = this.getCharacteristics().getCardColor().get(i); i--; - for (String s : cc.toStringArray()) { + for (final String s : cc.toStringArray()) { colors.addToCardColor(s); } if (!cc.getAdditional()) { @@ -1760,9 +1807,9 @@ public class Card extends GameEntity implements Comparable { } } while (j >= 0) { - CardColor cc = globalChanges.get(j); + final CardColor cc = globalChanges.get(j); j--; - for (String s : cc.toStringArray()) { + for (final String s : cc.toStringArray()) { colors.addToCardColor(s); } if (!cc.getAdditional()) { @@ -1781,7 +1828,7 @@ public class Card extends GameEntity implements Comparable { * @return a int. */ public final int getCMC() { - return CardUtil.getConvertedManaCost(getCharacteristics().getManaCost()); + return CardUtil.getConvertedManaCost(this.getCharacteristics().getManaCost()); } /** @@ -1793,7 +1840,7 @@ public class Card extends GameEntity implements Comparable { * @since 1.1.6 */ public final Player getChosenPlayer() { - return chosenPlayer; + return this.chosenPlayer; } /** @@ -1806,7 +1853,7 @@ public class Card extends GameEntity implements Comparable { * @since 1.1.6 */ public final void setChosenPlayer(final Player p) { - chosenPlayer = p; + this.chosenPlayer = p; } /** @@ -1817,7 +1864,7 @@ public class Card extends GameEntity implements Comparable { * @return an int */ public final int getChosenNumber() { - return chosenNumber; + return this.chosenNumber; } /** @@ -1829,7 +1876,7 @@ public class Card extends GameEntity implements Comparable { * an int */ public final void setChosenNumber(final int i) { - chosenNumber = i; + this.chosenNumber = i; } // used for cards like Belbe's Portal, Conspiracy, Cover of Darkness, etc. @@ -1841,7 +1888,7 @@ public class Card extends GameEntity implements Comparable { * @return a {@link java.lang.String} object. */ public final String getChosenType() { - return chosenType; + return this.chosenType; } /** @@ -1853,7 +1900,7 @@ public class Card extends GameEntity implements Comparable { * a {@link java.lang.String} object. */ public final void setChosenType(final String s) { - chosenType = s; + this.chosenType = s; } /** @@ -1864,7 +1911,7 @@ public class Card extends GameEntity implements Comparable { * @return an ArrayList object. */ public final ArrayList getChosenColor() { - return chosenColor; + return this.chosenColor; } /** @@ -1876,7 +1923,7 @@ public class Card extends GameEntity implements Comparable { * an ArrayList object. */ public final void setChosenColor(final ArrayList s) { - chosenColor = s; + this.chosenColor = s; } // used for cards like Meddling Mage... @@ -1888,7 +1935,7 @@ public class Card extends GameEntity implements Comparable { * @return a {@link java.lang.String} object. */ public final String getNamedCard() { - return namedCard; + return this.namedCard; } /** @@ -1900,7 +1947,7 @@ public class Card extends GameEntity implements Comparable { * a {@link java.lang.String} object. */ public final void setNamedCard(final String s) { - namedCard = s; + this.namedCard = s; } /** @@ -1912,7 +1959,7 @@ public class Card extends GameEntity implements Comparable { * a boolean. */ public final void setDrawnThisTurn(final boolean b) { - drawnThisTurn = b; + this.drawnThisTurn = b; } /** @@ -1923,7 +1970,7 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean getDrawnThisTurn() { - return drawnThisTurn; + return this.drawnThisTurn; } /** @@ -1934,7 +1981,7 @@ public class Card extends GameEntity implements Comparable { * @return a list of cards this card has gained control of */ public final ArrayList getGainControlTargets() { - return gainControlTargets; + return this.gainControlTargets; } /** @@ -1946,7 +1993,7 @@ public class Card extends GameEntity implements Comparable { * a {@link forge.Card} object. */ public final void addGainControlTarget(final Card c) { - gainControlTargets.add(c); + this.gainControlTargets.add(c); } /** @@ -1955,7 +2002,7 @@ public class Card extends GameEntity implements Comparable { * used primarily with AbilityFactory_GainControl */ public final void clearGainControlTargets() { - gainControlTargets.clear(); + this.gainControlTargets.clear(); } /** @@ -1968,7 +2015,7 @@ public class Card extends GameEntity implements Comparable { * @return a {@link java.util.ArrayList} object. */ public final ArrayList getGainControlReleaseCommands() { - return gainControlReleaseCommands; + return this.gainControlReleaseCommands; } /** @@ -1982,7 +2029,7 @@ public class Card extends GameEntity implements Comparable { * the Command to be executed */ public final void addGainControlReleaseCommand(final Command c) { - gainControlReleaseCommands.add(c); + this.gainControlReleaseCommands.add(c); } /** @@ -1991,7 +2038,7 @@ public class Card extends GameEntity implements Comparable { *

*/ public final void clearGainControlReleaseCommands() { - gainControlReleaseCommands.clear(); + this.gainControlReleaseCommands.clear(); } /** @@ -2002,7 +2049,7 @@ public class Card extends GameEntity implements Comparable { * @return a {@link java.lang.String} object. */ public final String getSpellText() { - return text; + return this.text; } /** @@ -2014,7 +2061,7 @@ public class Card extends GameEntity implements Comparable { * a {@link java.lang.String} object. */ public final void setText(final String t) { - text = t; + this.text = t; } // get the text that should be displayed @@ -2026,16 +2073,17 @@ public class Card extends GameEntity implements Comparable { * @return a {@link java.lang.String} object. */ public String getText() { - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); sb.append(this.getAbilityText()); - String nonAbilityText = getNonAbilityText(); + final String nonAbilityText = this.getNonAbilityText(); if (nonAbilityText.length() > 0) { sb.append("\r\n \r\nNon ability features: \r\n"); - sb.append(nonAbilityText.replaceAll("CARDNAME", getName())); + sb.append(nonAbilityText.replaceAll("CARDNAME", this.getName())); } - - if(characteristicsMap.get("Cloner") != null) { - sb.append("\r\nCloned by:").append(characteristicsMap.get("Cloner").getName()).append(" (").append(getUniqueNumber()).append(")"); + + if (this.characteristicsMap.get("Cloner") != null) { + sb.append("\r\nCloned by:").append(this.characteristicsMap.get("Cloner").getName()).append(" (") + .append(this.getUniqueNumber()).append(")"); } return sb.toString(); @@ -2051,10 +2099,10 @@ public class Card extends GameEntity implements Comparable { * @return a {@link java.lang.String} object. */ public final String getNonAbilityText() { - StringBuilder sb = new StringBuilder(); - ArrayList keyword = getHiddenExtrinsicKeyword(); + final StringBuilder sb = new StringBuilder(); + final ArrayList keyword = this.getHiddenExtrinsicKeyword(); - sb.append(keywordsToText(keyword)); + sb.append(this.keywordsToText(keyword)); return sb.toString(); } @@ -2070,9 +2118,9 @@ public class Card extends GameEntity implements Comparable { * @return a {@link java.lang.String} object. */ public final String keywordsToText(final ArrayList keyword) { - StringBuilder sb = new StringBuilder(); - StringBuilder sbLong = new StringBuilder(); - StringBuilder sbMana = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); + final StringBuilder sbLong = new StringBuilder(); + final StringBuilder sbMana = new StringBuilder(); for (int i = 0; i < keyword.size(); i++) { if (!keyword.get(i).toString().contains("CostChange") @@ -2082,13 +2130,13 @@ public class Card extends GameEntity implements Comparable { && !keyword.get(i).toString().contains("CantBlock") && !keyword.get(i).toString().contains("CantBeBlockedBy")) { if (keyword.get(i).toString().contains("StaticEffect")) { - String[] k = keyword.get(i).split(":"); + final String[] k = keyword.get(i).split(":"); sbLong.append(k[5]).append("\r\n"); } else if (keyword.get(i).toString().contains("Protection:")) { - String[] k = keyword.get(i).split(":"); + final String[] k = keyword.get(i).split(":"); sbLong.append(k[2]).append("\r\n"); } else if (keyword.get(i).toString().contains("Creatures can't attack unless their controller pays")) { - String[] k = keyword.get(i).split(":"); + final String[] k = keyword.get(i).split(":"); if (!k[3].equals("no text")) { sbLong.append(k[3]).append("\r\n"); } @@ -2105,8 +2153,8 @@ public class Card extends GameEntity implements Comparable { k = k.replace(":", " "); sbLong.append(k).append("\r\n"); } else if (keyword.get(i).startsWith("Champion")) { - String k = getKeyword().get(i); - String[] kk = k.split(":"); + final String k = this.getKeyword().get(i); + final String[] kk = k.split(":"); String types = kk[1]; if (kk.length > 2) { types = kk[2]; @@ -2133,8 +2181,8 @@ public class Card extends GameEntity implements Comparable { } else if (keyword.get(i).toString().contains("tap: add ")) { sbMana.append(keyword.get(i).toString()).append("\r\n"); } else if (keyword.get(i).contains("Bloodthirst")) { - String k = keyword.get(i); - String[] kk = k.split(" "); + final String k = keyword.get(i); + final String[] kk = k.split(" "); sbLong.append(keyword.get(i)).append( " (If an opponent was dealt damage this turn, this creature enters the battlefield with "); sbLong.append(kk[1]).append(" +1/+1 counter"); @@ -2148,7 +2196,7 @@ public class Card extends GameEntity implements Comparable { sbLong.append(" on it.)").append("\r\n"); } } else if (keyword.get(i).startsWith("Modular")) { - String numCounters = keyword.get(i).split(" ")[1]; + final String numCounters = keyword.get(i).split(" ")[1]; sbLong.append(keyword.get(i)); sbLong.append(" (This enters the battlefield with "); sbLong.append(numCounters); @@ -2162,7 +2210,7 @@ public class Card extends GameEntity implements Comparable { continue; } else if (keyword.get(i).contains("Haunt")) { sb.append("\r\nHaunt ("); - if (isCreature()) { + if (this.isCreature()) { sb.append("When this creature dies, exile it haunting target creature."); } else { sb.append("When this spell card is put into a graveyard after resolving, "); @@ -2173,7 +2221,7 @@ public class Card extends GameEntity implements Comparable { } else if (keyword.get(i).equals("Convoke")) { sb.append("Convoke (Each creature you tap while casting this spell reduces its cost by 1 or by one mana of that creature's color.)"); } else { - if (i != 0 && sb.length() != 0) { + if ((i != 0) && (sb.length() != 0)) { sb.append(", "); } sb.append(keyword.get(i).toString()); @@ -2200,11 +2248,11 @@ public class Card extends GameEntity implements Comparable { * @return a {@link java.lang.String} object. */ public String getAbilityText() { - if (isInstant() || isSorcery()) { - StringBuilder sb = abilityTextInstantSorcery(); + if (this.isInstant() || this.isSorcery()) { + final StringBuilder sb = this.abilityTextInstantSorcery(); - if (haunting != null) { - sb.append("Haunting: ").append(haunting); + if (this.haunting != null) { + sb.append("Haunting: ").append(this.haunting); sb.append("\r\n"); } @@ -2212,17 +2260,17 @@ public class Card extends GameEntity implements Comparable { sb.delete(sb.lastIndexOf("\r\n"), sb.lastIndexOf("\r\n") + 3); } - return sb.toString().replaceAll("CARDNAME", getName()); + return sb.toString().replaceAll("CARDNAME", this.getName()); } - StringBuilder sb = new StringBuilder(); - ArrayList keyword = getUnhiddenKeyword(); + final StringBuilder sb = new StringBuilder(); + final ArrayList keyword = this.getUnhiddenKeyword(); - sb.append(keywordsToText(keyword)); + sb.append(this.keywordsToText(keyword)); // Give spellText line breaks for easier reading sb.append("\r\n"); - sb.append(text.replaceAll("\\\\r\\\\n", "\r\n")); + sb.append(this.text.replaceAll("\\\\r\\\\n", "\r\n")); sb.append("\r\n"); /* @@ -2232,33 +2280,33 @@ public class Card extends GameEntity implements Comparable { */ // Triggered abilities - for (Trigger trig : getCharacteristics().getTriggers()) { + for (final Trigger trig : this.getCharacteristics().getTriggers()) { if (!trig.isSecondary()) { sb.append(trig.toString() + "\r\n"); } } // static abilities - for (StaticAbility stAb : getCharacteristics().getStaticAbilities()) { + for (final StaticAbility stAb : this.getCharacteristics().getStaticAbilities()) { sb.append(stAb.toString() + "\r\n"); } - ArrayList addedManaStrings = new ArrayList(); - SpellAbility[] abilities = getSpellAbility(); + final ArrayList addedManaStrings = new ArrayList(); + final SpellAbility[] abilities = this.getSpellAbility(); boolean primaryCost = true; - for (SpellAbility sa : abilities) { + for (final SpellAbility sa : abilities) { // only add abilities not Spell portions of cards - if (!isPermanent()) { + if (!this.isPermanent()) { continue; } - if (sa instanceof SpellPermanent && primaryCost && !isAura()) { + if ((sa instanceof SpellPermanent) && primaryCost && !this.isAura()) { // For Alt costs, make sure to display the cost! primaryCost = false; continue; } - String sAbility = sa.toString(); + final String sAbility = sa.toString(); if (sa instanceof AbilityMana) { if (addedManaStrings.contains(sAbility)) { @@ -2267,10 +2315,10 @@ public class Card extends GameEntity implements Comparable { addedManaStrings.add(sAbility); } - if (sa instanceof SpellPermanent && !isAura()) { + if ((sa instanceof SpellPermanent) && !this.isAura()) { sb.insert(0, "\r\n"); sb.insert(0, sAbility); - } else if (!sAbility.endsWith(getName())) { + } else if (!sAbility.endsWith(this.getName())) { sb.append(sAbility); sb.append("\r\n"); // The test above appears to prevent the card name from showing @@ -2293,21 +2341,21 @@ public class Card extends GameEntity implements Comparable { // replace tripple line feeds with double line feeds int start; - String s = "\r\n\r\n\r\n"; + final String s = "\r\n\r\n\r\n"; while (sb.toString().contains(s)) { start = sb.lastIndexOf(s); - if (start < 0 || start >= sb.length()) { + if ((start < 0) || (start >= sb.length())) { break; } sb.replace(start, start + 4, "\r\n"); } // Remembered cards - if (rememberedObjects.size() > 0) { + if (this.rememberedObjects.size() > 0) { sb.append("\r\nRemembered: \r\n"); - for (Object o : rememberedObjects) { + for (final Object o : this.rememberedObjects) { if (o instanceof Card) { - Card c = (Card) o; + final Card c = (Card) o; if (c.isFaceDown()) { sb.append("Face Down "); } else { @@ -2323,17 +2371,17 @@ public class Card extends GameEntity implements Comparable { } } - if (hauntedBy.size() != 0) { + if (this.hauntedBy.size() != 0) { sb.append("Haunted by: "); - for (Card c : hauntedBy) { + for (final Card c : this.hauntedBy) { sb.append(c).append(","); } sb.deleteCharAt(sb.length() - 1); sb.append("\r\n"); } - if (haunting != null) { - sb.append("Haunting: ").append(haunting); + if (this.haunting != null) { + sb.append("Haunting: ").append(this.haunting); sb.append("\r\n"); } @@ -2342,16 +2390,17 @@ public class Card extends GameEntity implements Comparable { * sb.append("Controller(s):"); for(Object o : controllerObjects) { * sb.append(o); } sb.append("\r\n"); */ - return sb.toString().replaceAll("CARDNAME", getName()).trim(); + return sb.toString().replaceAll("CARDNAME", this.getName()).trim(); } // getText() /** * TODO: Write javadoc for this method. + * * @return */ private StringBuilder abilityTextInstantSorcery() { - String s = getSpellText(); - StringBuilder sb = new StringBuilder(); + final String s = this.getSpellText(); + final StringBuilder sb = new StringBuilder(); // Give spellText line breaks for easier reading sb.append(s.replaceAll("\\\\r\\\\n", "\r\n")); @@ -2365,24 +2414,24 @@ public class Card extends GameEntity implements Comparable { } // Add SpellAbilities - SpellAbility[] sa = getSpellAbility(); - for (int i = 0; i < sa.length; i++) { - sb.append(sa[i].toString() + "\r\n"); + final SpellAbility[] sa = this.getSpellAbility(); + for (final SpellAbility element : sa) { + sb.append(element.toString() + "\r\n"); } // Add Keywords - ArrayList kw = getKeyword(); + final ArrayList kw = this.getKeyword(); // Triggered abilities - for (Trigger trig : getCharacteristics().getTriggers()) { + for (final Trigger trig : this.getCharacteristics().getTriggers()) { if (!trig.isSecondary()) { sb.append(trig.toString() + "\r\n"); } } // static abilities - for (StaticAbility stAb : getCharacteristics().getStaticAbilities()) { - String stAbD = stAb.toString(); + for (final StaticAbility stAb : this.getCharacteristics().getStaticAbilities()) { + final String stAbD = stAb.toString(); if (!stAbD.equals("")) { sb.append(stAbD + "\r\n"); } @@ -2390,7 +2439,7 @@ public class Card extends GameEntity implements Comparable { // Ripple + Dredge + Madness + CARDNAME is {color} + Recover. for (int i = 0; i < kw.size(); i++) { - String keyword = kw.get(i); + final String keyword = kw.get(i); if ((keyword.startsWith("Ripple") && !sb.toString().contains("Ripple")) || (keyword.startsWith("Dredge") && !sb.toString().contains("Dredge")) || (keyword.startsWith("Madness") && !sb.toString().contains("Madness")) @@ -2407,8 +2456,8 @@ public class Card extends GameEntity implements Comparable { if (keyword.startsWith("Flashback")) { sb.append("Flashback"); if (keyword.contains(" ")) { - final Cost fbCost = new Cost(keyword.substring(10), getName(), true); - sb.append(" "+fbCost.toString()).delete(sb.length()-2, sb.length()-1); + final Cost fbCost = new Cost(keyword.substring(10), this.getName(), true); + sb.append(" " + fbCost.toString()).delete(sb.length() - 2, sb.length() - 1); } sb.append("\r\n"); } @@ -2438,7 +2487,7 @@ public class Card extends GameEntity implements Comparable { sb.delete(sb.lastIndexOf("\r\n"), sb.lastIndexOf("\r\n") + 3); } sb.append("Haunt ("); - if (isCreature()) { + if (this.isCreature()) { sb.append("When this creature dies, exile it haunting target creature."); } else { sb.append("When this spell card is put into a graveyard after resolving, "); @@ -2464,7 +2513,7 @@ public class Card extends GameEntity implements Comparable { * @return a {@link java.util.ArrayList} object. */ public final ArrayList getManaAbility() { - return new ArrayList(getCharacteristics().getManaAbility()); + return new ArrayList(this.getCharacteristics().getManaAbility()); } // Returns basic mana abilities plus "reflected mana" abilities @@ -2476,11 +2525,11 @@ public class Card extends GameEntity implements Comparable { * @return a {@link java.util.ArrayList} object. */ public final ArrayList getAIPlayableMana() { - ArrayList res = new ArrayList(); - for (AbilityMana am : getManaAbility()) { + final ArrayList res = new ArrayList(); + for (final AbilityMana am : this.getManaAbility()) { // if a mana ability has a mana cost the AI will miscalculate - Cost cost = am.getPayCosts(); + final Cost cost = am.getPayCosts(); if (!cost.hasNoManaCost()) { continue; } @@ -2504,8 +2553,8 @@ public class Card extends GameEntity implements Comparable { * @return a {@link java.util.ArrayList} object. */ public final ArrayList getBasicMana() { - ArrayList res = new ArrayList(); - for (AbilityMana am : getManaAbility()) { + final ArrayList res = new ArrayList(); + for (final AbilityMana am : this.getManaAbility()) { if (am.isBasic() && !res.contains(am)) { res.add(am); } @@ -2519,9 +2568,9 @@ public class Card extends GameEntity implements Comparable { *

*/ public final void clearFirstSpell() { - for (int i = 0; i < getCharacteristics().getSpellAbility().size(); i++) { - if (getCharacteristics().getSpellAbility().get(i).isSpell()) { - getCharacteristics().getSpellAbility().remove(i); + for (int i = 0; i < this.getCharacteristics().getSpellAbility().size(); i++) { + if (this.getCharacteristics().getSpellAbility().get(i).isSpell()) { + this.getCharacteristics().getSpellAbility().remove(i); return; } } @@ -2533,12 +2582,12 @@ public class Card extends GameEntity implements Comparable { *

*/ public final void clearAllButFirstSpellAbility() { - if (!getCharacteristics().getSpellAbility().isEmpty()) { - SpellAbility first = getCharacteristics().getSpellAbility().get(0); - getCharacteristics().getSpellAbility().clear(); - getCharacteristics().getSpellAbility().add(first); + if (!this.getCharacteristics().getSpellAbility().isEmpty()) { + final SpellAbility first = this.getCharacteristics().getSpellAbility().get(0); + this.getCharacteristics().getSpellAbility().clear(); + this.getCharacteristics().getSpellAbility().add(first); } - getCharacteristics().getManaAbility().clear(); + this.getCharacteristics().getManaAbility().clear(); } /** @@ -2549,13 +2598,13 @@ public class Card extends GameEntity implements Comparable { * @return a {@link java.util.ArrayList} object. */ public final ArrayList getAllButFirstSpellAbility() { - ArrayList sas = new ArrayList(); - sas.addAll(getCharacteristics().getSpellAbility()); + final ArrayList sas = new ArrayList(); + sas.addAll(this.getCharacteristics().getSpellAbility()); if (!sas.isEmpty()) { - SpellAbility first = getCharacteristics().getSpellAbility().get(0); + final SpellAbility first = this.getCharacteristics().getSpellAbility().get(0); sas.remove(first); } - sas.addAll(getCharacteristics().getManaAbility()); + sas.addAll(this.getCharacteristics().getManaAbility()); return sas; } @@ -2566,8 +2615,8 @@ public class Card extends GameEntity implements Comparable { *

*/ public final void clearSpellAbility() { - getCharacteristics().getSpellAbility().clear(); - getCharacteristics().getManaAbility().clear(); + this.getCharacteristics().getSpellAbility().clear(); + this.getCharacteristics().getManaAbility().clear(); } /** @@ -2578,7 +2627,7 @@ public class Card extends GameEntity implements Comparable { * @return a {@link forge.card.spellability.SpellPermanent} object. */ public final SpellPermanent getSpellPermanent() { - for (SpellAbility sa : getCharacteristics().getSpellAbility()) { + for (final SpellAbility sa : this.getCharacteristics().getSpellAbility()) { if (sa instanceof SpellPermanent) { return (SpellPermanent) sa; } @@ -2592,7 +2641,7 @@ public class Card extends GameEntity implements Comparable { *

*/ public final void clearSpellKeepManaAbility() { - getCharacteristics().getSpellAbility().clear(); + this.getCharacteristics().getSpellAbility().clear(); } /** @@ -2601,7 +2650,7 @@ public class Card extends GameEntity implements Comparable { *

*/ public final void clearManaAbility() { - getCharacteristics().getManaAbility().clear(); + this.getCharacteristics().getManaAbility().clear(); } /** @@ -2615,9 +2664,9 @@ public class Card extends GameEntity implements Comparable { public final void addFirstSpellAbility(final SpellAbility a) { a.setSourceCard(this); if (a instanceof AbilityMana) { - getCharacteristics().getManaAbility().add(0, (AbilityMana) a); + this.getCharacteristics().getManaAbility().add(0, (AbilityMana) a); } else { - getCharacteristics().getSpellAbility().add(0, a); + this.getCharacteristics().getSpellAbility().add(0, a); } } @@ -2632,9 +2681,9 @@ public class Card extends GameEntity implements Comparable { public final void addSpellAbility(final SpellAbility a) { a.setSourceCard(this); if (a instanceof AbilityMana) { - getCharacteristics().getManaAbility().add((AbilityMana) a); + this.getCharacteristics().getManaAbility().add((AbilityMana) a); } else { - getCharacteristics().getSpellAbility().add(a); + this.getCharacteristics().getSpellAbility().add(a); } } @@ -2650,9 +2699,9 @@ public class Card extends GameEntity implements Comparable { if (a instanceof AbilityMana) { // if (a.isExtrinsic()) //never remove intrinsic mana abilities, is // this the way to go?? - getCharacteristics().getManaAbility().remove(a); + this.getCharacteristics().getManaAbility().remove(a); } else { - getCharacteristics().getSpellAbility().remove(a); + this.getCharacteristics().getSpellAbility().remove(a); } } @@ -2663,15 +2712,15 @@ public class Card extends GameEntity implements Comparable { */ public final void removeAllExtrinsicManaAbilities() { // temp ArrayList, otherwise ConcurrentModificationExceptions occur: - ArrayList saList = new ArrayList(); + final ArrayList saList = new ArrayList(); - for (SpellAbility var : getCharacteristics().getManaAbility()) { + for (final SpellAbility var : this.getCharacteristics().getManaAbility()) { if (var.isExtrinsic()) { saList.add(var); } } - for (SpellAbility sa : saList) { - removeSpellAbility(sa); + for (final SpellAbility sa : saList) { + this.removeSpellAbility(sa); } } @@ -2683,8 +2732,8 @@ public class Card extends GameEntity implements Comparable { * @return a {@link java.util.ArrayList} object. */ public final ArrayList getIntrinsicManaAbilitiesDescriptions() { - ArrayList list = new ArrayList(); - for (SpellAbility var : getCharacteristics().getManaAbility()) { + final ArrayList list = new ArrayList(); + for (final SpellAbility var : this.getCharacteristics().getManaAbility()) { if (var.isIntrinsic()) { list.add(var.toString()); } @@ -2700,9 +2749,9 @@ public class Card extends GameEntity implements Comparable { * @return an array of {@link forge.card.spellability.SpellAbility} objects. */ public final SpellAbility[] getSpellAbility() { - ArrayList res = new ArrayList(getCharacteristics().getSpellAbility()); - res.addAll(getManaAbility()); - SpellAbility[] s = new SpellAbility[res.size()]; + final ArrayList res = new ArrayList(this.getCharacteristics().getSpellAbility()); + res.addAll(this.getManaAbility()); + final SpellAbility[] s = new SpellAbility[res.size()]; res.toArray(s); return s; } @@ -2715,8 +2764,8 @@ public class Card extends GameEntity implements Comparable { * @return a {@link java.util.ArrayList} object. */ public final ArrayList getSpellAbilities() { - ArrayList res = new ArrayList(getCharacteristics().getSpellAbility()); - res.addAll(getManaAbility()); + final ArrayList res = new ArrayList(this.getCharacteristics().getSpellAbility()); + res.addAll(this.getManaAbility()); return res; } @@ -2727,15 +2776,15 @@ public class Card extends GameEntity implements Comparable { * @return ArrayList */ public final ArrayList getAllSpellAbilities() { - ArrayList res = new ArrayList(); + final ArrayList res = new ArrayList(); - String curState = curCharacteristics; - for(String key : characteristicsMap.keySet()) { - setState(key); - res.addAll(getSpellAbilities()); + final String curState = this.curCharacteristics; + for (final String key : this.characteristicsMap.keySet()) { + this.setState(key); + res.addAll(this.getSpellAbilities()); } - - setState(curState); + + this.setState(curState); return res; } @@ -2748,10 +2797,10 @@ public class Card extends GameEntity implements Comparable { * @return a {@link java.util.ArrayList} object. */ public final ArrayList getSpells() { - ArrayList s = new ArrayList(getCharacteristics().getSpellAbility()); - ArrayList res = new ArrayList(); + final ArrayList s = new ArrayList(this.getCharacteristics().getSpellAbility()); + final ArrayList res = new ArrayList(); - for (SpellAbility sa : s) { + for (final SpellAbility sa : s) { if (sa.isSpell()) { res.add(sa); } @@ -2767,10 +2816,10 @@ public class Card extends GameEntity implements Comparable { * @return a {@link java.util.ArrayList} object. */ public final ArrayList getBasicSpells() { - ArrayList s = new ArrayList(getCharacteristics().getSpellAbility()); - ArrayList res = new ArrayList(); + final ArrayList s = new ArrayList(this.getCharacteristics().getSpellAbility()); + final ArrayList res = new ArrayList(); - for (SpellAbility sa : s) { + for (final SpellAbility sa : s) { if (sa.isSpell() && !sa.isFlashBackAbility() && !sa.isBuyBackAbility()) { res.add(sa); } @@ -2786,10 +2835,10 @@ public class Card extends GameEntity implements Comparable { * @return a {@link java.util.ArrayList} object. */ public final ArrayList getAdditionalCostSpells() { - ArrayList s = new ArrayList(getCharacteristics().getSpellAbility()); - ArrayList res = new ArrayList(); + final ArrayList s = new ArrayList(this.getCharacteristics().getSpellAbility()); + final ArrayList res = new ArrayList(); - for (SpellAbility sa : s) { + for (final SpellAbility sa : s) { if (sa.isSpell() && !sa.getAdditionalManaCost().equals("")) { res.add(sa); } @@ -2807,7 +2856,7 @@ public class Card extends GameEntity implements Comparable { * a int. */ public final void setShield(final int n) { - nShield = n; + this.nShield = n; } /** @@ -2818,7 +2867,7 @@ public class Card extends GameEntity implements Comparable { * @return a int. */ public final int getShield() { - return nShield; + return this.nShield; } /** @@ -2827,7 +2876,7 @@ public class Card extends GameEntity implements Comparable { *

*/ public final void addShield() { - nShield++; + this.nShield++; } /** @@ -2836,19 +2885,32 @@ public class Card extends GameEntity implements Comparable { *

*/ public final void subtractShield() { - nShield--; + this.nShield--; } - + + /** + * Adds the regenerated this turn. + */ public final void addRegeneratedThisTurn() { - regeneratedThisTurn += 1; + this.regeneratedThisTurn += 1; } - + + /** + * Gets the regenerated this turn. + * + * @return the regenerated this turn + */ public final int getRegeneratedThisTurn() { - return regeneratedThisTurn; + return this.regeneratedThisTurn; } - + + /** + * Sets the regenerated this turn. + * + * @param n the new regenerated this turn + */ public final void setRegeneratedThisTurn(final int n) { - regeneratedThisTurn = n; + this.regeneratedThisTurn = n; } /** @@ -2857,7 +2919,7 @@ public class Card extends GameEntity implements Comparable { *

*/ public final void resetShield() { - nShield = 0; + this.nShield = 0; } /** @@ -2868,7 +2930,7 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean canBeShielded() { - return !hasKeyword("CARDNAME can't be regenerated."); + return !this.hasKeyword("CARDNAME can't be regenerated."); } // is this "Card" supposed to be a token? @@ -2881,7 +2943,7 @@ public class Card extends GameEntity implements Comparable { * a boolean. */ public final void setToken(final boolean b) { - token = b; + this.token = b; } /** @@ -2892,7 +2954,7 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean isToken() { - return token; + return this.token; } /** @@ -2904,7 +2966,7 @@ public class Card extends GameEntity implements Comparable { * a boolean. */ public final void setCopiedToken(final boolean b) { - copiedToken = b; + this.copiedToken = b; } /** @@ -2915,7 +2977,7 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean isCopiedToken() { - return copiedToken; + return this.copiedToken; } /** @@ -2927,7 +2989,7 @@ public class Card extends GameEntity implements Comparable { * a boolean. */ public final void setCopiedSpell(final boolean b) { - copiedSpell = b; + this.copiedSpell = b; } /** @@ -2938,7 +3000,7 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean isCopiedSpell() { - return copiedSpell; + return this.copiedSpell; } /** @@ -2950,7 +3012,7 @@ public class Card extends GameEntity implements Comparable { * a {@link java.lang.String} object. */ public final void addSpellChoice(final String string) { - choicesMade.add(string); + this.choicesMade.add(string); } /** @@ -2961,7 +3023,7 @@ public class Card extends GameEntity implements Comparable { * @return a {@link java.util.ArrayList} object. */ public final ArrayList getChoices() { - return choicesMade; + return this.choicesMade; } /** @@ -2974,7 +3036,7 @@ public class Card extends GameEntity implements Comparable { * @return a {@link java.lang.String} object. */ public final String getChoice(final int i) { - return choicesMade.get(i); + return this.choicesMade.get(i); } /** @@ -2986,7 +3048,7 @@ public class Card extends GameEntity implements Comparable { * a {@link java.lang.String} object. */ public final void setSpellChoiceTarget(final String string) { - targetsForChoices.add(string); + this.targetsForChoices.add(string); } /** @@ -2997,7 +3059,7 @@ public class Card extends GameEntity implements Comparable { * @return a {@link java.util.ArrayList} object. */ public final ArrayList getChoiceTargets() { - return targetsForChoices; + return this.targetsForChoices; } /** @@ -3010,7 +3072,7 @@ public class Card extends GameEntity implements Comparable { * @return a {@link java.lang.String} object. */ public final String getChoiceTarget(final int i) { - return targetsForChoices.get(i); + return this.targetsForChoices.get(i); } /** @@ -3022,7 +3084,7 @@ public class Card extends GameEntity implements Comparable { * a boolean. */ public final void setSpellWithChoices(final boolean b) { - spellWithChoices = b; + this.spellWithChoices = b; } /** @@ -3033,7 +3095,7 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean hasChoices() { - return spellWithChoices; + return this.spellWithChoices; } /** @@ -3045,7 +3107,7 @@ public class Card extends GameEntity implements Comparable { * a boolean. */ public final void setCopiesSpells(final boolean b) { - spellCopyingCard = b; + this.spellCopyingCard = b; } /** @@ -3056,7 +3118,7 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean copiesSpells() { - return spellCopyingCard; + return this.spellCopyingCard; } /** @@ -3067,7 +3129,7 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean isFaceDown() { - return curCharacteristics.equals("FaceDown"); + return this.curCharacteristics.equals("FaceDown"); } /** @@ -3079,7 +3141,7 @@ public class Card extends GameEntity implements Comparable { * a boolean. */ public final void setCanMorph(final boolean b) { - canMorph = b; + this.canMorph = b; } /** @@ -3090,7 +3152,7 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean getCanMorph() { - return canMorph; + return this.canMorph; } /** @@ -3104,7 +3166,7 @@ public class Card extends GameEntity implements Comparable { * a {@link forge.ZCTrigger} object. */ public final void addTrigger(final Command c, final ZCTrigger typeIn) { - zcTriggers.add(new AbilityTriggered(this, c, typeIn)); + this.zcTriggers.add(new AbilityTriggered(this, c, typeIn)); } /** @@ -3118,7 +3180,7 @@ public class Card extends GameEntity implements Comparable { * a {@link forge.ZCTrigger} object. */ public final void removeTrigger(final Command c, final ZCTrigger typeIn) { - zcTriggers.remove(new AbilityTriggered(this, c, typeIn)); + this.zcTriggers.remove(new AbilityTriggered(this, c, typeIn)); } /** @@ -3130,7 +3192,7 @@ public class Card extends GameEntity implements Comparable { * a {@link forge.ZCTrigger} object. */ public final void executeTrigger(final ZCTrigger type) { - for (AbilityTriggered t : zcTriggers) { + for (final AbilityTriggered t : this.zcTriggers) { if (t.getTrigger().equals(type) && t.isBasic()) { t.execute(); } @@ -3143,7 +3205,7 @@ public class Card extends GameEntity implements Comparable { *

*/ public final void clearTriggers() { - zcTriggers.clear(); + this.zcTriggers.clear(); } /** @@ -3155,7 +3217,7 @@ public class Card extends GameEntity implements Comparable { * a {@link forge.Command} object. */ public final void addComesIntoPlayCommand(final Command c) { - addTrigger(c, ZCTrigger.ENTERFIELD); + this.addTrigger(c, ZCTrigger.ENTERFIELD); } /** @@ -3167,7 +3229,7 @@ public class Card extends GameEntity implements Comparable { * a {@link forge.Command} object. */ public final void removeComesIntoPlayCommand(final Command c) { - removeTrigger(c, ZCTrigger.ENTERFIELD); + this.removeTrigger(c, ZCTrigger.ENTERFIELD); } /** @@ -3176,7 +3238,7 @@ public class Card extends GameEntity implements Comparable { *

*/ public final void comesIntoPlay() { - executeTrigger(ZCTrigger.ENTERFIELD); + this.executeTrigger(ZCTrigger.ENTERFIELD); } /** @@ -3188,7 +3250,7 @@ public class Card extends GameEntity implements Comparable { * a {@link forge.Command} object. */ public final void addDestroyCommand(final Command c) { - addTrigger(c, ZCTrigger.DESTROY); + this.addTrigger(c, ZCTrigger.DESTROY); } /** @@ -3200,7 +3262,7 @@ public class Card extends GameEntity implements Comparable { * a {@link forge.Command} object. */ public final void removeDestroyCommand(final Command c) { - removeTrigger(c, ZCTrigger.DESTROY); + this.removeTrigger(c, ZCTrigger.DESTROY); } /** @@ -3209,7 +3271,7 @@ public class Card extends GameEntity implements Comparable { *

*/ public final void destroy() { - executeTrigger(ZCTrigger.DESTROY); + this.executeTrigger(ZCTrigger.DESTROY); } /** @@ -3221,7 +3283,7 @@ public class Card extends GameEntity implements Comparable { * a {@link forge.Command} object. */ public final void addLeavesPlayCommand(final Command c) { - addTrigger(c, ZCTrigger.LEAVEFIELD); + this.addTrigger(c, ZCTrigger.LEAVEFIELD); } /** @@ -3233,7 +3295,7 @@ public class Card extends GameEntity implements Comparable { * a {@link forge.Command} object. */ public final void removeLeavesPlayCommand(final Command c) { - removeTrigger(c, ZCTrigger.LEAVEFIELD); + this.removeTrigger(c, ZCTrigger.LEAVEFIELD); } /** @@ -3242,7 +3304,7 @@ public class Card extends GameEntity implements Comparable { *

*/ public final void leavesPlay() { - executeTrigger(ZCTrigger.LEAVEFIELD); + this.executeTrigger(ZCTrigger.LEAVEFIELD); } /** @@ -3254,7 +3316,7 @@ public class Card extends GameEntity implements Comparable { * a {@link forge.Command} object. */ public final void addEquipCommand(final Command c) { - equipCommandList.add(c); + this.equipCommandList.add(c); } /** @@ -3266,7 +3328,7 @@ public class Card extends GameEntity implements Comparable { * a {@link forge.Command} object. */ public final void removeEquipCommand(final Command c) { - equipCommandList.remove(c); + this.equipCommandList.remove(c); } /** @@ -3275,7 +3337,7 @@ public class Card extends GameEntity implements Comparable { *

*/ public final void equip() { - for (Command var : equipCommandList) { + for (final Command var : this.equipCommandList) { var.execute(); } } @@ -3289,7 +3351,7 @@ public class Card extends GameEntity implements Comparable { * a {@link forge.Command} object. */ public final void addUnEquipCommand(final Command c) { - unEquipCommandList.add(c); + this.unEquipCommandList.add(c); } /** @@ -3301,7 +3363,7 @@ public class Card extends GameEntity implements Comparable { * a {@link forge.Command} object. */ public final void removeUnEquipCommand(final Command c) { - unEquipCommandList.remove(c); + this.unEquipCommandList.remove(c); } /** @@ -3310,7 +3372,7 @@ public class Card extends GameEntity implements Comparable { *

*/ public final void unEquip() { - for (Command var : unEquipCommandList) { + for (final Command var : this.unEquipCommandList) { var.execute(); } } @@ -3324,7 +3386,7 @@ public class Card extends GameEntity implements Comparable { * a {@link forge.Command} object. */ public final void addEnchantCommand(final Command c) { - enchantCommandList.add(c); + this.enchantCommandList.add(c); } /** @@ -3333,7 +3395,7 @@ public class Card extends GameEntity implements Comparable { *

*/ public final void clearEnchantCommand() { - enchantCommandList.clear(); + this.enchantCommandList.clear(); } /** @@ -3342,7 +3404,7 @@ public class Card extends GameEntity implements Comparable { *

*/ public final void enchant() { - for (Command var : enchantCommandList) { + for (final Command var : this.enchantCommandList) { var.execute(); } } @@ -3356,7 +3418,7 @@ public class Card extends GameEntity implements Comparable { * a {@link forge.Command} object. */ public final void addUnEnchantCommand(final Command c) { - unEnchantCommandList.add(c); + this.unEnchantCommandList.add(c); } /** @@ -3365,7 +3427,7 @@ public class Card extends GameEntity implements Comparable { *

*/ public final void clearUnEnchantCommand() { - unEnchantCommandList.clear(); + this.unEnchantCommandList.clear(); } /** @@ -3374,7 +3436,7 @@ public class Card extends GameEntity implements Comparable { *

*/ public final void unEnchant() { - for (Command var : unEnchantCommandList) { + for (final Command var : this.unEnchantCommandList) { var.execute(); } } @@ -3388,7 +3450,7 @@ public class Card extends GameEntity implements Comparable { * a {@link forge.Command} object. */ public final void addUntapCommand(final Command c) { - untapCommandList.add(c); + this.untapCommandList.add(c); } /** @@ -3400,7 +3462,7 @@ public class Card extends GameEntity implements Comparable { * a {@link forge.Command} object. */ public final void addChangeControllerCommand(final Command c) { - changeControllerCommandList.add(c); + this.changeControllerCommandList.add(c); } /** @@ -3412,7 +3474,7 @@ public class Card extends GameEntity implements Comparable { * a boolean. */ public final void setSickness(final boolean b) { - sickness = b; + this.sickness = b; } /** @@ -3423,7 +3485,7 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean hasSickness() { - return !hasKeyword("Haste") && sickness; + return !this.hasKeyword("Haste") && this.sickness; } /** @@ -3433,7 +3495,7 @@ public class Card extends GameEntity implements Comparable { * @return boolean */ public final boolean isSick() { - return !hasKeyword("Haste") && sickness && isCreature(); + return !this.hasKeyword("Haste") && this.sickness && this.isCreature(); } /** @@ -3445,7 +3507,7 @@ public class Card extends GameEntity implements Comparable { * a {@link java.lang.String} object. */ public final void setImageName(final String s) { - getCharacteristics().setImageName(s); + this.getCharacteristics().setImageName(s); } /** @@ -3456,10 +3518,10 @@ public class Card extends GameEntity implements Comparable { * @return a {@link java.lang.String} object. */ public final String getImageName() { - if (!getCharacteristics().getImageName().equals("")) { - return getCharacteristics().getImageName(); + if (!this.getCharacteristics().getImageName().equals("")) { + return this.getCharacteristics().getImageName(); } - return getName(); + return this.getName(); } /** @@ -3470,7 +3532,7 @@ public class Card extends GameEntity implements Comparable { * @return a {@link forge.Player} object. */ public final Player getOwner() { - return owner; + return this.owner; } /** @@ -3479,10 +3541,10 @@ public class Card extends GameEntity implements Comparable { * @return a {@link forge.Player} object. */ public final Player getController() { - if (controllerObjects.size() == 0) { - return owner; + if (this.controllerObjects.size() == 0) { + return this.owner; } - Object topController = controllerObjects.get(controllerObjects.size() - 1); + final Object topController = this.controllerObjects.get(this.controllerObjects.size() - 1); if (topController instanceof Player) { return (Player) topController; } else { @@ -3498,28 +3560,28 @@ public class Card extends GameEntity implements Comparable { * an Object */ public final void addController(final Object controllerObject) { - Object prevController = controllerObjects.size() == 0 ? owner : controllerObjects - .get(controllerObjects.size() - 1); + final Object prevController = this.controllerObjects.size() == 0 ? this.owner : this.controllerObjects + .get(this.controllerObjects.size() - 1); if (!controllerObject.equals(prevController)) { if (controllerObject instanceof Player) { - for (int i = 0; i < controllerObjects.size(); i++) { - if (controllerObjects.get(i) instanceof Player) { - controllerObjects.remove(i); + for (int i = 0; i < this.controllerObjects.size(); i++) { + if (this.controllerObjects.get(i) instanceof Player) { + this.controllerObjects.remove(i); } } } - controllerObjects.add(controllerObject); - if (AllZone.getGameAction() != null && prevController != null) { + this.controllerObjects.add(controllerObject); + if ((AllZone.getGameAction() != null) && (prevController != null)) { AllZone.getGameAction().controllerChangeZoneCorrection(this); } if (prevController != null) { - for (Command c : changeControllerCommandList) { + for (final Command c : this.changeControllerCommandList) { c.execute(); } } - updateObservers(); + this.updateObservers(); } } @@ -3531,17 +3593,17 @@ public class Card extends GameEntity implements Comparable { * a Object */ public final void removeController(final Object controllerObject) { - Object currentController = getController(); - controllerObjects.remove(controllerObject); + final Object currentController = this.getController(); + this.controllerObjects.remove(controllerObject); - if (!currentController.equals(getController())) { + if (!currentController.equals(this.getController())) { AllZone.getGameAction().controllerChangeZoneCorrection(this); - for (Command c : changeControllerCommandList) { + for (final Command c : this.changeControllerCommandList) { c.execute(); } - updateObservers(); + this.updateObservers(); } } @@ -3550,7 +3612,7 @@ public class Card extends GameEntity implements Comparable { * TODO Write javadoc for this method. */ public final void clearControllers() { - controllerObjects.clear(); + this.controllerObjects.clear(); } /** @@ -3560,7 +3622,7 @@ public class Card extends GameEntity implements Comparable { * @return an ArrayList */ public final ArrayList getControllerObjects() { - return controllerObjects; + return this.controllerObjects; } /** @@ -3571,7 +3633,7 @@ public class Card extends GameEntity implements Comparable { * an Object */ public final void setControllerObjects(final ArrayList in) { - controllerObjects = in; + this.controllerObjects = in; } /** @@ -3583,7 +3645,7 @@ public class Card extends GameEntity implements Comparable { * a {@link forge.Player} object. */ public final void setOwner(final Player player) { - owner = player; + this.owner = player; this.updateObservers(); } @@ -3609,7 +3671,7 @@ public class Card extends GameEntity implements Comparable { * @return a {@link java.util.ArrayList} object. */ public final ArrayList getEquippedBy() { - return equippedBy; + return this.equippedBy; } /** @@ -3621,7 +3683,7 @@ public class Card extends GameEntity implements Comparable { * a {@link java.util.ArrayList} object. */ public final void setEquippedBy(final ArrayList list) { - equippedBy = list; + this.equippedBy = list; } /** @@ -3632,7 +3694,7 @@ public class Card extends GameEntity implements Comparable { * @return a {@link java.util.ArrayList} object. */ public final ArrayList getEquipping() { - return equipping; + return this.equipping; } /** @@ -3643,10 +3705,10 @@ public class Card extends GameEntity implements Comparable { * @return a {@link forge.Card} object. */ public final Card getEquippingCard() { - if (equipping.size() == 0) { + if (this.equipping.size() == 0) { return null; } - return equipping.get(0); + return this.equipping.get(0); } /** @@ -3658,7 +3720,7 @@ public class Card extends GameEntity implements Comparable { * a {@link java.util.ArrayList} object. */ public final void setEquipping(final ArrayList list) { - equipping = list; + this.equipping = list; } /** @@ -3669,7 +3731,7 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean isEquipped() { - return !equippedBy.isEmpty(); + return !this.equippedBy.isEmpty(); } /** @@ -3680,7 +3742,7 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean isEquipping() { - return equipping.size() != 0; + return this.equipping.size() != 0; } /** @@ -3692,7 +3754,7 @@ public class Card extends GameEntity implements Comparable { * a {@link forge.Card} object. */ public final void addEquippedBy(final Card c) { - equippedBy.add(c); + this.equippedBy.add(c); this.updateObservers(); } @@ -3705,7 +3767,7 @@ public class Card extends GameEntity implements Comparable { * a {@link forge.Card} object. */ public final void removeEquippedBy(final Card c) { - equippedBy.remove(c); + this.equippedBy.remove(c); this.updateObservers(); } @@ -3718,8 +3780,8 @@ public class Card extends GameEntity implements Comparable { * a {@link forge.Card} object. */ public final void addEquipping(final Card c) { - equipping.add(c); - setTimestamp(AllZone.getNextTimestamp()); + this.equipping.add(c); + this.setTimestamp(AllZone.getNextTimestamp()); this.updateObservers(); } @@ -3732,7 +3794,7 @@ public class Card extends GameEntity implements Comparable { * a {@link forge.Card} object. */ public final void removeEquipping(final Card c) { - equipping.remove(c); + this.equipping.remove(c); this.updateObservers(); } @@ -3746,7 +3808,7 @@ public class Card extends GameEntity implements Comparable { * a {@link forge.Card} object. */ public final void equipCard(final Card c) { - addEquipping(c); + this.addEquipping(c); c.addEquippedBy(this); this.equip(); } @@ -3762,11 +3824,11 @@ public class Card extends GameEntity implements Comparable { public final void unEquipCard(final Card c) // equipment.unEquipCard(equippedCard); { this.unEquip(); - equipping.remove(c); + this.equipping.remove(c); c.removeEquippedBy(this); // Run triggers - Map runParams = new TreeMap(); + final Map runParams = new TreeMap(); runParams.put("Equipment", this); runParams.put("Card", c); AllZone.getTriggerHandler().runTrigger("Unequip", runParams); @@ -3778,9 +3840,10 @@ public class Card extends GameEntity implements Comparable { *

*/ public final void unEquipAllCards() { - while (equippedBy.size() > 0) { // while there exists equipment, unequip - // the first one - equippedBy.get(0).unEquipCard(this); + while (this.equippedBy.size() > 0) { // while there exists equipment, + // unequip + // the first one + this.equippedBy.get(0).unEquipCard(this); } } @@ -3792,7 +3855,7 @@ public class Card extends GameEntity implements Comparable { * @return a {@link forge.GameEntity} object. */ public final GameEntity getEnchanting() { - return enchanting; + return this.enchanting; } /** @@ -3803,8 +3866,8 @@ public class Card extends GameEntity implements Comparable { * @return a {@link forge.Card} object. */ public final Card getEnchantingCard() { - if (enchanting != null && enchanting instanceof Card) { - return (Card) enchanting; + if ((this.enchanting != null) && (this.enchanting instanceof Card)) { + return (Card) this.enchanting; } return null; } @@ -3817,8 +3880,8 @@ public class Card extends GameEntity implements Comparable { * @return a {@link forge.Player} object. */ public final Player getEnchantingPlayer() { - if (enchanting != null && enchanting instanceof Player) { - return (Player) enchanting; + if ((this.enchanting != null) && (this.enchanting instanceof Player)) { + return (Player) this.enchanting; } return null; } @@ -3832,7 +3895,7 @@ public class Card extends GameEntity implements Comparable { * a GameEntity object. */ public final void setEnchanting(final GameEntity e) { - enchanting = e; + this.enchanting = e; } /** @@ -3843,7 +3906,7 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean isEnchanting() { - return enchanting != null; + return this.enchanting != null; } /** @@ -3854,7 +3917,7 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean isEnchantingCard() { - return getEnchantingCard() != null; + return this.getEnchantingCard() != null; } /** @@ -3865,7 +3928,7 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean isEnchantingPlayer() { - return getEnchantingPlayer() != null; + return this.getEnchantingPlayer() != null; } /** @@ -3877,8 +3940,8 @@ public class Card extends GameEntity implements Comparable { * false otherwise */ public final boolean isEnchantedBy(final String cardName) { - ArrayList allAuras = this.getEnchantedBy(); - for (Card aura : allAuras) { + final ArrayList allAuras = this.getEnchantedBy(); + for (final Card aura : allAuras) { if (aura.getName().equals(cardName)) { return true; } @@ -3895,8 +3958,8 @@ public class Card extends GameEntity implements Comparable { * a {@link forge.GameEntity} object. */ public final void addEnchanting(final GameEntity e) { - enchanting = e; - setTimestamp(AllZone.getNextTimestamp()); + this.enchanting = e; + this.setTimestamp(AllZone.getNextTimestamp()); this.updateObservers(); } @@ -3909,8 +3972,8 @@ public class Card extends GameEntity implements Comparable { * a {@link forge.GameEntity} object. */ public final void removeEnchanting(final GameEntity e) { - if (enchanting.equals(e)) { - enchanting = null; + if (this.enchanting.equals(e)) { + this.enchanting = null; this.updateObservers(); } } @@ -3924,7 +3987,7 @@ public class Card extends GameEntity implements Comparable { * a {@link forge.GameEntity} object. */ public final void enchantEntity(final GameEntity entity) { - addEnchanting(entity); + this.addEnchanting(entity); entity.addEnchantedBy(this); this.enchant(); } @@ -3938,9 +4001,9 @@ public class Card extends GameEntity implements Comparable { * a {@link forge.GameEntity} object. */ public final void unEnchantEntity(final GameEntity gameEntity) { - if (enchanting != null && enchanting.equals(gameEntity)) { + if ((this.enchanting != null) && this.enchanting.equals(gameEntity)) { this.unEnchant(); - enchanting = null; + this.enchanting = null; gameEntity.removeEnchantedBy(this); } } @@ -3954,8 +4017,8 @@ public class Card extends GameEntity implements Comparable { * @return an array of {@link forge.Card} objects. */ public final Card[] getAttachedCardsByMindsDesire() { - Card[] c = new Card[attachedByMindsDesire.size()]; - attachedByMindsDesire.toArray(c); + final Card[] c = new Card[this.attachedByMindsDesire.size()]; + this.attachedByMindsDesire.toArray(c); return c; } @@ -3967,7 +4030,7 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean hasAttachedCardsByMindsDesire() { - return getAttachedCardsByMindsDesire().length != 0; + return this.getAttachedCardsByMindsDesire().length != 0; } /** @@ -3979,7 +4042,7 @@ public class Card extends GameEntity implements Comparable { * a {@link forge.Card} object. */ public final void attachCardByMindsDesire(final Card c) { - attachedByMindsDesire.add(c); + this.attachedByMindsDesire.add(c); this.updateObservers(); } @@ -3992,7 +4055,7 @@ public class Card extends GameEntity implements Comparable { * a {@link forge.Card} object. */ public final void unattachCardByMindDesire(final Card c) { - attachedByMindsDesire.remove(c); + this.attachedByMindsDesire.remove(c); this.updateObservers(); } @@ -4005,7 +4068,7 @@ public class Card extends GameEntity implements Comparable { * a {@link java.util.ArrayList} object. */ public final void setType(final ArrayList a) { - getCharacteristics().setType(new ArrayList(a)); + this.getCharacteristics().setType(new ArrayList(a)); } /** @@ -4017,7 +4080,7 @@ public class Card extends GameEntity implements Comparable { * a {@link java.lang.String} object. */ public final void addType(final String a) { - getCharacteristics().getType().add(a); + this.getCharacteristics().getType().add(a); } /** @@ -4029,7 +4092,7 @@ public class Card extends GameEntity implements Comparable { * a {@link java.lang.String} object. */ public final void removeType(final String a) { - getCharacteristics().getType().remove(a); + this.getCharacteristics().getType().remove(a); } /** @@ -4042,20 +4105,20 @@ public class Card extends GameEntity implements Comparable { public final ArrayList getType() { // see if type changes are in effect - if (!changedCardTypes.isEmpty()) { + if (!this.changedCardTypes.isEmpty()) { - ArrayList newType = new ArrayList(getCharacteristics().getType()); - ArrayList types = changedCardTypes; + final ArrayList newType = new ArrayList(this.getCharacteristics().getType()); + final ArrayList types = this.changedCardTypes; Collections.sort(types); // sorts types by timeStamp - for (CardType ct : types) { - ArrayList removeTypes = new ArrayList(); + for (final CardType ct : types) { + final ArrayList removeTypes = new ArrayList(); if (ct.getRemoveType() != null) { removeTypes.addAll(ct.getRemoveType()); } // remove old types for (int i = 0; i < newType.size(); i++) { - String t = newType.get(i); + final String t = newType.get(i); if (ct.isRemoveSuperTypes() && CardUtil.isASuperType(t)) { removeTypes.add(t); } @@ -4081,7 +4144,7 @@ public class Card extends GameEntity implements Comparable { } // nothing changed - return new ArrayList(getCharacteristics().getType()); + return new ArrayList(this.getCharacteristics().getType()); } /** @@ -4092,7 +4155,7 @@ public class Card extends GameEntity implements Comparable { * a ArrayList */ public final void setChangedCardTypes(final ArrayList types) { - changedCardTypes = types; + this.changedCardTypes = types; } /** @@ -4102,7 +4165,7 @@ public class Card extends GameEntity implements Comparable { * @return ArrayList */ public final ArrayList getChangedCardTypes() { - return changedCardTypes; + return this.changedCardTypes; } /** @@ -4126,9 +4189,9 @@ public class Card extends GameEntity implements Comparable { */ public final void addChangedCardTypes(final ArrayList types, final ArrayList removeTypes, final boolean removeSuperTypes, final boolean removeCardTypes, final boolean removeSubTypes, - final boolean removeCreatureTypes, long timestamp) { + final boolean removeCreatureTypes, final long timestamp) { - changedCardTypes.add(new CardType(types, removeTypes, removeSuperTypes, removeCardTypes, removeSubTypes, + this.changedCardTypes.add(new CardType(types, removeTypes, removeSuperTypes, removeCardTypes, removeSubTypes, removeCreatureTypes, timestamp)); } @@ -4153,7 +4216,7 @@ public class Card extends GameEntity implements Comparable { */ public final void addChangedCardTypes(final String[] types, final String[] removeTypes, final boolean removeSuperTypes, final boolean removeCardTypes, final boolean removeSubTypes, - final boolean removeCreatureTypes, long timestamp) { + final boolean removeCreatureTypes, final long timestamp) { ArrayList typeList = null; ArrayList removeTypeList = null; if (types != null) { @@ -4164,7 +4227,7 @@ public class Card extends GameEntity implements Comparable { removeTypeList = new ArrayList(Arrays.asList(removeTypes)); } - addChangedCardTypes(typeList, removeTypeList, removeSuperTypes, removeCardTypes, removeSubTypes, + this.addChangedCardTypes(typeList, removeTypeList, removeSuperTypes, removeCardTypes, removeSubTypes, removeCreatureTypes, timestamp); } @@ -4175,11 +4238,11 @@ public class Card extends GameEntity implements Comparable { * @param timestamp * long */ - public final void removeChangedCardTypes(long timestamp) { - for (int i = 0; i < changedCardTypes.size(); i++) { - CardType cardT = changedCardTypes.get(i); + public final void removeChangedCardTypes(final long timestamp) { + for (int i = 0; i < this.changedCardTypes.size(); i++) { + final CardType cardT = this.changedCardTypes.get(i); if (cardT.getTimestamp() == timestamp) { - changedCardTypes.remove(cardT); + this.changedCardTypes.remove(cardT); } } } @@ -4192,9 +4255,9 @@ public class Card extends GameEntity implements Comparable { * @return a {@link java.util.ArrayList} object. */ public final ArrayList clearAllTypes() { - ArrayList originalTypes = new ArrayList(); - originalTypes.addAll(getCharacteristics().getType()); - getCharacteristics().getType().clear(); + final ArrayList originalTypes = new ArrayList(); + originalTypes.addAll(this.getCharacteristics().getType()); + this.getCharacteristics().getType().clear(); return originalTypes; } @@ -4207,7 +4270,7 @@ public class Card extends GameEntity implements Comparable { * a {@link java.util.ArrayList} object. */ public final void setPrevType(final ArrayList a) { - prevType = new ArrayList(a); + this.prevType = new ArrayList(a); } /** @@ -4219,7 +4282,7 @@ public class Card extends GameEntity implements Comparable { * a {@link java.lang.String} object. */ public final void addPrevType(final String a) { - prevType.add(a); + this.prevType.add(a); } /** @@ -4231,7 +4294,7 @@ public class Card extends GameEntity implements Comparable { * a {@link java.lang.String} object. */ public final void removePrevType(final String a) { - prevType.remove(a); + this.prevType.remove(a); } /** @@ -4242,7 +4305,7 @@ public class Card extends GameEntity implements Comparable { * @return a {@link java.util.ArrayList} object. */ public final ArrayList getPrevType() { - return new ArrayList(prevType); + return new ArrayList(this.prevType); } // values that are printed on card @@ -4254,7 +4317,7 @@ public class Card extends GameEntity implements Comparable { * @return a int. */ public final int getBaseLoyalty() { - return baseLoyalty; + return this.baseLoyalty; } // values that are printed on card @@ -4267,7 +4330,7 @@ public class Card extends GameEntity implements Comparable { * a int. */ public final void setBaseLoyalty(final int n) { - baseLoyalty = n; + this.baseLoyalty = n; } // values that are printed on card @@ -4279,7 +4342,7 @@ public class Card extends GameEntity implements Comparable { * @return a int. */ public final int getBaseAttack() { - return getCharacteristics().getBaseAttack(); + return this.getCharacteristics().getBaseAttack(); } /** @@ -4290,7 +4353,7 @@ public class Card extends GameEntity implements Comparable { * @return a int. */ public final int getBaseDefense() { - return getCharacteristics().getBaseDefense(); + return this.getCharacteristics().getBaseDefense(); } // values that are printed on card @@ -4303,7 +4366,7 @@ public class Card extends GameEntity implements Comparable { * a int. */ public final void setBaseAttack(final int n) { - getCharacteristics().setBaseAttack(n); + this.getCharacteristics().setBaseAttack(n); } /** @@ -4315,7 +4378,7 @@ public class Card extends GameEntity implements Comparable { * a int. */ public final void setBaseDefense(final int n) { - getCharacteristics().setBaseDefense(n); + this.getCharacteristics().setBaseDefense(n); } // values that are printed on card @@ -4327,7 +4390,7 @@ public class Card extends GameEntity implements Comparable { * @return a {@link java.lang.String} object. */ public final String getBaseAttackString() { - return (null == baseAttackString) ? "" + getBaseAttack() : baseAttackString; + return (null == this.baseAttackString) ? "" + this.getBaseAttack() : this.baseAttackString; } /** @@ -4338,7 +4401,7 @@ public class Card extends GameEntity implements Comparable { * @return a {@link java.lang.String} object. */ public final String getBaseDefenseString() { - return (null == baseDefenseString) ? "" + getBaseDefense() : baseDefenseString; + return (null == this.baseDefenseString) ? "" + this.getBaseDefense() : this.baseDefenseString; } // values that are printed on card @@ -4351,7 +4414,7 @@ public class Card extends GameEntity implements Comparable { * a {@link java.lang.String} object. */ public final void setBaseAttackString(final String s) { - baseAttackString = s; + this.baseAttackString = s; } /** @@ -4363,7 +4426,7 @@ public class Card extends GameEntity implements Comparable { * a {@link java.lang.String} object. */ public final void setBaseDefenseString(final String s) { - baseDefenseString = s; + this.baseDefenseString = s; } /** @@ -4374,7 +4437,7 @@ public class Card extends GameEntity implements Comparable { * ArrayList */ public final void setNewPT(final ArrayList pt) { - newPT = pt; + this.newPT = pt; } /** @@ -4384,7 +4447,7 @@ public class Card extends GameEntity implements Comparable { * @return ArrayList */ public final ArrayList getNewPT() { - return newPT; + return this.newPT; } /** @@ -4394,11 +4457,11 @@ public class Card extends GameEntity implements Comparable { * @return int */ public final int getSetPower() { - if (newPT.isEmpty()) { + if (this.newPT.isEmpty()) { return -1; } - CardPowerToughness latestPT = getLatestPT(); + final CardPowerToughness latestPT = this.getLatestPT(); return latestPT.getPower(); } @@ -4410,11 +4473,11 @@ public class Card extends GameEntity implements Comparable { * @return int */ public final int getSetToughness() { - if (newPT.isEmpty()) { + if (this.newPT.isEmpty()) { return -1; } - CardPowerToughness latestPT = getLatestPT(); + final CardPowerToughness latestPT = this.getLatestPT(); return latestPT.getToughness(); } @@ -4429,7 +4492,7 @@ public class Card extends GameEntity implements Comparable { CardPowerToughness latestPT = new CardPowerToughness(-1, -1, 0); long max = 0; - for (CardPowerToughness pt : newPT) { + for (final CardPowerToughness pt : this.newPT) { if (pt.getTimestamp() >= max) { max = pt.getTimestamp(); latestPT = pt; @@ -4450,8 +4513,8 @@ public class Card extends GameEntity implements Comparable { * @param timestamp * int */ - public final void addNewPT(final int power, final int toughness, long timestamp) { - newPT.add(new CardPowerToughness(power, toughness, timestamp)); + public final void addNewPT(final int power, final int toughness, final long timestamp) { + this.newPT.add(new CardPowerToughness(power, toughness, timestamp)); } /** @@ -4461,11 +4524,11 @@ public class Card extends GameEntity implements Comparable { * @param timestamp * long */ - public final void removeNewPT(long timestamp) { - for (int i = 0; i < newPT.size(); i++) { - CardPowerToughness cardPT = newPT.get(i); + public final void removeNewPT(final long timestamp) { + for (int i = 0; i < this.newPT.size(); i++) { + final CardPowerToughness cardPT = this.newPT.get(i); if (cardPT.getTimestamp() == timestamp) { - newPT.remove(cardPT); + this.newPT.remove(cardPT); } } } @@ -4477,8 +4540,8 @@ public class Card extends GameEntity implements Comparable { * @return int */ public final int getCurrentPower() { - int total = getBaseAttack(); - int setPower = getSetPower(); + int total = this.getBaseAttack(); + final int setPower = this.getSetPower(); if (setPower != -1) { total = setPower; } @@ -4494,15 +4557,12 @@ public class Card extends GameEntity implements Comparable { * @return a int. */ public final int getUnswitchedAttack() { - int total = getCurrentPower(); + int total = this.getCurrentPower(); - total += getTempAttackBoost() - + getSemiPermanentAttackBoost() - + getCounters(Counters.P1P1) - + getCounters(Counters.P1P2) - + getCounters(Counters.P1P0) - - getCounters(Counters.M1M1) - + (2 * getCounters(Counters.P2P2) - (2 * getCounters(Counters.M2M1)) - (2 * getCounters(Counters.M2M2)) - getCounters(Counters.M1M0)); + total += ((this.getTempAttackBoost() + this.getSemiPermanentAttackBoost() + this.getCounters(Counters.P1P1) + + this.getCounters(Counters.P1P2) + this.getCounters(Counters.P1P0)) - this.getCounters(Counters.M1M1)) + + ((2 * this.getCounters(Counters.P2P2)) - (2 * this.getCounters(Counters.M2M1)) + - (2 * this.getCounters(Counters.M2M2)) - this.getCounters(Counters.M1M0)); return total; } @@ -4514,10 +4574,10 @@ public class Card extends GameEntity implements Comparable { * @return a int. */ public final int getNetAttack() { - if (this.getAmountOfKeyword("CARDNAME's power and toughness are switched") % 2 != 0) { - return getUnswitchedDefense(); + if ((this.getAmountOfKeyword("CARDNAME's power and toughness are switched") % 2) != 0) { + return this.getUnswitchedDefense(); } else { - return getUnswitchedAttack(); + return this.getUnswitchedAttack(); } } @@ -4528,9 +4588,9 @@ public class Card extends GameEntity implements Comparable { * @return an int */ public final int getCurrentToughness() { - int total = getBaseDefense(); + int total = this.getBaseDefense(); - int setToughness = getSetToughness(); + final int setToughness = this.getSetToughness(); if (setToughness != -1) { total = setToughness; } @@ -4546,12 +4606,15 @@ public class Card extends GameEntity implements Comparable { * @return a int. */ public final int getUnswitchedDefense() { - int total = getCurrentToughness(); + int total = this.getCurrentToughness(); - total += getTempDefenseBoost() + getSemiPermanentDefenseBoost() + getCounters(Counters.P1P1) - + (2 * getCounters(Counters.P1P2)) - getCounters(Counters.M1M1) + getCounters(Counters.P0P1) - - (2 * getCounters(Counters.M0M2)) + (2 * getCounters(Counters.P2P2)) - getCounters(Counters.M0M1) - - getCounters(Counters.M2M1) - (2 * getCounters(Counters.M2M2)); + total += (((((this.getTempDefenseBoost() + this.getSemiPermanentDefenseBoost() + + this.getCounters(Counters.P1P1) + (2 * this.getCounters(Counters.P1P2))) - this + .getCounters(Counters.M1M1)) + this.getCounters(Counters.P0P1)) - (2 * this.getCounters(Counters.M0M2))) + (2 * this + .getCounters(Counters.P2P2))) + - this.getCounters(Counters.M0M1) + - this.getCounters(Counters.M2M1) + - (2 * this.getCounters(Counters.M2M2)); return total; } @@ -4563,10 +4626,10 @@ public class Card extends GameEntity implements Comparable { * @return a int. */ public final int getNetDefense() { - if (this.getAmountOfKeyword("CARDNAME's power and toughness are switched") % 2 != 0) { - return getUnswitchedAttack(); + if ((this.getAmountOfKeyword("CARDNAME's power and toughness are switched") % 2) != 0) { + return this.getUnswitchedAttack(); } else { - return getUnswitchedDefense(); + return this.getUnswitchedDefense(); } } @@ -4579,14 +4642,14 @@ public class Card extends GameEntity implements Comparable { * @return a int. */ public final int getNetCombatDamage() { - if (hasKeyword("CARDNAME assigns no combat damage")) { + if (this.hasKeyword("CARDNAME assigns no combat damage")) { return 0; } if (AllZoneUtil.isCardInPlay("Doran, the Siege Tower")) { - return getNetDefense(); + return this.getNetDefense(); } - return getNetAttack(); + return this.getNetAttack(); } /** @@ -4598,7 +4661,7 @@ public class Card extends GameEntity implements Comparable { * a int. */ public final void setRandomPicture(final int n) { - randomPicture = n; + this.randomPicture = n; } /** @@ -4609,7 +4672,7 @@ public class Card extends GameEntity implements Comparable { * @return a int. */ public final int getRandomPicture() { - return randomPicture; + return this.randomPicture; } /** @@ -4621,7 +4684,7 @@ public class Card extends GameEntity implements Comparable { * a int. */ public final void addMultiKickerMagnitude(final int n) { - multiKickerMagnitude += n; + this.multiKickerMagnitude += n; } /** @@ -4633,7 +4696,7 @@ public class Card extends GameEntity implements Comparable { * a int. */ public final void setMultiKickerMagnitude(final int n) { - multiKickerMagnitude = n; + this.multiKickerMagnitude = n; } /** @@ -4644,7 +4707,7 @@ public class Card extends GameEntity implements Comparable { * @return a int. */ public final int getMultiKickerMagnitude() { - return multiKickerMagnitude; + return this.multiKickerMagnitude; } /** @@ -4656,7 +4719,7 @@ public class Card extends GameEntity implements Comparable { * a int. */ public final void addReplicateMagnitude(final int n) { - replicateMagnitude += n; + this.replicateMagnitude += n; } /** @@ -4668,7 +4731,7 @@ public class Card extends GameEntity implements Comparable { * a int. */ public final void setReplicateMagnitude(final int n) { - replicateMagnitude = n; + this.replicateMagnitude = n; } /** @@ -4679,7 +4742,7 @@ public class Card extends GameEntity implements Comparable { * @return a int. */ public final int getReplicateMagnitude() { - return replicateMagnitude; + return this.replicateMagnitude; } // for cards like Giant Growth, etc. @@ -4691,7 +4754,7 @@ public class Card extends GameEntity implements Comparable { * @return a int. */ public final int getTempAttackBoost() { - return tempAttackBoost; + return this.tempAttackBoost; } /** @@ -4702,7 +4765,7 @@ public class Card extends GameEntity implements Comparable { * @return a int. */ public final int getTempDefenseBoost() { - return tempDefenseBoost; + return this.tempDefenseBoost; } /** @@ -4714,7 +4777,7 @@ public class Card extends GameEntity implements Comparable { * a int. */ public final void addTempAttackBoost(final int n) { - tempAttackBoost += n; + this.tempAttackBoost += n; } /** @@ -4726,7 +4789,7 @@ public class Card extends GameEntity implements Comparable { * a int. */ public final void addTempDefenseBoost(final int n) { - tempDefenseBoost += n; + this.tempDefenseBoost += n; } /** @@ -4738,7 +4801,7 @@ public class Card extends GameEntity implements Comparable { * a int. */ public final void setTempAttackBoost(final int n) { - tempAttackBoost = n; + this.tempAttackBoost = n; } /** @@ -4750,7 +4813,7 @@ public class Card extends GameEntity implements Comparable { * a int. */ public final void setTempDefenseBoost(final int n) { - tempDefenseBoost = n; + this.tempDefenseBoost = n; } // for cards like Glorious Anthem, etc. @@ -4762,7 +4825,7 @@ public class Card extends GameEntity implements Comparable { * @return a int. */ public final int getSemiPermanentAttackBoost() { - return semiPermanentAttackBoost; + return this.semiPermanentAttackBoost; } /** @@ -4773,7 +4836,7 @@ public class Card extends GameEntity implements Comparable { * @return a int. */ public final int getSemiPermanentDefenseBoost() { - return semiPermanentDefenseBoost; + return this.semiPermanentDefenseBoost; } /** @@ -4785,7 +4848,7 @@ public class Card extends GameEntity implements Comparable { * a int. */ public final void addSemiPermanentAttackBoost(final int n) { - semiPermanentAttackBoost += n; + this.semiPermanentAttackBoost += n; } /** @@ -4797,7 +4860,7 @@ public class Card extends GameEntity implements Comparable { * a int. */ public final void addSemiPermanentDefenseBoost(final int n) { - semiPermanentDefenseBoost += n; + this.semiPermanentDefenseBoost += n; } /** @@ -4809,7 +4872,7 @@ public class Card extends GameEntity implements Comparable { * a int. */ public final void setSemiPermanentAttackBoost(final int n) { - semiPermanentAttackBoost = n; + this.semiPermanentAttackBoost = n; } /** @@ -4821,7 +4884,7 @@ public class Card extends GameEntity implements Comparable { * a int. */ public final void setSemiPermanentDefenseBoost(final int n) { - semiPermanentDefenseBoost = n; + this.semiPermanentDefenseBoost = n; } /** @@ -4832,7 +4895,7 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean isUntapped() { - return !tapped; + return !this.tapped; } /** @@ -4843,7 +4906,7 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean isTapped() { - return tapped; + return this.tapped; } /** @@ -4855,8 +4918,8 @@ public class Card extends GameEntity implements Comparable { * a boolean. */ public final void setTapped(final boolean b) { - tapped = b; - updateObservers(); + this.tapped = b; + this.updateObservers(); } /** @@ -4865,13 +4928,13 @@ public class Card extends GameEntity implements Comparable { *

*/ public final void tap() { - if (isUntapped()) { + if (this.isUntapped()) { // Run triggers - Map runParams = new TreeMap(); + final Map runParams = new TreeMap(); runParams.put("Card", this); AllZone.getTriggerHandler().runTrigger("Taps", runParams); } - setTapped(true); + this.setTapped(true); } /** @@ -4880,19 +4943,19 @@ public class Card extends GameEntity implements Comparable { *

*/ public final void untap() { - if (isTapped()) { + if (this.isTapped()) { // Run triggers - Map runParams = new TreeMap(); + final Map runParams = new TreeMap(); runParams.put("Card", this); AllZone.getTriggerHandler().runTrigger("Untaps", runParams); } - for (Command var : untapCommandList) { + for (final Command var : this.untapCommandList) { var.execute(); } - setTapped(false); + this.setTapped(false); } // keywords are like flying, fear, first strike, etc... @@ -4904,8 +4967,8 @@ public class Card extends GameEntity implements Comparable { * @return a {@link java.util.ArrayList} object. */ public final ArrayList getKeyword() { - ArrayList keywords = getUnhiddenKeyword(); - ArrayList a4 = new ArrayList(getHiddenExtrinsicKeyword()); + final ArrayList keywords = this.getUnhiddenKeyword(); + final ArrayList a4 = new ArrayList(this.getHiddenExtrinsicKeyword()); keywords.addAll(a4); return keywords; @@ -4920,7 +4983,7 @@ public class Card extends GameEntity implements Comparable { */ public final int getKeywordAmount(final String keyword) { int res = 0; - for (String k : getKeyword()) { + for (final String k : this.getKeyword()) { if (k.equals(keyword)) { res++; } @@ -4936,7 +4999,7 @@ public class Card extends GameEntity implements Comparable { * the new changed card keywords */ public final void setChangedCardKeywords(final ArrayList kw) { - changedCardKeywords = kw; + this.changedCardKeywords = kw; } /** @@ -4945,7 +5008,7 @@ public class Card extends GameEntity implements Comparable { * @return the changed card keywords */ public final ArrayList getChangedCardKeywords() { - return changedCardKeywords; + return this.changedCardKeywords; } /** @@ -4961,9 +5024,9 @@ public class Card extends GameEntity implements Comparable { * the timestamp */ public final void addChangedCardKeywords(final ArrayList keywords, final ArrayList removeKeywords, - final boolean removeAllKeywords, long timestamp) { + final boolean removeAllKeywords, final long timestamp) { - changedCardKeywords.add(new CardKeywords(keywords, removeKeywords, removeAllKeywords, timestamp)); + this.changedCardKeywords.add(new CardKeywords(keywords, removeKeywords, removeAllKeywords, timestamp)); } /** @@ -4979,7 +5042,7 @@ public class Card extends GameEntity implements Comparable { * the timestamp */ public final void addChangedCardKeywords(final String[] keywords, final String[] removeKeywords, - final boolean removeAllKeywords, long timestamp) { + final boolean removeAllKeywords, final long timestamp) { ArrayList keywordsList = null; ArrayList removeKeywordsList = null; if (keywords != null) { @@ -4990,7 +5053,7 @@ public class Card extends GameEntity implements Comparable { removeKeywordsList = new ArrayList(Arrays.asList(removeKeywords)); } - addChangedCardKeywords(keywordsList, removeKeywordsList, removeAllKeywords, timestamp); + this.addChangedCardKeywords(keywordsList, removeKeywordsList, removeAllKeywords, timestamp); } /** @@ -4999,11 +5062,11 @@ public class Card extends GameEntity implements Comparable { * @param timestamp * the timestamp */ - public final void removeChangedCardKeywords(long timestamp) { - for (int i = 0; i < changedCardKeywords.size(); i++) { - CardKeywords cardK = changedCardKeywords.get(i); + public final void removeChangedCardKeywords(final long timestamp) { + for (int i = 0; i < this.changedCardKeywords.size(); i++) { + final CardKeywords cardK = this.changedCardKeywords.get(i); if (cardK.getTimestamp() == timestamp) { - changedCardKeywords.remove(cardK); + this.changedCardKeywords.remove(cardK); } } } @@ -5017,17 +5080,17 @@ public class Card extends GameEntity implements Comparable { * @return a {@link java.util.ArrayList} object. */ public final ArrayList getUnhiddenKeyword() { - ArrayList keywords = new ArrayList(getIntrinsicKeyword()); - ArrayList a2 = new ArrayList(getExtrinsicKeyword()); + final ArrayList keywords = new ArrayList(this.getIntrinsicKeyword()); + final ArrayList a2 = new ArrayList(this.getExtrinsicKeyword()); keywords.addAll(a2); // see if keyword changes are in effect - if (!changedCardKeywords.isEmpty()) { + if (!this.changedCardKeywords.isEmpty()) { - ArrayList newKeywords = changedCardKeywords; + final ArrayList newKeywords = this.changedCardKeywords; Collections.sort(newKeywords); // sorts newKeywords by timeStamp - for (CardKeywords ck : newKeywords) { + for (final CardKeywords ck : newKeywords) { if (ck.isRemoveAllKeywords()) { keywords.clear(); @@ -5053,7 +5116,7 @@ public class Card extends GameEntity implements Comparable { * @return a {@link java.util.ArrayList} object. */ public final ArrayList getIntrinsicAbilities() { - return getCharacteristics().getIntrinsicAbility(); + return this.getCharacteristics().getIntrinsicAbility(); } /** @@ -5064,7 +5127,7 @@ public class Card extends GameEntity implements Comparable { * @return a {@link java.util.ArrayList} object. */ public final ArrayList getIntrinsicKeyword() { - return new ArrayList(getCharacteristics().getIntrinsicKeyword()); + return new ArrayList(this.getCharacteristics().getIntrinsicKeyword()); } /** @@ -5073,7 +5136,7 @@ public class Card extends GameEntity implements Comparable { *

*/ public final void clearIntrinsicKeyword() { - getCharacteristics().getIntrinsicKeyword().clear(); + this.getCharacteristics().getIntrinsicKeyword().clear(); } /** @@ -5085,7 +5148,7 @@ public class Card extends GameEntity implements Comparable { * a {@link java.util.ArrayList} object. */ public final void setIntrinsicKeyword(final ArrayList a) { - getCharacteristics().setIntrinsicKeyword(new ArrayList(a)); + this.getCharacteristics().setIntrinsicKeyword(new ArrayList(a)); } /** @@ -5094,10 +5157,11 @@ public class Card extends GameEntity implements Comparable { *

*/ public final void clearAllKeywords() { - getCharacteristics().getIntrinsicKeyword().clear(); - extrinsicKeyword.clear(); - hiddenExtrinsicKeyword.clear(); // Hidden keywords won't be displayed on - // the card + this.getCharacteristics().getIntrinsicKeyword().clear(); + this.extrinsicKeyword.clear(); + this.hiddenExtrinsicKeyword.clear(); // Hidden keywords won't be + // displayed on + // the card } /** @@ -5109,7 +5173,7 @@ public class Card extends GameEntity implements Comparable { * a {@link java.util.ArrayList} object. */ public final void setIntrinsicAbilities(final ArrayList a) { - getCharacteristics().setIntrinsicAbility(new ArrayList(a)); + this.getCharacteristics().setIntrinsicAbility(new ArrayList(a)); } /** @@ -5122,7 +5186,7 @@ public class Card extends GameEntity implements Comparable { */ public final void addIntrinsicKeyword(final String s) { if (s.trim().length() != 0) { - getCharacteristics().getIntrinsicKeyword().add(s); + this.getCharacteristics().getIntrinsicKeyword().add(s); // intrinsicKeyword.add((getName().trim().length()== 0 ? s // :s.replaceAll(getName(), "CARDNAME"))); } @@ -5138,7 +5202,7 @@ public class Card extends GameEntity implements Comparable { */ public final void addIntrinsicAbility(final String s) { if (s.trim().length() != 0) { - getCharacteristics().getIntrinsicAbility().add(s); + this.getCharacteristics().getIntrinsicAbility().add(s); } } @@ -5151,9 +5215,9 @@ public class Card extends GameEntity implements Comparable { * a {@link java.lang.String} object. */ public final void addNonStackingIntrinsicKeyword(final String s) { - if (!getIntrinsicKeyword().contains(s) && s.trim().length() != 0) { - getCharacteristics().getIntrinsicKeyword().add( - (getName().trim().length() == 0 ? s : s.replaceAll(getName(), "CARDNAME"))); + if (!this.getIntrinsicKeyword().contains(s) && (s.trim().length() != 0)) { + this.getCharacteristics().getIntrinsicKeyword() + .add((this.getName().trim().length() == 0 ? s : s.replaceAll(this.getName(), "CARDNAME"))); } } @@ -5166,7 +5230,7 @@ public class Card extends GameEntity implements Comparable { * a {@link java.lang.String} object. */ public final void removeIntrinsicKeyword(final String s) { - getCharacteristics().getIntrinsicKeyword().remove(s); + this.getCharacteristics().getIntrinsicKeyword().remove(s); } /** @@ -5177,7 +5241,7 @@ public class Card extends GameEntity implements Comparable { * @return a int. */ public final int getIntrinsicKeywordSize() { - return getCharacteristics().getIntrinsicKeyword().size(); + return this.getCharacteristics().getIntrinsicKeyword().size(); } /** @@ -5188,7 +5252,7 @@ public class Card extends GameEntity implements Comparable { * @return a {@link java.util.ArrayList} object. */ public ArrayList getExtrinsicKeyword() { - return new ArrayList(extrinsicKeyword); + return new ArrayList(this.extrinsicKeyword); } /** @@ -5200,7 +5264,7 @@ public class Card extends GameEntity implements Comparable { * a {@link java.util.ArrayList} object. */ public final void setExtrinsicKeyword(final ArrayList a) { - extrinsicKeyword = new ArrayList(a); + this.extrinsicKeyword = new ArrayList(a); } /** @@ -5214,9 +5278,9 @@ public class Card extends GameEntity implements Comparable { public void addExtrinsicKeyword(final String s) { // if(!hasKeyword(s)){ if (s.startsWith("HIDDEN")) { - addHiddenExtrinsicKeyword(s); + this.addHiddenExtrinsicKeyword(s); } else { - extrinsicKeyword.add(s); + this.extrinsicKeyword.add(s); // extrinsicKeyword.add((getName().trim().length()==0 ? s // :s.replaceAll(getName(), "CARDNAME"))); // } @@ -5233,9 +5297,9 @@ public class Card extends GameEntity implements Comparable { */ public final void addStackingExtrinsicKeyword(final String s) { if (s.startsWith("HIDDEN")) { - addHiddenExtrinsicKeyword(s); + this.addHiddenExtrinsicKeyword(s); } else { - extrinsicKeyword.add(s); + this.extrinsicKeyword.add(s); } } @@ -5249,9 +5313,9 @@ public class Card extends GameEntity implements Comparable { */ public void removeExtrinsicKeyword(final String s) { if (s.startsWith("HIDDEN")) { - removeHiddenExtrinsicKeyword(s); + this.removeHiddenExtrinsicKeyword(s); } else { - extrinsicKeyword.remove(s); + this.extrinsicKeyword.remove(s); } } @@ -5263,7 +5327,7 @@ public class Card extends GameEntity implements Comparable { * @return a int. */ public int getExtrinsicKeywordSize() { - return extrinsicKeyword.size(); + return this.extrinsicKeyword.size(); } /** @@ -5274,7 +5338,7 @@ public class Card extends GameEntity implements Comparable { * @return a {@link java.util.ArrayList} object. */ public final ArrayList getPrevIntrinsicKeyword() { - return new ArrayList(prevIntrinsicKeyword); + return new ArrayList(this.prevIntrinsicKeyword); } /** @@ -5286,7 +5350,7 @@ public class Card extends GameEntity implements Comparable { * a {@link java.util.ArrayList} object. */ public final void setPrevIntrinsicKeyword(final ArrayList a) { - prevIntrinsicKeyword = new ArrayList(a); + this.prevIntrinsicKeyword = new ArrayList(a); this.updateObservers(); } @@ -5299,7 +5363,7 @@ public class Card extends GameEntity implements Comparable { * a {@link java.lang.String} object. */ public final void addPrevIntrinsicKeyword(final String s) { - prevIntrinsicKeyword.add(s); + this.prevIntrinsicKeyword.add(s); } /** @@ -5311,7 +5375,7 @@ public class Card extends GameEntity implements Comparable { * a {@link java.lang.String} object. */ public final void removePrevIntrinsicKeyword(final String s) { - prevIntrinsicKeyword.remove(s); + this.prevIntrinsicKeyword.remove(s); this.updateObservers(); } @@ -5323,7 +5387,7 @@ public class Card extends GameEntity implements Comparable { * @return a int. */ public final int getPrevIntrinsicKeywordSize() { - return prevIntrinsicKeyword.size(); + return this.prevIntrinsicKeyword.size(); } // Hidden Keywords will be returned without the indicator HIDDEN @@ -5335,9 +5399,9 @@ public class Card extends GameEntity implements Comparable { * @return a {@link java.util.ArrayList} object. */ public final ArrayList getHiddenExtrinsicKeyword() { - ArrayList keywords = new ArrayList(); - for (int i = 0; i < hiddenExtrinsicKeyword.size(); i++) { - String keyword = hiddenExtrinsicKeyword.get(i); + final ArrayList keywords = new ArrayList(); + for (int i = 0; i < this.hiddenExtrinsicKeyword.size(); i++) { + final String keyword = this.hiddenExtrinsicKeyword.get(i); keywords.add(keyword.substring(7)); } return keywords; @@ -5352,7 +5416,7 @@ public class Card extends GameEntity implements Comparable { * a {@link java.lang.String} object. */ public final void addHiddenExtrinsicKeyword(final String s) { - hiddenExtrinsicKeyword.add(s); + this.hiddenExtrinsicKeyword.add(s); } /** @@ -5364,7 +5428,7 @@ public class Card extends GameEntity implements Comparable { * a {@link java.lang.String} object. */ public final void removeHiddenExtrinsicKeyword(final String s) { - hiddenExtrinsicKeyword.remove(s); + this.hiddenExtrinsicKeyword.remove(s); // this.updateObservers(); } @@ -5377,7 +5441,7 @@ public class Card extends GameEntity implements Comparable { * a {@link java.util.ArrayList} object. */ public final void setStaticAbilityStrings(final ArrayList a) { - getCharacteristics().setStaticAbilityStrings(new ArrayList(a)); + this.getCharacteristics().setStaticAbilityStrings(new ArrayList(a)); } /** @@ -5386,7 +5450,7 @@ public class Card extends GameEntity implements Comparable { * @return the static ability strings */ public final ArrayList getStaticAbilityStrings() { - return getCharacteristics().getStaticAbilityStrings(); + return this.getCharacteristics().getStaticAbilityStrings(); } /** @@ -5399,7 +5463,7 @@ public class Card extends GameEntity implements Comparable { */ public final void addStaticAbilityString(final String s) { if (s.trim().length() != 0) { - getCharacteristics().getStaticAbilityStrings().add(s); + this.getCharacteristics().getStaticAbilityStrings().add(s); } } @@ -5410,7 +5474,7 @@ public class Card extends GameEntity implements Comparable { * the new static abilities */ public final void setStaticAbilities(final ArrayList a) { - getCharacteristics().setStaticAbilities(new ArrayList(a)); + this.getCharacteristics().setStaticAbilities(new ArrayList(a)); } /** @@ -5419,7 +5483,7 @@ public class Card extends GameEntity implements Comparable { * @return the static abilities */ public final ArrayList getStaticAbilities() { - return new ArrayList(getCharacteristics().getStaticAbilities()); + return new ArrayList(this.getCharacteristics().getStaticAbilities()); } /** @@ -5431,8 +5495,8 @@ public class Card extends GameEntity implements Comparable { public final void addStaticAbility(final String s) { if (s.trim().length() != 0) { - StaticAbility stAb = new StaticAbility(s, this); - getCharacteristics().getStaticAbilities().add(stAb); + final StaticAbility stAb = new StaticAbility(s, this); + this.getCharacteristics().getStaticAbilities().add(stAb); } } @@ -5444,7 +5508,7 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean isPermanent() { - return !(isInstant() || isSorcery() || isImmutable()); + return !(this.isInstant() || this.isSorcery() || this.isImmutable()); } /** @@ -5455,7 +5519,8 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean isSpell() { - return (isInstant() || isSorcery() || (isAura() && !AllZoneUtil.getCardsIn(Zone.Battlefield).contains(this))); + return (this.isInstant() || this.isSorcery() || (this.isAura() && !AllZoneUtil.getCardsIn(Zone.Battlefield) + .contains(this))); } /** @@ -5466,7 +5531,7 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean isCreature() { - return typeContains("Creature"); + return this.typeContains("Creature"); } /** @@ -5477,7 +5542,7 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean isWall() { - return typeContains("Wall"); + return this.typeContains("Wall"); } /** @@ -5488,7 +5553,7 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean isBasicLand() { - return typeContains("Basic"); + return this.typeContains("Basic"); } /** @@ -5499,7 +5564,7 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean isLand() { - return typeContains("Land"); + return this.typeContains("Land"); } /** @@ -5510,7 +5575,7 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean isSorcery() { - return typeContains("Sorcery"); + return this.typeContains("Sorcery"); } /** @@ -5521,7 +5586,7 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean isInstant() { - return typeContains("Instant"); + return this.typeContains("Instant"); } /** @@ -5532,7 +5597,7 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean isArtifact() { - return typeContains("Artifact"); + return this.typeContains("Artifact"); } /** @@ -5543,7 +5608,7 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean isEquipment() { - return typeContains("Equipment"); + return this.typeContains("Equipment"); } /** @@ -5554,7 +5619,7 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean isPlaneswalker() { - return typeContains("Planeswalker"); + return this.typeContains("Planeswalker"); } /** @@ -5565,7 +5630,7 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean isEmblem() { - return typeContains("Emblem"); + return this.typeContains("Emblem"); } /** @@ -5576,7 +5641,7 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean isTribal() { - return typeContains("Tribal"); + return this.typeContains("Tribal"); } /** @@ -5587,7 +5652,7 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean isSnow() { - return typeContains("Snow"); + return this.typeContains("Snow"); } // global and local enchantments @@ -5599,7 +5664,7 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean isEnchantment() { - return typeContains("Enchantment"); + return this.typeContains("Enchantment"); } /** @@ -5610,7 +5675,7 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean isAura() { - return typeContains("Aura"); + return this.typeContains("Aura"); } /** @@ -5621,11 +5686,11 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean isGlobalEnchantment() { - return typeContains("Enchantment") && (!isAura()); + return this.typeContains("Enchantment") && (!this.isAura()); } private boolean typeContains(final String s) { - Iterator it = this.getType().iterator(); + final Iterator it = this.getType().iterator(); while (it.hasNext()) { if (it.next().toString().startsWith(s)) { return true; @@ -5644,7 +5709,7 @@ public class Card extends GameEntity implements Comparable { * a int. */ public final void setUniqueNumber(final int n) { - uniqueNumber = n; + this.uniqueNumber = n; this.updateObservers(); } @@ -5656,7 +5721,7 @@ public class Card extends GameEntity implements Comparable { * @return a int. */ public final int getUniqueNumber() { - return uniqueNumber; + return this.uniqueNumber; } /** @@ -5668,7 +5733,7 @@ public class Card extends GameEntity implements Comparable { * a long. */ public final void setValue(final long n) { - value = n; + this.value = n; } /** @@ -5679,7 +5744,7 @@ public class Card extends GameEntity implements Comparable { * @return a long. */ public final long getValue() { - return value; + return this.value; } /** {@inheritDoc} */ @@ -5698,9 +5763,9 @@ public class Card extends GameEntity implements Comparable { * of null as being lowly." --Braids */ return +1; - } else if (getUniqueNumber() > that.getUniqueNumber()) { + } else if (this.getUniqueNumber() > that.getUniqueNumber()) { return +1; - } else if (getUniqueNumber() < that.getUniqueNumber()) { + } else if (this.getUniqueNumber() < that.getUniqueNumber()) { return -1; } else { return 0; @@ -5711,9 +5776,9 @@ public class Card extends GameEntity implements Comparable { @Override public final boolean equals(final Object o) { if (o instanceof Card) { - Card c = (Card) o; - int a = getUniqueNumber(); - int b = c.getUniqueNumber(); + final Card c = (Card) o; + final int a = this.getUniqueNumber(); + final int b = c.getUniqueNumber(); return (a == b); } return false; @@ -5722,7 +5787,7 @@ public class Card extends GameEntity implements Comparable { /** {@inheritDoc} */ @Override public final int hashCode() { - return getUniqueNumber(); + return this.getUniqueNumber(); } /** {@inheritDoc} */ @@ -5739,7 +5804,7 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean hasUnearth() { - return unearth; + return this.unearth; } /** @@ -5751,7 +5816,7 @@ public class Card extends GameEntity implements Comparable { * a boolean. */ public final void setUnearth(final boolean b) { - unearth = b; + this.unearth = b; } /** @@ -5762,7 +5827,7 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean isUnearthed() { - return unearthed; + return this.unearthed; } /** @@ -5774,7 +5839,7 @@ public class Card extends GameEntity implements Comparable { * a boolean. */ public final void setUnearthed(final boolean b) { - unearthed = b; + this.unearthed = b; } /** @@ -5785,7 +5850,7 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean hasMadness() { - return madness; + return this.madness; } /** @@ -5797,7 +5862,7 @@ public class Card extends GameEntity implements Comparable { * a boolean. */ public final void setMadness(final boolean b) { - madness = b; + this.madness = b; } /** @@ -5808,7 +5873,7 @@ public class Card extends GameEntity implements Comparable { * @return a {@link java.lang.String} object. */ public final String getMadnessCost() { - return madnessCost; + return this.madnessCost; } /** @@ -5820,7 +5885,7 @@ public class Card extends GameEntity implements Comparable { * a {@link java.lang.String} object. */ public final void setMadnessCost(final String cost) { - madnessCost = cost; + this.madnessCost = cost; } /** @@ -5831,7 +5896,7 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean hasSuspend() { - return suspend; + return this.suspend; } /** @@ -5843,7 +5908,7 @@ public class Card extends GameEntity implements Comparable { * a boolean. */ public final void setSuspend(final boolean b) { - suspend = b; + this.suspend = b; } /** @@ -5854,7 +5919,7 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean wasSuspendCast() { - return suspendCast; + return this.suspendCast; } /** @@ -5866,7 +5931,7 @@ public class Card extends GameEntity implements Comparable { * a boolean. */ public final void setSuspendCast(final boolean b) { - suspendCast = b; + this.suspendCast = b; } /** @@ -5878,7 +5943,7 @@ public class Card extends GameEntity implements Comparable { * a boolean. */ public final void setKicked(final boolean b) { - kicked = b; + this.kicked = b; } /** @@ -5889,7 +5954,7 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean isKicked() { - return kicked; + return this.kicked; } /** @@ -5898,7 +5963,7 @@ public class Card extends GameEntity implements Comparable { * @return true, if is phased out */ public final boolean isPhasedOut() { - return phasedOut; + return this.phasedOut; } /** @@ -5925,7 +5990,7 @@ public class Card extends GameEntity implements Comparable { * the direct */ public final void phase(final boolean direct) { - boolean phasingIn = this.isPhasedOut(); + final boolean phasingIn = this.isPhasedOut(); if (!this.switchPhaseState()) { // Switch Phase State returns False if the Permanent can't Phase Out @@ -5936,13 +6001,13 @@ public class Card extends GameEntity implements Comparable { this.setDirectlyPhasedOut(direct); } - for (Card eq : this.getEquippedBy()) { + for (final Card eq : this.getEquippedBy()) { if (eq.isPhasedOut() == phasingIn) { eq.phase(false); } } - for (Card aura : this.getEnchantedBy()) { + for (final Card aura : this.getEnchantedBy()) { if (aura.isPhasedOut() == phasingIn) { aura.phase(false); } @@ -5955,7 +6020,7 @@ public class Card extends GameEntity implements Comparable { } this.phasedOut = !this.phasedOut; - if (this.phasedOut && isToken()) { + if (this.phasedOut && this.isToken()) { // 702.23k Phased-out tokens cease to exist as a state-based action. // See rule 704.5d. // 702.23d The phasing event doesn't actually cause a permanent to @@ -6001,7 +6066,7 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean isReflectedLand() { - for (AbilityMana am : getCharacteristics().getManaAbility()) { + for (final AbilityMana am : this.getCharacteristics().getManaAbility()) { if (am.isReflectedMana()) { return true; } @@ -6019,12 +6084,13 @@ public class Card extends GameEntity implements Comparable { * a {@link java.lang.String} object. * @return a boolean. */ + @Override public final boolean hasKeyword(final String keyword) { String kw = new String(keyword); if (kw.startsWith("HIDDEN")) { kw = kw.substring(7); } - return getKeyword().contains(kw); + return this.getKeyword().contains(kw); } /** @@ -6037,7 +6103,7 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean hasStartOfKeyword(final String keyword) { - ArrayList a = getKeyword(); + final ArrayList a = this.getKeyword(); for (int i = 0; i < a.size(); i++) { if (a.get(i).toString().startsWith(keyword)) { return true; @@ -6056,7 +6122,7 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean hasStartOfUnHiddenKeyword(final String keyword) { - ArrayList a = this.getUnhiddenKeyword(); + final ArrayList a = this.getUnhiddenKeyword(); for (int i = 0; i < a.size(); i++) { if (a.get(i).toString().startsWith(keyword)) { return true; @@ -6075,7 +6141,7 @@ public class Card extends GameEntity implements Comparable { * @return a int. */ public final int getKeywordPosition(final String k) { - ArrayList a = getKeyword(); + final ArrayList a = this.getKeyword(); for (int i = 0; i < a.size(); i++) { if (a.get(i).toString().startsWith(k)) { return i; @@ -6094,7 +6160,7 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean keywordsContain(final String keyword) { - ArrayList a = getKeyword(); + final ArrayList a = this.getKeyword(); for (int i = 0; i < a.size(); i++) { if (a.get(i).toString().contains(keyword)) { return true; @@ -6113,8 +6179,8 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean hasAnyKeyword(final String[] keywords) { - for (int i = 0; i < keywords.length; i++) { - if (hasKeyword(keywords[i])) { + for (final String keyword : keywords) { + if (this.hasKeyword(keyword)) { return true; } } @@ -6133,7 +6199,7 @@ public class Card extends GameEntity implements Comparable { */ public final boolean hasAnyKeyword(final ArrayList keywords) { for (int i = 0; i < keywords.size(); i++) { - if (hasKeyword(keywords.get(i))) { + if (this.hasKeyword(keywords.get(i))) { return true; } } @@ -6153,7 +6219,7 @@ public class Card extends GameEntity implements Comparable { */ public final int getAmountOfKeyword(final String k) { int count = 0; - ArrayList keywords = getKeyword(); + final ArrayList keywords = this.getKeyword(); for (int j = 0; j < keywords.size(); j++) { if (keywords.get(j).equals(k)) { count++; @@ -6176,11 +6242,11 @@ public class Card extends GameEntity implements Comparable { */ public final int getKeywordMagnitude(final String k) { int count = 0; - ArrayList keywords = getKeyword(); - for (String kw : keywords) { + final ArrayList keywords = this.getKeyword(); + for (final String kw : keywords) { if (kw.startsWith(k)) { - String[] parse = kw.split(" "); - String s = parse[1]; + final String[] parse = kw.split(" "); + final String s = parse[1]; count += Integer.parseInt(s); } } @@ -6191,9 +6257,9 @@ public class Card extends GameEntity implements Comparable { if (s.equals("")) { return s; } - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); // to handle hyphenated Types - String[] types = s.split("-"); + final String[] types = s.split("-"); for (int i = 0; i < types.length; i++) { if (i != 0) { sb.append("-"); @@ -6216,10 +6282,11 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean isType(String cardType) { - cardType = toMixedCase(cardType); + cardType = this.toMixedCase(cardType); - if (typeContains(cardType) - || ((isCreature() || isTribal()) && CardUtil.isACreatureType(cardType) && typeContains("AllCreatureTypes"))) { + if (this.typeContains(cardType) + || ((this.isCreature() || this.isTribal()) && CardUtil.isACreatureType(cardType) && this + .typeContains("AllCreatureTypes"))) { return true; } return false; @@ -6242,29 +6309,31 @@ public class Card extends GameEntity implements Comparable { @Override public final boolean isValid(final String restriction, final Player sourceController, final Card source) { - if (getName().equals("Mana Pool") || isImmutable()) { + if (this.getName().equals("Mana Pool") || this.isImmutable()) { return false; } - String[] incR = restriction.split("\\.", 2); // Inclusive restrictions are - // Card types + final String[] incR = restriction.split("\\.", 2); // Inclusive + // restrictions are + // Card types - if (incR[0].equals("Spell") && !isSpell()) { + if (incR[0].equals("Spell") && !this.isSpell()) { return false; } - if (incR[0].equals("Permanent") && (isInstant() || isSorcery())) { + if (incR[0].equals("Permanent") && (this.isInstant() || this.isSorcery())) { return false; } if (!incR[0].equals("card") && !incR[0].equals("Card") && !incR[0].equals("Spell") - && !incR[0].equals("Permanent") && !(isType(incR[0]))) { + && !incR[0].equals("Permanent") && !(this.isType(incR[0]))) { return false; // Check for wrong type } if (incR.length > 1) { final String excR = incR[1]; - String[] exR = excR.split("\\+"); // Exclusive Restrictions are ... + final String[] exR = excR.split("\\+"); // Exclusive Restrictions + // are ... for (int j = 0; j < exR.length; j++) { - if (!hasProperty(exR[j], sourceController, source)) { + if (!this.hasProperty(exR[j], sourceController, source)) { return false; } } @@ -6290,19 +6359,19 @@ public class Card extends GameEntity implements Comparable { public boolean hasProperty(final String property, final Player sourceController, final Card source) { // by name can also have color names, so needs to happen before colors. if (property.startsWith("named")) { - if (!getName().equals(property.substring(5))) { + if (!this.getName().equals(property.substring(5))) { return false; } } else if (property.startsWith("notnamed")) { - if (getName().equals(property.substring(8))) { + if (this.getName().equals(property.substring(8))) { return false; } } else if (property.startsWith("sameName")) { - if (!getName().equals(source.getName())) { + if (!this.getName().equals(source.getName())) { return false; } } else if (property.equals("NamedCard")) { - if (!getName().equals(source.getNamedCard())) { + if (!this.getName().equals(source.getNamedCard())) { return false; } } @@ -6326,10 +6395,10 @@ public class Card extends GameEntity implements Comparable { } } else if (property.contains("MonoColor")) { // ... Card is monocolored - if (property.startsWith("non") && (CardUtil.getColors(this).size() == 1 && !isColorless())) { + if (property.startsWith("non") && ((CardUtil.getColors(this).size() == 1) && !this.isColorless())) { return false; } - if (!property.startsWith("non") && (CardUtil.getColors(this).size() > 1 || isColorless())) { + if (!property.startsWith("non") && ((CardUtil.getColors(this).size() > 1) || this.isColorless())) { return false; } } else if (property.equals("ChosenColor")) { @@ -6342,45 +6411,45 @@ public class Card extends GameEntity implements Comparable { return false; } } else if (property.equals("DoubleFaced")) { - if (!isDoubleFaced) { + if (!this.isDoubleFaced) { return false; } } else if (property.equals("Flip")) { - if (!isFlip) { + if (!this.isFlip) { return false; } } else if (property.startsWith("YouCtrl")) { - if (!getController().isPlayer(sourceController)) { + if (!this.getController().isPlayer(sourceController)) { return false; } } else if (property.startsWith("YouDontCtrl")) { - if (getController().isPlayer(sourceController)) { + if (this.getController().isPlayer(sourceController)) { return false; } } else if (property.startsWith("EnchantedPlayerCtrl")) { - Object o = source.getEnchanting(); + final Object o = source.getEnchanting(); if (o instanceof Player) { - if (!getController().isPlayer((Player) o)) { + if (!this.getController().isPlayer((Player) o)) { return false; } } else { // source not enchanting a player return false; } } else if (property.startsWith("YouOwn")) { - if (!getOwner().isPlayer(sourceController)) { + if (!this.getOwner().isPlayer(sourceController)) { return false; } } else if (property.startsWith("YouDontOwn")) { - if (getOwner().isPlayer(sourceController)) { + if (this.getOwner().isPlayer(sourceController)) { return false; } } else if (property.startsWith("OwnerDoesntControl")) { - if (getOwner().isPlayer(getController())) { + if (this.getOwner().isPlayer(this.getController())) { return false; } } else if (property.startsWith("ControllerControls")) { - String type = property.substring(18); - CardList list = getController().getCardsIn(Zone.Battlefield); + final String type = property.substring(18); + final CardList list = this.getController().getCardsIn(Zone.Battlefield); if (list.getType(type).isEmpty()) { return false; } @@ -6393,51 +6462,52 @@ public class Card extends GameEntity implements Comparable { return false; } } else if (property.startsWith("AttachedBy")) { - if (!equippedBy.contains(source) && !getEnchantedBy().contains(source)) { + if (!this.equippedBy.contains(source) && !this.getEnchantedBy().contains(source)) { return false; } } else if (property.equals("Attached")) { - if (!equipping.contains(source) && !source.equals(enchanting)) { + if (!this.equipping.contains(source) && !source.equals(this.enchanting)) { return false; } } else if (property.startsWith("AttachedTo")) { - String restriction = property.split("AttachedTo ")[1]; - if ((enchanting == null || !enchanting.isValid(restriction, sourceController, source)) - && (equipping.isEmpty() || equipping.get(0).isValid(restriction, sourceController, source))) { + final String restriction = property.split("AttachedTo ")[1]; + if (((this.enchanting == null) || !this.enchanting.isValid(restriction, sourceController, source)) + && (this.equipping.isEmpty() || this.equipping.get(0) + .isValid(restriction, sourceController, source))) { return false; } } else if (property.startsWith("EnchantedBy")) { - if (!getEnchantedBy().contains(source)) { + if (!this.getEnchantedBy().contains(source)) { return false; } } else if (property.startsWith("NotEnchantedBy")) { - if (getEnchantedBy().contains(source)) { + if (this.getEnchantedBy().contains(source)) { return false; } } else if (property.startsWith("Enchanted")) { - if (!source.equals(enchanting)) { + if (!source.equals(this.enchanting)) { return false; } } else if (property.startsWith("EquippedBy")) { - if (!equippedBy.contains(source)) { + if (!this.equippedBy.contains(source)) { return false; } } else if (property.startsWith("Equipped")) { - if (!equipping.contains(source)) { + if (!this.equipping.contains(source)) { return false; } } else if (property.startsWith("HauntedBy")) { - if (!hauntedBy.contains(source)) { + if (!this.hauntedBy.contains(source)) { return false; } } else if (property.startsWith("Above")) { // "Are Above" Source - CardList list = this.getOwner().getCardsIn(Zone.Graveyard); + final CardList list = this.getOwner().getCardsIn(Zone.Graveyard); if (!list.getAbove(source, this)) { return false; } } else if (property.startsWith("DirectlyAbove")) { // "Are Directly Above" // Source - CardList list = this.getOwner().getCardsIn(Zone.Graveyard); + final CardList list = this.getOwner().getCardsIn(Zone.Graveyard); if (!list.getDirectlyAbove(source, this)) { return false; } @@ -6449,58 +6519,58 @@ public class Card extends GameEntity implements Comparable { return false; } } else if (property.startsWith("TopGraveyard")) { - CardList list = this.getOwner().getCardsIn(Zone.Graveyard); + final CardList list = this.getOwner().getCardsIn(Zone.Graveyard); list.reverse(); if (list.isEmpty() || !this.equals(list.get(0))) { return false; } } else if (property.startsWith("TopLibrary")) { - CardList list = this.getOwner().getCardsIn(Zone.Library); + final CardList list = this.getOwner().getCardsIn(Zone.Library); if (list.isEmpty() || !this.equals(list.get(0))) { return false; } } else if (property.startsWith("Cloned")) { - if (cloneOrigin == null || !cloneOrigin.equals(source)) { + if ((this.cloneOrigin == null) || !this.cloneOrigin.equals(source)) { return false; } } else if (property.startsWith("DamagedBy")) { - if (!receivedDamageFromThisTurn.containsKey(source)) { + if (!this.receivedDamageFromThisTurn.containsKey(source)) { return false; } } else if (property.startsWith("Damaged")) { - if (!dealtDamageToThisTurn.containsKey(source)) { + if (!this.dealtDamageToThisTurn.containsKey(source)) { return false; } } else if (property.startsWith("SharesColorWith")) { if (property.equals("SharesColorWith")) { - if(!sharesColorWith(source)) { + if (!this.sharesColorWith(source)) { return false; } } else { - String restriction = property.split("SharesColorWith ")[1]; + final String restriction = property.split("SharesColorWith ")[1]; if (restriction.equals("TopCardOfLibrary")) { - CardList list = sourceController.getCardsIn(Zone.Library); - if (list.isEmpty() || !sharesColorWith(list.get(0))) { + final CardList list = sourceController.getCardsIn(Zone.Library); + if (list.isEmpty() || !this.sharesColorWith(list.get(0))) { return false; } } else { boolean shares = false; - for (Card card : sourceController.getCardsIn(Constant.Zone.Battlefield)) { - if (card.isValid(restriction, sourceController, source) && sharesColorWith(card)) { + for (final Card card : sourceController.getCardsIn(Constant.Zone.Battlefield)) { + if (card.isValid(restriction, sourceController, source) && this.sharesColorWith(card)) { shares = true; } } - if(!shares) { + if (!shares) { return false; } } } } else if (property.startsWith("withFlashback")) { boolean fb = false; - if (hasStartOfUnHiddenKeyword("Flashback")) { + if (this.hasStartOfUnHiddenKeyword("Flashback")) { fb = true; } - for (SpellAbility sa : this.getSpellAbilities()) { + for (final SpellAbility sa : this.getSpellAbilities()) { if (sa.isFlashBackAbility()) { fb = true; } @@ -6510,125 +6580,123 @@ public class Card extends GameEntity implements Comparable { } } else if (property.startsWith("with")) { // ... Card keywords - if (property.startsWith("without") && hasStartOfUnHiddenKeyword(property.substring(7))) { + if (property.startsWith("without") && this.hasStartOfUnHiddenKeyword(property.substring(7))) { return false; } - if (!property.startsWith("without") && !hasStartOfUnHiddenKeyword(property.substring(4))) { + if (!property.startsWith("without") && !this.hasStartOfUnHiddenKeyword(property.substring(4))) { return false; } } else if (property.startsWith("tapped")) { - if (!isTapped()) { + if (!this.isTapped()) { return false; } } else if (property.startsWith("untapped")) { - if (!isUntapped()) { + if (!this.isUntapped()) { return false; } } else if (property.startsWith("faceDown")) { - if (!isFaceDown()) { + if (!this.isFaceDown()) { return false; } } else if (property.startsWith("faceUp")) { - if (isFaceDown()) { + if (this.isFaceDown()) { return false; } } else if (property.startsWith("hasLevelUp")) { - if (!hasLevelUp()) { + if (!this.hasLevelUp()) { return false; } } else if (property.startsWith("enteredBattlefieldThisTurn")) { - if (!(getTurnInZone() == AllZone.getPhase().getTurn())) { + if (!(this.getTurnInZone() == AllZone.getPhase().getTurn())) { return false; } } else if (property.startsWith("dealtDamageToYouThisTurn")) { - if (!(dealtDmgToHumanThisTurn && getController().isPlayer(AllZone.getComputerPlayer())) - && !(dealtDmgToComputerThisTurn && getController().isPlayer(AllZone.getHumanPlayer()))) { + if (!(this.dealtDmgToHumanThisTurn && this.getController().isPlayer(AllZone.getComputerPlayer())) + && !(this.dealtDmgToComputerThisTurn && this.getController().isPlayer(AllZone.getHumanPlayer()))) { return false; } } else if (property.startsWith("wasDealtDamageThisTurn")) { - if ((getReceivedDamageFromThisTurn().keySet()).isEmpty()) { + if ((this.getReceivedDamageFromThisTurn().keySet()).isEmpty()) { return false; } } else if (property.startsWith("greatestPower")) { - CardList list = AllZoneUtil.getCreaturesInPlay(); - for (Card crd : list) { - if (crd.getNetAttack() > getNetAttack()) { + final CardList list = AllZoneUtil.getCreaturesInPlay(); + for (final Card crd : list) { + if (crd.getNetAttack() > this.getNetAttack()) { return false; } } } else if (property.startsWith("leastPower")) { - CardList list = AllZoneUtil.getCreaturesInPlay(); - for (Card crd : list) { - if (crd.getNetAttack() < getNetAttack()) { + final CardList list = AllZoneUtil.getCreaturesInPlay(); + for (final Card crd : list) { + if (crd.getNetAttack() < this.getNetAttack()) { return false; } } } else if (property.startsWith("greatestCMC")) { - CardList list = AllZoneUtil.getCreaturesInPlay(); - for (Card crd : list) { - if (crd.getCMC() > getCMC()) { + final CardList list = AllZoneUtil.getCreaturesInPlay(); + for (final Card crd : list) { + if (crd.getCMC() > this.getCMC()) { return false; } } } else if (property.startsWith("enchanted")) { - if (!isEnchanted()) { + if (!this.isEnchanted()) { return false; } } else if (property.startsWith("unenchanted")) { - if (isEnchanted()) { + if (this.isEnchanted()) { return false; } } else if (property.startsWith("enchanting")) { - if (!isEnchanting()) { + if (!this.isEnchanting()) { return false; } } else if (property.startsWith("equipped")) { - if (!isEquipped()) { + if (!this.isEquipped()) { return false; } } else if (property.startsWith("unequipped")) { - if (isEquipped()) { + if (this.isEquipped()) { return false; } } else if (property.startsWith("equipping")) { - if (!isEquipping()) { + if (!this.isEquipping()) { return false; } } else if (property.startsWith("token")) { - if (!isToken()) { + if (!this.isToken()) { return false; } } else if (property.startsWith("nonToken")) { - if (isToken()) { + if (this.isToken()) { return false; } } else if (property.startsWith("hasXCost")) { - if (getSpellAbility().length > 0) { - if (!getSpellAbility()[0].isXCost()) { + if (this.getSpellAbility().length > 0) { + if (!this.getSpellAbility()[0].isXCost()) { return false; } } - } else if (property.startsWith("power") - || property.startsWith("toughness") - || property.startsWith("cmc")) { + } else if (property.startsWith("power") || property.startsWith("toughness") || property.startsWith("cmc")) { int x = 0; int y = 0; String rhs = ""; if (property.startsWith("power")) { rhs = property.substring(7); - y = getNetAttack(); + y = this.getNetAttack(); } else if (property.startsWith("toughness")) { rhs = property.substring(11); - y = getNetDefense(); + y = this.getNetDefense(); } else if (property.startsWith("cmc")) { - rhs = property.substring(5); - y = getCMC(); + rhs = property.substring(5); + y = this.getCMC(); } try { x = Integer.parseInt(rhs); - } catch (NumberFormatException e) { + } catch (final NumberFormatException e) { x = CardFactoryUtil.xCount(source, source.getSVar(rhs)); } @@ -6657,40 +6725,40 @@ public class Card extends GameEntity implements Comparable { // TODO get a working regex out of this pattern so the amount of // digits doesn't matter int number = 0; - String[] splitProperty = property.split("_"); - String strNum = splitProperty[1].substring(2); - String comparator = splitProperty[1].substring(0, 2); + final String[] splitProperty = property.split("_"); + final String strNum = splitProperty[1].substring(2); + final String comparator = splitProperty[1].substring(0, 2); String counterType = ""; try { number = Integer.parseInt(strNum); - } catch (NumberFormatException e) { + } catch (final NumberFormatException e) { number = CardFactoryUtil.xCount(source, source.getSVar(strNum)); } counterType = splitProperty[2]; - int actualnumber = getCounters(Counters.getType(counterType)); + final int actualnumber = this.getCounters(Counters.getType(counterType)); if (!AllZoneUtil.compare(actualnumber, comparator, number)) { return false; } } else if (property.startsWith("attacking")) { - if (!isAttacking()) { + if (!this.isAttacking()) { return false; } } else if (property.startsWith("notattacking")) { - if (isAttacking()) { + if (this.isAttacking()) { return false; } } else if (property.equals("blocking")) { - if (!isBlocking()) { + if (!this.isBlocking()) { return false; } } else if (property.startsWith("blockingSource")) { - if (!isBlocking(source)) { + if (!this.isBlocking(source)) { return false; } } else if (property.startsWith("notblocking")) { - if (isBlocking()) { + if (this.isBlocking()) { return false; } } else if (property.equals("blocked")) { @@ -6698,7 +6766,7 @@ public class Card extends GameEntity implements Comparable { return false; } } else if (property.startsWith("blockedBySource")) { - if (!isBlockedBy(source)) { + if (!this.isBlockedBy(source)) { return false; } } else if (property.startsWith("unblocked")) { @@ -6706,32 +6774,32 @@ public class Card extends GameEntity implements Comparable { return false; } } else if (property.startsWith("kicked")) { - if (!isKicked()) { + if (!this.isKicked()) { return false; } } else if (property.startsWith("notkicked")) { - if (isKicked()) { + if (this.isKicked()) { return false; } } else if (property.startsWith("evoked")) { - if (!isEvoked()) { + if (!this.isEvoked()) { return false; } } else if (property.equals("HasDevoured")) { - if (devouredCards.size() == 0) { + if (this.devouredCards.size() == 0) { return false; } } else if (property.equals("HasNotDevoured")) { - if (devouredCards.size() != 0) { + if (this.devouredCards.size() != 0) { return false; } } else if (property.startsWith("non")) { // ... Other Card types - if (isType(property.substring(3))) { + if (this.isType(property.substring(3))) { return false; } } else if (property.equals("CostsPhyrexianMana")) { - if (!getCharacteristics().getManaCost().contains("P")) { + if (!this.getCharacteristics().getManaCost().contains("P")) { return false; } } else if (property.equals("IsRemembered")) { @@ -6740,8 +6808,8 @@ public class Card extends GameEntity implements Comparable { } } else if (property.equals("SameNameAsImprinted")) { boolean b = false; - for (Card card : source.getImprinted()) { - if (getName().equals(card.getName())) { + for (final Card card : source.getImprinted()) { + if (this.getName().equals(card.getName())) { b = true; } } @@ -6750,11 +6818,11 @@ public class Card extends GameEntity implements Comparable { } } else { if (property.equals("ChosenType")) { - if (!isType(source.getChosenType())) { + if (!this.isType(source.getChosenType())) { return false; } } else { - if (!isType(property)) { + if (!this.isType(property)) { return false; } } @@ -6782,7 +6850,7 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean isImmutable() { - return isImmutable; + return this.isImmutable; } /* @@ -6880,11 +6948,11 @@ public class Card extends GameEntity implements Comparable { */ public final boolean sharesColorWith(final Card c1) { boolean shares = false; - shares |= (isBlack() && c1.isBlack()); - shares |= (isBlue() && c1.isBlue()); - shares |= (isGreen() && c1.isGreen()); - shares |= (isRed() && c1.isRed()); - shares |= (isWhite() && c1.isWhite()); + shares |= (this.isBlack() && c1.isBlack()); + shares |= (this.isBlue() && c1.isBlue()); + shares |= (this.isGreen() && c1.isGreen()); + shares |= (this.isRed() && c1.isRed()); + shares |= (this.isWhite() && c1.isWhite()); return shares; } @@ -6907,7 +6975,7 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean isBlocking() { - CardList blockers = AllZone.getCombat().getAllBlockers(); + final CardList blockers = AllZone.getCombat().getAllBlockers(); return blockers.contains(this); } @@ -6955,8 +7023,8 @@ public class Card extends GameEntity implements Comparable { * @param damage * a int. */ - public final void addReceivedDamageFromThisTurn(final Card c, int damage) { - receivedDamageFromThisTurn.put(c, damage); + public final void addReceivedDamageFromThisTurn(final Card c, final int damage) { + this.receivedDamageFromThisTurn.put(c, damage); } /** @@ -6968,7 +7036,7 @@ public class Card extends GameEntity implements Comparable { * a Map object. */ public final void setReceivedDamageFromThisTurn(final Map receivedDamageList) { - receivedDamageFromThisTurn = receivedDamageList; + this.receivedDamageFromThisTurn = receivedDamageList; } /** @@ -6979,7 +7047,7 @@ public class Card extends GameEntity implements Comparable { * @return a Map object. */ public final Map getReceivedDamageFromThisTurn() { - return receivedDamageFromThisTurn; + return this.receivedDamageFromThisTurn; } /** @@ -6988,7 +7056,7 @@ public class Card extends GameEntity implements Comparable { *

*/ public final void resetReceivedDamageFromThisTurn() { - receivedDamageFromThisTurn.clear(); + this.receivedDamageFromThisTurn.clear(); } /** @@ -7001,8 +7069,8 @@ public class Card extends GameEntity implements Comparable { * @param damage * a int. */ - public final void addDealtDamageToThisTurn(final Card c, int damage) { - dealtDamageToThisTurn.put(c, damage); + public final void addDealtDamageToThisTurn(final Card c, final int damage) { + this.dealtDamageToThisTurn.put(c, damage); } /** @@ -7014,7 +7082,7 @@ public class Card extends GameEntity implements Comparable { * a {@link java.util.Map} object. */ public final void setDealtDamageToThisTurn(final Map dealtDamageList) { - dealtDamageToThisTurn = dealtDamageList; + this.dealtDamageToThisTurn = dealtDamageList; } /** @@ -7025,7 +7093,7 @@ public class Card extends GameEntity implements Comparable { * @return a {@link java.util.Map} object. */ public final Map getDealtDamageToThisTurn() { - return dealtDamageToThisTurn; + return this.dealtDamageToThisTurn; } /** @@ -7034,7 +7102,7 @@ public class Card extends GameEntity implements Comparable { *

*/ public final void resetDealtDamageToThisTurn() { - dealtDamageToThisTurn.clear(); + this.dealtDamageToThisTurn.clear(); } // how much damage is enough to kill the creature (for AI) @@ -7052,7 +7120,7 @@ public class Card extends GameEntity implements Comparable { * @return a int. */ public final int getEnoughDamageToKill(final int maxDamage, final Card source, final boolean isCombat) { - return getEnoughDamageToKill(maxDamage, source, isCombat, false); + return this.getEnoughDamageToKill(maxDamage, source, isCombat, false); } /** @@ -7072,19 +7140,19 @@ public class Card extends GameEntity implements Comparable { */ public final int getEnoughDamageToKill(final int maxDamage, final Card source, final boolean isCombat, final boolean noPrevention) { - int killDamage = getKillDamage(); + final int killDamage = this.getKillDamage(); - if (hasKeyword("Indestructible") || getShield() > 0) { + if (this.hasKeyword("Indestructible") || (this.getShield() > 0)) { if (!(source.hasKeyword("Wither") || source.hasKeyword("Infect"))) { return maxDamage + 1; } } else if (source.hasKeyword("Deathtouch")) { for (int i = 1; i <= maxDamage; i++) { if (noPrevention) { - if (staticReplaceDamage(i, source, isCombat) > 0) { + if (this.staticReplaceDamage(i, source, isCombat) > 0) { return i; } - } else if (predictDamage(i, source, isCombat) > 0) { + } else if (this.predictDamage(i, source, isCombat) > 0) { return i; } } @@ -7092,11 +7160,11 @@ public class Card extends GameEntity implements Comparable { for (int i = 1; i <= maxDamage; i++) { if (noPrevention) { - if (staticReplaceDamage(i, source, isCombat) >= killDamage) { + if (this.staticReplaceDamage(i, source, isCombat) >= killDamage) { return i; } } else { - if (predictDamage(i, source, isCombat) >= killDamage) { + if (this.predictDamage(i, source, isCombat) >= killDamage) { return i; } } @@ -7114,9 +7182,10 @@ public class Card extends GameEntity implements Comparable { * @return a int. */ public final int getKillDamage() { - int killDamage = getLethalDamage() + getPreventNextDamage(); - if (killDamage > getPreventNextDamage() && hasStartOfKeyword("When CARDNAME is dealt damage, destroy it.")) { - killDamage = 1 + getPreventNextDamage(); + int killDamage = this.getLethalDamage() + this.getPreventNextDamage(); + if ((killDamage > this.getPreventNextDamage()) + && this.hasStartOfKeyword("When CARDNAME is dealt damage, destroy it.")) { + killDamage = 1 + this.getPreventNextDamage(); } return killDamage; @@ -7132,7 +7201,7 @@ public class Card extends GameEntity implements Comparable { * @return a int. */ public final int getLethalDamage() { - int lethalDamage = getNetDefense() - getDamage() - getTotalAssignedDamage(); + final int lethalDamage = this.getNetDefense() - this.getDamage() - this.getTotalAssignedDamage(); return lethalDamage; } @@ -7149,7 +7218,7 @@ public class Card extends GameEntity implements Comparable { // if // (this.hasKeyword("Prevent all damage that would be dealt to CARDNAME.")) // n = 0; - damage = n; + this.damage = n; } /** @@ -7160,7 +7229,7 @@ public class Card extends GameEntity implements Comparable { * @return a int. */ public final int getDamage() { - return damage; + return this.damage; } /** @@ -7178,13 +7247,13 @@ public class Card extends GameEntity implements Comparable { damage = 0; } - int assignedDamage = damage; + final int assignedDamage = damage; Log.debug(this + " - was assigned " + assignedDamage + " damage, by " + sourceCard); - if (!assignedDamageMap.containsKey(sourceCard)) { - assignedDamageMap.put(sourceCard, assignedDamage); + if (!this.assignedDamageMap.containsKey(sourceCard)) { + this.assignedDamageMap.put(sourceCard, assignedDamage); } else { - assignedDamageMap.put(sourceCard, assignedDamageMap.get(sourceCard) + assignedDamage); + this.assignedDamageMap.put(sourceCard, this.assignedDamageMap.get(sourceCard) + assignedDamage); } Log.debug("***"); @@ -7205,7 +7274,7 @@ public class Card extends GameEntity implements Comparable { *

*/ public final void clearAssignedDamage() { - assignedDamageMap.clear(); + this.assignedDamageMap.clear(); } /** @@ -7218,9 +7287,9 @@ public class Card extends GameEntity implements Comparable { public final int getTotalAssignedDamage() { int total = 0; - Collection c = assignedDamageMap.values(); + final Collection c = this.assignedDamageMap.values(); - Iterator itr = c.iterator(); + final Iterator itr = c.iterator(); while (itr.hasNext()) { total += itr.next(); } @@ -7236,7 +7305,7 @@ public class Card extends GameEntity implements Comparable { * @return a {@link java.util.Map} object. */ public final Map getAssignedDamageMap() { - return assignedDamageMap; + return this.assignedDamageMap; } /** @@ -7248,24 +7317,24 @@ public class Card extends GameEntity implements Comparable { * a {@link java.util.Map} object. */ public final void addCombatDamage(final Map map) { - CardList list = new CardList(); + final CardList list = new CardList(); - for (Entry entry : map.entrySet()) { - Card source = entry.getKey(); + for (final Entry entry : map.entrySet()) { + final Card source = entry.getKey(); list.add(source); int damageToAdd = entry.getValue(); - damageToAdd = replaceDamage(damageToAdd, source, true); - damageToAdd = preventDamage(damageToAdd, source, true); + damageToAdd = this.replaceDamage(damageToAdd, source, true); + damageToAdd = this.preventDamage(damageToAdd, source, true); - if (damageToAdd > 0 && isCreature()) { + if ((damageToAdd > 0) && this.isCreature()) { GameActionUtil.executeCombatDamageToCreatureEffects(source, this, damageToAdd); } map.put(source, damageToAdd); } if (AllZoneUtil.isCardInPlay(this)) { - addDamage(map); + this.addDamage(map); } } @@ -7291,9 +7360,9 @@ public class Card extends GameEntity implements Comparable { int restDamage = damage; - restDamage = staticReplaceDamage(restDamage, source, isCombat); + restDamage = this.staticReplaceDamage(restDamage, source, isCombat); - restDamage = staticDamagePrevention(restDamage, possiblePrevention, source, isCombat); + restDamage = this.staticDamagePrevention(restDamage, possiblePrevention, source, isCombat); return restDamage; } @@ -7324,7 +7393,7 @@ public class Card extends GameEntity implements Comparable { int restDamage = damage - possiblePrvenetion; - restDamage = staticDamagePrevention(restDamage, source, isCombat); + restDamage = this.staticDamagePrevention(restDamage, source, isCombat); return restDamage; } @@ -7353,15 +7422,15 @@ public class Card extends GameEntity implements Comparable { int restDamage = damageIn; - if (hasProtectionFrom(source)) { + if (this.hasProtectionFrom(source)) { return 0; } if (isCombat) { - if (hasKeyword("Prevent all combat damage that would be dealt to and dealt by CARDNAME.")) { + if (this.hasKeyword("Prevent all combat damage that would be dealt to and dealt by CARDNAME.")) { return 0; } - if (hasKeyword("Prevent all combat damage that would be dealt to CARDNAME.")) { + if (this.hasKeyword("Prevent all combat damage that would be dealt to CARDNAME.")) { return 0; } if (source.hasKeyword("Prevent all combat damage that would be dealt to and dealt by CARDNAME.")) { @@ -7371,10 +7440,10 @@ public class Card extends GameEntity implements Comparable { return 0; } } - if (hasKeyword("Prevent all damage that would be dealt to CARDNAME.")) { + if (this.hasKeyword("Prevent all damage that would be dealt to CARDNAME.")) { return 0; } - if (hasKeyword("Prevent all damage that would be dealt to and dealt by CARDNAME.")) { + if (this.hasKeyword("Prevent all damage that would be dealt to and dealt by CARDNAME.")) { return 0; } if (source.hasKeyword("Prevent all damage that would be dealt to and dealt by CARDNAME.")) { @@ -7384,8 +7453,8 @@ public class Card extends GameEntity implements Comparable { return 0; } - if (hasStartOfKeyword("Absorb")) { - int absorbed = this.getKeywordMagnitude("Absorb"); + if (this.hasStartOfKeyword("Absorb")) { + final int absorbed = this.getKeywordMagnitude("Absorb"); if (restDamage > absorbed) { restDamage = restDamage - absorbed; } else { @@ -7393,8 +7462,8 @@ public class Card extends GameEntity implements Comparable { } } - if (hasStartOfKeyword("PreventAllDamageBy")) { - String valid = getKeyword().get(getKeywordPosition("PreventAllDamageBy")); + if (this.hasStartOfKeyword("PreventAllDamageBy")) { + String valid = this.getKeyword().get(this.getKeywordPosition("PreventAllDamageBy")); valid = valid.split(" ", 2)[1]; if (source.isValid(valid, this.getController(), this)) { return 0; @@ -7402,17 +7471,17 @@ public class Card extends GameEntity implements Comparable { } // Prevent Damage static abilities - CardList allp = AllZoneUtil.getCardsIn(Zone.Battlefield); - for (Card ca : allp) { - ArrayList staticAbilities = ca.getStaticAbilities(); - for (StaticAbility stAb : staticAbilities) { + final CardList allp = AllZoneUtil.getCardsIn(Zone.Battlefield); + for (final Card ca : allp) { + final ArrayList staticAbilities = ca.getStaticAbilities(); + for (final StaticAbility stAb : staticAbilities) { restDamage = stAb.applyAbility("PreventDamage", source, this, restDamage, isCombat); } } // specific Cards - if (isCreature()) { // and not a planeswalker - if (getName().equals("Swans of Bryn Argoll")) { + if (this.isCreature()) { // and not a planeswalker + if (this.getName().equals("Swans of Bryn Argoll")) { return 0; } @@ -7450,12 +7519,12 @@ public class Card extends GameEntity implements Comparable { int restDamage = damage; - if (getName().equals("Swans of Bryn Argoll")) { + if (this.getName().equals("Swans of Bryn Argoll")) { source.getController().drawCards(restDamage); return 0; } - restDamage = staticDamagePrevention(restDamage, source, isCombat); + restDamage = this.staticDamagePrevention(restDamage, source, isCombat); if (restDamage == 0) { return 0; @@ -7467,16 +7536,16 @@ public class Card extends GameEntity implements Comparable { this.subtractCounter(Counters.P1P1, 1); } - if (restDamage >= getPreventNextDamage()) { - restDamage = restDamage - getPreventNextDamage(); - setPreventNextDamage(0); + if (restDamage >= this.getPreventNextDamage()) { + restDamage = restDamage - this.getPreventNextDamage(); + this.setPreventNextDamage(0); } else { - setPreventNextDamage(getPreventNextDamage() - restDamage); + this.setPreventNextDamage(this.getPreventNextDamage() - restDamage); restDamage = 0; } - if (getName().equals("Phyrexian Hydra")) { - addCounter(Counters.M1M1, restDamage); + if (this.getName().equals("Phyrexian Hydra")) { + this.addCounter(Counters.M1M1, restDamage); return 0; } @@ -7504,30 +7573,30 @@ public class Card extends GameEntity implements Comparable { int restDamage = damage; if (AllZoneUtil.isCardInPlay("Sulfuric Vapors") && source.isSpell() && source.isRed()) { - int amount = AllZoneUtil.getCardsIn(Zone.Battlefield, "Sulfuric Vapors").size(); + final int amount = AllZoneUtil.getCardsIn(Zone.Battlefield, "Sulfuric Vapors").size(); for (int i = 0; i < amount; i++) { restDamage += 1; } } if (AllZoneUtil.isCardInPlay("Pyromancer's Swath", source.getController()) - && (source.isInstant() || source.isSorcery()) && isCreature()) { - int amount = source.getController().getCardsIn(Zone.Battlefield, "Pyromancer's Swath").size(); + && (source.isInstant() || source.isSorcery()) && this.isCreature()) { + final int amount = source.getController().getCardsIn(Zone.Battlefield, "Pyromancer's Swath").size(); for (int i = 0; i < amount; i++) { restDamage += 2; } } - if (AllZoneUtil.isCardInPlay("Furnace of Rath") && isCreature()) { - int amount = AllZoneUtil.getCardsIn(Zone.Battlefield, "Furnace of Rath").size(); + if (AllZoneUtil.isCardInPlay("Furnace of Rath") && this.isCreature()) { + final int amount = AllZoneUtil.getCardsIn(Zone.Battlefield, "Furnace of Rath").size(); for (int i = 0; i < amount; i++) { restDamage += restDamage; } } if (AllZoneUtil.isCardInPlay("Gratuitous Violence", source.getController()) && source.isCreature() - && isCreature()) { - int amount = source.getController().getCardsIn(Zone.Battlefield, "Gratuitous Violence").size(); + && this.isCreature()) { + final int amount = source.getController().getCardsIn(Zone.Battlefield, "Gratuitous Violence").size(); for (int i = 0; i < amount; i++) { restDamage += restDamage; } @@ -7535,14 +7604,14 @@ public class Card extends GameEntity implements Comparable { if (AllZoneUtil.isCardInPlay("Fire Servant", source.getController()) && source.isRed() && (source.isInstant() || source.isSorcery())) { - int amount = source.getController().getCardsIn(Zone.Battlefield, "Fire Servant").size(); + final int amount = source.getController().getCardsIn(Zone.Battlefield, "Fire Servant").size(); for (int i = 0; i < amount; i++) { restDamage += restDamage; } } - if (AllZoneUtil.isCardInPlay("Benevolent Unicorn") && source.isSpell() && isCreature()) { - int amount = AllZoneUtil.getCardsIn(Zone.Battlefield, "Benevolent Unicorn").size(); + if (AllZoneUtil.isCardInPlay("Benevolent Unicorn") && source.isSpell() && this.isCreature()) { + final int amount = AllZoneUtil.getCardsIn(Zone.Battlefield, "Benevolent Unicorn").size(); for (int i = 0; i < amount; i++) { if (restDamage > 0) { restDamage -= 1; @@ -7550,8 +7619,8 @@ public class Card extends GameEntity implements Comparable { } } - if (AllZoneUtil.isCardInPlay("Lashknife Barrier", getController()) && isCreature()) { - int amount = getController().getCardsIn(Zone.Battlefield, "Lashknife Barrier").size(); + if (AllZoneUtil.isCardInPlay("Lashknife Barrier", this.getController()) && this.isCreature()) { + final int amount = this.getController().getCardsIn(Zone.Battlefield, "Lashknife Barrier").size(); for (int i = 0; i < amount; i++) { if (restDamage > 0) { restDamage -= 1; @@ -7559,12 +7628,12 @@ public class Card extends GameEntity implements Comparable { } } - if (AllZoneUtil.isCardInPlay("Divine Presence") && isCreature() && restDamage > 3) { + if (AllZoneUtil.isCardInPlay("Divine Presence") && this.isCreature() && (restDamage > 3)) { restDamage = 3; } - if (getName().equals("Phytohydra")) { + if (this.getName().equals("Phytohydra")) { return 0; } @@ -7588,29 +7657,29 @@ public class Card extends GameEntity implements Comparable { public final int replaceDamage(final int damageIn, final Card source, final boolean isCombat) { int restDamage = damageIn; - CardList auras = new CardList(getEnchantedBy().toArray()); + final CardList auras = new CardList(this.getEnchantedBy().toArray()); - if (getName().equals("Phytohydra")) { - addCounter(Counters.P1P1, restDamage); + if (this.getName().equals("Phytohydra")) { + this.addCounter(Counters.P1P1, restDamage); return 0; } if (auras.containsName("Treacherous Link")) { - getController().addDamage(restDamage, source); + this.getController().addDamage(restDamage, source); return 0; } - restDamage = staticReplaceDamage(restDamage, source, isCombat); + restDamage = this.staticReplaceDamage(restDamage, source, isCombat); - if (getName().equals("Lichenthrope")) { - addCounter(Counters.M1M1, restDamage); + if (this.getName().equals("Lichenthrope")) { + this.addCounter(Counters.M1M1, restDamage); return 0; } - - if (getName().equals("Dralnu, Lich Lord")) { - CardList choices = getController().getCardsIn(Zone.Battlefield); - for(int i = 0;i< restDamage;i++) { - getController().sacrificePermanent("Sacrifice a permanent.", choices); + + if (this.getName().equals("Dralnu, Lich Lord")) { + final CardList choices = this.getController().getCardsIn(Zone.Battlefield); + for (int i = 0; i < restDamage; i++) { + this.getController().sacrificePermanent("Sacrifice a permanent.", choices); } return 0; } @@ -7627,12 +7696,12 @@ public class Card extends GameEntity implements Comparable { * a {@link java.util.Map} object. */ public final void addDamage(final Map sourcesMap) { - for (Entry entry : sourcesMap.entrySet()) { - addDamageAfterPrevention(entry.getValue(), entry.getKey(), true); // damage - // prevention - // is - // already - // checked! + for (final Entry entry : sourcesMap.entrySet()) { + this.addDamageAfterPrevention(entry.getValue(), entry.getKey(), true); // damage + // prevention + // is + // already + // checked! } } @@ -7652,23 +7721,23 @@ public class Card extends GameEntity implements Comparable { */ @Override public final void addDamageAfterPrevention(final int damageIn, final Card source, final boolean isCombat) { - int damageToAdd = damageIn; + final int damageToAdd = damageIn; boolean wither = false; if (damageToAdd == 0) { return; // Rule 119.8 } - System.out.println("Adding " + damageToAdd + " damage to " + getName()); - Log.debug("Adding " + damageToAdd + " damage to " + getName()); + System.out.println("Adding " + damageToAdd + " damage to " + this.getName()); + Log.debug("Adding " + damageToAdd + " damage to " + this.getName()); - addReceivedDamageFromThisTurn(source, damageToAdd); + this.addReceivedDamageFromThisTurn(source, damageToAdd); source.addDealtDamageToThisTurn(this, damageToAdd); GameActionUtil.executeDamageDealingEffects(source, damageToAdd); // Run triggers - Map runParams = new TreeMap(); + final Map runParams = new TreeMap(); runParams.put("DamageSource", source); runParams.put("DamageTarget", this); runParams.put("DamageAmount", damageToAdd); @@ -7687,10 +7756,10 @@ public class Card extends GameEntity implements Comparable { GameActionUtil.executeDamageToCreatureEffects(source, this, damageToAdd); if (AllZoneUtil.isCardInPlay(this) && wither) { - addCounter(Counters.M1M1, damageToAdd); + this.addCounter(Counters.M1M1, damageToAdd); } if (AllZoneUtil.isCardInPlay(this) && !wither) { - damage += damageToAdd; + this.damage += damageToAdd; } } @@ -7706,7 +7775,7 @@ public class Card extends GameEntity implements Comparable { * a {@link forge.SetInfo} object. */ public final void addSet(final SetInfo sInfo) { - getCharacteristics().getSets().add(sInfo); + this.getCharacteristics().getSets().add(sInfo); } /** @@ -7717,7 +7786,7 @@ public class Card extends GameEntity implements Comparable { * @return a {@link java.util.ArrayList} object. */ public final ArrayList getSets() { - return getCharacteristics().getSets(); + return this.getCharacteristics().getSets(); } /** @@ -7729,7 +7798,7 @@ public class Card extends GameEntity implements Comparable { * a {@link java.util.ArrayList} object. */ public final void setSets(final ArrayList siList) { - getCharacteristics().setSets(siList); + this.getCharacteristics().setSets(siList); } /** @@ -7741,7 +7810,7 @@ public class Card extends GameEntity implements Comparable { * a {@link java.lang.String} object. */ public final void setCurSetCode(final String setCode) { - curSetCode = setCode; + this.curSetCode = setCode; } /** @@ -7752,7 +7821,7 @@ public class Card extends GameEntity implements Comparable { * @return a {@link java.lang.String} object. */ public final String getCurSetCode() { - return curSetCode; + return this.curSetCode; } /** @@ -7761,14 +7830,15 @@ public class Card extends GameEntity implements Comparable { *

*/ public final void setRandomSetCode() { - if (getCharacteristics().getSets().size() < 1) { + if (this.getCharacteristics().getSets().size() < 1) { return; } - Random r = MyRandom.getRandom(); - SetInfo si = getCharacteristics().getSets().get(r.nextInt(getCharacteristics().getSets().size())); + final Random r = MyRandom.getRandom(); + final SetInfo si = this.getCharacteristics().getSets() + .get(r.nextInt(this.getCharacteristics().getSets().size())); - curSetCode = si.getCode(); + this.curSetCode = si.getCode(); } /** @@ -7781,7 +7851,7 @@ public class Card extends GameEntity implements Comparable { * @return a {@link java.lang.String} object. */ public final String getSetImageName(final String setCode) { - return "/" + setCode + "/" + getImageName(); + return "/" + setCode + "/" + this.getImageName(); } /** @@ -7792,7 +7862,7 @@ public class Card extends GameEntity implements Comparable { * @return a {@link java.lang.String} object. */ public final String getCurSetImage() { - return getSetImageName(curSetCode); + return this.getSetImageName(this.curSetCode); } /** @@ -7803,9 +7873,9 @@ public class Card extends GameEntity implements Comparable { * @return a {@link java.lang.String} object. */ public final String getCurSetRarity() { - for (int i = 0; i < getCharacteristics().getSets().size(); i++) { - if (getCharacteristics().getSets().get(i).getCode().equals(curSetCode)) { - return getCharacteristics().getSets().get(i).getRarity(); + for (int i = 0; i < this.getCharacteristics().getSets().size(); i++) { + if (this.getCharacteristics().getSets().get(i).getCode().equals(this.curSetCode)) { + return this.getCharacteristics().getSets().get(i).getRarity(); } } @@ -7820,9 +7890,9 @@ public class Card extends GameEntity implements Comparable { * @return a {@link java.lang.String} object. */ public final String getCurSetURL() { - for (int i = 0; i < getCharacteristics().getSets().size(); i++) { - if (getCharacteristics().getSets().get(i).getCode().equals(curSetCode)) { - return getCharacteristics().getSets().get(i).getUrl(); + for (int i = 0; i < this.getCharacteristics().getSets().size(); i++) { + if (this.getCharacteristics().getSets().get(i).getCode().equals(this.curSetCode)) { + return this.getCharacteristics().getSets().get(i).getUrl(); } } @@ -7849,7 +7919,7 @@ public class Card extends GameEntity implements Comparable { * a {@link java.lang.String} object. */ public final void setImageFilename(final String iFN) { - getCharacteristics().setImageFilename(iFN); + this.getCharacteristics().setImageFilename(iFN); } /** @@ -7860,7 +7930,7 @@ public class Card extends GameEntity implements Comparable { * @return a {@link java.lang.String} object. */ public final String getImageFilename() { - return getCharacteristics().getImageFilename(); + return this.getCharacteristics().getImageFilename(); } /** @@ -7872,7 +7942,7 @@ public class Card extends GameEntity implements Comparable { * a boolean. */ public final void setEvoked(final boolean evokedIn) { - evoked = evokedIn; + this.evoked = evokedIn; } /** @@ -7883,7 +7953,7 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean isEvoked() { - return evoked; + return this.evoked; } /** @@ -7894,7 +7964,7 @@ public class Card extends GameEntity implements Comparable { * a long */ public final void setTimestamp(final long t) { - timestamp = t; + this.timestamp = t; } /** @@ -7904,7 +7974,7 @@ public class Card extends GameEntity implements Comparable { * @return a long */ public final long getTimestamp() { - return timestamp; + return this.timestamp; } /** @@ -7914,8 +7984,8 @@ public class Card extends GameEntity implements Comparable { * @return an int */ public final int getFoil() { - if (getCharacteristics().getsVars().containsKey("Foil")) { - return Integer.parseInt(getCharacteristics().getsVars().get("Foil")); + if (this.getCharacteristics().getsVars().containsKey("Foil")) { + return Integer.parseInt(this.getCharacteristics().getsVars().get("Foil")); } return 0; } @@ -7928,7 +7998,7 @@ public class Card extends GameEntity implements Comparable { * an int */ public final void setFoil(final int f) { - getCharacteristics().getsVars().put("Foil", Integer.toString(f)); + this.getCharacteristics().getsVars().put("Foil", Integer.toString(f)); } /** @@ -7938,7 +8008,7 @@ public class Card extends GameEntity implements Comparable { * the c */ public final void addHauntedBy(final Card c) { - hauntedBy.add(c); + this.hauntedBy.add(c); if (c != null) { c.setHaunting(this); } @@ -7950,7 +8020,7 @@ public class Card extends GameEntity implements Comparable { * @return the haunted by */ public final ArrayList getHauntedBy() { - return hauntedBy; + return this.hauntedBy; } /** @@ -7960,7 +8030,7 @@ public class Card extends GameEntity implements Comparable { * the c */ public final void removeHauntedBy(final Card c) { - hauntedBy.remove(c); + this.hauntedBy.remove(c); } /** @@ -7969,7 +8039,7 @@ public class Card extends GameEntity implements Comparable { * @return the haunting */ public final Card getHaunting() { - return haunting; + return this.haunting; } /** @@ -7979,7 +8049,7 @@ public class Card extends GameEntity implements Comparable { * the new haunting */ public final void setHaunting(final Card c) { - haunting = c; + this.haunting = c; } /** @@ -7989,8 +8059,8 @@ public class Card extends GameEntity implements Comparable { */ public final int getDamageDoneThisTurn() { int sum = 0; - for (Card c : dealtDamageToThisTurn.keySet()) { - sum += dealtDamageToThisTurn.get(c); + for (final Card c : this.dealtDamageToThisTurn.keySet()) { + sum += this.dealtDamageToThisTurn.get(c); } return sum; @@ -8002,7 +8072,7 @@ public class Card extends GameEntity implements Comparable { * @return the cardColorsOverridden */ public final boolean isCardColorsOverridden() { - return getCharacteristics().isCardColorsOverridden(); + return this.getCharacteristics().isCardColorsOverridden(); } /** @@ -8012,21 +8082,24 @@ public class Card extends GameEntity implements Comparable { * the cardColorsOverridden to set */ public final void setCardColorsOverridden(final boolean cardColorsOverridden0) { - getCharacteristics().setCardColorsOverridden(cardColorsOverridden0); + this.getCharacteristics().setCardColorsOverridden(cardColorsOverridden0); } + /* (non-Javadoc) + * @see forge.GameEntity#hasProtectionFrom(forge.Card) + */ @Override - public boolean hasProtectionFrom(Card source) { + public boolean hasProtectionFrom(final Card source) { if (source == null) { return false; } - if (isImmutable()) { + if (this.isImmutable()) { return true; } - if (getKeyword() != null) { - final ArrayList list = getKeyword(); + if (this.getKeyword() != null) { + final ArrayList list = this.getKeyword(); String kw = ""; for (int i = 0; i < list.size(); i++) { @@ -8090,7 +8163,7 @@ public class Card extends GameEntity implements Comparable { if (kw.startsWith("Protection:")) { // uses isValid final String characteristic = kw.split(":")[1]; final String[] characteristics = characteristic.split(","); - if (source.isValid(characteristics, getController(), this)) { + if (source.isValid(characteristics, this.getController(), this)) { return true; } } @@ -8103,13 +8176,15 @@ public class Card extends GameEntity implements Comparable { /** * * is In Zone. - * @param zone Constant.Zone + * + * @param zone + * Constant.Zone * @return boolean */ public boolean isInZone(final Constant.Zone zone) { return AllZone.isCardInZone(this, zone); } - + /** * Can target. * @@ -8119,11 +8194,11 @@ public class Card extends GameEntity implements Comparable { */ @Override public final boolean canBeTargetedBy(final SpellAbility sa) { - - if(sa == null) { + + if (sa == null) { return true; } - + // CantTarget static abilities final CardList allp = AllZoneUtil.getCardsIn(Zone.Battlefield); for (final Card ca : allp) { @@ -8134,18 +8209,20 @@ public class Card extends GameEntity implements Comparable { } } } - - if(!isInZone(Constant.Zone.Battlefield)) { //keywords don't work outside the battlefield + + if (!this.isInZone(Constant.Zone.Battlefield)) { // keywords don't work + // outside the + // battlefield return true; } - - if (hasProtectionFrom(sa.getSourceCard())) { + + if (this.hasProtectionFrom(sa.getSourceCard())) { return false; } - if (getKeyword() != null) { - final ArrayList list = getKeyword(); - Card source = sa.getSourceCard(); + if (this.getKeyword() != null) { + final ArrayList list = this.getKeyword(); + final Card source = sa.getSourceCard(); String kw = ""; for (int i = 0; i < list.size(); i++) { @@ -8155,12 +8232,13 @@ public class Card extends GameEntity implements Comparable { } if (kw.equals("Hexproof")) { - if (!sa.getActivatingPlayer().equals(getController())) { + if (!sa.getActivatingPlayer().equals(this.getController())) { return false; } } - if (kw.equals("CARDNAME can't be the target of Aura spells.") || kw.equals("CARDNAME can't be enchanted.")) { + if (kw.equals("CARDNAME can't be the target of Aura spells.") + || kw.equals("CARDNAME can't be enchanted.")) { if (source.isAura() && sa.isSpell()) { return false; } diff --git a/src/main/java/forge/CardReader.java b/src/main/java/forge/CardReader.java index 990df917f90..8044217bb89 100644 --- a/src/main/java/forge/CardReader.java +++ b/src/main/java/forge/CardReader.java @@ -96,7 +96,7 @@ public class CardReader implements Runnable { private transient Enumeration zipEnum; private transient long estimatedFilesRemaining = // NOPMD by Braids on - // 8/18/11 10:56 PM + CardReader.// 8/18/11 10:56 PM UNKNOWN_NUMBER_OF_FILES_REMAINING; private transient Iterable findNonDirsIterable; // NOPMD by Braids on @@ -182,7 +182,7 @@ public class CardReader implements Runnable { if (useZip && zipFile.exists()) { try { this.zip = new ZipFile(zipFile); - } catch (Exception exn) { + } catch (final Exception exn) { System.err.println("Error reading zip file \"" // NOPMD by // Braids on // 8/18/11 10:53 @@ -197,12 +197,12 @@ public class CardReader implements Runnable { } - if (useZip && zip != null) { - zipEnum = zip.entries(); - estimatedFilesRemaining = zip.size(); + if (useZip && (this.zip != null)) { + this.zipEnum = this.zip.entries(); + this.estimatedFilesRemaining = this.zip.size(); } - setEncoding(DEFAULT_CHARSET_NAME); + this.setEncoding(CardReader.DEFAULT_CHARSET_NAME); } // CardReader() @@ -213,12 +213,13 @@ public class CardReader implements Runnable { * @throws Throwable * indirectly */ + @Override protected final void finalize() throws Throwable { try { - if (findNonDirsIterable != null) { + if (this.findNonDirsIterable != null) { for (@SuppressWarnings("unused") - // Do nothing; just exercising the Iterable. - File ignored : findNonDirsIterable) { + final// Do nothing; just exercising the Iterable. + File ignored : this.findNonDirsIterable) { } } } finally { @@ -229,8 +230,9 @@ public class CardReader implements Runnable { /** * Reads the rest of ALL the cards into memory. This is not lazy. */ + @Override public final void run() { - loadCardsUntilYouFind(null); + this.loadCardsUntilYouFind(null); } /** @@ -261,27 +263,28 @@ public class CardReader implements Runnable { // Iterate through txt files or zip archive. // Report relevant numbers to progress monitor model. - if (zip == null) { - if (estimatedFilesRemaining == UNKNOWN_NUMBER_OF_FILES_REMAINING) { - final Generator findNonDirsGen = new FindNonDirectoriesSkipDotDirectoriesGenerator(cardsfolder); - estimatedFilesRemaining = GeneratorFunctions.estimateSize(findNonDirsGen); - findNonDirsIterable = YieldUtils.toIterable(findNonDirsGen); + if (this.zip == null) { + if (this.estimatedFilesRemaining == CardReader.UNKNOWN_NUMBER_OF_FILES_REMAINING) { + final Generator findNonDirsGen = new FindNonDirectoriesSkipDotDirectoriesGenerator( + this.cardsfolder); + this.estimatedFilesRemaining = GeneratorFunctions.estimateSize(findNonDirsGen); + this.findNonDirsIterable = YieldUtils.toIterable(findNonDirsGen); } if (monitor != null) { - monitor.setTotalUnitsThisPhase(estimatedFilesRemaining); + monitor.setTotalUnitsThisPhase(this.estimatedFilesRemaining); } - for (File cardTxtFile : findNonDirsIterable) { - if (!cardTxtFile.getName().endsWith(CARD_FILE_DOT_EXTENSION)) { + for (final File cardTxtFile : this.findNonDirsIterable) { + if (!cardTxtFile.getName().endsWith(CardReader.CARD_FILE_DOT_EXTENSION)) { monitor.incrementUnitsCompletedThisPhase(1L); continue; } - result = loadCard(cardTxtFile); + result = this.loadCard(cardTxtFile); monitor.incrementUnitsCompletedThisPhase(1L); - if (cardName != null && cardName.equals(result.getName())) { + if ((cardName != null) && cardName.equals(result.getName())) { break; // no thread leak here if entire card DB is loaded, // or if this object is finalized. } @@ -289,22 +292,22 @@ public class CardReader implements Runnable { } // endfor } else { - monitor.setTotalUnitsThisPhase(estimatedFilesRemaining); + monitor.setTotalUnitsThisPhase(this.estimatedFilesRemaining); ZipEntry entry; // zipEnum was initialized in the constructor. - while (zipEnum.hasMoreElements()) { - entry = (ZipEntry) zipEnum.nextElement(); + while (this.zipEnum.hasMoreElements()) { + entry = this.zipEnum.nextElement(); - if (entry.isDirectory() || !entry.getName().endsWith(CARD_FILE_DOT_EXTENSION)) { + if (entry.isDirectory() || !entry.getName().endsWith(CardReader.CARD_FILE_DOT_EXTENSION)) { monitor.incrementUnitsCompletedThisPhase(1L); continue; } - result = loadCard(entry); + result = this.loadCard(entry); monitor.incrementUnitsCompletedThisPhase(1L); - if (cardName != null && cardName.equals(result.getName())) { + if ((cardName != null) && cardName.equals(result.getName())) { break; } } @@ -348,7 +351,7 @@ public class CardReader implements Runnable { line = line.trim(); } return line; - } catch (Exception ex) { + } catch (final Exception ex) { ErrorViewer.showError(ex); throw new RuntimeException("CardReader : readLine(Card) error", ex); // NOPMD // by @@ -372,17 +375,17 @@ public class CardReader implements Runnable { */ protected final Card loadCard(final InputStream inputStream) { final Card card = new Card(); - rulesReader.reset(); + this.rulesReader.reset(); InputStreamReader inputStreamReader = null; BufferedReader reader = null; try { - inputStreamReader = new InputStreamReader(inputStream, charset); + inputStreamReader = new InputStreamReader(inputStream, this.charset); reader = new BufferedReader(inputStreamReader); - String line = readLine(reader); + String line = CardReader.readLine(reader); while (!"End".equals(line)) { - rulesReader.parseLine(line); + this.rulesReader.parseLine(line); if (line.isEmpty()) { // Ignore empty lines. } else if (line.charAt(0) == '#') { // NOPMD by Braids on @@ -391,7 +394,7 @@ public class CardReader implements Runnable { } else if (line.startsWith("Name:")) { final String value = line.substring(5); // System.out.println(s); - if (mapToFill.containsKey(value)) { + if (this.mapToFill.containsKey(value)) { break; // this card has already been loaded. } else { card.setName(value); @@ -403,7 +406,7 @@ public class CardReader implements Runnable { card.setManaCost(value); } } else if (line.startsWith("Types:")) { - addTypes(card, line.substring("Types:".length())); + CardReader.addTypes(card, line.substring("Types:".length())); } else if (line.startsWith("Text:")) { String value = line.substring("Text:".length()); // if (!t.equals("no text")); @@ -457,10 +460,9 @@ public class CardReader implements Runnable { // 8/18/11 11:08 PM } else if (line.equals("ALTERNATE")) { String mode; - if(card.isFlip()) { + if (card.isFlip()) { mode = "Flipped"; - } - else { + } else { mode = "Transformed"; } card.addAlternateState(mode); @@ -474,9 +476,9 @@ public class CardReader implements Runnable { } } else if (line.startsWith("Colors:")) { final String value = line.substring("Colors:".length()); - ArrayList newCols = new ArrayList(); - for (String col : value.split(",")) { - CardColor newCol = new CardColor(card); + final ArrayList newCols = new ArrayList(); + for (final String col : value.split(",")) { + final CardColor newCol = new CardColor(card); newCol.addToCardColor(col); newCols.add(newCol); } @@ -485,18 +487,20 @@ public class CardReader implements Runnable { card.setCardColorsOverridden(true); } - line = readLine(reader); + line = CardReader.readLine(reader); } // while !End } finally { try { reader.close(); - } catch (IOException ignored) { // NOPMD by Braids on 8/18/11 11:08 - // PM + } catch (final IOException ignored) { // NOPMD by Braids on 8/18/11 + // 11:08 + // PM } try { inputStreamReader.close(); - } catch (IOException ignored) { // NOPMD by Braids on 8/18/11 11:08 - // PM + } catch (final IOException ignored) { // NOPMD by Braids on 8/18/11 + // 11:08 + // PM } } @@ -504,8 +508,8 @@ public class CardReader implements Runnable { card.setState("Original"); } - listRulesToFill.add(rulesReader.getCard()); - mapToFill.put(card.getName(), card); + this.listRulesToFill.add(this.rulesReader.getCard()); + this.mapToFill.put(card.getName(), card); return card; } @@ -531,16 +535,17 @@ public class CardReader implements Runnable { FileInputStream fileInputStream = null; try { fileInputStream = new FileInputStream(pathToTxtFile); - return loadCard(fileInputStream); - } catch (FileNotFoundException ex) { + return this.loadCard(fileInputStream); + } catch (final FileNotFoundException ex) { ErrorViewer.showError(ex, "File \"%s\" exception", pathToTxtFile.getAbsolutePath()); throw new RuntimeException(// NOPMD by Braids on 8/18/11 10:53 PM "CardReader : run error -- file exception -- filename is " + pathToTxtFile.getPath(), ex); } finally { try { fileInputStream.close(); - } catch (IOException ignored) { // NOPMD by Braids on 8/18/11 11:08 - // PM + } catch (final IOException ignored) { // NOPMD by Braids on 8/18/11 + // 11:08 + // PM } } } @@ -556,10 +561,10 @@ public class CardReader implements Runnable { protected final Card loadCard(final ZipEntry entry) { InputStream zipInputStream = null; try { - zipInputStream = zip.getInputStream(entry); - return loadCard(zipInputStream); + zipInputStream = this.zip.getInputStream(entry); + return this.loadCard(zipInputStream); - } catch (IOException exn) { + } catch (final IOException exn) { throw new RuntimeException(exn); // NOPMD by Braids on 8/18/11 10:53 // PM } finally { @@ -567,8 +572,9 @@ public class CardReader implements Runnable { if (zipInputStream != null) { zipInputStream.close(); } - } catch (IOException ignored) { // NOPMD by Braids on 8/18/11 11:08 - // PM + } catch (final IOException ignored) { // NOPMD by Braids on 8/18/11 + // 11:08 + // PM } } } @@ -597,19 +603,20 @@ public class CardReader implements Runnable { * http://www.slightlymagic.net/forum/viewtopic.php?f=52&t=4887#p63189 */ - baseFileName = HYPHEN_OR_SPACE.matcher(baseFileName).replaceAll("_"); - baseFileName = MULTIPLE_UNDERSCORES.matcher(baseFileName).replaceAll("_"); - baseFileName = PUNCTUATION_TO_ZAP.matcher(baseFileName).replaceAll(""); + baseFileName = CardReader.HYPHEN_OR_SPACE.matcher(baseFileName).replaceAll("_"); + baseFileName = CardReader.MULTIPLE_UNDERSCORES.matcher(baseFileName).replaceAll("_"); + baseFileName = CardReader.PUNCTUATION_TO_ZAP.matcher(baseFileName).replaceAll(""); // Place the file within a single-letter subdirectory. - final StringBuffer buf = new StringBuffer(1 + 1 + baseFileName.length() + CARD_FILE_DOT_EXTENSION.length()); + final StringBuffer buf = new StringBuffer(1 + 1 + baseFileName.length() + + CardReader.CARD_FILE_DOT_EXTENSION.length()); buf.append(Character.toLowerCase(baseFileName.charAt(0))); // Zip file is always created with unix-style path names. buf.append('/'); buf.append(baseFileName.toLowerCase(Locale.ENGLISH)); - buf.append(CARD_FILE_DOT_EXTENSION); + buf.append(CardReader.CARD_FILE_DOT_EXTENSION); return buf.toString(); } @@ -628,25 +635,25 @@ public class CardReader implements Runnable { // 11:08 PM UtilFunctions.checkNotNull("canonicalASCIIName", canonicalASCIIName); - final String cardFilePath = toMostLikelyPath(canonicalASCIIName); + final String cardFilePath = this.toMostLikelyPath(canonicalASCIIName); Card result = null; - if (zip != null) { - final ZipEntry entry = zip.getEntry(cardFilePath); + if (this.zip != null) { + final ZipEntry entry = this.zip.getEntry(cardFilePath); if (entry != null) { - result = loadCard(entry); + result = this.loadCard(entry); } } if (result == null) { - result = loadCard(new File(cardsfolder, cardFilePath)); + result = this.loadCard(new File(this.cardsfolder, cardFilePath)); } - if (result == null || !(result.getName().equals(canonicalASCIIName))) { + if ((result == null) || !(result.getName().equals(canonicalASCIIName))) { // System.err.println(":Could not find \"" + cardFilePath + "\"."); - result = loadCardsUntilYouFind(canonicalASCIIName); + result = this.loadCardsUntilYouFind(canonicalASCIIName); } return result; diff --git a/src/main/java/forge/CardUtil.java b/src/main/java/forge/CardUtil.java index ee3877fa214..dfe3d14bc27 100644 --- a/src/main/java/forge/CardUtil.java +++ b/src/main/java/forge/CardUtil.java @@ -51,11 +51,11 @@ public final class CardUtil { * @return a int. */ public static int getRandomIndex(final Object[] o) { - if (o == null || o.length == 0) { + if ((o == null) || (o.length == 0)) { throw new RuntimeException("CardUtil : getRandomIndex() argument is null or length is 0"); } - return RANDOM.nextInt(o.length); + return CardUtil.RANDOM.nextInt(o.length); } /** @@ -68,7 +68,7 @@ public final class CardUtil { * @return a {@link forge.Card} object. */ public static Card getRandom(final Card[] o) { - return o[getRandomIndex(o)]; + return o[CardUtil.getRandomIndex(o)]; } /** @@ -81,11 +81,11 @@ public final class CardUtil { * @return a int. */ public static int getRandomIndex(final SpellAbilityList list) { - if (list == null || list.size() == 0) { + if ((list == null) || (list.size() == 0)) { throw new RuntimeException("CardUtil : getRandomIndex(SpellAbilityList) argument is null or length is 0"); } - return RANDOM.nextInt(list.size()); + return CardUtil.RANDOM.nextInt(list.size()); } /** @@ -98,7 +98,7 @@ public final class CardUtil { * @return a int. */ public static int getRandomIndex(final CardList c) { - return RANDOM.nextInt(c.size()); + return CardUtil.RANDOM.nextInt(c.size()); } // returns Card Name (unique number) attack/defense @@ -126,11 +126,11 @@ public final class CardUtil { * @return an array of {@link forge.Card} objects. */ public static Card[] toCard(final Collection col) { - Object[] o = col.toArray(); - Card[] c = new Card[o.length]; + final Object[] o = col.toArray(); + final Card[] c = new Card[o.length]; for (int i = 0; i < c.length; i++) { - Object swap = o[i]; + final Object swap = o[i]; if (swap instanceof Card) { c[i] = (Card) o[i]; } else { @@ -152,7 +152,7 @@ public final class CardUtil { * @return an array of {@link forge.Card} objects. */ public static Card[] toCard(final ArrayList list) { - Card[] c = new Card[list.size()]; + final Card[] c = new Card[list.size()]; list.toArray(c); return c; } @@ -167,9 +167,9 @@ public final class CardUtil { * @return a {@link java.util.ArrayList} object. */ public static ArrayList toList(final Card[] c) { - ArrayList a = new ArrayList(); - for (int i = 0; i < c.length; i++) { - a.add(c[i]); + final ArrayList a = new ArrayList(); + for (final Card element : c) { + a.add(element); } return a; } @@ -185,14 +185,14 @@ public final class CardUtil { * @return a {@link java.lang.String} object. */ public static String getShortColor(final String longColor) { - Map map = new HashMap(); + final Map map = new HashMap(); map.put(Constant.Color.BLACK.toString(), "B"); map.put(Constant.Color.BLUE.toString(), "U"); map.put(Constant.Color.GREEN.toString(), "G"); map.put(Constant.Color.RED.toString(), "R"); map.put(Constant.Color.WHITE.toString(), "W"); - Object o = map.get(longColor); + final Object o = map.get(longColor); if (o == null) { throw new RuntimeException("CardUtil : getShortColor() invalid argument - " + longColor); } @@ -212,7 +212,7 @@ public final class CardUtil { * @return a boolean. */ public static boolean isColor(final Card c, final String col) { - ArrayList list = getColors(c); + final ArrayList list = CardUtil.getColors(c); return list.contains(col); } @@ -239,8 +239,8 @@ public final class CardUtil { * @return a {@link java.util.ArrayList} object. */ public static ArrayList getOnlyColors(final Card c) { - String m = c.getManaCost(); - Set colors = new HashSet(); + final String m = c.getManaCost(); + final Set colors = new HashSet(); for (int i = 0; i < m.length(); i++) { switch (m.charAt(i)) { @@ -265,9 +265,9 @@ public final class CardUtil { break; } } - for (String kw : c.getKeyword()) { + for (final String kw : c.getKeyword()) { if (kw.startsWith(c.getName() + " is ") || kw.startsWith("CARDNAME is ")) { - for (String color : Constant.Color.COLORS) { + for (final String color : Constant.Color.COLORS) { if (kw.endsWith(color + ".")) { colors.add(color); } @@ -313,7 +313,7 @@ public final class CardUtil { * @return a int. */ public static int getConvertedManaCost(final SpellAbility sa) { - return getConvertedManaCost(sa.getManaCost()); + return CardUtil.getConvertedManaCost(sa.getManaCost()); } /** @@ -329,7 +329,7 @@ public final class CardUtil { if (c.isToken() && !c.isCopiedToken()) { return 0; } - return getConvertedManaCost(c.getManaCost()); + return CardUtil.getConvertedManaCost(c.getManaCost()); } /** @@ -346,7 +346,7 @@ public final class CardUtil { return 0; } - ManaCost cost = new ManaCost(manaCost); + final ManaCost cost = new ManaCost(manaCost); return cost.getConvertedManaCost(); } @@ -413,8 +413,7 @@ public final class CardUtil { return c.getEquipping().get(0); // else if(relation.startsWith("target ")) return c.getTargetCard(); } else { - throw new IllegalArgumentException("Error at CardUtil.getRelative: " - + relation + "is not a valid relation"); + throw new IllegalArgumentException("Error at CardUtil.getRelative: " + relation + "is not a valid relation"); } } @@ -428,7 +427,7 @@ public final class CardUtil { * @return a boolean. */ public static boolean isACardType(final String cardType) { - return getAllCardTypes().contains(cardType); + return CardUtil.getAllCardTypes().contains(cardType); } /** @@ -439,7 +438,7 @@ public final class CardUtil { * @return a {@link java.util.ArrayList} object. */ public static ArrayList getAllCardTypes() { - ArrayList types = new ArrayList(); + final ArrayList types = new ArrayList(); // types.addAll(getCardTypes()); types.addAll(Constant.CardTypes.CARD_TYPES[0].getList()); @@ -460,7 +459,7 @@ public final class CardUtil { * @return a {@link java.util.ArrayList} object. */ public static ArrayList getCardTypes() { - ArrayList types = new ArrayList(); + final ArrayList types = new ArrayList(); // types.add("Artifact"); // types.add("Creature"); @@ -485,7 +484,7 @@ public final class CardUtil { * @since 1.1.3 */ public static ArrayList getBasicTypes() { - ArrayList types = new ArrayList(); + final ArrayList types = new ArrayList(); types.addAll(Constant.CardTypes.BASIC_TYPES[0].getList()); @@ -498,7 +497,7 @@ public final class CardUtil { * @return the land types */ public static ArrayList getLandTypes() { - ArrayList types = new ArrayList(); + final ArrayList types = new ArrayList(); types.addAll(Constant.CardTypes.BASIC_TYPES[0].getList()); types.addAll(Constant.CardTypes.LAND_TYPES[0].getList()); @@ -515,7 +514,7 @@ public final class CardUtil { * @since 1.1.6 */ public static ArrayList getCreatureTypes() { - ArrayList types = new ArrayList(); + final ArrayList types = new ArrayList(); types.addAll(Constant.CardTypes.CREATURE_TYPES[0].getList()); @@ -546,7 +545,7 @@ public final class CardUtil { * @return a boolean. */ public static boolean isASubType(final String cardType) { - return (!isASuperType(cardType) && !isACardType(cardType)); + return (!CardUtil.isASuperType(cardType) && !CardUtil.isACardType(cardType)); } /** @@ -624,7 +623,7 @@ public final class CardUtil { * @return a boolean. */ public static boolean isStackingKeyword(final String keyword) { - return !isNonStackingKeyword(keyword); + return !CardUtil.isNonStackingKeyword(keyword); } /** @@ -639,8 +638,8 @@ public final class CardUtil { * @return the string */ public static String buildIdealFilename(final String cardName, final int artIndex, final int artIndexMax) { - String nn = artIndexMax > 1 ? Integer.toString(artIndex + 1) : ""; - String mwsCardName = GuiDisplayUtil.cleanStringMWS(cardName); + final String nn = artIndexMax > 1 ? Integer.toString(artIndex + 1) : ""; + final String mwsCardName = GuiDisplayUtil.cleanStringMWS(cardName); // 3 letter set code with MWS filename format return String.format("%s%s.full.jpg", mwsCardName, nn); } @@ -655,18 +654,19 @@ public final class CardUtil { * @return a {@link java.lang.String} object. */ public static String buildFilename(final Card card) { - boolean token = card.isToken() && !card.isCopiedToken(); + final boolean token = card.isToken() && !card.isCopiedToken(); final String set = card.getCurSetCode(); - Predicate findSetInfo = new Predicate() { + final Predicate findSetInfo = new Predicate() { @Override public boolean isTrue(final SetInfo subject) { return subject.getCode().equals(set); } }; - SetInfo neededSet = findSetInfo.first(card.getSets()); - int cntPictures = neededSet == null ? 1 : neededSet.getPicCount(); - return buildFilename(card.getName(), card.getCurSetCode(), card.getRandomPicture(), cntPictures, token); + final SetInfo neededSet = findSetInfo.first(card.getSets()); + final int cntPictures = neededSet == null ? 1 : neededSet.getPicCount(); + return CardUtil + .buildFilename(card.getName(), card.getCurSetCode(), card.getRandomPicture(), cntPictures, token); } /** @@ -677,41 +677,48 @@ public final class CardUtil { * @return the string */ public static String buildFilename(final CardPrinted card) { - int maxIndex = card.getCard().getSetInfo(card.getSet()).getCopiesCount(); - return buildFilename(card.getName(), card.getSet(), card.getArtIndex(), maxIndex, false); + final int maxIndex = card.getCard().getSetInfo(card.getSet()).getCopiesCount(); + return CardUtil.buildFilename(card.getName(), card.getSet(), card.getArtIndex(), maxIndex, false); + } + + /** + * Builds the filename. + * + * @param card the card + * @param nameToUse the name to use + * @return the string + */ + public static String buildFilename(final CardPrinted card, final String nameToUse) { + final int maxIndex = card.getCard().getSetInfo(card.getSet()).getCopiesCount(); + return CardUtil.buildFilename(nameToUse, card.getSet(), card.getArtIndex(), maxIndex, false); } - public static String buildFilename(final CardPrinted card, String nameToUse) { - int maxIndex = card.getCard().getSetInfo(card.getSet()).getCopiesCount(); - return buildFilename(nameToUse, card.getSet(), card.getArtIndex(), maxIndex, false); - } - private static String buildFilename(final String cardName, final String setName, final int artIndex, final int artIndexMax, final boolean isToken) { - File path = ForgeProps.getFile(isToken ? NewConstants.IMAGE_TOKEN : NewConstants.IMAGE_BASE); - String nn = artIndexMax > 1 ? Integer.toString(artIndex + 1) : ""; - String cleanCardName = GuiDisplayUtil.cleanString(cardName); + final File path = ForgeProps.getFile(isToken ? NewConstants.IMAGE_TOKEN : NewConstants.IMAGE_BASE); + final String nn = artIndexMax > 1 ? Integer.toString(artIndex + 1) : ""; + final String cleanCardName = GuiDisplayUtil.cleanString(cardName); File f = null; if (StringUtils.isNotBlank(setName)) { - String mwsCardName = GuiDisplayUtil.cleanStringMWS(cardName); + final String mwsCardName = GuiDisplayUtil.cleanStringMWS(cardName); // First, try 3 letter set code with MWS filename format - String mwsSet3 = String.format("%s/%s%s.full", setName, mwsCardName, nn); + final String mwsSet3 = String.format("%s/%s%s.full", setName, mwsCardName, nn); f = new File(path, mwsSet3 + ".jpg"); if (f.exists()) { return mwsSet3; } // Second, try 2 letter set code with MWS filename format - String mwsSet2 = String.format("%s/%s%s.full", SetUtils.getCode2ByCode(setName), mwsCardName, nn); + final String mwsSet2 = String.format("%s/%s%s.full", SetUtils.getCode2ByCode(setName), mwsCardName, nn); f = new File(path, mwsSet2 + ".jpg"); if (f.exists()) { return mwsSet2; } // Third, try 3 letter set code with Forge filename format - String forgeSet3 = String.format("%s/%s%s", setName, cleanCardName, nn); + final String forgeSet3 = String.format("%s/%s%s", setName, cleanCardName, nn); f = new File(path, forgeSet3 + ".jpg"); if (f.exists()) { return forgeSet3; @@ -719,7 +726,7 @@ public final class CardUtil { } // Last, give up with set images, go with the old picture type - String forgePlain = String.format("%s%s", cleanCardName, nn); + final String forgePlain = String.format("%s%s", cleanCardName, nn); f = new File(path, forgePlain + ".jpg"); if (f.exists()) { @@ -750,7 +757,7 @@ public final class CardUtil { return 0; } - ManaCost cost = new ManaCost(manaCost); + final ManaCost cost = new ManaCost(manaCost); return cost.getWeightedManaCost(); } @@ -765,7 +772,7 @@ public final class CardUtil { */ public static String getShortColorsString(final ArrayList colors) { String colorDesc = ""; - for (String col : colors) { + for (final String col : colors) { if (col.equalsIgnoreCase("White")) { colorDesc += "W"; } else if (col.equalsIgnoreCase("Blue")) { @@ -888,7 +895,7 @@ public final class CardUtil { * @return a copy of C with LastKnownInfo stuff retained. */ public static Card getLKICopy(final Card c) { - Card res = AllZone.getCardFactory().copyCard(c); + final Card res = AllZone.getCardFactory().copyCard(c); res.setControllerObjects(c.getControllerObjects()); res.addTempAttackBoost(c.getTempAttackBoost()); res.addTempDefenseBoost(c.getTempDefenseBoost()); @@ -899,7 +906,7 @@ public final class CardUtil { res.setNewPT(c.getNewPT()); res.setReceivedDamageFromThisTurn(c.getReceivedDamageFromThisTurn()); res.setHaunting(c.getHaunting()); - for (Card haunter : c.getHauntedBy()) { + for (final Card haunter : c.getHauntedBy()) { res.addHauntedBy(haunter); } @@ -918,14 +925,14 @@ public final class CardUtil { * @return the radiance */ public static CardList getRadiance(final Card source, final Card origin, final String[] valid) { - CardList res = new CardList(); + final CardList res = new CardList(); - for (CardColor col : origin.getColor()) { - for (String strCol : col.toStringArray()) { + for (final CardColor col : origin.getColor()) { + for (final String strCol : col.toStringArray()) { if (strCol.equalsIgnoreCase("Colorless")) { continue; } - for (Card c : AllZoneUtil.getColorInPlay(strCol)) { + for (final Card c : AllZoneUtil.getColorInPlay(strCol)) { if (!res.contains(c) && c.isValid(valid, source.getController(), source) && !c.equals(origin)) { res.add(c); } @@ -935,48 +942,54 @@ public final class CardUtil { return res; } - - public static ArrayList getConvokableColors(final Card cardToConvoke, ManaCost cost) - { - ArrayList usableColors = new ArrayList(); - - if(cost.getColorlessManaAmount() > 0) - { + + /** + * Gets the convokable colors. + * + * @param cardToConvoke the card to convoke + * @param cost the cost + * @return the convokable colors + */ + public static ArrayList getConvokableColors(final Card cardToConvoke, final ManaCost cost) { + final ArrayList usableColors = new ArrayList(); + + if (cost.getColorlessManaAmount() > 0) { usableColors.add("colorless"); } - for(CardColor col : cardToConvoke.getColor()) - { - for(String strCol : col.toStringArray()) - { - if(strCol.equals("colorless")) - { + for (final CardColor col : cardToConvoke.getColor()) { + for (final String strCol : col.toStringArray()) { + if (strCol.equals("colorless")) { continue; } - if(cost.toString().contains(InputPayManaCostUtil.getShortColorString(strCol))) - { + if (cost.toString().contains(InputPayManaCostUtil.getShortColorString(strCol))) { usableColors.add(strCol.toString()); } } } - + return usableColors; } - + + /** + * Gets the face down characteristic. + * + * @return the face down characteristic + */ public static CardCharacteristics getFaceDownCharacteristic() { - ArrayList types = new ArrayList(); + final ArrayList types = new ArrayList(); types.add("Creature"); - - CardCharacteristics ret = new CardCharacteristics(); + + final CardCharacteristics ret = new CardCharacteristics(); ret.setBaseAttack(2); ret.setBaseDefense(2); - + ret.setName(""); ret.setType(types); - + ret.setImageFilename("morph.jpg"); - + return ret; - + } } // end class CardUtil diff --git a/src/main/java/forge/Combat.java b/src/main/java/forge/Combat.java index 2113732a974..926947b6d71 100644 --- a/src/main/java/forge/Combat.java +++ b/src/main/java/forge/Combat.java @@ -225,7 +225,9 @@ public class Combat { if (attackingPlayer != null) { return attackingPlayer; } - else return AllZone.getPhase().getPlayerTurn(); + else { + return AllZone.getPhase().getPlayerTurn(); + } } /** @@ -239,7 +241,9 @@ public class Combat { if (attackingPlayer != null) { return defendingPlayer; } - else return AllZone.getPhase().getPlayerTurn().getOpponent(); + else { + return AllZone.getPhase().getPlayerTurn().getOpponent(); + } } /** diff --git a/src/main/java/forge/CombatUtil.java b/src/main/java/forge/CombatUtil.java index e0d625833e2..83eb19111c3 100644 --- a/src/main/java/forge/CombatUtil.java +++ b/src/main/java/forge/CombatUtil.java @@ -43,19 +43,19 @@ public class CombatUtil { return false; } - if (combat.getAllBlockers().size() > 1 && AllZoneUtil.isCardInPlay("Caverns of Despair")) { + if ((combat.getAllBlockers().size() > 1) && AllZoneUtil.isCardInPlay("Caverns of Despair")) { return false; } - if (combat.getAllBlockers().size() > 0 && AllZoneUtil.isCardInPlay("Silent Arbiter")) { + if ((combat.getAllBlockers().size() > 0) && AllZoneUtil.isCardInPlay("Silent Arbiter")) { return false; } - if (combat.getAllBlockers().size() > 0 && AllZoneUtil.isCardInPlay("Dueling Grounds")) { + if ((combat.getAllBlockers().size() > 0) && AllZoneUtil.isCardInPlay("Dueling Grounds")) { return false; } - return canBlock(blocker); + return CombatUtil.canBlock(blocker); } // can the creature block at all? @@ -83,11 +83,11 @@ public class CombatUtil { return false; } - CardList kulrath = AllZoneUtil.getCardsIn(Zone.Battlefield, "Kulrath Knight"); + final CardList kulrath = AllZoneUtil.getCardsIn(Zone.Battlefield, "Kulrath Knight"); if (kulrath.size() > 0) { for (int i = 0; i < kulrath.size(); i++) { - Card cKK = kulrath.get(i); - Player oppKK = cKK.getController().getOpponent(); + final Card cKK = kulrath.get(i); + final Player oppKK = cKK.getController().getOpponent(); if (blocker.getController().equals(oppKK) && blocker.hasCounters()) { return false; @@ -117,11 +117,11 @@ public class CombatUtil { } if (attacker.hasKeyword("CARDNAME can't be blocked by more than one creature.") - && combat.getBlockers(attacker).size() > 0) { + && (combat.getBlockers(attacker).size() > 0)) { return false; } - return canBeBlocked(attacker); + return CombatUtil.canBeBlocked(attacker); } // can the attacker be blocked at all? @@ -147,7 +147,7 @@ public class CombatUtil { // Landwalk if (!AllZoneUtil.isCardInPlay("Staff of the Ages")) { // "Creatures with landwalk abilities can be blocked as though they didn't have those abilities." - CardList blkCL = attacker.getController().getOpponent().getCardsIn(Zone.Battlefield); + final CardList blkCL = attacker.getController().getOpponent().getCardsIn(Zone.Battlefield); CardList temp = new CardList(); if (attacker.hasKeyword("Plainswalk")) { @@ -160,8 +160,7 @@ public class CombatUtil { if (attacker.hasKeyword("Islandwalk")) { temp = blkCL.getType("Island"); - if (!AllZoneUtil.isCardInPlay("Undertow") - && !AllZoneUtil.isCardInPlay("Gosta Dirk") && !temp.isEmpty()) { + if (!AllZoneUtil.isCardInPlay("Undertow") && !AllZoneUtil.isCardInPlay("Gosta Dirk") && !temp.isEmpty()) { return false; } } @@ -190,6 +189,7 @@ public class CombatUtil { if (attacker.hasKeyword("Legendary landwalk")) { temp = blkCL.filter(new CardListFilter() { + @Override public boolean addCard(final Card c) { return c.isLand() && c.isType("Legendary"); } @@ -201,6 +201,7 @@ public class CombatUtil { if (attacker.hasKeyword("Snow swampwalk")) { temp = blkCL.filter(new CardListFilter() { + @Override public boolean addCard(final Card c) { return c.isType("Swamp") && c.isSnow(); } @@ -212,6 +213,7 @@ public class CombatUtil { if (attacker.hasKeyword("Snow forestwalk")) { temp = blkCL.filter(new CardListFilter() { + @Override public boolean addCard(final Card c) { return c.isType("Forest") && c.isSnow(); } @@ -223,6 +225,7 @@ public class CombatUtil { if (attacker.hasKeyword("Snow islandwalk")) { temp = blkCL.filter(new CardListFilter() { + @Override public boolean addCard(final Card c) { return c.isType("Island") && c.isSnow(); } @@ -234,6 +237,7 @@ public class CombatUtil { if (attacker.hasKeyword("Snow plainswalk")) { temp = blkCL.filter(new CardListFilter() { + @Override public boolean addCard(final Card c) { return c.isType("Plains") && c.isSnow(); } @@ -245,6 +249,7 @@ public class CombatUtil { if (attacker.hasKeyword("Snow mountainwalk")) { temp = blkCL.filter(new CardListFilter() { + @Override public boolean addCard(final Card c) { return c.isType("Mountain") && c.isSnow(); } @@ -256,6 +261,7 @@ public class CombatUtil { if (attacker.hasKeyword("Snow landwalk")) { temp = blkCL.filter(new CardListFilter() { + @Override public boolean addCard(final Card c) { return c.isLand() && c.isSnow(); } @@ -267,6 +273,7 @@ public class CombatUtil { if (attacker.hasKeyword("Desertwalk")) { temp = blkCL.filter(new CardListFilter() { + @Override public boolean addCard(final Card c) { return c.isLand() && c.isType("Desert"); } @@ -278,6 +285,7 @@ public class CombatUtil { if (attacker.hasKeyword("Nonbasic landwalk")) { temp = blkCL.filter(new CardListFilter() { + @Override public boolean addCard(final Card c) { return c.isLand() && !c.isBasicLand(); } @@ -289,17 +297,24 @@ public class CombatUtil { } return true; } - + + /** + * Can be blocked. + * + * @param attacker the attacker + * @param blockers the blockers + * @return true, if successful + */ public static boolean canBeBlocked(final Card attacker, final CardList blockers) { - if(!canBeBlocked(attacker)) { + if (!CombatUtil.canBeBlocked(attacker)) { return false; } - for (Card blocker : blockers) { - if (canBlock(attacker, blocker)) { + for (final Card blocker : blockers) { + if (CombatUtil.canBlock(attacker, blocker)) { return true; } } - + return false; } @@ -315,21 +330,20 @@ public class CombatUtil { */ public static boolean finishedMandatotyBlocks(final Combat combat) { - CardList blockers = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer()); - CardList attackers = new CardList(combat.getAttackers()); + final CardList blockers = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer()); + final CardList attackers = new CardList(combat.getAttackers()); // if a creature does not block but should, return false - for (Card blocker : blockers) { + for (final Card blocker : blockers) { // lure effects - if (!combat.getAllBlockers().contains(blocker) && mustBlockAnAttacker(blocker, combat)) { + if (!combat.getAllBlockers().contains(blocker) && CombatUtil.mustBlockAnAttacker(blocker, combat)) { return false; } // "CARDNAME blocks each turn if able." - if (!combat.getAllBlockers().contains(blocker) - && blocker.hasKeyword("CARDNAME blocks each turn if able.")) { - for (Card attacker : attackers) { - if (canBlock(attacker, blocker, combat)) { + if (!combat.getAllBlockers().contains(blocker) && blocker.hasKeyword("CARDNAME blocks each turn if able.")) { + for (final Card attacker : attackers) { + if (CombatUtil.canBlock(attacker, blocker, combat)) { return false; } } @@ -357,21 +371,21 @@ public class CombatUtil { return false; } - if (!canBlock(blocker, combat)) { + if (!CombatUtil.canBlock(blocker, combat)) { return false; } CardList attackersWithLure = new CardList(combat.getAttackers()); attackersWithLure = attackersWithLure.getKeyword("All creatures able to block CARDNAME do so."); - for (Card attacker : attackersWithLure) { - if (canBeBlocked(attacker, combat) && canBlock(attacker, blocker)) { + for (final Card attacker : attackersWithLure) { + if (CombatUtil.canBeBlocked(attacker, combat) && CombatUtil.canBlock(attacker, blocker)) { return true; } } - for (Card attacker : blocker.getMustBlockCards()) { - if (canBeBlocked(attacker, combat) && canBlock(attacker, blocker)) { + for (final Card attacker : blocker.getMustBlockCards()) { + if (CombatUtil.canBeBlocked(attacker, combat) && CombatUtil.canBlock(attacker, blocker)) { return true; } } @@ -395,25 +409,25 @@ public class CombatUtil { */ public static boolean canBlock(final Card attacker, final Card blocker, final Combat combat) { - if (attacker == null || blocker == null) { + if ((attacker == null) || (blocker == null)) { return false; } - if (!canBlock(blocker, combat)) { + if (!CombatUtil.canBlock(blocker, combat)) { return false; } - if (!canBeBlocked(attacker, combat)) { + if (!CombatUtil.canBeBlocked(attacker, combat)) { return false; } // if the attacker has no lure effect, but the blocker can block another // attacker with lure, the blocker can't block the former if (!attacker.hasKeyword("All creatures able to block CARDNAME do so.") - && !(blocker.getMustBlockCards().contains(attacker)) && mustBlockAnAttacker(blocker, combat)) { + && !(blocker.getMustBlockCards().contains(attacker)) && CombatUtil.mustBlockAnAttacker(blocker, combat)) { return false; } - return canBlock(attacker, blocker); + return CombatUtil.canBlock(attacker, blocker); } // can the blocker block the attacker? @@ -429,14 +443,14 @@ public class CombatUtil { * @return a boolean. */ public static boolean canBlock(final Card attacker, final Card blocker) { - if (attacker == null || blocker == null) { + if ((attacker == null) || (blocker == null)) { return false; } - if (!canBlock(blocker)) { + if (!CombatUtil.canBlock(blocker)) { return false; } - if (!canBeBlocked(attacker)) { + if (!CombatUtil.canBeBlocked(attacker)) { return false; } @@ -445,10 +459,10 @@ public class CombatUtil { } if (blocker.hasStartOfKeyword("CARDNAME can't block ")) { - for (String kw : blocker.getKeyword()) { + for (final String kw : blocker.getKeyword()) { if (kw.startsWith("CARDNAME can't block ")) { - String unblockableCard = kw.substring(21); - int id = Integer.parseInt(unblockableCard.substring(unblockableCard.lastIndexOf("(") + 1, + final String unblockableCard = kw.substring(21); + final int id = Integer.parseInt(unblockableCard.substring(unblockableCard.lastIndexOf("(") + 1, unblockableCard.length() - 1)); if (attacker.getUniqueNumber() == id) { return false; @@ -473,26 +487,24 @@ public class CombatUtil { } if (attacker.hasKeyword("Creatures with power less than CARDNAME's power can't block it.") - && attacker.getNetAttack() > blocker.getNetAttack()) { + && (attacker.getNetAttack() > blocker.getNetAttack())) { return false; } - if (blocker.getNetAttack() > attacker.getNetAttack() - && blocker - .hasKeyword("CARDNAME can't be blocked by creatures " - + "with power greater than CARDNAME's power.")) { + if ((blocker.getNetAttack() > attacker.getNetAttack()) + && blocker.hasKeyword("CARDNAME can't be blocked by creatures " + + "with power greater than CARDNAME's power.")) { return false; } - if (blocker.getNetAttack() >= attacker.getNetDefense() - && blocker - .hasKeyword("CARDNAME can't be blocked by creatures with " - + "power equal to or greater than CARDNAME's toughness.")) { + if ((blocker.getNetAttack() >= attacker.getNetDefense()) + && blocker.hasKeyword("CARDNAME can't be blocked by creatures with " + + "power equal to or greater than CARDNAME's toughness.")) { return false; } if (attacker.hasStartOfKeyword("CantBeBlockedBy")) { - int keywordPosition = attacker.getKeywordPosition("CantBeBlockedBy"); - String parse = attacker.getKeyword().get(keywordPosition).toString(); - String[] k = parse.split(" ", 2); + final int keywordPosition = attacker.getKeywordPosition("CantBeBlockedBy"); + final String parse = attacker.getKeyword().get(keywordPosition).toString(); + final String[] k = parse.split(" ", 2); final String[] restrictions = k[1].split(","); if (blocker.isValid(restrictions, attacker.getController(), attacker)) { return false; @@ -500,9 +512,9 @@ public class CombatUtil { } if (blocker.hasStartOfKeyword("CantBlock")) { - int keywordPosition = blocker.getKeywordPosition("CantBlock"); - String parse = blocker.getKeyword().get(keywordPosition).toString(); - String[] k = parse.split(" ", 2); + final int keywordPosition = blocker.getKeywordPosition("CantBlock"); + final String parse = blocker.getKeyword().get(keywordPosition).toString(); + final String[] k = parse.split(" ", 2); final String[] restrictions = k[1].split(","); if (attacker.isValid(restrictions, blocker.getController(), blocker)) { return false; @@ -589,24 +601,24 @@ public class CombatUtil { */ public static boolean canAttack(final Card c, final Combat combat) { - if (combat.getAttackers().length > 1 + if ((combat.getAttackers().length > 1) && AllZoneUtil.isCardInPlay("Crawlspace", c.getController().getOpponent())) { return false; } - if (combat.getAttackers().length > 1 && AllZoneUtil.isCardInPlay("Caverns of Despair")) { + if ((combat.getAttackers().length > 1) && AllZoneUtil.isCardInPlay("Caverns of Despair")) { return false; } - if (combat.getAttackers().length > 0 && AllZoneUtil.isCardInPlay("Silent Arbiter")) { + if ((combat.getAttackers().length > 0) && AllZoneUtil.isCardInPlay("Silent Arbiter")) { return false; } - if (combat.getAttackers().length > 0 && AllZoneUtil.isCardInPlay("Dueling Grounds")) { + if ((combat.getAttackers().length > 0) && AllZoneUtil.isCardInPlay("Dueling Grounds")) { return false; } - return canAttack(c); + return CombatUtil.canAttack(c); } // can a creature attack at the moment? @@ -624,7 +636,7 @@ public class CombatUtil { return false; } - return canAttackNextTurn(c); + return CombatUtil.canAttackNextTurn(c); } // can a creature attack if untapped and without summoning sickness? @@ -648,7 +660,7 @@ public class CombatUtil { int keywordPosition = 0; boolean hasKeyword = false; - ArrayList attackerKeywords = c.getKeyword(); + final ArrayList attackerKeywords = c.getKeyword(); for (int i = 0; i < attackerKeywords.size(); i++) { if (attackerKeywords.get(i).toString() .startsWith("CARDNAME can't attack if defending player controls an untapped creature with power")) { @@ -661,7 +673,7 @@ public class CombatUtil { // "CARDNAME can't attack if defending player controls an untapped creature with power" // ... is present if (hasKeyword) { - String tmpString = c.getKeyword().get(keywordPosition).toString(); + final String tmpString = c.getKeyword().get(keywordPosition).toString(); final String[] asSeparateWords = tmpString.trim().split(" "); if (asSeparateWords.length >= 15) { @@ -670,10 +682,10 @@ public class CombatUtil { CardList list = AllZoneUtil.getCreaturesInPlay(c.getController().getOpponent()); list = list.filter(new CardListFilter() { + @Override public boolean addCard(final Card ct) { - return ((ct.isUntapped() && ct.getNetAttack() >= powerLimit[0] && asSeparateWords[14] - .contains("greater")) - || (ct.isUntapped() && ct.getNetAttack() <= powerLimit[0] && asSeparateWords[14] + return ((ct.isUntapped() && (ct.getNetAttack() >= powerLimit[0]) && asSeparateWords[14] + .contains("greater")) || (ct.isUntapped() && (ct.getNetAttack() <= powerLimit[0]) && asSeparateWords[14] .contains("less"))); } }); @@ -685,7 +697,7 @@ public class CombatUtil { } // hasKeyword = CARDNAME can't attack if defending player controls an // untapped creature with power ... - CardList list = c.getController().getOpponent().getCardsIn(Zone.Battlefield); + final CardList list = c.getController().getOpponent().getCardsIn(Zone.Battlefield); CardList temp; if (c.hasKeyword("CARDNAME can't attack unless defending player controls an Island.")) { @@ -716,6 +728,7 @@ public class CombatUtil { } if (c.hasKeyword("CARDNAME can't attack unless defending player controls a snow land.")) { temp = list.filter(new CardListFilter() { + @Override public boolean addCard(final Card c) { return c.isLand() && c.isSnow(); } @@ -733,7 +746,7 @@ public class CombatUtil { } if (c.getName().equals("Harbor Serpent")) { - CardList allislands = AllZoneUtil.getCardsIn(Zone.Battlefield).getType("Island"); + final CardList allislands = AllZoneUtil.getCardsIn(Zone.Battlefield).getType("Island"); if (allislands.size() < 5) { return false; } @@ -753,10 +766,10 @@ public class CombatUtil { } if (AllZoneUtil.isCardInPlay("Kulrath Knight")) { - CardList all = AllZoneUtil.getCardsIn(Zone.Battlefield, "Kulrath Knight"); + final CardList all = AllZoneUtil.getCardsIn(Zone.Battlefield, "Kulrath Knight"); for (int i = 0; i < all.size(); i++) { - Card cKK = all.get(i); - Player oppKK = cKK.getController().getOpponent(); + final Card cKK = all.get(i); + final Player oppKK = cKK.getController().getOpponent(); if (c.getController().equals(oppKK) && c.hasCounters()) { return false; @@ -783,12 +796,13 @@ public class CombatUtil { CardList list = AllZoneUtil.getCreaturesInPlay(player); list = list.filter(new CardListFilter() { + @Override public boolean addCard(final Card c) { - return canBlock(att, c) && (c.hasFirstStrike() || c.hasDoubleStrike()); + return CombatUtil.canBlock(att, c) && (c.hasFirstStrike() || c.hasDoubleStrike()); } }); - return totalDamageOfBlockers(attacker, list); + return CombatUtil.totalDamageOfBlockers(attacker, list); } @@ -829,7 +843,7 @@ public class CombatUtil { public static int damageIfUnblocked(final Card attacker, final Player attacked, final Combat combat) { int damage = attacker.getNetCombatDamage(); int sum = 0; - damage += predictPowerBonusOfAttacker(attacker, null, combat); + damage += CombatUtil.predictPowerBonusOfAttacker(attacker, null, combat); if (!attacker.hasKeyword("Infect")) { sum = attacked.predictDamage(damage, attacker, true); if (attacker.hasKeyword("Double Strike")) { @@ -856,14 +870,14 @@ public class CombatUtil { public static int poisonIfUnblocked(final Card attacker, final Player attacked, final Combat combat) { int damage = attacker.getNetCombatDamage(); int poison = 0; - damage += predictPowerBonusOfAttacker(attacker, null, null); + damage += CombatUtil.predictPowerBonusOfAttacker(attacker, null, null); if (attacker.hasKeyword("Infect")) { poison += attacked.predictDamage(damage, attacker, true); if (attacker.hasKeyword("Double Strike")) { poison += attacked.predictDamage(damage, attacker, true); } } - if (attacker.hasKeyword("Poisonous") && damage > 0) { + if (attacker.hasKeyword("Poisonous") && (damage > 0)) { poison += attacker.getKeywordMagnitude("Poisonous"); } return poison; @@ -883,8 +897,8 @@ public class CombatUtil { */ public static int sumDamageIfUnblocked(final CardList attackers, final Player attacked) { int sum = 0; - for (Card attacker : attackers) { - sum += damageIfUnblocked(attacker, attacked, null); + for (final Card attacker : attackers) { + sum += CombatUtil.damageIfUnblocked(attacker, attacked, null); } return sum; } @@ -903,8 +917,8 @@ public class CombatUtil { */ public static int sumPoisonIfUnblocked(final CardList attackers, final Player attacked) { int sum = 0; - for (Card attacker : attackers) { - sum += poisonIfUnblocked(attacker, attacked, null); + for (final Card attacker : attackers) { + sum += CombatUtil.poisonIfUnblocked(attacker, attacked, null); } return sum; } @@ -923,24 +937,24 @@ public class CombatUtil { int damage = 0; - CardList attackers = combat.sortAttackerByDefender()[0]; - CardList unblocked = new CardList(); + final CardList attackers = combat.sortAttackerByDefender()[0]; + final CardList unblocked = new CardList(); - for (Card attacker : attackers) { + for (final Card attacker : attackers) { - CardList blockers = combat.getBlockers(attacker); + final CardList blockers = combat.getBlockers(attacker); if (blockers.size() == 0) { unblocked.add(attacker); } else if (attacker.hasKeyword("Trample") - && getAttack(attacker) > CombatUtil.totalShieldDamage(attacker, blockers)) { + && (CombatUtil.getAttack(attacker) > CombatUtil.totalShieldDamage(attacker, blockers))) { if (!attacker.hasKeyword("Infect")) { - damage += getAttack(attacker) - CombatUtil.totalShieldDamage(attacker, blockers); + damage += CombatUtil.getAttack(attacker) - CombatUtil.totalShieldDamage(attacker, blockers); } } } - damage += sumDamageIfUnblocked(unblocked, AllZone.getComputerPlayer()); + damage += CombatUtil.sumDamageIfUnblocked(unblocked, AllZone.getComputerPlayer()); if (!AllZone.getComputerPlayer().canLoseLife()) { damage = 0; @@ -963,19 +977,19 @@ public class CombatUtil { int poison = 0; - CardList attackers = combat.sortAttackerByDefender()[0]; - CardList unblocked = new CardList(); + final CardList attackers = combat.sortAttackerByDefender()[0]; + final CardList unblocked = new CardList(); - for (Card attacker : attackers) { + for (final Card attacker : attackers) { - CardList blockers = combat.getBlockers(attacker); + final CardList blockers = combat.getBlockers(attacker); if (blockers.size() == 0) { unblocked.add(attacker); } else if (attacker.hasKeyword("Trample") - && getAttack(attacker) > CombatUtil.totalShieldDamage(attacker, blockers)) { + && (CombatUtil.getAttack(attacker) > CombatUtil.totalShieldDamage(attacker, blockers))) { if (attacker.hasKeyword("Infect")) { - poison += getAttack(attacker) - CombatUtil.totalShieldDamage(attacker, blockers); + poison += CombatUtil.getAttack(attacker) - CombatUtil.totalShieldDamage(attacker, blockers); } if (attacker.hasKeyword("Poisonous")) { poison += attacker.getKeywordMagnitude("Poisonous"); @@ -983,7 +997,7 @@ public class CombatUtil { } } - poison += sumPoisonIfUnblocked(unblocked, AllZone.getComputerPlayer()); + poison += CombatUtil.sumPoisonIfUnblocked(unblocked, AllZone.getComputerPlayer()); return AllZone.getComputerPlayer().getPoisonCounters() + poison; } @@ -1005,12 +1019,12 @@ public class CombatUtil { return false; } - if (lifeThatWouldRemain(combat) < Math.min(4, AllZone.getComputerPlayer().getLife()) + if ((CombatUtil.lifeThatWouldRemain(combat) < Math.min(4, AllZone.getComputerPlayer().getLife())) && !AllZone.getComputerPlayer().cantLoseForZeroOrLessLife()) { return true; } - return (resultingPoison(combat) > Math.max(7, AllZone.getComputerPlayer().getPoisonCounters())); + return (CombatUtil.resultingPoison(combat) > Math.max(7, AllZone.getComputerPlayer().getPoisonCounters())); } // Checks if the life of the attacked Player would be reduced @@ -1025,7 +1039,7 @@ public class CombatUtil { */ public static boolean wouldLoseLife(final Combat combat) { - return (lifeThatWouldRemain(combat) < AllZone.getComputerPlayer().getLife()); + return (CombatUtil.lifeThatWouldRemain(combat) < AllZone.getComputerPlayer().getLife()); } // Checks if the life of the attacked Player/Planeswalker is in danger @@ -1045,11 +1059,11 @@ public class CombatUtil { return false; } - if (lifeThatWouldRemain(combat) < 1 && !AllZone.getComputerPlayer().cantLoseForZeroOrLessLife()) { + if ((CombatUtil.lifeThatWouldRemain(combat) < 1) && !AllZone.getComputerPlayer().cantLoseForZeroOrLessLife()) { return true; } - return (resultingPoison(combat) > 9); + return (CombatUtil.resultingPoison(combat) > 9); } // This calculates the amount of damage a blockgang can deal to the attacker @@ -1068,8 +1082,8 @@ public class CombatUtil { public static int totalDamageOfBlockers(final Card attacker, final CardList defenders) { int damage = 0; - for (Card defender : defenders) { - damage += dealsDamageAsBlocker(attacker, defender); + for (final Card defender : defenders) { + damage += CombatUtil.dealsDamageAsBlocker(attacker, defender); } return damage; } @@ -1101,20 +1115,19 @@ public class CombatUtil { if (flankingMagnitude >= defender.getNetDefense()) { return 0; } - if (flankingMagnitude >= defender.getNetDefense() - defender.getDamage() + if ((flankingMagnitude >= (defender.getNetDefense() - defender.getDamage())) && !defender.hasKeyword("Indestructible")) { return 0; } } // flanking - if (attacker.hasKeyword("Indestructible") && !(defender.hasKeyword("Wither") - || defender.hasKeyword("Infect"))) { + if (attacker.hasKeyword("Indestructible") && !(defender.hasKeyword("Wither") || defender.hasKeyword("Infect"))) { return 0; } - int defenderDamage = defender.getNetAttack() + predictPowerBonusOfBlocker(attacker, defender); + int defenderDamage = defender.getNetAttack() + CombatUtil.predictPowerBonusOfBlocker(attacker, defender); if (AllZoneUtil.isCardInPlay("Doran, the Siege Tower")) { - defenderDamage = defender.getNetDefense() + predictToughnessBonusOfBlocker(attacker, defender); + defenderDamage = defender.getNetDefense() + CombatUtil.predictToughnessBonusOfBlocker(attacker, defender); } // consider static Damage Prevention @@ -1144,8 +1157,8 @@ public class CombatUtil { int defenderDefense = 0; - for (Card defender : defenders) { - defenderDefense += shieldDamage(attacker, defender); + for (final Card defender : defenders) { + defenderDefense += CombatUtil.shieldDamage(attacker, defender); } return defenderDefense; @@ -1166,7 +1179,7 @@ public class CombatUtil { */ public static int shieldDamage(final Card attacker, final Card defender) { - if (!canDestroyBlocker(defender, attacker, null, false)) { + if (!CombatUtil.canDestroyBlocker(defender, attacker, null, false)) { return 100; } @@ -1178,16 +1191,16 @@ public class CombatUtil { if (flankingMagnitude >= defender.getNetDefense()) { return 0; } - if (flankingMagnitude >= defender.getNetDefense() - defender.getDamage() + if ((flankingMagnitude >= (defender.getNetDefense() - defender.getDamage())) && !defender.hasKeyword("Indestructible")) { return 0; } } // flanking - int defBushidoMagnitude = defender.getKeywordMagnitude("Bushido"); + final int defBushidoMagnitude = defender.getKeywordMagnitude("Bushido"); - int defenderDefense = defender.getNetDefense() - flankingMagnitude + defBushidoMagnitude; + final int defenderDefense = (defender.getNetDefense() - flankingMagnitude) + defBushidoMagnitude; return defenderDefense; } // shieldDamage @@ -1205,10 +1218,10 @@ public class CombatUtil { public static boolean combatantWouldBeDestroyed(final Card combatant) { if (combatant.isAttacking()) { - return attackerWouldBeDestroyed(combatant); + return CombatUtil.attackerWouldBeDestroyed(combatant); } if (combatant.isBlocking()) { - return blockerWouldBeDestroyed(combatant); + return CombatUtil.blockerWouldBeDestroyed(combatant); } return false; } @@ -1224,16 +1237,16 @@ public class CombatUtil { * @return a boolean. */ public static boolean attackerWouldBeDestroyed(final Card attacker) { - CardList blockers = AllZone.getCombat().getBlockers(attacker); + final CardList blockers = AllZone.getCombat().getBlockers(attacker); - for (Card defender : blockers) { + for (final Card defender : blockers) { if (CombatUtil.canDestroyAttacker(attacker, defender, AllZone.getCombat(), true) && !(defender.hasKeyword("Wither") || defender.hasKeyword("Infect"))) { return true; } } - return totalDamageOfBlockers(attacker, blockers) >= attacker.getKillDamage(); + return CombatUtil.totalDamageOfBlockers(attacker, blockers) >= attacker.getKillDamage(); } // Will this trigger trigger? @@ -1254,9 +1267,9 @@ public class CombatUtil { */ public static boolean combatTriggerWillTrigger(final Card attacker, final Card defender, final Trigger trigger, Combat combat) { - HashMap trigParams = trigger.getMapParams(); + final HashMap trigParams = trigger.getMapParams(); boolean willTrigger = false; - Card source = trigger.getHostCard(); + final Card source = trigger.getHostCard(); if (combat == null) { combat = AllZone.getCombat(); } @@ -1283,7 +1296,7 @@ public class CombatUtil { } // defender == null means unblocked - if (defender == null && trigParams.get("Mode").equals("AttackerUnblocked")) { + if ((defender == null) && trigParams.get("Mode").equals("AttackerUnblocked")) { willTrigger = true; if (trigParams.containsKey("ValidCard")) { if (!trigger.matchesValid(attacker, trigParams.get("ValidCard").split(","), source)) { @@ -1356,18 +1369,19 @@ public class CombatUtil { power += defender.getKeywordMagnitude("Bushido"); - ArrayList theTriggers = new ArrayList(defender.getTriggers()); + final ArrayList theTriggers = new ArrayList(defender.getTriggers()); theTriggers.addAll(attacker.getTriggers()); - for (Trigger trigger : theTriggers) { - HashMap trigParams = trigger.getMapParams(); - Card source = trigger.getHostCard(); + for (final Trigger trigger : theTriggers) { + final HashMap trigParams = trigger.getMapParams(); + final Card source = trigger.getHostCard(); - if (!combatTriggerWillTrigger(attacker, defender, trigger, null) || !trigParams.containsKey("Execute")) { + if (!CombatUtil.combatTriggerWillTrigger(attacker, defender, trigger, null) + || !trigParams.containsKey("Execute")) { continue; } - String ability = source.getSVar(trigParams.get("Execute")); - AbilityFactory abilityFactory = new AbilityFactory(); - HashMap abilityParams = abilityFactory.getMapParams(ability, source); + final String ability = source.getSVar(trigParams.get("Execute")); + final AbilityFactory abilityFactory = new AbilityFactory(); + final HashMap abilityParams = abilityFactory.getMapParams(ability, source); if (abilityParams.containsKey("AB") && !abilityParams.get("AB").equals("Pump")) { continue; } @@ -1377,7 +1391,7 @@ public class CombatUtil { if (abilityParams.containsKey("ValidTgts") || abilityParams.containsKey("Tgt")) { continue; // targeted pumping not supported } - ArrayList list = AbilityFactory.getDefinedCards(source, abilityParams.get("Defined"), null); + final ArrayList list = AbilityFactory.getDefinedCards(source, abilityParams.get("Defined"), null); if (abilityParams.containsKey("Defined") && abilityParams.get("Defined").equals("TriggeredBlocker")) { list.add(defender); } @@ -1397,7 +1411,7 @@ public class CombatUtil { } try { power += Integer.parseInt(att); - } catch (NumberFormatException nfe) { + } catch (final NumberFormatException nfe) { // can't parse the number (X for example) power += 0; } @@ -1427,18 +1441,19 @@ public class CombatUtil { toughness += defender.getKeywordMagnitude("Bushido"); - ArrayList theTriggers = new ArrayList(defender.getTriggers()); + final ArrayList theTriggers = new ArrayList(defender.getTriggers()); theTriggers.addAll(attacker.getTriggers()); - for (Trigger trigger : theTriggers) { - HashMap trigParams = trigger.getMapParams(); - Card source = trigger.getHostCard(); + for (final Trigger trigger : theTriggers) { + final HashMap trigParams = trigger.getMapParams(); + final Card source = trigger.getHostCard(); - if (!combatTriggerWillTrigger(attacker, defender, trigger, null) || !trigParams.containsKey("Execute")) { + if (!CombatUtil.combatTriggerWillTrigger(attacker, defender, trigger, null) + || !trigParams.containsKey("Execute")) { continue; } - String ability = source.getSVar(trigParams.get("Execute")); - AbilityFactory abilityFactory = new AbilityFactory(); - HashMap abilityParams = abilityFactory.getMapParams(ability, source); + final String ability = source.getSVar(trigParams.get("Execute")); + final AbilityFactory abilityFactory = new AbilityFactory(); + final HashMap abilityParams = abilityFactory.getMapParams(ability, source); if (abilityParams.containsKey("AB") && !abilityParams.get("AB").equals("Pump")) { continue; } @@ -1448,7 +1463,7 @@ public class CombatUtil { if (abilityParams.containsKey("ValidTgts") || abilityParams.containsKey("Tgt")) { continue; // targeted pumping not supported } - ArrayList list = AbilityFactory.getDefinedCards(source, abilityParams.get("Defined"), null); + final ArrayList list = AbilityFactory.getDefinedCards(source, abilityParams.get("Defined"), null); if (abilityParams.containsKey("Defined") && abilityParams.get("Defined").equals("TriggeredBlocker")) { list.add(defender); } @@ -1468,7 +1483,7 @@ public class CombatUtil { } try { toughness += Integer.parseInt(def); - } catch (NumberFormatException nfe) { + } catch (final NumberFormatException nfe) { // can't parse the number (X for example) toughness += 0; } @@ -1496,7 +1511,7 @@ public class CombatUtil { power += attacker.getKeywordMagnitude("Bushido"); - ArrayList theTriggers = new ArrayList(attacker.getTriggers()); + final ArrayList theTriggers = new ArrayList(attacker.getTriggers()); // if the defender has first strike and wither the attacker will deal // less damage than expected if (null != defender) { @@ -1509,16 +1524,17 @@ public class CombatUtil { theTriggers.addAll(defender.getTriggers()); } - for (Trigger trigger : theTriggers) { - HashMap trigParams = trigger.getMapParams(); - Card source = trigger.getHostCard(); + for (final Trigger trigger : theTriggers) { + final HashMap trigParams = trigger.getMapParams(); + final Card source = trigger.getHostCard(); - if (!combatTriggerWillTrigger(attacker, defender, trigger, null) || !trigParams.containsKey("Execute")) { + if (!CombatUtil.combatTriggerWillTrigger(attacker, defender, trigger, null) + || !trigParams.containsKey("Execute")) { continue; } - String ability = source.getSVar(trigParams.get("Execute")); - AbilityFactory abilityFactory = new AbilityFactory(); - HashMap abilityParams = abilityFactory.getMapParams(ability, source); + final String ability = source.getSVar(trigParams.get("Execute")); + final AbilityFactory abilityFactory = new AbilityFactory(); + final HashMap abilityParams = abilityFactory.getMapParams(ability, source); if (abilityParams.containsKey("ValidTgts") || abilityParams.containsKey("Tgt")) { continue; // targeted pumping not supported } @@ -1560,7 +1576,7 @@ public class CombatUtil { } try { power += Integer.parseInt(att); - } catch (NumberFormatException nfe) { + } catch (final NumberFormatException nfe) { // can't parse the number (X for example) power += 0; } @@ -1586,22 +1602,23 @@ public class CombatUtil { public static int predictToughnessBonusOfAttacker(final Card attacker, final Card defender, final Combat combat) { int toughness = 0; - ArrayList theTriggers = new ArrayList(attacker.getTriggers()); + final ArrayList theTriggers = new ArrayList(attacker.getTriggers()); if (defender != null) { toughness += attacker.getKeywordMagnitude("Bushido"); theTriggers.addAll(defender.getTriggers()); } - for (Trigger trigger : theTriggers) { - HashMap trigParams = trigger.getMapParams(); - Card source = trigger.getHostCard(); + for (final Trigger trigger : theTriggers) { + final HashMap trigParams = trigger.getMapParams(); + final Card source = trigger.getHostCard(); - if (!combatTriggerWillTrigger(attacker, defender, trigger, null) || !trigParams.containsKey("Execute")) { + if (!CombatUtil.combatTriggerWillTrigger(attacker, defender, trigger, null) + || !trigParams.containsKey("Execute")) { continue; } - String ability = source.getSVar(trigParams.get("Execute")); - AbilityFactory abilityFactory = new AbilityFactory(); - HashMap abilityParams = abilityFactory.getMapParams(ability, source); + final String ability = source.getSVar(trigParams.get("Execute")); + final AbilityFactory abilityFactory = new AbilityFactory(); + final HashMap abilityParams = abilityFactory.getMapParams(ability, source); if (abilityParams.containsKey("ValidTgts") || abilityParams.containsKey("Tgt")) { continue; // targeted pumping not supported } @@ -1609,14 +1626,13 @@ public class CombatUtil { // DealDamage triggers if ((abilityParams.containsKey("AB") && abilityParams.get("AB").equals("DealDamage")) || (abilityParams.containsKey("DB") && abilityParams.get("DB").equals("DealDamage"))) { - if (!abilityParams.containsKey("Defined") - || !abilityParams.get("Defined").equals("TriggeredAttacker")) { + if (!abilityParams.containsKey("Defined") || !abilityParams.get("Defined").equals("TriggeredAttacker")) { continue; } int damage = 0; try { damage = Integer.parseInt(abilityParams.get("NumDmg")); - } catch (NumberFormatException nfe) { + } catch (final NumberFormatException nfe) { // can't parse the number (X for example) continue; } @@ -1663,7 +1679,7 @@ public class CombatUtil { } try { toughness += Integer.parseInt(def); - } catch (NumberFormatException nfe) { + } catch (final NumberFormatException nfe) { // can't parse the number (X for example) toughness += 0; } @@ -1702,7 +1718,7 @@ public class CombatUtil { if (flankingMagnitude >= defender.getNetDefense()) { return false; } - if (flankingMagnitude >= defender.getNetDefense() - defender.getDamage() + if ((flankingMagnitude >= (defender.getNetDefense() - defender.getDamage())) && !defender.hasKeyword("Indestructible")) { return false; } @@ -1713,11 +1729,13 @@ public class CombatUtil { return false; } - int defenderDamage = defender.getNetAttack() + predictPowerBonusOfBlocker(attacker, defender); - int attackerDamage = attacker.getNetAttack() + predictPowerBonusOfAttacker(attacker, defender, combat); + int defenderDamage = defender.getNetAttack() + CombatUtil.predictPowerBonusOfBlocker(attacker, defender); + int attackerDamage = attacker.getNetAttack() + + CombatUtil.predictPowerBonusOfAttacker(attacker, defender, combat); if (AllZoneUtil.isCardInPlay("Doran, the Siege Tower")) { - defenderDamage = defender.getNetDefense() + predictToughnessBonusOfBlocker(attacker, defender); - attackerDamage = attacker.getNetDefense() + predictToughnessBonusOfAttacker(attacker, defender, combat); + defenderDamage = defender.getNetDefense() + CombatUtil.predictToughnessBonusOfBlocker(attacker, defender); + attackerDamage = attacker.getNetDefense() + + CombatUtil.predictToughnessBonusOfAttacker(attacker, defender, combat); } int possibleDefenderPrevention = 0; @@ -1731,11 +1749,13 @@ public class CombatUtil { defenderDamage = attacker.predictDamage(defenderDamage, possibleAttackerPrevention, defender, true); attackerDamage = defender.predictDamage(attackerDamage, possibleDefenderPrevention, attacker, true); - int defenderLife = defender.getKillDamage() + predictToughnessBonusOfBlocker(attacker, defender); - int attackerLife = attacker.getKillDamage() + predictToughnessBonusOfAttacker(attacker, defender, combat); + final int defenderLife = defender.getKillDamage() + + CombatUtil.predictToughnessBonusOfBlocker(attacker, defender); + final int attackerLife = attacker.getKillDamage() + + CombatUtil.predictToughnessBonusOfAttacker(attacker, defender, combat); if (defender.hasKeyword("Double Strike")) { - if (defender.hasKeyword("Deathtouch") && defenderDamage > 0) { + if (defender.hasKeyword("Deathtouch") && (defenderDamage > 0)) { return true; } if (defenderDamage >= attackerLife) { @@ -1749,29 +1769,30 @@ public class CombatUtil { if (attackerDamage >= defenderLife) { return false; } - if (attackerDamage > 0 && attacker.hasKeyword("Deathtouch")) { + if ((attackerDamage > 0) && attacker.hasKeyword("Deathtouch")) { return false; } } - if (attackerLife <= 2 * defenderDamage) { + if (attackerLife <= (2 * defenderDamage)) { return true; } } // defender double strike else { // no double strike for defender // Attacker may kill the blocker before he can deal any damage - if (attacker.hasKeyword("Double Strike") || attacker.hasKeyword("First Strike") - && !defender.hasKeyword("Indestructible") && !defender.hasKeyword("First Strike")) { + if (attacker.hasKeyword("Double Strike") + || (attacker.hasKeyword("First Strike") && !defender.hasKeyword("Indestructible") && !defender + .hasKeyword("First Strike"))) { if (attackerDamage >= defenderLife) { return false; } - if (attackerDamage > 0 && attacker.hasKeyword("Deathtouch")) { + if ((attackerDamage > 0) && attacker.hasKeyword("Deathtouch")) { return false; } } - if (defender.hasKeyword("Deathtouch") && defenderDamage > 0) { + if (defender.hasKeyword("Deathtouch") && (defenderDamage > 0)) { return true; } @@ -1792,9 +1813,9 @@ public class CombatUtil { * @return a boolean. */ public static boolean blockerWouldBeDestroyed(final Card blocker) { - Card attacker = AllZone.getCombat().getAttackerBlockedBy(blocker); + final Card attacker = AllZone.getCombat().getAttackerBlockedBy(blocker); - if (canDestroyBlocker(blocker, attacker, AllZone.getCombat(), true) + if (CombatUtil.canDestroyBlocker(blocker, attacker, AllZone.getCombat(), true) && !(attacker.hasKeyword("Wither") || attacker.hasKeyword("Infect"))) { return true; } @@ -1842,11 +1863,13 @@ public class CombatUtil { return true; } - int defenderDamage = defender.getNetAttack() + predictPowerBonusOfBlocker(attacker, defender); - int attackerDamage = attacker.getNetAttack() + predictPowerBonusOfAttacker(attacker, defender, combat); + int defenderDamage = defender.getNetAttack() + CombatUtil.predictPowerBonusOfBlocker(attacker, defender); + int attackerDamage = attacker.getNetAttack() + + CombatUtil.predictPowerBonusOfAttacker(attacker, defender, combat); if (AllZoneUtil.isCardInPlay("Doran, the Siege Tower")) { - defenderDamage = defender.getNetDefense() + predictToughnessBonusOfBlocker(attacker, defender); - attackerDamage = attacker.getNetDefense() + predictToughnessBonusOfAttacker(attacker, defender, combat); + defenderDamage = defender.getNetDefense() + CombatUtil.predictToughnessBonusOfBlocker(attacker, defender); + attackerDamage = attacker.getNetDefense() + + CombatUtil.predictToughnessBonusOfAttacker(attacker, defender, combat); } int possibleDefenderPrevention = 0; @@ -1860,11 +1883,13 @@ public class CombatUtil { defenderDamage = attacker.predictDamage(defenderDamage, possibleAttackerPrevention, defender, true); attackerDamage = defender.predictDamage(attackerDamage, possibleDefenderPrevention, attacker, true); - int defenderLife = defender.getKillDamage() + predictToughnessBonusOfBlocker(attacker, defender); - int attackerLife = attacker.getKillDamage() + predictToughnessBonusOfAttacker(attacker, defender, combat); + final int defenderLife = defender.getKillDamage() + + CombatUtil.predictToughnessBonusOfBlocker(attacker, defender); + final int attackerLife = attacker.getKillDamage() + + CombatUtil.predictToughnessBonusOfAttacker(attacker, defender, combat); if (attacker.hasKeyword("Double Strike")) { - if (attacker.hasKeyword("Deathtouch") && attackerDamage > 0) { + if (attacker.hasKeyword("Deathtouch") && (attackerDamage > 0)) { return true; } if (attackerDamage >= defenderLife) { @@ -1878,29 +1903,30 @@ public class CombatUtil { if (defenderDamage >= attackerLife) { return false; } - if (defenderDamage > 0 && defender.hasKeyword("Deathtouch")) { + if ((defenderDamage > 0) && defender.hasKeyword("Deathtouch")) { return false; } } - if (defenderLife <= 2 * attackerDamage) { + if (defenderLife <= (2 * attackerDamage)) { return true; } } // attacker double strike else { // no double strike for attacker // Defender may kill the attacker before he can deal any damage - if (defender.hasKeyword("Double Strike") || defender.hasKeyword("First Strike") - && !attacker.hasKeyword("Indestructible") && !attacker.hasKeyword("First Strike")) { + if (defender.hasKeyword("Double Strike") + || (defender.hasKeyword("First Strike") && !attacker.hasKeyword("Indestructible") && !attacker + .hasKeyword("First Strike"))) { if (defenderDamage >= attackerLife) { return false; } - if (defenderDamage > 0 && defender.hasKeyword("Deathtouch")) { + if ((defenderDamage > 0) && defender.hasKeyword("Deathtouch")) { return false; } } - if (attacker.hasKeyword("Deathtouch") && attackerDamage > 0) { + if (attacker.hasKeyword("Deathtouch") && (attackerDamage > 0)) { return true; } @@ -1916,8 +1942,8 @@ public class CombatUtil { *

*/ public static void removeAllDamage() { - CardList cl = AllZoneUtil.getCardsIn(Zone.Battlefield); - for (Card c : cl) { + final CardList cl = AllZoneUtil.getCardsIn(Zone.Battlefield); + for (final Card c : cl) { c.setDamage(0); } } @@ -1931,16 +1957,16 @@ public class CombatUtil { AllZone.getDisplay().showCombat(""); Card[] defend = null; - StringBuilder display = new StringBuilder(); + final StringBuilder display = new StringBuilder(); // Loop through Defenders // Append Defending Player/Planeswalker - ArrayList defenders = AllZone.getCombat().getDefenders(); - CardList[] attackers = AllZone.getCombat().sortAttackerByDefender(); + final ArrayList defenders = AllZone.getCombat().getDefenders(); + final CardList[] attackers = AllZone.getCombat().sortAttackerByDefender(); // Not a big fan of the triple nested loop here for (int def = 0; def < defenders.size(); def++) { - if (attackers[def] == null || attackers[def].size() == 0) { + if ((attackers[def] == null) || (attackers[def].size() == 0)) { continue; } @@ -1952,19 +1978,19 @@ public class CombatUtil { display.append(defenders.get(def).toString()); display.append("\n"); - CardList list = attackers[def]; + final CardList list = attackers[def]; - for (Card c : list) { + for (final Card c : list) { // loop through attackers display.append("-> "); - display.append(combatantToString(c)).append("\n"); + display.append(CombatUtil.combatantToString(c)).append("\n"); defend = AllZone.getCombat().getBlockers(c).toArray(); // loop through blockers - for (int inner = 0; inner < defend.length; inner++) { + for (final Card element : defend) { display.append(" [ "); - display.append(combatantToString(defend[inner])).append("\n"); + display.append(CombatUtil.combatantToString(element)).append("\n"); } } // loop through attackers } @@ -1982,9 +2008,9 @@ public class CombatUtil { * @return a {@link java.lang.String} object. */ private static String combatantToString(final Card c) { - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); - String name = (c.isFaceDown()) ? "Morph" : c.getName(); + final String name = (c.isFaceDown()) ? "Morph" : c.getName(); sb.append(name); sb.append(" (").append(c.getUniqueNumber()).append(") "); @@ -2015,7 +2041,7 @@ public class CombatUtil { * a boolean. */ public static void checkPropagandaEffects(final Card c, final boolean bLast) { - String cost = CardFactoryUtil.getPropagandaCost(c); + final String cost = CardFactoryUtil.getPropagandaCost(c); if (cost.equals("0")) { if (!c.hasKeyword("Vigilance")) { c.tap(); @@ -2029,7 +2055,7 @@ public class CombatUtil { final Card crd = c; - String phase = AllZone.getPhase().getPhase(); + final String phase = AllZone.getPhase().getPhase(); if (phase.equals(Constant.Phase.COMBAT_DECLARE_ATTACKERS) || phase.equals(Constant.Phase.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY)) { @@ -2045,6 +2071,7 @@ public class CombatUtil { private static final long serialVersionUID = -6483405139208343935L; + @Override public void execute() { AllZone.getCombat().removeFromCombat(crd); @@ -2057,6 +2084,7 @@ public class CombatUtil { final Command paidCommand = new Command() { private static final long serialVersionUID = -8303368287601871955L; + @Override public void execute() { // if Propaganda is paid, tap this card if (!crd.hasKeyword("Vigilance")) { @@ -2071,8 +2099,8 @@ public class CombatUtil { if (c.getController().isHuman()) { AllZone.getInputControl().setInput( - new InputPayManaCostAbility(c + " - Pay to Attack\r\n", ability.getManaCost(), - paidCommand, unpaidCommand)); + new InputPayManaCostAbility(c + " - Pay to Attack\r\n", ability.getManaCost(), paidCommand, + unpaidCommand)); } else { // computer if (ComputerUtil.canPayCost(ability)) { ComputerUtil.playNoStack(ability); @@ -2097,16 +2125,15 @@ public class CombatUtil { * @param c * a {@link forge.Card} object. */ - public static void checkDeclareAttackers(final Card c) // this method checks - // triggered effects of - // attacking creatures, - // right before defending - // player declares blockers - { + public static void checkDeclareAttackers(final Card c) { // this method checks + // triggered effects of + // attacking creatures, + // right before defending + // player declares blockers // Run triggers - HashMap runParams = new HashMap(); + final HashMap runParams = new HashMap(); runParams.put("Attacker", c); - CardList otherAttackers = new CardList(AllZone.getCombat().getAttackers()); + final CardList otherAttackers = new CardList(AllZone.getCombat().getAttackers()); otherAttackers.remove(c); runParams.put("OtherAttackers", otherAttackers); runParams.put("Attacked", AllZone.getCombat().getDefenderByAttacker(c)); @@ -2114,20 +2141,21 @@ public class CombatUtil { // Annihilator: if (!c.getCreatureAttackedThisCombat()) { - ArrayList kws = c.getKeyword(); - Pattern p = Pattern.compile("Annihilator [0-9]+"); + final ArrayList kws = c.getKeyword(); + final Pattern p = Pattern.compile("Annihilator [0-9]+"); Matcher m; - for (String key : kws) { + for (final String key : kws) { m = p.matcher(key); if (m.find()) { - String[] k = key.split(" "); + final String[] k = key.split(" "); final int a = Integer.valueOf(k[1]); final Card crd = c; final Ability ability = new Ability(c, "0") { + @Override public void resolve() { if (crd.getController().isHuman()) { - CardList list = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); + final CardList list = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); ComputerUtil.sacrificePermanents(a, list); } else { AllZone.getInputControl().setInput(PlayerUtil.inputSacrificePermanents(a)); @@ -2135,7 +2163,7 @@ public class CombatUtil { } }; - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); sb.append("Annihilator - Defending player sacrifices ").append(a).append(" permanents."); ability.setStackDescription(sb.toString()); @@ -2159,8 +2187,9 @@ public class CombatUtil { CardList enchantments = c.getController().getCardsIn(Zone.Library); enchantments = enchantments.filter(new CardListFilter() { + @Override public boolean addCard(final Card c) { - if (c.isEnchantment() && c.getCMC() <= 3) { + if (c.isEnchantment() && (c.getCMC() <= 3)) { return true; } else { return false; @@ -2170,27 +2199,27 @@ public class CombatUtil { if (enchantments.size() > 0) { if (c.getController().isHuman()) { - Object o = GuiUtils.getChoiceOptional("Pick an enchantment to put onto the battlefield", + final Object o = GuiUtils.getChoiceOptional("Pick an enchantment to put onto the battlefield", enchantments.toArray()); if (o != null) { - Card crd = (Card) o; + final Card crd = (Card) o; AllZone.getGameAction().moveToPlay(crd); if (crd.isAura()) { Object obj = null; if (crd.hasKeyword("Enchant creature")) { - CardList creats = AllZoneUtil.getCreaturesInPlay(); + final CardList creats = AllZoneUtil.getCreaturesInPlay(); obj = GuiUtils.getChoiceOptional("Pick a creature to attach " + crd.getName() + " to", creats.toArray()); } else if (crd.hasKeyword("Enchant land") || crd.hasKeyword("Enchant land you control")) { - CardList lands = AllZoneUtil.getLandsInPlay(); + final CardList lands = AllZoneUtil.getLandsInPlay(); if (lands.size() > 0) { obj = GuiUtils.getChoiceOptional("Pick a land to attach " + crd.getName() + " to", lands.toArray()); } } if (obj != null) { - Card target = (Card) obj; + final Card target = (Card) obj; if (AllZoneUtil.isCardInPlay(target)) { crd.enchantEntity(target); } @@ -2199,20 +2228,21 @@ public class CombatUtil { c.getController().shuffle(); // we have to have cards like glorious anthem take // effect immediately: - 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(); } } } else if (c.getController().isComputer()) { enchantments = enchantments.filter(new CardListFilter() { + @Override public boolean addCard(final Card c) { return !c.isAura(); } }); if (enchantments.size() > 0) { - Card card = CardFactoryUtil.getBestEnchantmentAI(enchantments, null, false); + final Card card = CardFactoryUtil.getBestEnchantmentAI(enchantments, null, false); AllZone.getGameAction().moveToPlay(card); c.getController().shuffle(); } @@ -2221,9 +2251,10 @@ public class CombatUtil { } // Zur the enchanter else if (c.getName().equals("Spectral Bears")) { - Player opp = c.getController().getOpponent(); + final Player opp = c.getController().getOpponent(); CardList list = opp.getCardsIn(Zone.Battlefield); list = list.filter(new CardListFilter() { + @Override public boolean addCard(final Card crd) { return crd.isBlack() && !crd.isToken(); } @@ -2232,22 +2263,23 @@ public class CombatUtil { c.addExtrinsicKeyword("This card doesn't untap during your next untap step."); } } else if (c.getName().equals("Spectral Force")) { - Player opp = c.getController().getOpponent(); + final Player opp = c.getController().getOpponent(); CardList list = opp.getCardsIn(Zone.Battlefield); list = list.filter(CardListFilter.BLACK); if (list.size() == 0) { c.addExtrinsicKeyword("This card doesn't untap during your next untap step."); } } else if (c.getName().equals("Witch-Maw Nephilim") && !c.getCreatureAttackedThisCombat() - && c.getNetAttack() >= 10) { + && (c.getNetAttack() >= 10)) { final Card charger = c; - Ability ability2 = new Ability(c, "0") { + final Ability ability2 = new Ability(c, "0") { @Override public void resolve() { final Command untilEOT = new Command() { private static final long serialVersionUID = -1703473800920781454L; + @Override public void execute() { if (AllZoneUtil.isCardInPlay(charger)) { charger.removeIntrinsicKeyword("Trample"); @@ -2263,7 +2295,7 @@ public class CombatUtil { } // resolve }; // ability - StringBuilder sb2 = new StringBuilder(); + final StringBuilder sb2 = new StringBuilder(); sb2.append(c.getName()).append(" - gains trample until end of turn if its power is 10 or greater."); ability2.setStackDescription(sb2.toString()); @@ -2271,49 +2303,43 @@ public class CombatUtil { } // Witch-Maw Nephilim - /*else if (c.getName().equals("Preeminent Captain") && !c.getCreatureAttackedThisCombat()) { - System.out.println("Preeminent Captain Attacks"); - - CardList soldiers = c.getController().getCardsIn(Zone.Hand); - soldiers = soldiers.getType("Soldier"); - - if (soldiers.size() > 0) { - if (c.getController().isHuman()) { - Object o = GuiUtils.getChoiceOptional("Pick a soldier to put onto the battlefield", - soldiers.toArray()); - if (o != null) { - Card card = (Card) o; - AllZone.getGameAction().moveToPlay(card); - - card.tap(); - AllZone.getCombat().addAttacker(card); - - card.setCreatureAttackedThisCombat(true); - } - } else if (c.getController().isComputer()) { - Card card = CardFactoryUtil.getBestCreatureAI(soldiers); - if (card != null) { - AllZone.getGameAction().moveToPlay(card); - - card.tap(); - AllZone.getCombat().addAttacker(card); - card.setCreatureAttackedThisCombat(true); - } - } - - } // if (creatures.size() > 0) - }*/ // Preeminent Captain + /* + * else if (c.getName().equals("Preeminent Captain") && + * !c.getCreatureAttackedThisCombat()) { + * System.out.println("Preeminent Captain Attacks"); + * + * CardList soldiers = c.getController().getCardsIn(Zone.Hand); soldiers + * = soldiers.getType("Soldier"); + * + * if (soldiers.size() > 0) { if (c.getController().isHuman()) { Object + * o = + * GuiUtils.getChoiceOptional("Pick a soldier to put onto the battlefield" + * , soldiers.toArray()); if (o != null) { Card card = (Card) o; + * AllZone.getGameAction().moveToPlay(card); + * + * card.tap(); AllZone.getCombat().addAttacker(card); + * + * card.setCreatureAttackedThisCombat(true); } } else if + * (c.getController().isComputer()) { Card card = + * CardFactoryUtil.getBestCreatureAI(soldiers); if (card != null) { + * AllZone.getGameAction().moveToPlay(card); + * + * card.tap(); AllZone.getCombat().addAttacker(card); + * card.setCreatureAttackedThisCombat(true); } } + * + * } // if (creatures.size() > 0) } + */// Preeminent Captain else if (c.getName().equals("Sapling of Colfenor") && !c.getCreatureAttackedThisCombat()) { - Player player = c.getController(); + final Player player = c.getController(); - PlayerZone lib = player.getZone(Constant.Zone.Library); + final PlayerZone lib = player.getZone(Constant.Zone.Library); if (lib.size() > 0) { - CardList cl = new CardList(); + final CardList cl = new CardList(); cl.add(lib.get(0)); GuiUtils.getChoiceOptional("Top card", cl.toArray()); - Card top = lib.get(0); + final Card top = lib.get(0); if (top.isCreature()) { player.gainLife(top.getBaseDefense(), c); player.loseLife(top.getBaseAttack(), c); @@ -2337,7 +2363,7 @@ public class CombatUtil { public static void checkUnblockedAttackers(final Card c) { // Run triggers - HashMap runParams = new HashMap(); + final HashMap runParams = new HashMap(); runParams.put("Card", c); AllZone.getTriggerHandler().runTrigger("AttackerUnblocked", runParams); } @@ -2351,9 +2377,9 @@ public class CombatUtil { * a {@link forge.CardList} object. */ public static void checkDeclareBlockers(final CardList cl) { - for (Card c : cl) { + for (final Card c : cl) { if (!c.getCreatureBlockedThisCombat()) { - for (Ability ab : CardFactoryUtil.getBushidoEffects(c)) { + for (final Ability ab : CardFactoryUtil.getBushidoEffects(c)) { AllZone.getStack().add(ab); } } @@ -2377,7 +2403,7 @@ public class CombatUtil { // System.out.println(a.getName() + " got blocked by " + b.getName()); // Run triggers - HashMap runParams = new HashMap(); + final HashMap runParams = new HashMap(); runParams.put("Attacker", a); runParams.put("Blocker", b); AllZone.getTriggerHandler().runTrigger("Blocks", runParams); @@ -2388,22 +2414,22 @@ public class CombatUtil { AllZone.getTriggerHandler().runTrigger("AttackerBlocked", runParams); // Bushido - for (Ability ab : CardFactoryUtil.getBushidoEffects(a)) { + for (final Ability ab : CardFactoryUtil.getBushidoEffects(a)) { AllZone.getStack().add(ab); } // Rampage - ArrayList keywords = a.getKeyword(); - Pattern p = Pattern.compile("Rampage [0-9]+"); + final ArrayList keywords = a.getKeyword(); + final Pattern p = Pattern.compile("Rampage [0-9]+"); Matcher m; - for (String keyword : keywords) { + for (final String keyword : keywords) { m = p.matcher(keyword); if (m.find()) { - String[] k = keyword.split(" "); + final String[] k = keyword.split(" "); final int magnitude = Integer.valueOf(k[1]); final int numBlockers = AllZone.getCombat().getBlockers(a).size(); if (numBlockers > 1) { - executeRampageAbility(a, magnitude, numBlockers); + CombatUtil.executeRampageAbility(a, magnitude, numBlockers); } } // find } // end Rampage @@ -2412,7 +2438,7 @@ public class CombatUtil { if (a.hasKeyword("Flanking") && !b.hasKeyword("Flanking")) { int flankingMagnitude = 0; String kw = ""; - ArrayList list = a.getKeyword(); + final ArrayList list = a.getKeyword(); for (int i = 0; i < list.size(); i++) { kw = list.get(i); @@ -2422,7 +2448,7 @@ public class CombatUtil { } final int mag = flankingMagnitude; final Card blocker = b; - Ability ability2 = new Ability(b, "0") { + final Ability ability2 = new Ability(b, "0") { @Override public void resolve() { @@ -2430,6 +2456,7 @@ public class CombatUtil { private static final long serialVersionUID = 7662543891117427727L; + @Override public void execute() { if (AllZoneUtil.isCardInPlay(blocker)) { blocker.addTempAttackBoost(mag); @@ -2449,7 +2476,7 @@ public class CombatUtil { }; // ability - StringBuilder sb2 = new StringBuilder(); + final StringBuilder sb2 = new StringBuilder(); sb2.append(b.getName()).append(" - gets -").append(mag).append("/-").append(mag).append(" until EOT."); ability2.setStackDescription(sb2.toString()); @@ -2459,9 +2486,9 @@ public class CombatUtil { } // flanking if (a.getName().equals("Robber Fly") && !a.getCreatureGotBlockedThisCombat()) { - Player opp = b.getController(); - CardList list = opp.getCardsIn(Zone.Hand); - int handSize = list.size(); + final Player opp = b.getController(); + final CardList list = opp.getCardsIn(Zone.Hand); + final int handSize = list.size(); // opponent discards their hand, opp.discardRandom(handSize, a.getSpellAbility()[0]); @@ -2493,6 +2520,7 @@ public class CombatUtil { final Command untilEOT = new Command() { private static final long serialVersionUID = 1497565871061029469L; + @Override public void execute() { if (AllZoneUtil.isCardInPlay(crd)) { crd.addTempAttackBoost(-1); @@ -2511,25 +2539,26 @@ public class CombatUtil { }; // ability - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); sb.append(c).append(" - (Exalted) gets +1/+1 until EOT."); ability.setStackDescription(sb.toString()); AllZone.getStack().addSimultaneousStackEntry(ability); } - Player phasingPlayer = c.getController(); + final Player phasingPlayer = c.getController(); // Finest Hour untaps the creature on the first combat phase if ((phasingPlayer.getCardsIn(Zone.Battlefield, "Finest Hour").size() > 0) && AllZone.getPhase().isFirstCombat()) { // Untap the attacking creature - Ability fhUntap = new Ability(c, "0") { + final Ability fhUntap = new Ability(c, "0") { + @Override public void resolve() { crd.untap(); } }; - StringBuilder sbUntap = new StringBuilder(); + final StringBuilder sbUntap = new StringBuilder(); sbUntap.append(c).append(" - (Exalted) untap."); fhUntap.setStackDescription(sbUntap.toString()); @@ -2537,13 +2566,14 @@ public class CombatUtil { // If any Finest Hours, queue up a new combat phase for (int ix = 0; ix < phasingPlayer.getCardsIn(Zone.Battlefield, "Finest Hour").size(); ix++) { - Ability fhAddCombat = new Ability(c, "0") { + final Ability fhAddCombat = new Ability(c, "0") { + @Override public void resolve() { AllZone.getPhase().addExtraCombat(); } }; - StringBuilder sbACom = new StringBuilder(); + final StringBuilder sbACom = new StringBuilder(); sbACom.append(c).append(" - (Exalted) ").append(phasingPlayer).append(" gets Extra Combat Phase."); fhAddCombat.setStackDescription(sbACom.toString()); @@ -2554,11 +2584,12 @@ public class CombatUtil { if (phasingPlayer.getCardsIn(Zone.Battlefield, "Sovereigns of Lost Alara").size() > 0) { for (int i = 0; i < phasingPlayer.getCardsIn(Zone.Battlefield, "Sovereigns of Lost Alara").size(); i++) { final Card attacker = c; - Ability ability4 = new Ability(c, "0") { + final Ability ability4 = new Ability(c, "0") { @Override public void resolve() { CardList enchantments = attacker.getController().getCardsIn(Zone.Library); enchantments = enchantments.filter(new CardListFilter() { + @Override public boolean addCard(final Card c) { if (attacker.hasKeyword("Protection from enchantments") || (attacker.hasKeyword("Protection from everything"))) { @@ -2568,23 +2599,23 @@ public class CombatUtil { .hasProtectionFrom(c, attacker)); } }); - Player player = attacker.getController(); + final Player player = attacker.getController(); Card enchantment = null; if (player.isHuman()) { - Card[] target = new Card[enchantments.size()]; + final Card[] target = new Card[enchantments.size()]; for (int j = 0; j < enchantments.size(); j++) { - Card crd = enchantments.get(j); + final Card crd = enchantments.get(j); target[j] = crd; } - Object check = GuiUtils.getChoiceOptional("Select enchantment to enchant exalted creature", - target); + final Object check = GuiUtils.getChoiceOptional( + "Select enchantment to enchant exalted creature", target); if (check != null) { enchantment = ((Card) check); } } else { enchantment = CardFactoryUtil.getBestEnchantmentAI(enchantments, this, false); } - if (enchantment != null && AllZoneUtil.isCardInPlay(attacker)) { + if ((enchantment != null) && AllZoneUtil.isCardInPlay(attacker)) { GameAction.changeZone(AllZone.getZoneOf(enchantment), enchantment.getOwner().getZone(Constant.Zone.Battlefield), enchantment); enchantment.enchantEntity(attacker); @@ -2593,7 +2624,7 @@ public class CombatUtil { } // resolve }; // ability4 - StringBuilder sb4 = new StringBuilder(); + final StringBuilder sb4 = new StringBuilder(); sb4.append(c).append( " - (Exalted) searches library for an Aura card that could enchant that creature, "); sb4.append("put it onto the battlefield attached to that creature, then shuffles library."); @@ -2622,13 +2653,14 @@ public class CombatUtil { Ability ability; // numBlockers -1 since it is for every creature beyond the first - for (int i = 0; i < numBlockers - 1; i++) { + for (int i = 0; i < (numBlockers - 1); i++) { ability = new Ability(c, "0") { @Override public void resolve() { final Command untilEOT = new Command() { private static final long serialVersionUID = -3215615538474963181L; + @Override public void execute() { if (AllZoneUtil.isCardInPlay(crd)) { crd.addTempAttackBoost(-pump); @@ -2647,7 +2679,7 @@ public class CombatUtil { }; // ability - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); sb.append(c).append(" - (Rampage) gets +").append(pump).append("/+").append(pump).append(" until EOT."); ability.setStackDescription(sb.toString()); diff --git a/src/main/java/forge/ComputerAIGeneral.java b/src/main/java/forge/ComputerAIGeneral.java index b091d7f661d..c43ecfc763d 100644 --- a/src/main/java/forge/ComputerAIGeneral.java +++ b/src/main/java/forge/ComputerAIGeneral.java @@ -35,13 +35,14 @@ public class ComputerAIGeneral implements Computer { * main1. *

*/ + @Override public final void main1() { ComputerUtil.chooseLandsToPlay(); if (AllZone.getStack().size() == 0) { - playCards(Constant.Phase.MAIN1); + this.playCards(Constant.Phase.MAIN1); } else { - stackResponse(); + this.stackResponse(); } } // main1() @@ -50,13 +51,14 @@ public class ComputerAIGeneral implements Computer { * main2. *

*/ + @Override public final void main2() { ComputerUtil.chooseLandsToPlay(); if (AllZone.getStack().size() == 0) { - playCards(Constant.Phase.MAIN2); + this.playCards(Constant.Phase.MAIN2); } else { - stackResponse(); + this.stackResponse(); } } @@ -69,9 +71,9 @@ public class ComputerAIGeneral implements Computer { * a {@link java.lang.String} object. */ private void playCards(final String phase) { - SpellAbility[] sp = phase.equals(Constant.Phase.MAIN1) ? getMain1() : getMain2(); + final SpellAbility[] sp = phase.equals(Constant.Phase.MAIN1) ? this.getMain1() : this.getMain2(); - boolean nextPhase = ComputerUtil.playAbilities(sp); + final boolean nextPhase = ComputerUtil.playAbilities(sp); if (nextPhase) { AllZone.getPhase().passPriority(); @@ -88,11 +90,12 @@ public class ComputerAIGeneral implements Computer { private SpellAbility[] getMain1() { // Card list of all cards to consider CardList hand = AllZone.getComputerPlayer().getCardsIn(Zone.Hand); - - final boolean hasACardGivingHaste = hasACardGivingHaste(); + + final boolean hasACardGivingHaste = this.hasACardGivingHaste(); if (AllZone.getComputerPlayer().getManaPool().isEmpty()) { hand = hand.filter(new CardListFilter() { + @Override public boolean addCard(final Card c) { if (c.getSVar("PlayMain1").equals("TRUE")) { @@ -104,17 +107,17 @@ public class ComputerAIGeneral implements Computer { return true; } - if (c.isCreature() && (hasACardGivingHaste || c.hasKeyword("Haste")) || c.hasKeyword("Exalted")) { - return true; + if ((c.isCreature() && (hasACardGivingHaste || c.hasKeyword("Haste"))) || c.hasKeyword("Exalted")) { + return true; } // get all cards the computer controls with BuffedBy - CardList buffed = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); + final CardList buffed = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); for (int j = 0; j < buffed.size(); j++) { - Card buffedcard = buffed.get(j); + final Card buffedcard = buffed.get(j); if (buffedcard.getSVar("BuffedBy").length() > 0) { - String buffedby = buffedcard.getSVar("BuffedBy"); - String[] bffdby = buffedby.split(","); + final String buffedby = buffedcard.getSVar("BuffedBy"); + final String[] bffdby = buffedby.split(","); if (c.isValid(bffdby, c.getController(), c)) { return true; } @@ -122,12 +125,12 @@ public class ComputerAIGeneral implements Computer { } // BuffedBy // get all cards the human controls with AntiBuffedBy - CardList antibuffed = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield); + final CardList antibuffed = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield); for (int k = 0; k < antibuffed.size(); k++) { - Card buffedcard = antibuffed.get(k); + final Card buffedcard = antibuffed.get(k); if (buffedcard.getSVar("AntiBuffedBy").length() > 0) { - String buffedby = buffedcard.getSVar("AntiBuffedBy"); - String[] bffdby = buffedby.split(","); + final String buffedby = buffedcard.getSVar("AntiBuffedBy"); + final String[] bffdby = buffedby.split(","); if (c.isValid(bffdby, c.getController(), c)) { return true; } @@ -138,19 +141,20 @@ public class ComputerAIGeneral implements Computer { return false; } - CardList vengevines = AllZone.getComputerPlayer().getCardsIn(Zone.Graveyard, "Vengevine"); + final CardList vengevines = AllZone.getComputerPlayer().getCardsIn(Zone.Graveyard, "Vengevine"); if (vengevines.size() > 0) { - CardList creatures = AllZone.getComputerPlayer().getCardsIn(Zone.Hand); - CardList creatures2 = new CardList(); + final CardList creatures = AllZone.getComputerPlayer().getCardsIn(Zone.Hand); + final CardList creatures2 = new CardList(); for (int i = 0; i < creatures.size(); i++) { if (creatures.get(i).isCreature() - && CardUtil.getConvertedManaCost(creatures.get(i).getManaCost()) <= 3) { + && (CardUtil.getConvertedManaCost(creatures.get(i).getManaCost()) <= 3)) { creatures2.add(creatures.get(i)); } } - if (creatures2.size() + CardUtil.getThisTurnCast("Creature.YouCtrl", - vengevines.get(0)).size() > 1 - && c.isCreature() && CardUtil.getConvertedManaCost(c.getManaCost()) <= 3) { + if (((creatures2.size() + CardUtil.getThisTurnCast("Creature.YouCtrl", vengevines.get(0)) + .size()) > 1) + && c.isCreature() + && (CardUtil.getConvertedManaCost(c.getManaCost()) <= 3)) { return true; } } // AI Improvement for Vengevine @@ -159,12 +163,13 @@ public class ComputerAIGeneral implements Computer { } }); } - CardList all = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); + final CardList all = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); all.addAll(CardFactoryUtil.getExternalZoneActivationCards(AllZone.getComputerPlayer())); all.addAll(hand); CardList humanPlayable = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield); humanPlayable = humanPlayable.filter(new CardListFilter() { + @Override public boolean addCard(final Card c) { return (c.canAnyPlayerActivate()); } @@ -172,9 +177,9 @@ public class ComputerAIGeneral implements Computer { all.addAll(humanPlayable); - return getPlayable(all); + return this.getPlayable(all); } // getMain1() - + /** *

* hasACardGivingHaste. @@ -183,17 +188,17 @@ public class ComputerAIGeneral implements Computer { * @return a boolean. */ public boolean hasACardGivingHaste() { - CardList all = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); + final CardList all = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); all.addAll(CardFactoryUtil.getExternalZoneActivationCards(AllZone.getComputerPlayer())); all.addAll(AllZone.getComputerPlayer().getCardsIn(Zone.Hand)); - - for (Card c : all) { - for (SpellAbility sa : c.getSpellAbility()) { - if(sa.getAbilityFactory() == null) { + + for (final Card c : all) { + for (final SpellAbility sa : c.getSpellAbility()) { + if (sa.getAbilityFactory() == null) { continue; } - AbilityFactory af = sa.getAbilityFactory(); - HashMap abilityParams = af.getMapParams(); + final AbilityFactory af = sa.getAbilityFactory(); + final HashMap abilityParams = af.getMapParams(); if (abilityParams.containsKey("AB") && !abilityParams.get("AB").equals("Pump")) { continue; } @@ -205,9 +210,9 @@ public class ComputerAIGeneral implements Computer { } } } - + return false; - } //hasACardGivingHaste + } // hasACardGivingHaste /** *

@@ -221,6 +226,7 @@ public class ComputerAIGeneral implements Computer { CardList all = AllZone.getComputerPlayer().getCardsIn(Zone.Hand); // Don't play permanents with Flash before humans declare attackers step all = all.filter(new CardListFilter() { + @Override public boolean addCard(final Card c) { if (c.isPermanent() && c.hasKeyword("Flash") @@ -239,6 +245,7 @@ public class ComputerAIGeneral implements Computer { all = all.getNotKeyword("At the beginning of the end step, sacrifice CARDNAME."); all = all.filter(new CardListFilter() { + @Override public boolean addCard(final Card c) { if (c.isLand()) { return false; @@ -249,13 +256,14 @@ public class ComputerAIGeneral implements Computer { CardList humanPlayable = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield); humanPlayable = humanPlayable.filter(new CardListFilter() { + @Override public boolean addCard(final Card c) { return (c.canAnyPlayerActivate()); } }); all.addAll(humanPlayable); - return getPlayable(all); + return this.getPlayable(all); } // getMain2() /** @@ -269,6 +277,7 @@ public class ComputerAIGeneral implements Computer { CardList all = AllZone.getComputerPlayer().getCardsIn(Zone.Hand); // Don't play permanents with Flash before humans declare attackers step all = all.filter(new CardListFilter() { + @Override public boolean addCard(final Card c) { if (c.isPermanent() && c.hasKeyword("Flash") @@ -284,6 +293,7 @@ public class ComputerAIGeneral implements Computer { CardList humanPlayable = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield); humanPlayable = humanPlayable.filter(new CardListFilter() { + @Override public boolean addCard(final Card c) { return (c.canAnyPlayerActivate()); } @@ -300,7 +310,7 @@ public class ComputerAIGeneral implements Computer { * @return an array of {@link forge.card.spellability.SpellAbility} objects. */ private SpellAbility[] getOtherPhases() { - return getPlayable(getAvailableSpellAbilities()); + return this.getPlayable(this.getAvailableSpellAbilities()); } /** @@ -311,7 +321,7 @@ public class ComputerAIGeneral implements Computer { * @return a {@link java.util.ArrayList} object. */ private ArrayList getPossibleCounters() { - return getPlayableCounters(getAvailableSpellAbilities()); + return this.getPlayableCounters(this.getAvailableSpellAbilities()); } /** @@ -322,7 +332,7 @@ public class ComputerAIGeneral implements Computer { * @return a {@link java.util.ArrayList} object. */ private ArrayList getPossibleETBCounters() { - return getETBCounters(getAvailableSpellAbilities()); + return this.getETBCounters(this.getAvailableSpellAbilities()); } /** @@ -334,9 +344,9 @@ public class ComputerAIGeneral implements Computer { * @return an array of {@link forge.card.spellability.SpellAbility} objects. */ private SpellAbility[] getPlayable(final CardList l) { - ArrayList spellAbility = new ArrayList(); - for (Card c : l) { - for (SpellAbility sa : c.getSpellAbility()) { + final ArrayList spellAbility = new ArrayList(); + for (final Card c : l) { + for (final SpellAbility sa : c.getSpellAbility()) { spellAbility.add(sa); } } @@ -353,11 +363,11 @@ public class ComputerAIGeneral implements Computer { * @return a {@link java.util.ArrayList} object. */ private ArrayList getPlayableCounters(final CardList l) { - ArrayList spellAbility = new ArrayList(); - for (Card c : l) { - for (SpellAbility sa : c.getSpellAbility()) { + final ArrayList spellAbility = new ArrayList(); + for (final Card c : l) { + for (final 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); } } @@ -376,9 +386,9 @@ public class ComputerAIGeneral implements Computer { * @return a {@link java.util.ArrayList} object. */ private ArrayList getETBCounters(final CardList l) { - ArrayList spellAbility = new ArrayList(); - for (Card c : l) { - for (SpellAbility sa : c.getSpellAbility()) { + final ArrayList spellAbility = new ArrayList(); + for (final Card c : l) { + for (final SpellAbility sa : c.getSpellAbility()) { // Or if this Permanent has an ETB ability with Counter if (sa instanceof SpellPermanent) { if (SpellPermanent.checkETBEffects(c, sa, "Counter")) { @@ -396,8 +406,9 @@ public class ComputerAIGeneral implements Computer { * begin_combat. *

*/ + @Override public final void beginCombat() { - stackResponse(); + this.stackResponse(); } /** @@ -405,20 +416,21 @@ public class ComputerAIGeneral implements Computer { * declare_attackers. *

*/ + @Override public final void declareAttackers() { // 12/2/10(sol) the decision making here has moved to getAttackers() AllZone.setCombat(ComputerUtil.getAttackers()); - Card[] att = AllZone.getCombat().getAttackers(); + final Card[] att = AllZone.getCombat().getAttackers(); if (att.length > 0) { AllZone.getPhase().setCombat(true); } - for (int i = 0; i < att.length; i++) { + for (final Card element : att) { // tapping of attackers happens after Propaganda is paid for // if (!att[i].hasKeyword("Vigilance")) att[i].tap(); - Log.debug("Computer just assigned " + att[i].getName() + " as an attacker."); + Log.debug("Computer just assigned " + element.getName() + " as an attacker."); } AllZone.getComputerPlayer().getZone(Zone.Battlefield).updateObservers(); @@ -432,8 +444,9 @@ public class ComputerAIGeneral implements Computer { * declare_attackers_after. *

*/ + @Override public final void declareAttackersAfter() { - stackResponse(); + this.stackResponse(); } /** @@ -441,8 +454,9 @@ public class ComputerAIGeneral implements Computer { * declare_blockers. *

*/ + @Override public final void declareBlockers() { - CardList blockers = AllZoneUtil.getCreaturesInPlay(AllZone.getComputerPlayer()); + final CardList blockers = AllZoneUtil.getCreaturesInPlay(AllZone.getComputerPlayer()); AllZone.setCombat(ComputerUtilBlock.getBlockers(AllZone.getCombat(), blockers)); @@ -456,8 +470,9 @@ public class ComputerAIGeneral implements Computer { * declare_blockers_after. *

*/ + @Override public final void declareBlockersAfter() { - stackResponse(); + this.stackResponse(); } /** @@ -465,8 +480,9 @@ public class ComputerAIGeneral implements Computer { * end_of_combat. *

*/ + @Override public final void endOfCombat() { - stackResponse(); + this.stackResponse(); } // end of Human's turn @@ -475,8 +491,9 @@ public class ComputerAIGeneral implements Computer { * end_of_turn. *

*/ + @Override public final void endOfTurn() { - stackResponse(); + this.stackResponse(); } /** @@ -484,8 +501,9 @@ public class ComputerAIGeneral implements Computer { * stack_not_empty. *

*/ + @Override public final void stackNotEmpty() { - stackResponse(); + this.stackResponse(); } /** @@ -495,7 +513,7 @@ public class ComputerAIGeneral implements Computer { */ public final void stackResponse() { // if top of stack is empty - SpellAbility[] sas = getOtherPhases(); + final SpellAbility[] sas = this.getOtherPhases(); if (AllZone.getStack().size() == 0) { boolean pass = (sas.length == 0) @@ -519,9 +537,9 @@ public class ComputerAIGeneral implements Computer { } // top of stack is owned by human, - ArrayList possibleCounters = getPossibleCounters(); + ArrayList possibleCounters = this.getPossibleCounters(); - if (possibleCounters.size() > 0 && ComputerUtil.playCounterSpell(possibleCounters)) { + if ((possibleCounters.size() > 0) && ComputerUtil.playCounterSpell(possibleCounters)) { // Responding CounterSpell is on the Stack trying to Counter the // Spell // If playCounterSpell returns true, a Spell is hitting the Stack @@ -529,8 +547,8 @@ public class ComputerAIGeneral implements Computer { } possibleCounters.clear(); - possibleCounters = getPossibleETBCounters(); - if (possibleCounters.size() > 0 && !ComputerUtil.playAbilities(possibleCounters)) { + possibleCounters = this.getPossibleETBCounters(); + if ((possibleCounters.size() > 0) && !ComputerUtil.playAbilities(possibleCounters)) { // Responding Permanent w/ ETB Counter is on the Stack // AllZone.getPhase().passPriority(); return; diff --git a/src/main/java/forge/ComputerUtil.java b/src/main/java/forge/ComputerUtil.java index 489f67ac883..0d129157e45 100644 --- a/src/main/java/forge/ComputerUtil.java +++ b/src/main/java/forge/ComputerUtil.java @@ -1,7 +1,5 @@ package forge; -import static forge.error.ErrorViewer.showError; - import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; @@ -11,13 +9,14 @@ import forge.Constant.Zone; import forge.card.abilityfactory.AbilityFactory; import forge.card.cardfactory.CardFactoryUtil; import forge.card.cost.Cost; -import forge.card.cost.CostUtil; import forge.card.cost.CostPayment; +import forge.card.cost.CostUtil; import forge.card.mana.ManaCost; import forge.card.mana.ManaPool; import forge.card.spellability.AbilityMana; import forge.card.spellability.SpellAbility; import forge.card.spellability.Target; +import forge.error.ErrorViewer; /** *

@@ -42,33 +41,36 @@ public class ComputerUtil { */ public static boolean playAbilities(final SpellAbility[] all) { // not sure "playing biggest spell" matters? - sortSpellAbilityByCost(all); + ComputerUtil.sortSpellAbilityByCost(all); // MyRandom.shuffle(all); - for (SpellAbility sa : all) { + for (final SpellAbility sa : all) { // Don't add Counterspells to the "normal" playcard lookupss - AbilityFactory af = sa.getAbilityFactory(); - if (af != null && af.getAPI().equals("Counter")) { + final AbilityFactory af = sa.getAbilityFactory(); + if ((af != null) && af.getAPI().equals("Counter")) { continue; } sa.setActivatingPlayer(AllZone.getComputerPlayer()); - Card source = sa.getSourceCard(); - + final Card source = sa.getSourceCard(); + boolean flashb = false; - - //Flashback + + // Flashback if (source.isInZone(Constant.Zone.Graveyard) && sa.isSpell() && (source.isInstant() || source.isSorcery())) { - for(String keyword : source.getKeyword()) { + for (final String keyword : source.getKeyword()) { if (keyword.startsWith("Flashback")) { - SpellAbility flashback = sa.copy(); + final SpellAbility flashback = sa.copy(); flashback.setActivatingPlayer(AllZone.getComputerPlayer()); flashback.setFlashBackAbility(true); - if (!keyword.equals("Flashback")) {//there is a flashback cost (and not the cards cost) + if (!keyword.equals("Flashback")) { // there is a + // flashback cost + // (and not the cards + // cost) final Cost fbCost = new Cost(keyword.substring(10), source.getName(), false); flashback.setPayCosts(fbCost); } - if (canBePlayedAndPayedByAI(flashback)) { - handlePlayingSpellAbility(flashback); + if (ComputerUtil.canBePlayedAndPayedByAI(flashback)) { + ComputerUtil.handlePlayingSpellAbility(flashback); return false; } @@ -77,8 +79,8 @@ public class ComputerUtil { } } - if ((!flashb || source.hasStartOfKeyword("May be played")) && canBePlayedAndPayedByAI(sa)) { - handlePlayingSpellAbility(sa); + if ((!flashb || source.hasStartOfKeyword("May be played")) && ComputerUtil.canBePlayedAndPayedByAI(sa)) { + ComputerUtil.handlePlayingSpellAbility(sa); return false; } @@ -96,11 +98,11 @@ public class ComputerUtil { * @return a boolean. */ public static boolean playAbilities(final ArrayList all) { - SpellAbility[] sas = new SpellAbility[all.size()]; + final SpellAbility[] sas = new SpellAbility[all.size()]; for (int i = 0; i < sas.length; i++) { sas[i] = all.get(i); } - return playAbilities(sas); + return ComputerUtil.playAbilities(sas); } // playCards() /** @@ -113,26 +115,26 @@ public class ComputerUtil { */ public static void handlePlayingSpellAbility(final SpellAbility sa) { AllZone.getStack().freezeStack(); - Card source = sa.getSourceCard(); + final Card source = sa.getSourceCard(); if (sa.isSpell() && !source.isCopiedSpell()) { sa.setSourceCard(AllZone.getGameAction().moveToStack(source)); } - Cost cost = sa.getPayCosts(); - Target tgt = sa.getTarget(); + final Cost cost = sa.getPayCosts(); + final Target tgt = sa.getTarget(); if (cost == null) { - payManaCost(sa); + ComputerUtil.payManaCost(sa); sa.chooseTargetAI(); sa.getBeforePayManaAI().execute(); AllZone.getStack().addAndUnfreeze(sa); } else { - if (tgt != null && tgt.doesTarget()) { + if ((tgt != null) && tgt.doesTarget()) { sa.chooseTargetAI(); } - CostPayment pay = new CostPayment(cost, sa); + final CostPayment pay = new CostPayment(cost, sa); if (pay.payComputerCosts()) { AllZone.getStack().addAndUnfreeze(sa); } @@ -154,13 +156,13 @@ public class ComputerUtil { int restrict = 0; - Card source = sa.getSourceCard(); - Target tgt = sa.getTarget(); - AbilityFactory af = sa.getAbilityFactory(); - HashMap params = af.getMapParams(); + final Card source = sa.getSourceCard(); + final Target tgt = sa.getTarget(); + final AbilityFactory af = sa.getAbilityFactory(); + final HashMap params = af.getMapParams(); // Play higher costing spells first? - Cost cost = sa.getPayCosts(); + final Cost cost = sa.getPayCosts(); // Convert cost to CMC // String totalMana = source.getSVar("PayX"); // + cost.getCMC() @@ -181,11 +183,11 @@ public class ComputerUtil { } // Unless Cost gets significant bonus + 10-Payment Amount - String unless = params.get("UnlessCost"); + final String unless = params.get("UnlessCost"); if (unless != null) { - int amount = AbilityFactory.calculateAmount(source, unless, sa); + final int amount = AbilityFactory.calculateAmount(source, unless, sa); - int usableManaSources = CardFactoryUtil.getUsableManaSources(AllZone.getHumanPlayer()); + final int usableManaSources = CardFactoryUtil.getUsableManaSources(AllZone.getHumanPlayer()); // If the Unless isn't enough, this should be less likely to be used if (amount > usableManaSources) { @@ -196,14 +198,14 @@ public class ComputerUtil { } // Then base on Targeting Restriction - String[] validTgts = tgt.getValidTgts(); - if (validTgts.length != 1 || !validTgts[0].equals("Card")) { + final String[] validTgts = tgt.getValidTgts(); + if ((validTgts.length != 1) || !validTgts[0].equals("Card")) { restrict += 10; } // And lastly give some bonus points to least restrictive TargetType // (Spell,Ability,Triggered) - String tgtType = tgt.getTargetSpellAbilityType(); + final String tgtType = tgt.getTargetSpellAbilityType(); restrict -= (5 * tgtType.split(",").length); return restrict; @@ -223,19 +225,22 @@ public class ComputerUtil { SpellAbility bestSA = null; int bestRestriction = Integer.MIN_VALUE; - for (SpellAbility sa : possibleCounters) { + for (final SpellAbility sa : possibleCounters) { SpellAbility currentSA = sa; sa.setActivatingPlayer(AllZone.getComputerPlayer()); - Card source = sa.getSourceCard(); - - //Flashback + final Card source = sa.getSourceCard(); + + // Flashback if (source.isInZone(Constant.Zone.Graveyard) && sa.isSpell() && (source.isInstant() || source.isSorcery())) { - for(String keyword : source.getKeyword()) { + for (final String keyword : source.getKeyword()) { if (keyword.startsWith("Flashback")) { - SpellAbility flashback = sa.copy(); + final SpellAbility flashback = sa.copy(); flashback.setActivatingPlayer(AllZone.getComputerPlayer()); flashback.setFlashBackAbility(true); - if (!keyword.equals("Flashback")) {//there is a flashback cost (and not the cards cost) + if (!keyword.equals("Flashback")) { // there is a + // flashback cost + // (and not the cards + // cost) final Cost fbCost = new Cost(keyword.substring(10), source.getName(), false); flashback.setPayCosts(fbCost); } @@ -243,14 +248,16 @@ public class ComputerUtil { } } } - - if (canBePlayedAndPayedByAI(currentSA)) { // checks everything nescessary + + if (ComputerUtil.canBePlayedAndPayedByAI(currentSA)) { // checks + // everything + // nescessary if (bestSA == null) { bestSA = currentSA; - bestRestriction = counterSpellRestriction(currentSA); + bestRestriction = ComputerUtil.counterSpellRestriction(currentSA); } else { // Compare bestSA with this SA - int restrictionLevel = counterSpellRestriction(currentSA); + final int restrictionLevel = ComputerUtil.counterSpellRestriction(currentSA); if (restrictionLevel > bestRestriction) { bestRestriction = restrictionLevel; @@ -269,22 +276,22 @@ public class ComputerUtil { // if (bestRestriction < targetedThreshold) return false; AllZone.getStack().freezeStack(); - Card source = bestSA.getSourceCard(); + final Card source = bestSA.getSourceCard(); if (bestSA.isSpell() && !source.isCopiedSpell()) { bestSA.setSourceCard(AllZone.getGameAction().moveToStack(source)); } - Cost cost = bestSA.getPayCosts(); + final Cost cost = bestSA.getPayCosts(); if (cost == null) { // Honestly Counterspells shouldn't use this branch - payManaCost(bestSA); + ComputerUtil.payManaCost(bestSA); bestSA.chooseTargetAI(); bestSA.getBeforePayManaAI().execute(); AllZone.getStack().addAndUnfreeze(bestSA); } else { - CostPayment pay = new CostPayment(cost, bestSA); + final CostPayment pay = new CostPayment(cost, bestSA); if (pay.payComputerCosts()) { AllZone.getStack().addAndUnfreeze(bestSA); } @@ -303,15 +310,15 @@ public class ComputerUtil { * a {@link forge.card.spellability.SpellAbility} object. */ public static final void playStack(final SpellAbility sa) { - if (canPayCost(sa)) { - Card source = sa.getSourceCard(); + if (ComputerUtil.canPayCost(sa)) { + final Card source = sa.getSourceCard(); if (sa.isSpell() && !source.isCopiedSpell()) { sa.setSourceCard(AllZone.getGameAction().moveToStack(source)); } sa.setActivatingPlayer(AllZone.getComputerPlayer()); - payManaCost(sa); + ComputerUtil.payManaCost(sa); AllZone.getStack().add(sa); } @@ -328,7 +335,7 @@ public class ComputerUtil { public static final void playStackFree(final SpellAbility sa) { sa.setActivatingPlayer(AllZone.getComputerPlayer()); - Card source = sa.getSourceCard(); + final Card source = sa.getSourceCard(); if (sa.isSpell() && !source.isCopiedSpell()) { sa.setSourceCard(AllZone.getGameAction().moveToStack(source)); } @@ -347,19 +354,19 @@ public class ComputerUtil { public static final void playNoStack(final SpellAbility sa) { // TODO: We should really restrict what doesn't use the Stack - if (canPayCost(sa)) { - Card source = sa.getSourceCard(); + if (ComputerUtil.canPayCost(sa)) { + final Card source = sa.getSourceCard(); if (sa.isSpell() && !source.isCopiedSpell()) { sa.setSourceCard(AllZone.getGameAction().moveToStack(source)); } sa.setActivatingPlayer(AllZone.getComputerPlayer()); - Cost cost = sa.getPayCosts(); + final Cost cost = sa.getPayCosts(); if (cost == null) { - payManaCost(sa); + ComputerUtil.payManaCost(sa); } else { - CostPayment pay = new CostPayment(cost, sa); + final CostPayment pay = new CostPayment(cost, sa); pay.payComputerCosts(); } @@ -382,7 +389,7 @@ public class ComputerUtil { * @since 1.0.15 */ public static boolean canBePlayedAndPayedByAI(final SpellAbility sa) { - return sa.canPlay() && sa.canPlayAI() && canPayCost(sa); + return sa.canPlay() && sa.canPlayAI() && ComputerUtil.canPayCost(sa); } /** @@ -395,7 +402,7 @@ public class ComputerUtil { * @return a boolean. */ public static boolean canPayCost(final SpellAbility sa) { - return canPayCost(sa, AllZone.getComputerPlayer()); + return ComputerUtil.canPayCost(sa, AllZone.getComputerPlayer()); } // canPayCost() /** @@ -410,11 +417,11 @@ public class ComputerUtil { * @return a boolean. */ public static boolean canPayCost(final SpellAbility sa, final Player player) { - if (!payManaCost(sa, player, true, 0)) { + if (!ComputerUtil.payManaCost(sa, player, true, 0)) { return false; } - return canPayAdditionalCosts(sa, player); + return ComputerUtil.canPayAdditionalCosts(sa, player); } // canPayCost() /** @@ -427,7 +434,7 @@ public class ComputerUtil { * @return a int. */ public static int determineLeftoverMana(final SpellAbility sa) { - return determineLeftoverMana(sa, AllZone.getComputerPlayer()); + return ComputerUtil.determineLeftoverMana(sa, AllZone.getComputerPlayer()); } /** @@ -447,7 +454,7 @@ public class ComputerUtil { int xMana = 0; for (int i = 1; i < 99; i++) { - if (!payManaCost(sa, player, true, xMana)) { + if (!ComputerUtil.payManaCost(sa, player, true, xMana)) { break; } xMana = i; @@ -466,7 +473,7 @@ public class ComputerUtil { * @return a boolean. */ public static boolean canPayAdditionalCosts(final SpellAbility sa) { - return canPayAdditionalCosts(sa, AllZone.getComputerPlayer()); + return ComputerUtil.canPayAdditionalCosts(sa, AllZone.getComputerPlayer()); } /** @@ -498,7 +505,7 @@ public class ComputerUtil { * a {@link forge.card.spellability.SpellAbility} object. */ public static void payManaCost(final SpellAbility sa) { - payManaCost(sa, AllZone.getComputerPlayer(), false, 0); + ComputerUtil.payManaCost(sa, AllZone.getComputerPlayer(), false, 0); } /** @@ -519,25 +526,25 @@ public class ComputerUtil { */ public static boolean payManaCost(final SpellAbility sa, final Player player, final boolean test, final int extraMana) { - String mana = sa.getPayCosts() != null ? sa.getPayCosts().getTotalMana() : sa.getManaCost(); + final String mana = sa.getPayCosts() != null ? sa.getPayCosts().getTotalMana() : sa.getManaCost(); ManaCost cost = new ManaCost(mana); cost = AllZone.getGameAction().getSpellCostChange(sa, cost); - ManaPool manapool = player.getManaPool(); + final ManaPool manapool = player.getManaPool(); - Card card = sa.getSourceCard(); + final Card card = sa.getSourceCard(); // Tack xMana Payments into mana here if X is a set value - if (sa.getPayCosts() != null && cost.getXcounter() > 0) { + if ((sa.getPayCosts() != null) && (cost.getXcounter() > 0)) { int manaToAdd = 0; - if (test && extraMana > 0) { + if (test && (extraMana > 0)) { manaToAdd = extraMana * cost.getXcounter(); } else { // For Count$xPaid set PayX in the AFs then use that here // Else calculate it as appropriate. - String xSvar = card.getSVar("X").equals("Count$xPaid") ? "PayX" : "X"; + final String xSvar = card.getSVar("X").equals("Count$xPaid") ? "PayX" : "X"; if (!card.getSVar(xSvar).equals("")) { if (xSvar.equals("PayX")) { manaToAdd = Integer.parseInt(card.getSVar(xSvar)) * cost.getXcounter(); // X @@ -559,26 +566,26 @@ public class ComputerUtil { ArrayList colors; - cost = ((ManaPool) manapool).subtractMana(sa, cost); + cost = manapool.subtractMana(sa, cost); if (card.getSVar("ManaNeededToAvoidNegativeEffect") != "") { cost.setManaNeededToAvoidNegativeEffect(card.getSVar("ManaNeededToAvoidNegativeEffect").split(",")); } - CardList manaSources = getAvailableMana(); + final CardList manaSources = ComputerUtil.getAvailableMana(); // this is to prevent errors for mana sources that have abilities that // cost mana. manaSources.remove(sa.getSourceCard()); for (int i = 0; i < manaSources.size(); i++) { - Card sourceCard = manaSources.get(i); + final Card sourceCard = manaSources.get(i); ArrayList manaAbilities = sourceCard.getAIPlayableMana(); boolean used = false; // this is for testing paying mana only - manaAbilities = sortForNeeded(cost, manaAbilities, player); + manaAbilities = ComputerUtil.sortForNeeded(cost, manaAbilities, player); - for (AbilityMana m : manaAbilities) { + for (final AbilityMana m : manaAbilities) { if (used) { break; // mana source already used in the test @@ -587,7 +594,7 @@ public class ComputerUtil { // if the AI can't pay the additional costs skip the mana // ability if (m.getPayCosts() != null) { - if (!canPayAdditionalCosts(m, player)) { + if (!ComputerUtil.canPayAdditionalCosts(m, player)) { continue; } } else if (sourceCard.isTapped()) { @@ -601,7 +608,7 @@ public class ComputerUtil { } } - colors = getProduceableColors(m, player); + colors = ComputerUtil.getProduceableColors(m, player); for (int j = 0; j < colors.size(); j++) { if (used) { break; // mana source already used in the test @@ -611,7 +618,7 @@ public class ComputerUtil { if (!test) { // Pay additional costs if (m.getPayCosts() != null) { - CostPayment pay = new CostPayment(m.getPayCosts(), m); + final CostPayment pay = new CostPayment(m.getPayCosts(), m); if (!pay.payComputerCosts()) { continue; } @@ -626,7 +633,7 @@ public class ComputerUtil { if (!test) { // resolve subabilities - AbilityFactory af = m.getAbilityFactory(); + final AbilityFactory af = m.getAbilityFactory(); if (af != null) { AbilityFactory.resolveSubAbilities(m); } @@ -636,16 +643,15 @@ public class ComputerUtil { } if (sourceCard.getName().equals("Rainbow Vale")) { - sourceCard - .addExtrinsicKeyword("An opponent gains control of CARDNAME " - + "at the beginning of the next end step."); + sourceCard.addExtrinsicKeyword("An opponent gains control of CARDNAME " + + "at the beginning of the next end step."); } // System.out.println("just subtracted " + // colors.get(j) + ", cost is now: " + // cost.toString()); // Run triggers - HashMap runParams = new HashMap(); + final HashMap runParams = new HashMap(); runParams.put("Card", sourceCard); runParams.put("Player", player); @@ -695,7 +701,7 @@ public class ComputerUtil { * @since 1.0.15 */ public static ArrayList getProduceableColors(final AbilityMana m, final Player player) { - ArrayList colors = new ArrayList(); + final ArrayList colors = new ArrayList(); // if the mana ability is not avaiable move to the next one m.setActivatingPlayer(player); @@ -733,7 +739,7 @@ public class ComputerUtil { * @return a {@link forge.CardList} object. */ public static CardList getAvailableMana() { - return getAvailableMana(AllZone.getComputerPlayer()); + return ComputerUtil.getAvailableMana(AllZone.getComputerPlayer()); } // getAvailableMana() // gets available mana sources and sorts them @@ -747,10 +753,11 @@ public class ComputerUtil { * @return a {@link forge.CardList} object. */ public static CardList getAvailableMana(final Player player) { - CardList list = player.getCardsIn(Zone.Battlefield); - CardList manaSources = list.filter(new CardListFilter() { + final CardList list = player.getCardsIn(Zone.Battlefield); + final CardList manaSources = list.filter(new CardListFilter() { + @Override public boolean addCard(final Card c) { - for (AbilityMana am : c.getAIPlayableMana()) { + for (final AbilityMana am : c.getAIPlayableMana()) { am.setActivatingPlayer(player); if (am.canPlay()) { return true; @@ -761,12 +768,12 @@ public class ComputerUtil { } }); // CardListFilter - CardList sortedManaSources = new CardList(); + final CardList sortedManaSources = new CardList(); // 1. Use lands that can only produce colorless mana without // drawback/cost first for (int i = 0; i < manaSources.size(); i++) { - Card card = manaSources.get(i); + final Card card = manaSources.get(i); if (card.isCreature() || card.isEnchanted()) { continue; // don't use creatures before other permanents @@ -774,18 +781,18 @@ public class ComputerUtil { int usableManaAbilities = 0; boolean needsLimitedResources = false; - ArrayList manaAbilities = card.getAIPlayableMana(); + final ArrayList manaAbilities = card.getAIPlayableMana(); - for (AbilityMana m : manaAbilities) { + for (final AbilityMana m : manaAbilities) { - Cost cost = m.getPayCosts(); + final Cost cost = m.getPayCosts(); needsLimitedResources |= !cost.isReusuableResource(); // if the AI can't pay the additional costs skip the mana // ability m.setActivatingPlayer(AllZone.getComputerPlayer()); if (cost != null) { - if (!canPayAdditionalCosts(m, player)) { + if (!ComputerUtil.canPayAdditionalCosts(m, player)) { continue; } } @@ -802,7 +809,7 @@ public class ComputerUtil { } // use lands that can only produce colorless mana first - if (usableManaAbilities == 1 && !needsLimitedResources && manaAbilities.get(0).mana().equals("1")) { + if ((usableManaAbilities == 1) && !needsLimitedResources && manaAbilities.get(0).mana().equals("1")) { sortedManaSources.add(card); } } @@ -811,7 +818,7 @@ public class ComputerUtil { // abilities (start with 1 and go up to 5) and no drawback/costs for (int number = 1; number < 6; number++) { for (int i = 0; i < manaSources.size(); i++) { - Card card = manaSources.get(i); + final Card card = manaSources.get(i); if (card.isCreature() || card.isEnchanted()) { continue; // don't use creatures before other permanents @@ -819,16 +826,16 @@ public class ComputerUtil { int usableManaAbilities = 0; boolean needsLimitedResources = false; - ArrayList manaAbilities = card.getAIPlayableMana(); + final ArrayList manaAbilities = card.getAIPlayableMana(); - for (AbilityMana m : manaAbilities) { + for (final AbilityMana m : manaAbilities) { - Cost cost = m.getPayCosts(); + final Cost cost = m.getPayCosts(); needsLimitedResources |= !cost.isReusuableResource(); // if the AI can't pay the additional costs skip the mana // ability if (cost != null) { - if (!canPayAdditionalCosts(m, player)) { + if (!ComputerUtil.canPayAdditionalCosts(m, player)) { continue; } } @@ -844,7 +851,7 @@ public class ComputerUtil { usableManaAbilities++; } - if (usableManaAbilities == number && !needsLimitedResources && !sortedManaSources.contains(card)) { + if ((usableManaAbilities == number) && !needsLimitedResources && !sortedManaSources.contains(card)) { sortedManaSources.add(card); } } @@ -875,27 +882,27 @@ public class ComputerUtil { * @return a {@link java.util.ArrayList} object. * @since 1.0.15 */ - public static ArrayList sortForNeeded(final ManaCost cost, - final ArrayList manaAbilities, final Player player) { + public static ArrayList sortForNeeded(final ManaCost cost, final ArrayList manaAbilities, + final Player player) { ArrayList colors; - ArrayList colorsNeededToAvoidNegativeEffect = cost.getManaNeededToAvoidNegativeEffect(); + final ArrayList colorsNeededToAvoidNegativeEffect = cost.getManaNeededToAvoidNegativeEffect(); - ArrayList res = new ArrayList(); + final ArrayList res = new ArrayList(); - ManaCost onlyColored = new ManaCost(cost.toString()); + final ManaCost onlyColored = new ManaCost(cost.toString()); onlyColored.removeColorlessMana(); - for (AbilityMana am : manaAbilities) { - colors = getProduceableColors(am, player); + for (final AbilityMana am : manaAbilities) { + colors = ComputerUtil.getProduceableColors(am, player); for (int j = 0; j < colors.size(); j++) { if (onlyColored.isNeeded(colors.get(j))) { res.add(am); break; } - for (String col : colorsNeededToAvoidNegativeEffect) { + for (final String col : colorsNeededToAvoidNegativeEffect) { if (col.equalsIgnoreCase(colors.get(j)) || CardUtil.getShortColor(col).equalsIgnoreCase(colors.get(j))) { res.add(am); @@ -904,19 +911,19 @@ public class ComputerUtil { } } - for (AbilityMana am : manaAbilities) { + for (final AbilityMana am : manaAbilities) { if (res.contains(am)) { break; } - colors = getProduceableColors(am, player); + colors = ComputerUtil.getProduceableColors(am, player); for (int j = 0; j < colors.size(); j++) { if (cost.isNeeded(colors.get(j))) { res.add(am); break; } - for (String col : colorsNeededToAvoidNegativeEffect) { + for (final String col : colorsNeededToAvoidNegativeEffect) { if (col.equalsIgnoreCase(colors.get(j)) || CardUtil.getShortColor(col).equalsIgnoreCase(colors.get(j))) { res.add(am); @@ -937,21 +944,22 @@ public class ComputerUtil { * @return a boolean. */ public static boolean chooseLandsToPlay() { - Player computer = AllZone.getComputerPlayer(); + final Player computer = AllZone.getComputerPlayer(); CardList landList = computer.getCardsIn(Zone.Hand); landList = landList.filter(CardListFilter.LANDS); - CardList lands = computer.getCardsIn(Zone.Graveyard).getType("Land"); - for (Card crd : lands) { + final CardList lands = computer.getCardsIn(Zone.Graveyard).getType("Land"); + for (final Card crd : lands) { if (crd.isLand() && crd.hasStartOfKeyword("May be played")) { landList.add(crd); } } landList = landList.filter(new CardListFilter() { + @Override public boolean addCard(final Card c) { if (c.getSVar("NeedsToPlay").length() > 0) { - String needsToPlay = c.getSVar("NeedsToPlay"); + final String needsToPlay = c.getSVar("NeedsToPlay"); CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield); list = list.getValidCards(needsToPlay.split(","), c.getController(), c); @@ -960,7 +968,7 @@ public class ComputerUtil { } } if (c.isType("Legendary") && !c.getName().equals("Flagstones of Trokair")) { - CardList list = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); + final CardList list = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); if (list.containsName(c.getName())) { return false; } @@ -968,10 +976,10 @@ public class ComputerUtil { // don't play the land if it has cycling and enough lands are // available - ArrayList spellAbilities = c.getSpellAbilities(); - for (SpellAbility sa : spellAbilities) { + final ArrayList spellAbilities = c.getSpellAbilities(); + for (final SpellAbility sa : spellAbilities) { if (sa.isCycling()) { - CardList hand = AllZone.getComputerPlayer().getCardsIn(Zone.Hand); + final CardList hand = AllZone.getComputerPlayer().getCardsIn(Zone.Hand); CardList lands = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); lands.addAll(hand); lands = lands.getType("Land"); @@ -988,13 +996,13 @@ public class ComputerUtil { while (!landList.isEmpty() && computer.canPlayLand()) { // play as many lands as you can int ix = 0; - while (landList.get(ix).isReflectedLand() && (ix + 1 < landList.size())) { + while (landList.get(ix).isReflectedLand() && ((ix + 1) < landList.size())) { // Skip through reflected lands. Choose last if they are all // reflected. ix++; } - Card land = landList.get(ix); + final Card land = landList.get(ix); landList.remove(ix); computer.playLand(land); @@ -1021,9 +1029,10 @@ public class ComputerUtil { public static Card getCardPreference(final Card activate, final String pref, final CardList typeList) { if (activate != null) { - String[] prefValid = activate.getSVar("AIPreference").split("\\$"); + final String[] prefValid = activate.getSVar("AIPreference").split("\\$"); if (prefValid[0].equals(pref)) { - CardList prefList = typeList.getValidCards(prefValid[1].split(","), activate.getController(), activate); + final CardList prefList = typeList.getValidCards(prefValid[1].split(","), activate.getController(), + activate); if (prefList.size() != 0) { prefList.shuffle(); return prefList.get(0); @@ -1034,9 +1043,10 @@ public class ComputerUtil { for (int ip = 0; ip < 9; ip++) { // priority 0 is the lowest, // priority 5 the highest final int priority = 9 - ip; - CardList sacMeList = typeList.filter(new CardListFilter() { + final CardList sacMeList = typeList.filter(new CardListFilter() { + @Override public boolean addCard(final Card c) { - return (!c.getSVar("SacMe").equals("") && Integer.parseInt(c.getSVar("SacMe")) == priority); + return (!c.getSVar("SacMe").equals("") && (Integer.parseInt(c.getSVar("SacMe")) == priority)); } }); if (sacMeList.size() != 0) { @@ -1051,10 +1061,10 @@ public class ComputerUtil { for (int ip = 0; ip < 9; ip++) { // priority 0 is the lowest, // priority 5 the highest final int priority = 9 - ip; - CardList sacMeList = typeList.filter(new CardListFilter() { + final CardList sacMeList = typeList.filter(new CardListFilter() { + @Override public boolean addCard(final Card c) { - return (!c.getSVar("DiscardMe").equals("") - && Integer.parseInt(c.getSVar("DiscardMe")) == priority); + return (!c.getSVar("DiscardMe").equals("") && (Integer.parseInt(c.getSVar("DiscardMe")) == priority)); } }); if (sacMeList.size() != 0) { @@ -1086,7 +1096,7 @@ public class ComputerUtil { final int amount) { CardList typeList = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); typeList = typeList.getValidCards(type.split(","), activate.getController(), activate); - if (target != null && target.getController().isComputer() && typeList.contains(target)) { + if ((target != null) && target.getController().isComputer() && typeList.contains(target)) { typeList.remove(target); // don't sacrifice the card we're pumping } @@ -1094,11 +1104,11 @@ public class ComputerUtil { return null; } - CardList sacList = new CardList(); + final CardList sacList = new CardList(); int count = 0; while (count < amount) { - Card prefCard = getCardPreference(activate, "SacCost", typeList); + final Card prefCard = ComputerUtil.getCardPreference(activate, "SacCost", typeList); if (prefCard != null) { sacList.add(prefCard); typeList.remove(prefCard); @@ -1134,7 +1144,7 @@ public class ComputerUtil { CardList hand = AllZone.getComputerPlayer().getCardsIn(Zone.Hand); Card sourceCard = null; - if (uTypes != null && sa != null) { + if ((uTypes != null) && (sa != null)) { hand = hand.getValidCards(uTypes, sa.getActivatingPlayer(), sa.getSourceCard()); } if (sa != null) { @@ -1145,12 +1155,12 @@ public class ComputerUtil { return null; } - CardList discardList = new CardList(); + final CardList discardList = new CardList(); int count = 0; // look for good discards while (count < numDiscard) { - Card prefCard = getCardPreference(sourceCard, "DiscardCost", hand); + final Card prefCard = ComputerUtil.getCardPreference(sourceCard, "DiscardCost", hand); if (prefCard != null) { discardList.add(prefCard); hand.remove(prefCard); @@ -1160,16 +1170,16 @@ public class ComputerUtil { } } - int discardsLeft = numDiscard - count; + final int discardsLeft = numDiscard - count; // chose rest for (int i = 0; i < discardsLeft; i++) { if (hand.size() <= 0) { continue; } - CardList landsInPlay = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield).getType("Land"); + final CardList landsInPlay = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield).getType("Land"); if (landsInPlay.size() > 5) { - CardList landsInHand = hand.getType("Land"); + final CardList landsInHand = hand.getType("Land"); if (landsInHand.size() > 0) { // discard lands discardList.add(landsInHand.get(0)); hand.remove(landsInHand.get(0)); @@ -1204,9 +1214,8 @@ public class ComputerUtil { * a int. * @return a {@link forge.CardList} object. */ - public static CardList chooseExileType(final String type, - final Card activate, final Card target, final int amount) { - return chooseExileFrom(Constant.Zone.Battlefield, type, activate, target, amount); + public static CardList chooseExileType(final String type, final Card activate, final Card target, final int amount) { + return ComputerUtil.chooseExileFrom(Constant.Zone.Battlefield, type, activate, target, amount); } /** @@ -1226,7 +1235,7 @@ public class ComputerUtil { */ public static CardList chooseExileFromHandType(final String type, final Card activate, final Card target, final int amount) { - return chooseExileFrom(Constant.Zone.Hand, type, activate, target, amount); + return ComputerUtil.chooseExileFrom(Constant.Zone.Hand, type, activate, target, amount); } /** @@ -1246,7 +1255,7 @@ public class ComputerUtil { */ public static CardList chooseExileFromGraveType(final String type, final Card activate, final Card target, final int amount) { - return chooseExileFrom(Constant.Zone.Graveyard, type, activate, target, amount); + return ComputerUtil.chooseExileFrom(Constant.Zone.Graveyard, type, activate, target, amount); } /** @@ -1270,7 +1279,7 @@ public class ComputerUtil { final Card target, final int amount) { CardList typeList = AllZone.getComputerPlayer().getCardsIn(zone); typeList = typeList.getValidCards(type.split(","), activate.getController(), activate); - if (target != null && target.getController().isComputer() && typeList.contains(target)) { + if ((target != null) && target.getController().isComputer() && typeList.contains(target)) { typeList.remove(target); // don't exile the card we're pumping } @@ -1279,7 +1288,7 @@ public class ComputerUtil { } CardListUtil.sortAttackLowFirst(typeList); - CardList exileList = new CardList(); + final CardList exileList = new CardList(); for (int i = 0; i < amount; i++) { exileList.add(typeList.get(i)); @@ -1319,7 +1328,7 @@ public class ComputerUtil { CardListUtil.sortAttackLowFirst(typeList); - CardList tapList = new CardList(); + final CardList tapList = new CardList(); for (int i = 0; i < amount; i++) { tapList.add(typeList.get(i)); @@ -1342,11 +1351,10 @@ public class ComputerUtil { * a int. * @return a {@link forge.CardList} object. */ - public static CardList chooseReturnType(final String type, - final Card activate, final Card target, final int amount) { + public static CardList chooseReturnType(final String type, final Card activate, final Card target, final int amount) { CardList typeList = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); typeList = typeList.getValidCards(type.split(","), activate.getController(), activate); - if (target != null && target.getController().isComputer() && typeList.contains(target)) { + if ((target != null) && target.getController().isComputer() && typeList.contains(target)) { // bounce // the // card @@ -1360,7 +1368,7 @@ public class ComputerUtil { } CardListUtil.sortAttackLowFirst(typeList); - CardList returnList = new CardList(); + final CardList returnList = new CardList(); for (int i = 0; i < amount; i++) { returnList.add(typeList.get(i)); @@ -1378,6 +1386,7 @@ public class ComputerUtil { public static CardList getPossibleAttackers() { CardList list = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); list = list.filter(new CardListFilter() { + @Override public boolean addCard(final Card c) { return CombatUtil.canAttack(c); } @@ -1393,7 +1402,7 @@ public class ComputerUtil { * @return a {@link forge.Combat} object. */ public static Combat getAttackers() { - ComputerUtilAttack att = new ComputerUtilAttack(AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield), + final ComputerUtilAttack att = new ComputerUtilAttack(AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield), AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield)); return att.getAttackers(); @@ -1407,7 +1416,7 @@ public class ComputerUtil { * @return a {@link forge.Combat} object. */ public static Combat getBlockers() { - CardList blockers = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); + final CardList blockers = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); return ComputerUtilBlock.getBlockers(AllZone.getCombat(), blockers); } @@ -1424,7 +1433,8 @@ public class ComputerUtil { static void sortSpellAbilityByCost(final SpellAbility[] sa) { // sort from highest cost to lowest // we want the highest costs first - Comparator c = new Comparator() { + final Comparator c = new Comparator() { + @Override public int compare(final SpellAbility a, final SpellAbility b) { int a1 = CardUtil.getConvertedManaCost(a); int b1 = CardUtil.getConvertedManaCost(b); @@ -1440,9 +1450,9 @@ public class ComputerUtil { // sort planeswalker abilities for ultimate if (a.getRestrictions().getPlaneswalker() && b.getRestrictions().getPlaneswalker()) { - if (a.getAbilityFactory() != null && a.getAbilityFactory().getMapParams().containsKey("Ultimate")) { + if ((a.getAbilityFactory() != null) && a.getAbilityFactory().getMapParams().containsKey("Ultimate")) { a1 += 1; - } else if (b.getAbilityFactory() != null + } else if ((b.getAbilityFactory() != null) && b.getAbilityFactory().getMapParams().containsKey("Ultimate")) { b1 += 1; } @@ -1466,7 +1476,7 @@ public class ComputerUtil { * @return the card list */ public static CardList sacrificePermanents(final int amount, final CardList list) { - CardList sacList = new CardList(); + final CardList sacList = new CardList(); // used in Annihilator and AF_Sacrifice int max = list.size(); if (max > amount) { @@ -1488,12 +1498,12 @@ public class ComputerUtil { c = list.get(0); } - ArrayList auras = c.getEnchantedBy(); + final ArrayList auras = c.getEnchantedBy(); if (auras.size() > 0) { // TODO: choose "worst" controlled enchanting Aura for (int j = 0; j < auras.size(); j++) { - Card aura = auras.get(j); + final Card aura = auras.get(j); if (aura.getController().isPlayer(c.getController()) && list.contains(aura)) { c = aura; break; @@ -1523,15 +1533,15 @@ public class ComputerUtil { return false; } - Player controller = card.getController(); - CardList l = controller.getCardsIn(Zone.Battlefield); - for (Card c : l) { - for (SpellAbility sa : c.getSpellAbility()) { + final Player controller = card.getController(); + final CardList l = controller.getCardsIn(Zone.Battlefield); + for (final Card c : l) { + for (final SpellAbility sa : c.getSpellAbility()) { // This try/catch should fix the "computer is thinking" bug try { - AbilityFactory af = sa.getAbilityFactory(); + final AbilityFactory af = sa.getAbilityFactory(); - if (!sa.isAbility() || af == null || !af.getAPI().equals("Regenerate")) { + if (!sa.isAbility() || (af == null) || !af.getAPI().equals("Regenerate")) { continue; // Not a Regenerate ability } @@ -1540,9 +1550,9 @@ public class ComputerUtil { continue; // Can't play ability } - HashMap mapParams = af.getMapParams(); + final HashMap mapParams = af.getMapParams(); - Target tgt = sa.getTarget(); + final Target tgt = sa.getTarget(); if (tgt != null) { if (AllZoneUtil.getCardsIn(Zone.Battlefield) .getValidCards(tgt.getValidTgts(), controller, sa.getSourceCard()).contains(card)) { @@ -1553,8 +1563,9 @@ public class ComputerUtil { return true; } - } catch (Exception ex) { - showError(ex, "There is an error in the card code for %s:%n", c.getName(), ex.getMessage()); + } catch (final Exception ex) { + ErrorViewer.showError(ex, "There is an error in the card code for %s:%n", c.getName(), + ex.getMessage()); } } } @@ -1574,16 +1585,16 @@ public class ComputerUtil { int prevented = 0; - Player controller = card.getController(); - CardList l = controller.getCardsIn(Zone.Battlefield); - for (Card c : l) { - for (SpellAbility sa : c.getSpellAbility()) { + final Player controller = card.getController(); + final CardList l = controller.getCardsIn(Zone.Battlefield); + for (final Card c : l) { + for (final 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 { - if (sa.getAbilityFactory() != null && sa.isAbility()) { - AbilityFactory af = sa.getAbilityFactory(); - HashMap mapParams = af.getMapParams(); + if ((sa.getAbilityFactory() != null) && sa.isAbility()) { + final AbilityFactory af = sa.getAbilityFactory(); + final HashMap mapParams = af.getMapParams(); if (mapParams.get("AB").equals("PreventDamage") && sa.canPlay() && ComputerUtil.canPayCost(sa, controller)) { if (AbilityFactory.getDefinedCards(sa.getSourceCard(), mapParams.get("Defined"), sa) @@ -1591,11 +1602,10 @@ public class ComputerUtil { prevented += AbilityFactory.calculateAmount(af.getHostCard(), mapParams.get("Amount"), sa); } - Target tgt = sa.getTarget(); + final Target tgt = sa.getTarget(); if (tgt != null) { if (AllZoneUtil.getCardsIn(Zone.Battlefield) - .getValidCards(tgt.getValidTgts(), - controller, af.getHostCard()).contains(card)) { + .getValidCards(tgt.getValidTgts(), controller, af.getHostCard()).contains(card)) { prevented += AbilityFactory.calculateAmount(af.getHostCard(), mapParams.get("Amount"), sa); } @@ -1603,10 +1613,11 @@ public class ComputerUtil { } } } - } catch (Exception ex) { - showError(ex, "There is an error in the card code for %s:%n", c.getName(), ex.getMessage()); + } catch (final Exception ex) { + ErrorViewer.showError(ex, "There is an error in the card code for %s:%n", c.getName(), + ex.getMessage()); } - } + } } return prevented; } diff --git a/src/main/java/forge/ComputerUtilAttack.java b/src/main/java/forge/ComputerUtilAttack.java index 3eed9b95fc1..ef358c1668c 100644 --- a/src/main/java/forge/ComputerUtilAttack.java +++ b/src/main/java/forge/ComputerUtilAttack.java @@ -20,12 +20,12 @@ import forge.card.trigger.Trigger; public class ComputerUtilAttack { // possible attackers and blockers - private CardList attackers; - private CardList blockers; + private final CardList attackers; + private final CardList blockers; private CardList playerCreatures; - private Random random = MyRandom.getRandom(); - private final int randomInt = random.nextInt(); + private final Random random = MyRandom.getRandom(); + private final int randomInt = this.random.nextInt(); private CardList humanList; // holds human player creatures private CardList computerList; // holds computer creatures @@ -42,8 +42,6 @@ public class ComputerUtilAttack { * an array of {@link forge.Card} objects. * @param possibleBlockers * an array of {@link forge.Card} objects. - * @param blockerLife - * a int. */ public ComputerUtilAttack(final Card[] possibleAttackers, final Card[] possibleBlockers) { this(new CardList(possibleAttackers), new CardList(possibleBlockers)); @@ -58,20 +56,18 @@ public class ComputerUtilAttack { * a {@link forge.CardList} object. * @param possibleBlockers * a {@link forge.CardList} object. - * @param blockerLife - * a int. */ public ComputerUtilAttack(final CardList possibleAttackers, final CardList possibleBlockers) { - humanList = new CardList(possibleBlockers.toArray()); - humanList = humanList.getType("Creature"); + this.humanList = new CardList(possibleBlockers.toArray()); + this.humanList = this.humanList.getType("Creature"); - computerList = new CardList(possibleAttackers.toArray()); - computerList = computerList.getType("Creature"); - playerCreatures = new CardList(possibleBlockers.toArray()); - playerCreatures = playerCreatures.getType("Creature"); + this.computerList = new CardList(possibleAttackers.toArray()); + this.computerList = this.computerList.getType("Creature"); + this.playerCreatures = new CardList(possibleBlockers.toArray()); + this.playerCreatures = this.playerCreatures.getType("Creature"); - attackers = getPossibleAttackers(possibleAttackers); - blockers = getPossibleBlockers(possibleBlockers, attackers); + this.attackers = this.getPossibleAttackers(possibleAttackers); + this.blockers = this.getPossibleBlockers(possibleBlockers, this.attackers); } // constructor /** @@ -84,20 +80,20 @@ public class ComputerUtilAttack { * @return a {@link forge.CardList} object. */ public final CardList sortAttackers(final CardList in) { - CardList list = new CardList(); + final CardList list = new CardList(); // Cards with triggers should come first (for Battle Cry) - for (Card attacker : in) { - ArrayList registeredTriggers = attacker.getTriggers(); - for (Trigger trigger : registeredTriggers) { - HashMap trigParams = trigger.getMapParams(); + for (final Card attacker : in) { + final ArrayList registeredTriggers = attacker.getTriggers(); + for (final Trigger trigger : registeredTriggers) { + final HashMap trigParams = trigger.getMapParams(); if (trigParams.get("Mode").equals("Attacks")) { list.add(attacker); } } } - for (Card attacker : in) { + for (final Card attacker : in) { if (!list.contains(attacker)) { list.add(attacker); } @@ -121,7 +117,7 @@ public class ComputerUtilAttack { public final boolean isEffectiveAttacker(final Card attacker, final 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; } @@ -132,10 +128,10 @@ public class ComputerUtilAttack { return true; } - CardList controlledByCompy = AllZone.getComputerPlayer().getAllCards(); + final CardList controlledByCompy = AllZone.getComputerPlayer().getAllCards(); - for (Card c : controlledByCompy) { - for (Trigger trigger : c.getTriggers()) { + for (final Card c : controlledByCompy) { + for (final Trigger trigger : c.getTriggers()) { if (CombatUtil.combatTriggerWillTrigger(attacker, null, trigger, combat)) { return true; } @@ -157,6 +153,7 @@ public class ComputerUtilAttack { public final CardList getPossibleAttackers(final CardList in) { CardList list = new CardList(in.toArray()); list = list.filter(new CardListFilter() { + @Override public boolean addCard(final Card c) { return CombatUtil.canAttack(c); } @@ -179,11 +176,12 @@ public class ComputerUtilAttack { CardList possibleBlockers = new CardList(blockers.toArray()); final CardList attackerList = new CardList(attackers.toArray()); possibleBlockers = possibleBlockers.filter(new CardListFilter() { + @Override public boolean addCard(final Card c) { if (!c.isCreature()) { return false; } - for (Card attacker : attackerList) { + for (final Card attacker : attackerList) { if (CombatUtil.canBlock(attacker, c)) { return true; } @@ -209,15 +207,15 @@ public class ComputerUtilAttack { * @return a {@link forge.CardList} object. */ public final CardList notNeededAsBlockers(final CardList attackers, final Combat combat) { - CardList notNeededAsBlockers = new CardList(attackers.toArray()); + final CardList notNeededAsBlockers = new CardList(attackers.toArray()); CardListUtil.sortAttackLowFirst(attackers); int blockersNeeded = attackers.size(); // don't hold back creatures that can't block any of the human creatures - CardList list = getPossibleBlockers(attackers, humanList); + final CardList list = this.getPossibleBlockers(attackers, this.humanList); for (int i = 0; i < list.size(); i++) { - if (!doesHumanAttackAndWin(i)) { + if (!this.doesHumanAttackAndWin(i)) { blockersNeeded = i; break; } else { @@ -236,34 +234,33 @@ public class ComputerUtilAttack { // In addition, if the computer guesses it needs no blockers, make sure // that // it won't be surprised by Exalted - int humanExaltedBonus = countExaltedBonus(AllZone.getHumanPlayer()); + final int humanExaltedBonus = this.countExaltedBonus(AllZone.getHumanPlayer()); if (humanExaltedBonus > 0) { - int nFinestHours = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield, "Finest Hour").size(); + final int nFinestHours = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield, "Finest Hour").size(); - if ((blockersNeeded == 0 || nFinestHours > 0) && humanList.size() > 0) { + if (((blockersNeeded == 0) || (nFinestHours > 0)) && (this.humanList.size() > 0)) { // // total attack = biggest creature + exalted, *2 if Rafiq is in // play - int humanBaseAttack = getAttack(humanList.get(0)) + humanExaltedBonus; + int humanBaseAttack = this.getAttack(this.humanList.get(0)) + humanExaltedBonus; if (nFinestHours > 0) { // For Finest Hour, one creature could attack and get the // bonus TWICE humanBaseAttack = humanBaseAttack + humanExaltedBonus; } - int totalExaltedAttack = AllZoneUtil.isCardInPlay("Rafiq of the Many", - AllZone.getHumanPlayer()) ? 2 * humanBaseAttack + final int totalExaltedAttack = AllZoneUtil.isCardInPlay("Rafiq of the Many", AllZone.getHumanPlayer()) ? 2 * humanBaseAttack : humanBaseAttack; if ((AllZone.getComputerPlayer().getLife() - 3) <= totalExaltedAttack) { // We will lose if there is an Exalted attack -- keep one // blocker - if (blockersNeeded == 0 && notNeededAsBlockers.size() > 0) { + if ((blockersNeeded == 0) && (notNeededAsBlockers.size() > 0)) { notNeededAsBlockers.remove(0); } // Finest Hour allows a second Exalted attack: keep a // blocker for that too - if (nFinestHours > 0 && notNeededAsBlockers.size() > 0) { + if ((nFinestHours > 0) && (notNeededAsBlockers.size() > 0)) { notNeededAsBlockers.remove(0); } } @@ -271,7 +268,7 @@ public class ComputerUtilAttack { } // re-add creatures with vigilance - for (Card c : attackers) { + for (final Card c : attackers) { if (c.hasKeyword("Vigilance")) { notNeededAsBlockers.add(c); } @@ -292,10 +289,10 @@ public class ComputerUtilAttack { */ public final boolean doesHumanAttackAndWin(final int nBlockingCreatures) { int totalAttack = 0; - int stop = humanList.size() - nBlockingCreatures; + final int stop = this.humanList.size() - nBlockingCreatures; for (int i = 0; i < stop; i++) { - totalAttack += getAttack(humanList.get(i)); + totalAttack += this.getAttack(this.humanList.get(i)); } // originally -3 so the computer will try to stay at 3 life @@ -313,41 +310,43 @@ public class ComputerUtilAttack { */ private boolean doAssault() { // Beastmaster Ascension - if (AllZoneUtil.isCardInPlay("Beastmaster Ascension", AllZone.getComputerPlayer()) && attackers.size() > 1) { - CardList beastions = AllZone.getComputerPlayer().getCardsIn(Constant.Zone.Battlefield) + if (AllZoneUtil.isCardInPlay("Beastmaster Ascension", AllZone.getComputerPlayer()) + && (this.attackers.size() > 1)) { + final CardList beastions = AllZone.getComputerPlayer().getCardsIn(Constant.Zone.Battlefield) .getName("Beastmaster Ascension"); int minCreatures = 7; - for (Card beastion : beastions) { - int counters = beastion.getCounters(Counters.QUEST); + for (final Card beastion : beastions) { + final int counters = beastion.getCounters(Counters.QUEST); minCreatures = Math.min(minCreatures, 7 - counters); } - if (attackers.size() >= minCreatures) { + if (this.attackers.size() >= minCreatures) { return true; } } - CardListUtil.sortAttack(attackers); + CardListUtil.sortAttack(this.attackers); - CardList remainingAttackers = new CardList(attackers.toArray()); - CardList blockableAttackers = new CardList(attackers.toArray()); - - for (int i = 0; i < attackers.size(); i++) { - if(!CombatUtil.canBeBlocked(attackers.get(i), blockers)) { - blockableAttackers.remove(attackers.get(i)); + final CardList remainingAttackers = new CardList(this.attackers.toArray()); + final CardList blockableAttackers = new CardList(this.attackers.toArray()); + + for (int i = 0; i < this.attackers.size(); i++) { + if (!CombatUtil.canBeBlocked(this.attackers.get(i), this.blockers)) { + blockableAttackers.remove(this.attackers.get(i)); } } - + // presumes the Human will block - for (int i = 0; i < blockers.size() && i < blockableAttackers.size(); i++) { + for (int i = 0; (i < this.blockers.size()) && (i < blockableAttackers.size()); i++) { remainingAttackers.remove(blockableAttackers.get(i)); } - - if(CombatUtil.sumDamageIfUnblocked(remainingAttackers, AllZone.getHumanPlayer()) > AllZone.getHumanPlayer().getLife() - && AllZone.getHumanPlayer().canLoseLife()) { + + if ((CombatUtil.sumDamageIfUnblocked(remainingAttackers, AllZone.getHumanPlayer()) > AllZone.getHumanPlayer() + .getLife()) && AllZone.getHumanPlayer().canLoseLife()) { return true; } - - if(CombatUtil.sumPoisonIfUnblocked(remainingAttackers, AllZone.getHumanPlayer()) >= 10 - AllZone.getHumanPlayer().getPoisonCounters()) { + + if (CombatUtil.sumPoisonIfUnblocked(remainingAttackers, AllZone.getHumanPlayer()) >= (10 - AllZone + .getHumanPlayer().getPoisonCounters())) { return true; } @@ -367,15 +366,15 @@ public class ComputerUtilAttack { public final void chooseDefender(final Combat c, final boolean bAssault) { // TODO split attackers to different planeswalker/human // AI will only attack one Defender per combat for now - ArrayList defs = c.getDefenders(); + final ArrayList defs = c.getDefenders(); // Randomly determine who EVERYONE is attacking // would be better to determine more individually int n = MyRandom.getRandom().nextInt(defs.size()); - Object entity = AllZone.getComputerPlayer().getMustAttackEntity(); + final Object entity = AllZone.getComputerPlayer().getMustAttackEntity(); if (null != entity) { - ArrayList defenders = AllZone.getCombat().getDefenders(); + final ArrayList defenders = AllZone.getCombat().getDefenders(); n = defenders.indexOf(entity); if (-1 == n) { System.out.println("getMustAttackEntity() returned something not in defenders."); @@ -384,7 +383,7 @@ public class ComputerUtilAttack { c.setCurrentDefender(n); } } else { - if (defs.size() == 1 || bAssault) { + if ((defs.size() == 1) || bAssault) { c.setCurrentDefender(0); } else { c.setCurrentDefender(n); @@ -407,22 +406,22 @@ public class ComputerUtilAttack { // randomInt is used so that the computer doesn't always // do the same thing on turn 3 if he had the same creatures in play // I know this is a little confusing - random.setSeed(AllZone.getPhase().getTurn() + randomInt); + this.random.setSeed(AllZone.getPhase().getTurn() + this.randomInt); - Combat combat = new Combat(); + final Combat combat = new Combat(); combat.setAttackingPlayer(AllZone.getCombat().getAttackingPlayer()); combat.setDefendingPlayer(AllZone.getCombat().getDefendingPlayer()); combat.setDefenders(AllZone.getCombat().getDefenders()); - boolean bAssault = doAssault(); + final boolean bAssault = this.doAssault(); // Determine who will be attacked - chooseDefender(combat, bAssault); + this.chooseDefender(combat, bAssault); - CardList attackersLeft = new CardList(attackers.toArray()); + CardList attackersLeft = new CardList(this.attackers.toArray()); // Attackers that don't really have a choice - for (Card attacker : attackers) { + for (final Card attacker : this.attackers) { if ((attacker.hasKeyword("CARDNAME attacks each turn if able.") || attacker.hasKeyword("At the beginning of the end step, destroy CARDNAME.") || attacker.hasKeyword("At the beginning of the end step, exile CARDNAME.") @@ -443,10 +442,10 @@ public class ComputerUtilAttack { int playerForcesForAttritionalAttack = 0; // examine the potential forces - CardList nextTurnAttackers = new CardList(); + final CardList nextTurnAttackers = new CardList(); int candidateCounterAttackDamage = 0; // int candidateTotalBlockDamage = 0; - for (Card pCard : playerCreatures) { + for (final Card pCard : this.playerCreatures) { // if the creature can attack next turn add it to counter attackers // list @@ -472,9 +471,9 @@ public class ComputerUtilAttack { } // get the potential damage and strength of the AI forces - CardList candidateAttackers = new CardList(); + final CardList candidateAttackers = new CardList(); int candidateUnblockedDamage = 0; - for (Card pCard : computerList) { + for (final Card pCard : this.computerList) { // if the creature can attack then it's a potential attacker this // turn, assume summoning sickness creatures will be able to if (CombatUtil.canAttackNextTurn(pCard)) { @@ -502,10 +501,10 @@ public class ComputerUtilAttack { */ // determine if the ai outnumbers the player - int outNumber = computerForces - playerForces; + final int outNumber = computerForces - playerForces; // compare the ratios, higher = better for ai - double ratioDiff = aiLifeToPlayerDamageRatio - playerLifeToDamageRatio; + final double ratioDiff = aiLifeToPlayerDamageRatio - playerLifeToDamageRatio; /* * System.out.println(String.valueOf(ratioDiff) + * " = ratio difference, higher = better for ai"); @@ -524,17 +523,17 @@ public class ComputerUtilAttack { // ********************* boolean doAttritionalAttack = false; // get list of attackers ordered from low power to high - CardListUtil.sortAttackLowFirst(attackers); + CardListUtil.sortAttackLowFirst(this.attackers); // get player life total int playerLife = AllZone.getHumanPlayer().getLife(); // get the list of attackers up to the first blocked one - CardList attritionalAttackers = new CardList(); - for (int x = 0; x < attackers.size() - playerForces; x++) { - attritionalAttackers.add(attackers.getCard(x)); + final CardList attritionalAttackers = new CardList(); + for (int x = 0; x < (this.attackers.size() - playerForces); x++) { + attritionalAttackers.add(this.attackers.getCard(x)); } // until the attackers are used up or the player would run out of life int attackRounds = 1; - while (attritionalAttackers.size() > 0 && playerLife > 0 && attackRounds < 99) { + while ((attritionalAttackers.size() > 0) && (playerLife > 0) && (attackRounds < 99)) { // sum attacker damage int damageThisRound = 0; for (int y = 0; y < attritionalAttackers.size(); y++) { @@ -565,11 +564,11 @@ public class ComputerUtilAttack { double unblockableDamage = 0; double turnsUntilDeathByUnblockable = 0; boolean doUnblockableAttack = false; - for (Card attacker : attackers) { + for (final Card attacker : this.attackers) { boolean isUnblockableCreature = true; // check blockers individually, as the bulk canBeBlocked doesn't // check all circumstances - for (Card blocker : blockers) { + for (final Card blocker : this.blockers) { if (CombatUtil.canBlock(attacker, blocker)) { isUnblockableCreature = false; } @@ -592,56 +591,58 @@ public class ComputerUtilAttack { // totals and other considerations // some bad "magic numbers" here, TODO replace with nice descriptive // variable names - if ((ratioDiff > 0 && doAttritionalAttack)) { // (playerLifeToDamageRatio - // <= 1 && ratioDiff >= 1 - // && outNumber > 0) || - aiAggression = 5; // attack at all costs - } else if ((playerLifeToDamageRatio < 2 && ratioDiff >= 0) - || ratioDiff > 3 || (ratioDiff > 0 && outNumber > 0)) { - aiAggression = 3; // attack expecting to kill creatures or damage - // player. - } else if (ratioDiff >= 0 || ratioDiff + outNumber >= -1) { + if (((ratioDiff > 0) && doAttritionalAttack)) { // (playerLifeToDamageRatio + // <= 1 && ratioDiff >= + // 1 + // && outNumber > 0) || + this.aiAggression = 5; // attack at all costs + } else if (((playerLifeToDamageRatio < 2) && (ratioDiff >= 0)) || (ratioDiff > 3) + || ((ratioDiff > 0) && (outNumber > 0))) { + this.aiAggression = 3; // attack expecting to kill creatures or + // damage + // player. + } else if ((ratioDiff >= 0) || ((ratioDiff + outNumber) >= -1)) { // at 0 ratio expect to potentially gain an advantage by attacking // first // if the ai has a slight advantage // or the ai has a significant advantage numerically but only a // slight disadvantage damage/life - aiAggression = 2; // attack expecting to destroy creatures/be - // unblockable - } else if (ratioDiff < 0 && aiLifeToPlayerDamageRatio > 1) { + this.aiAggression = 2; // attack expecting to destroy creatures/be + // unblockable + } else if ((ratioDiff < 0) && (aiLifeToPlayerDamageRatio > 1)) { // the player is overmatched but there are a few turns before death - aiAggression = 2; // attack expecting to destroy creatures/be - // unblockable + this.aiAggression = 2; // attack expecting to destroy creatures/be + // unblockable } else if (doUnblockableAttack || ((ratioDiff * -1) < turnsUntilDeathByUnblockable)) { - aiAggression = 1; // look for unblockable creatures that might be - // able to attack for a bit of + this.aiAggression = 1; // look for unblockable creatures that might + // be + // able to attack for a bit of // fatal damage even if the player is significantly better } else if (ratioDiff < 0) { - aiAggression = 0; + this.aiAggression = 0; } // stay at home to block - System.out.println(String.valueOf(aiAggression) + " = ai aggression"); + System.out.println(String.valueOf(this.aiAggression) + " = ai aggression"); // **************** // End of edits // **************** // Exalted - if (combat.getAttackers().length == 0 - && (countExaltedBonus(AllZone.getComputerPlayer()) >= 3 + if ((combat.getAttackers().length == 0) + && ((this.countExaltedBonus(AllZone.getComputerPlayer()) >= 3) || AllZoneUtil.isCardInPlay("Rafiq of the Many", AllZone.getComputerPlayer()) - || AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield, - "Battlegrace Angel").size() >= 2 || (AllZone - .getComputerPlayer().getCardsIn(Zone.Battlefield, "Finest Hour").size() >= 1) - && AllZone.getPhase().isFirstCombat()) && !bAssault) { + || (AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield, "Battlegrace Angel").size() >= 2) || ((AllZone + .getComputerPlayer().getCardsIn(Zone.Battlefield, "Finest Hour").size() >= 1) && AllZone + .getPhase().isFirstCombat())) && !bAssault) { int biggest = 0; Card att = null; for (int i = 0; i < attackersLeft.size(); i++) { - if (getAttack(attackersLeft.get(i)) > biggest) { - biggest = getAttack(attackersLeft.get(i)); + if (this.getAttack(attackersLeft.get(i)) > biggest) { + biggest = this.getAttack(attackersLeft.get(i)); att = attackersLeft.get(i); } } - if (att != null && CombatUtil.canAttack(att, combat)) { + if ((att != null) && CombatUtil.canAttack(att, combat)) { combat.addAttacker(att); } @@ -656,26 +657,26 @@ public class ComputerUtilAttack { for (int i = 0; i < attackersLeft.size(); i++) { if (CombatUtil.canAttack(attackersLeft.get(i), combat)) { combat.addAttacker(attackersLeft.get(i)); - } + } } } else { System.out.println("Normal attack"); - attackersLeft = notNeededAsBlockers(attackersLeft, combat); + attackersLeft = this.notNeededAsBlockers(attackersLeft, combat); System.out.println(attackersLeft.size()); - attackersLeft = sortAttackers(attackersLeft); + attackersLeft = this.sortAttackers(attackersLeft); for (int i = 0; i < attackersLeft.size(); i++) { - Card attacker = attackersLeft.get(i); + final Card attacker = attackersLeft.get(i); int totalFirstStrikeBlockPower = 0; if (!attacker.hasFirstStrike() && !attacker.hasDoubleStrike()) { totalFirstStrikeBlockPower = CombatUtil.getTotalFirstStrikeBlockPower(attacker, AllZone.getHumanPlayer()); } - if (shouldAttack(attacker, blockers, combat) - && (totalFirstStrikeBlockPower < attacker.getKillDamage() || aiAggression == 5) + if (this.shouldAttack(attacker, this.blockers, combat) + && ((totalFirstStrikeBlockPower < attacker.getKillDamage()) || (this.aiAggression == 5)) && CombatUtil.canAttack(attacker, combat)) { combat.addAttacker(attacker); } @@ -697,6 +698,7 @@ public class ComputerUtilAttack { public final int countExaltedBonus(final Player player) { CardList list = player.getCardsIn(Zone.Battlefield); list = list.filter(new CardListFilter() { + @Override public boolean addCard(final Card c) { return c.hasKeyword("Exalted"); } @@ -748,7 +750,7 @@ public class ComputerUtilAttack { boolean isWorthLessThanAllKillers = true; boolean canBeBlocked = false; - if (!isEffectiveAttacker(attacker, combat)) { + if (!this.isEffectiveAttacker(attacker, combat)) { return false; } @@ -756,7 +758,7 @@ public class ComputerUtilAttack { // number of factors about the attacking // context that will be relevant to the attackers decision according to // the selected strategy - for (Card defender : defenders) { + for (final Card defender : defenders) { if (CombatUtil.canBlock(attacker, defender)) { // , combat )) { canBeBlocked = true; if (CombatUtil.canDestroyAttacker(attacker, defender, combat, false)) { @@ -793,7 +795,7 @@ public class ComputerUtilAttack { // decide if the creature should attack based on the prevailing strategy // choice in aiAggression - switch (aiAggression) { + switch (this.aiAggression) { case 5: // all out attacking System.out.println(attacker.getName() + " = all out attacking"); return true; diff --git a/src/main/java/forge/Counters.java b/src/main/java/forge/Counters.java index 08fd653a158..ef6e521c9ec 100644 --- a/src/main/java/forge/Counters.java +++ b/src/main/java/forge/Counters.java @@ -256,7 +256,7 @@ public enum Counters { /** The STUDY. */ STUDY(), - + /** The THEFT. */ THEFT(), diff --git a/src/main/java/forge/GameAction.java b/src/main/java/forge/GameAction.java index 30b596f9571..48071e1378b 100644 --- a/src/main/java/forge/GameAction.java +++ b/src/main/java/forge/GameAction.java @@ -120,7 +120,7 @@ public class GameAction { c.switchStates("Cloner", "Original"); c.setState("Original"); } - + copied = AllZone.getCardFactory().copyCard(c); lastKnownInfo = CardUtil.getLKICopy(c); @@ -540,9 +540,8 @@ public class GameAction { if (c.isToken()) { return c; } - - if(c.isInAlternateState()) - { + + if (c.isInAlternateState()) { c.setState("Original"); } @@ -893,7 +892,8 @@ public class GameAction { if (entity instanceof Card) { final Card perm = (Card) entity; - if (!AllZoneUtil.isCardInPlay(perm) || perm.hasProtectionFrom(c) || perm.hasKeyword("CARDNAME can't be enchanted.") + if (!AllZoneUtil.isCardInPlay(perm) || perm.hasProtectionFrom(c) + || perm.hasKeyword("CARDNAME can't be enchanted.") || ((tgt != null) && !perm.isValid(tgt.getValidTgts(), c.getController(), c))) { c.unEnchantEntity(perm); this.moveToGraveyard(c); @@ -1342,13 +1342,13 @@ public class GameAction { AllZone.getHumanPlayer().getZone(Zone.Library).add(card); if (card.hasAlternateState()) { - if(card.isDoubleFaced()) { + if (card.isDoubleFaced()) { card.setState("Transformed"); } - if(card.isFlip()) { + if (card.isFlip()) { card.setState("Flipped"); } - + card.setImageFilename(CardUtil.buildFilename(card)); card.setState("Original"); @@ -1385,13 +1385,13 @@ public class GameAction { } if (card.hasAlternateState()) { - if(card.isDoubleFaced()) { + if (card.isDoubleFaced()) { card.setState("Transformed"); } - if(card.isFlip()) { + if (card.isFlip()) { card.setState("Flipped"); } - + card.setImageFilename(CardUtil.buildFilename(card)); card.setState("Original"); @@ -1634,9 +1634,8 @@ public class GameAction { } if (((flip == 0) && q.equals(0)) || ((flip == 1) && q.equals(1))) { - JOptionPane.showMessageDialog(null, - humanFlip + "\r\n" + ForgeProps.getLocalized(GameActionText.HUMAN_WIN), "", - JOptionPane.INFORMATION_MESSAGE); + JOptionPane.showMessageDialog(null, humanFlip + "\r\n" + ForgeProps.getLocalized(GameActionText.HUMAN_WIN), + "", JOptionPane.INFORMATION_MESSAGE); } else { this.computerStartsGame(); JOptionPane.showMessageDialog(null, @@ -1795,16 +1794,19 @@ public class GameAction { // for uncastables like lotus bloom, check if manaCost is blank sa.setActivatingPlayer(human); if (sa.canPlay() && (!sa.isSpell() || !sa.getManaCost().equals(""))) { - + boolean flashb = false; - - //check for flashback keywords + + // check for flashback keywords if (c.isInZone(Constant.Zone.Graveyard) && sa.isSpell() && (c.isInstant() || c.isSorcery())) { - for(String keyword : c.getKeyword()) { + for (final String keyword : c.getKeyword()) { if (keyword.startsWith("Flashback")) { - SpellAbility flashback = sa.copy(); + final SpellAbility flashback = sa.copy(); flashback.setFlashBackAbility(true); - if (!keyword.equals("Flashback")) {//there is a flashback cost (and not the cards cost) + if (!keyword.equals("Flashback")) { // there is a + // flashback cost + // (and not the + // cards cost) final Cost fbCost = new Cost(keyword.substring(10), c.getName(), false); flashback.setPayCosts(fbCost); } @@ -2072,97 +2074,94 @@ public class GameAction { } else if (spell.getSourceCard().hasKeyword("Convoke")) { CardList untappedCreats = spell.getActivatingPlayer().getCardsIn(Zone.Battlefield).getType("Creature"); untappedCreats = untappedCreats.filter(new CardListFilter() { - public boolean addCard(Card c) { - return !c.isTapped(); - } + @Override + public boolean addCard(final Card c) { + return !c.isTapped(); + } }); - - if(untappedCreats.size() != 0) - { - ArrayList choices = new ArrayList(); - for(Card c : untappedCreats) { + + if (untappedCreats.size() != 0) { + final ArrayList choices = new ArrayList(); + for (final Card c : untappedCreats) { choices.add(c); } choices.add("DONE"); ArrayList usableColors = new ArrayList(); ManaCost newCost = new ManaCost(originalCost.toString()); Object tapForConvoke = null; - if(sa.getActivatingPlayer().isHuman()) - { - tapForConvoke = GuiUtils.getChoiceOptional("Tap for Convoke? " + newCost.toString(), choices.toArray()); + if (sa.getActivatingPlayer().isHuman()) { + tapForConvoke = GuiUtils.getChoiceOptional("Tap for Convoke? " + newCost.toString(), + choices.toArray()); + } else { + // TODO: AI to choose a creature to tap would go here + // Probably along with deciding how many creatures to + // tap } - else { - //TODO: AI to choose a creature to tap would go here - //Probably along with deciding how many creatures to tap - } - while(tapForConvoke != null && (tapForConvoke instanceof Card) && untappedCreats.size() != 0) { - Card workingCard = (Card) tapForConvoke; + while ((tapForConvoke != null) && (tapForConvoke instanceof Card) && (untappedCreats.size() != 0)) { + final Card workingCard = (Card) tapForConvoke; usableColors = CardUtil.getConvokableColors(workingCard, newCost); - - if(usableColors.size() != 0) - { + + if (usableColors.size() != 0) { String chosenColor = usableColors.get(0); - if(usableColors.size() > 1) - { - if(sa.getActivatingPlayer().isHuman()) - { - chosenColor = (String)GuiUtils.getChoice("Convoke for which color?", usableColors.toArray()); - } - else - { - //TODO: AI for choosing which color to convoke goes here. + if (usableColors.size() > 1) { + if (sa.getActivatingPlayer().isHuman()) { + chosenColor = (String) GuiUtils.getChoice("Convoke for which color?", + usableColors.toArray()); + } else { + // TODO: AI for choosing which color to + // convoke goes here. } } - - if(chosenColor.equals("colorless")) - { + + if (chosenColor.equals("colorless")) { newCost.decreaseColorlessMana(1); - } - else - { + } else { String newCostStr = newCost.toString(); - newCostStr = newCostStr.replaceFirst(InputPayManaCostUtil.getShortColorString(chosenColor), ""); + newCostStr = newCostStr.replaceFirst( + InputPayManaCostUtil.getShortColorString(chosenColor), ""); newCost = new ManaCost(newCostStr.trim()); } - + sa.addTappedForConvoke(workingCard); choices.remove(workingCard); untappedCreats.remove(workingCard); - if(choices.size() < 2 || newCost.getConvertedManaCost() == 0) { + if ((choices.size() < 2) || (newCost.getConvertedManaCost() == 0)) { break; } - } - else - { + } else { untappedCreats.remove(workingCard); } - if(sa.getActivatingPlayer().isHuman()) - { - tapForConvoke = GuiUtils.getChoiceOptional("Tap for Convoke? " + newCost.toString(), choices.toArray()); - } - else { - //TODO: AI to choose a creature to tap would go here + if (sa.getActivatingPlayer().isHuman()) { + tapForConvoke = GuiUtils.getChoiceOptional("Tap for Convoke? " + newCost.toString(), + choices.toArray()); + } else { + // TODO: AI to choose a creature to tap would go + // here } } - - //will only be null if user cancelled. - if(tapForConvoke != null) { - //Convoked creats are tapped here with triggers suppressed, - //Then again when payment is done(In InputPayManaCost.done()) with suppression cleared. - //This is to make sure that triggers go off at the right time - //AND that you can't use mana tapabilities of convoked creatures - //to pay the convoked cost. + + // will only be null if user cancelled. + if (tapForConvoke != null) { + // Convoked creats are tapped here with triggers + // suppressed, + // Then again when payment is done(In + // InputPayManaCost.done()) with suppression cleared. + // This is to make sure that triggers go off at the + // right time + // AND that you can't use mana tapabilities of convoked + // creatures + // to pay the convoked cost. AllZone.getTriggerHandler().suppressMode("Taps"); - for(Card c : sa.getTappedForConvoke()) { + for (final Card c : sa.getTappedForConvoke()) { c.tap(); } AllZone.getTriggerHandler().clearSuppression("Taps"); - + manaCost = newCost; } } - + } } // isSpell @@ -2540,8 +2539,8 @@ public class GameAction { // Not Included as X Costs are not in // Colored Mana if (sa.isMultiKicker()) { - this.setCostCuttingGetMultiMickerManaCostPaidColored(this.getCostCuttingGetMultiMickerManaCostPaidColored() - + k[3]); + this.setCostCuttingGetMultiMickerManaCostPaidColored(this + .getCostCuttingGetMultiMickerManaCostPaidColored() + k[3]); // JOptionPane.showMessageDialog(null, // CostCutting_GetMultiMickerManaCostPaid_Colored, // "", JOptionPane.INFORMATION_MESSAGE); @@ -2665,7 +2664,7 @@ public class GameAction { AllZone.getInputControl().setInput(sa.getAfterPayMana()); } } else if (sa.getBeforePayMana() == null) { - AllZone.getInputControl().setInput(new InputPayManaCost(sa,manaCost)); + AllZone.getInputControl().setInput(new InputPayManaCost(sa, manaCost)); } else { AllZone.getInputControl().setInput(sa.getBeforePayMana()); } @@ -2820,30 +2819,49 @@ public class GameAction { } /** + * Gets the cost cutting get multi micker mana cost paid. + * * @return the costCuttingGetMultiMickerManaCostPaid */ public int getCostCuttingGetMultiMickerManaCostPaid() { - return costCuttingGetMultiMickerManaCostPaid; + return this.costCuttingGetMultiMickerManaCostPaid; } /** + * Sets the cost cutting get multi micker mana cost paid. + * * @param costCuttingGetMultiMickerManaCostPaid the costCuttingGetMultiMickerManaCostPaid to set */ - public void setCostCuttingGetMultiMickerManaCostPaid(int costCuttingGetMultiMickerManaCostPaid) { - this.costCuttingGetMultiMickerManaCostPaid = costCuttingGetMultiMickerManaCostPaid; // TODO: Add 0 to parameter's name. + public void setCostCuttingGetMultiMickerManaCostPaid(final int costCuttingGetMultiMickerManaCostPaid) { + this.costCuttingGetMultiMickerManaCostPaid = costCuttingGetMultiMickerManaCostPaid; // TODO: + // Add + // 0 + // to + // parameter's + // name. } /** + * Gets the cost cutting get multi micker mana cost paid colored. + * * @return the costCuttingGetMultiMickerManaCostPaidColored */ public String getCostCuttingGetMultiMickerManaCostPaidColored() { - return costCuttingGetMultiMickerManaCostPaidColored; + return this.costCuttingGetMultiMickerManaCostPaidColored; } /** + * Sets the cost cutting get multi micker mana cost paid colored. + * * @param costCuttingGetMultiMickerManaCostPaidColored the costCuttingGetMultiMickerManaCostPaidColored to set */ - public void setCostCuttingGetMultiMickerManaCostPaidColored(String costCuttingGetMultiMickerManaCostPaidColored) { - this.costCuttingGetMultiMickerManaCostPaidColored = costCuttingGetMultiMickerManaCostPaidColored; // TODO: Add 0 to parameter's name. + public void setCostCuttingGetMultiMickerManaCostPaidColored( + final String costCuttingGetMultiMickerManaCostPaidColored) { + this.costCuttingGetMultiMickerManaCostPaidColored = costCuttingGetMultiMickerManaCostPaidColored; // TODO: + // Add + // 0 + // to + // parameter's + // name. } } diff --git a/src/main/java/forge/GuiDownloadPicturesLQ.java b/src/main/java/forge/GuiDownloadPicturesLQ.java index 77d021d1b68..b02e1ea8b31 100644 --- a/src/main/java/forge/GuiDownloadPicturesLQ.java +++ b/src/main/java/forge/GuiDownloadPicturesLQ.java @@ -52,7 +52,7 @@ public class GuiDownloadPicturesLQ extends GuiDownloader { c.setState("Flip"); cList.addAll(createDLObjects(c, base)); } - if(c.isDoubleFaced()) { + if (c.isDoubleFaced()) { c.setState("Transformed"); cList.addAll(createDLObjects(c, base)); } diff --git a/src/main/java/forge/GuiDownloadSetPicturesLQ.java b/src/main/java/forge/GuiDownloadSetPicturesLQ.java index 125421723bb..47c3b9c8c0f 100644 --- a/src/main/java/forge/GuiDownloadSetPicturesLQ.java +++ b/src/main/java/forge/GuiDownloadSetPicturesLQ.java @@ -25,7 +25,7 @@ public class GuiDownloadSetPicturesLQ extends GuiDownloader { private static final long serialVersionUID = -7890794857949935256L; private String picturesPath; - + /** *

* Constructor for Gui_DownloadSetPictures_LQ. @@ -36,33 +36,38 @@ public class GuiDownloadSetPicturesLQ extends GuiDownloader { */ public GuiDownloadSetPicturesLQ(final JFrame frame) { super(frame); - + } - protected final void addCardToList(ArrayList cList, CardPrinted c, String cardName) - { + /** + * Adds the card to list. + * + * @param cList the c list + * @param c the c + * @param cardName the card name + */ + protected final void addCardToList(final ArrayList cList, final CardPrinted c, final String cardName) { final String urlBase = "http://cardforge.org/fpics/"; - String setCode3 = c.getSet(); - CardSet thisSet = SetUtils.getSetByCode(setCode3); - String setCode2 = thisSet.getCode2(); + final String setCode3 = c.getSet(); + final CardSet thisSet = SetUtils.getSetByCode(setCode3); + final String setCode2 = thisSet.getCode2(); - String imgFN = CardUtil.buildFilename(c, cardName); - boolean foundSetImage = imgFN.contains(setCode3) || imgFN.contains(setCode2); + final String imgFN = CardUtil.buildFilename(c, cardName); + final boolean foundSetImage = imgFN.contains(setCode3) || imgFN.contains(setCode2); - if(picturesPath == null) - { + if (this.picturesPath == null) { System.out.println("Oh snap!"); } if (!foundSetImage) { - int artsCnt = c.getCard().getSetInfo(setCode3).getCopiesCount(); - String fn = CardUtil.buildIdealFilename(cardName, c.getArtIndex(), artsCnt); - cList.add(new DownloadObject(fn, urlBase + setCode2 + "/" + Base64Coder.encodeString(fn, true), - picturesPath + File.separator + setCode3)); - System.out.println(String.format("%s [%s - %s]", cardName, setCode3, thisSet.getName() )); + final int artsCnt = c.getCard().getSetInfo(setCode3).getCopiesCount(); + final String fn = CardUtil.buildIdealFilename(cardName, c.getArtIndex(), artsCnt); + cList.add(new DownloadObject(fn, urlBase + setCode2 + "/" + Base64Coder.encodeString(fn, true), + this.picturesPath + File.separator + setCode3)); + System.out.println(String.format("%s [%s - %s]", cardName, setCode3, thisSet.getName())); } } - + /** *

* getNeededCards. @@ -70,40 +75,40 @@ public class GuiDownloadSetPicturesLQ extends GuiDownloader { * * @return an array of {@link forge.GuiDownloader.DownloadObject} objects. */ + @Override protected final DownloadObject[] getNeededImages() { - if(picturesPath == null) - { - picturesPath = ForgeProps.getFile(NewConstants.IMAGE_BASE).getPath(); + if (this.picturesPath == null) { + this.picturesPath = ForgeProps.getFile(NewConstants.IMAGE_BASE).getPath(); } // read token names and urls - DownloadObject[] cardTokenLQ = readFileWithNames(NewConstants.TOKEN_IMAGES, ForgeProps.getFile(NewConstants.IMAGE_TOKEN)); - ArrayList cList = new ArrayList(); + final DownloadObject[] cardTokenLQ = GuiDownloader.readFileWithNames(NewConstants.TOKEN_IMAGES, + ForgeProps.getFile(NewConstants.IMAGE_TOKEN)); + final ArrayList cList = new ArrayList(); - for (CardPrinted c : CardDb.instance().getAllCards()) { - String setCode3 = c.getSet(); + for (final CardPrinted c : CardDb.instance().getAllCards()) { + final String setCode3 = c.getSet(); if (StringUtils.isBlank(setCode3) || "???".equals(setCode3)) { continue; // we don't want cards from unknown sets } - addCardToList(cList, c, c.getCard().getName()); - if ( c.getCard().isDoubleFaced() ) - { - addCardToList(cList, c, c.getCard().getSlavePart().getName()); + this.addCardToList(cList, c, c.getCard().getName()); + if (c.getCard().isDoubleFaced()) { + this.addCardToList(cList, c, c.getCard().getSlavePart().getName()); } } // add missing tokens to the list of things to download File file; - File filebase = ForgeProps.getFile(NewConstants.IMAGE_TOKEN); - for (int i = 0; i < cardTokenLQ.length; i++) { - file = new File(filebase, cardTokenLQ[i].getName()); + final File filebase = ForgeProps.getFile(NewConstants.IMAGE_TOKEN); + for (final DownloadObject element : cardTokenLQ) { + file = new File(filebase, element.getName()); if (!file.exists()) { - cList.add(cardTokenLQ[i]); + cList.add(element); } } // return all card names and urls that are needed - DownloadObject[] out = new DownloadObject[cList.size()]; + final DownloadObject[] out = new DownloadObject[cList.size()]; cList.toArray(out); return out; diff --git a/src/main/java/forge/Upkeep.java b/src/main/java/forge/Upkeep.java index b30839cc539..c43a7d0cc04 100644 --- a/src/main/java/forge/Upkeep.java +++ b/src/main/java/forge/Upkeep.java @@ -502,8 +502,9 @@ public class Upkeep implements java.io.Serializable { for (final Card c : cards) { final Card abyss = c; - - final CardList abyssGetTargets = AllZoneUtil.getCreaturesInPlay(player).filter(CardListFilter.NON_ARTIFACTS); + + final CardList abyssGetTargets = AllZoneUtil.getCreaturesInPlay(player) + .filter(CardListFilter.NON_ARTIFACTS); final Ability sacrificeCreature = new Ability(abyss, "") { @Override @@ -533,11 +534,11 @@ public class Upkeep implements java.io.Serializable { }); // Input } } else { // computer - + final CardList indestruct = targets.getKeyword("Indestructible"); if (indestruct.size() > 0) { AllZone.getGameAction().destroyNoRegeneration(indestruct.get(0)); - } else if (targets.size() > 0){ + } else if (targets.size() > 0) { final Card target = CardFactoryUtil.getWorstCreatureAI(targets); if (null == target) { // must be nothing valid to destroy @@ -2455,7 +2456,7 @@ public class Upkeep implements java.io.Serializable { // is final Player player = AllZone.getPhase().getPlayerTurn(); final String keyword = "At the beginning of your upkeep, you may have this " - + "creature become a copy of target creature except it doesn't copy that " + + "creature become a copy of target creature except it doesn't copy that " + "creature's color. If you do, this creature gains this ability."; CardList list = player.getCardsIn(Zone.Battlefield); list = list.getKeyword(keyword); @@ -2482,15 +2483,16 @@ public class Upkeep implements java.io.Serializable { * add new to play */ - final Card newCopy = AllZone.getCardFactory().getCard(newTarget[0].getState("Original").getName(), player); + final Card newCopy = AllZone.getCardFactory().getCard( + newTarget[0].getState("Original").getName(), player); newCopy.setCurSetCode(newTarget[0].getCurSetCode()); newCopy.setImageFilename(newTarget[0].getImageFilename()); newCopy.setState(newTarget[0].getCurState()); - + CardFactoryUtil.copyCharacteristics(newCopy, c); c.addColor("U"); - + c.addExtrinsicKeyword(keyword); } } @@ -2528,7 +2530,7 @@ public class Upkeep implements java.io.Serializable { } }; ability.setDescription("At the beginning of your upkeep, you may have this creature become " - + "a copy of target creature except it doesn't copy that creature's color. If you do, this creature gains this ability."); + + "a copy of target creature except it doesn't copy that creature's color. If you do, this creature gains this ability."); ability.setStackDescription(c.getName() + " - you may have this creature become a copy of target creature."); AllZone.getStack().addSimultaneousStackEntry(ability); diff --git a/src/main/java/forge/card/BoosterGenerator.java b/src/main/java/forge/card/BoosterGenerator.java index 28a9a0a1ce9..8fe5e3ef28e 100644 --- a/src/main/java/forge/card/BoosterGenerator.java +++ b/src/main/java/forge/card/BoosterGenerator.java @@ -26,8 +26,7 @@ public class BoosterGenerator { // Function to open a booster as it is. /** The Constant IDENTITY_PICK. */ - public static final Lambda1, BoosterGenerator> IDENTITY_PICK - = new Lambda1, BoosterGenerator>() { + public static final Lambda1, BoosterGenerator> IDENTITY_PICK = new Lambda1, BoosterGenerator>() { @Override public List apply(final BoosterGenerator arg1) { return arg1.getBoosterPack(); @@ -133,8 +132,7 @@ public class BoosterGenerator { return this.pickRandomCards(source, count, false); } - private List pickRandomCards(final List source, - final int count, final boolean singleton) { + private List pickRandomCards(final List source, final int count, final boolean singleton) { int listSize = source == null ? 0 : source.size(); if ((count <= 0) || (listSize == 0)) { return BoosterGenerator.EMPTY_LIST; @@ -205,8 +203,9 @@ public class BoosterGenerator { /** * Gets the singleton booster pack. - * - * @param nAnyCard the n any card + * + * @param nAnyCard + * the n any card * @return the singleton booster pack */ public final List getSingletonBoosterPack(final int nAnyCard) { @@ -266,19 +265,19 @@ public class BoosterGenerator { temp.addAll(this.pickRandomCards(this.mythics, nMythics)); } if (nDoubls > 0) { - int dblFacedRarity = MyRandom.getRandom().nextInt(14); + final int dblFacedRarity = MyRandom.getRandom().nextInt(14); List listToUse; - if (dblFacedRarity < 9) { //Common - listToUse = doubleFacedCommons; - } else if (dblFacedRarity < 13) { //Uncommon - listToUse = doubleFacedUncommons; - } else {//Rare or Mythic - if(MyRandom.getRandom().nextInt(8) == 0) { - listToUse = doubleFacedMythics; + if (dblFacedRarity < 9) { // Common + listToUse = this.doubleFacedCommons; + } else if (dblFacedRarity < 13) { // Uncommon + listToUse = this.doubleFacedUncommons; + } else { // Rare or Mythic + if (MyRandom.getRandom().nextInt(8) == 0) { + listToUse = this.doubleFacedMythics; } else { - listToUse = doubleFacedRares; - } - } + listToUse = this.doubleFacedRares; + } + } temp.addAll(this.pickRandomCards(listToUse, nDoubls)); } diff --git a/src/main/java/forge/card/CardRules.java b/src/main/java/forge/card/CardRules.java index 48ef4bdbf61..cc684bb491f 100644 --- a/src/main/java/forge/card/CardRules.java +++ b/src/main/java/forge/card/CardRules.java @@ -48,7 +48,7 @@ public final class CardRules { * @return the name */ public String getName() { - return characteristics.getCardName(); + return this.characteristics.getCardName(); } /** @@ -57,7 +57,7 @@ public final class CardRules { * @return the type */ public CardType getType() { - return characteristics.getCardType(); + return this.characteristics.getCardType(); } /** @@ -66,7 +66,7 @@ public final class CardRules { * @return the mana cost */ public CardManaCost getManaCost() { - return characteristics.getManaCost(); + return this.characteristics.getManaCost(); } /** @@ -75,7 +75,7 @@ public final class CardRules { * @return the color */ public CardColor getColor() { - return characteristics.getColor(); + return this.characteristics.getColor(); } /** @@ -84,18 +84,25 @@ public final class CardRules { * @return the rules */ public String[] getRules() { - return characteristics.getCardRules(); + return this.characteristics.getCardRules(); } - - public final CardRules getSlavePart() { return slavePart; } - + + /** + * + * Gets Slave Part. + * @return CardRules + */ + public CardRules getSlavePart() { + return this.slavePart; + } + /** * Gets the sets printed. * * @return the sets printed */ public Set> getSetsPrinted() { - return characteristics.getSetsData().entrySet(); + return this.characteristics.getSetsData().entrySet(); } /** @@ -104,7 +111,7 @@ public final class CardRules { * @return the power */ public String getPower() { - return power; + return this.power; } /** @@ -113,7 +120,7 @@ public final class CardRules { * @return the int power */ public int getIntPower() { - return iPower; + return this.iPower; } /** @@ -122,7 +129,7 @@ public final class CardRules { * @return the toughness */ public String getToughness() { - return toughness; + return this.toughness; } /** @@ -131,7 +138,7 @@ public final class CardRules { * @return the int toughness */ public int getIntToughness() { - return iToughness; + return this.iToughness; } /** @@ -140,7 +147,7 @@ public final class CardRules { * @return the loyalty */ public String getLoyalty() { - return loyalty; + return this.loyalty; } /** @@ -149,7 +156,7 @@ public final class CardRules { * @return the rem ai decks */ public boolean getRemAIDecks() { - return isRemovedFromAIDecks; + return this.isRemovedFromAIDecks; } /** @@ -158,7 +165,7 @@ public final class CardRules { * @return the rem random decks */ public boolean getRemRandomDecks() { - return isRemovedFromRandomDecks; + return this.isRemovedFromRandomDecks; } /** @@ -167,11 +174,11 @@ public final class CardRules { * @return the p tor loyalty */ public String getPTorLoyalty() { - if (getType().isCreature()) { - return power + "/" + toughness; + if (this.getType().isCreature()) { + return this.power + "/" + this.toughness; } - if (getType().isPlaneswalker()) { - return loyalty; + if (this.getType().isPlaneswalker()) { + return this.loyalty; } return ""; } @@ -182,7 +189,7 @@ public final class CardRules { * @return true, if is alt state */ public boolean isAltState() { - return isDoubleFaced() && slavePart == null; + return this.isDoubleFaced() && (this.slavePart == null); } /** @@ -191,7 +198,7 @@ public final class CardRules { * @return true, if is double faced */ public boolean isDoubleFaced() { - return hasOtherFace; + return this.hasOtherFace; } /** @@ -201,8 +208,8 @@ public final class CardRules { * the chars * @param isDoubleFacedCard * the is double faced card - * @param isAlt0 - * the is alt0 + * @param otherPart + * the otherPart * @param removedFromRandomDecks * the removed from random decks * @param removedFromAIDecks @@ -210,31 +217,33 @@ public final class CardRules { */ public CardRules(final CardRuleCharacteristics chars, final boolean isDoubleFacedCard, final CardRules otherPart, final boolean removedFromRandomDecks, final boolean removedFromAIDecks) { - characteristics = chars; - slavePart = otherPart; - hasOtherFace = isDoubleFacedCard; + this.characteristics = chars; + this.slavePart = otherPart; + this.hasOtherFace = isDoubleFacedCard; this.isRemovedFromAIDecks = removedFromAIDecks; this.isRemovedFromRandomDecks = removedFromRandomDecks; // System.out.println(cardName); - if (getType().isCreature()) { - int slashPos = characteristics.getPtLine() == null ? -1 : characteristics.getPtLine().indexOf('/'); + if (this.getType().isCreature()) { + final int slashPos = this.characteristics.getPtLine() == null ? -1 : this.characteristics.getPtLine() + .indexOf('/'); if (slashPos == -1) { - throw new RuntimeException(String.format("Creature '%s' has bad p/t stats", getName())); + throw new RuntimeException(String.format("Creature '%s' has bad p/t stats", this.getName())); } - this.power = characteristics.getPtLine().substring(0, slashPos); - this.toughness = characteristics.getPtLine().substring(slashPos + 1, characteristics.getPtLine().length()); - this.iPower = StringUtils.isNumeric(power) ? Integer.parseInt(power) : 0; - this.iToughness = StringUtils.isNumeric(toughness) ? Integer.parseInt(toughness) : 0; - } else if (getType().isPlaneswalker()) { - this.loyalty = characteristics.getPtLine(); + this.power = this.characteristics.getPtLine().substring(0, slashPos); + this.toughness = this.characteristics.getPtLine().substring(slashPos + 1, + this.characteristics.getPtLine().length()); + this.iPower = StringUtils.isNumeric(this.power) ? Integer.parseInt(this.power) : 0; + this.iToughness = StringUtils.isNumeric(this.toughness) ? Integer.parseInt(this.toughness) : 0; + } else if (this.getType().isPlaneswalker()) { + this.loyalty = this.characteristics.getPtLine(); } - if (characteristics.getSetsData().isEmpty()) { - characteristics.getSetsData().put("???", new CardInSet(CardRarity.Unknown, 1)); + if (this.characteristics.getSetsData().isEmpty()) { + this.characteristics.getSetsData().put("???", new CardInSet(CardRarity.Unknown, 1)); } - setsPrinted = characteristics.getSetsData(); + this.setsPrinted = this.characteristics.getSetsData(); } /** @@ -245,10 +254,10 @@ public final class CardRules { * @return true, if successful */ public boolean rulesContain(final String text) { - if (characteristics.getCardRules() == null) { + if (this.characteristics.getCardRules() == null) { return false; } - for (String r : characteristics.getCardRules()) { + for (final String r : this.characteristics.getCardRules()) { if (StringUtils.containsIgnoreCase(r, text)) { return true; } @@ -264,7 +273,7 @@ public final class CardRules { public String getLatestSetPrinted() { String lastSet = null; // TODO: Make a true release-date based sorting - for (String cs : setsPrinted.keySet()) { + for (final String cs : this.setsPrinted.keySet()) { lastSet = cs; } return lastSet; @@ -278,11 +287,11 @@ public final class CardRules { * @return the sets the info */ public CardInSet getSetInfo(final String setCode) { - CardInSet result = setsPrinted.get(setCode); + final CardInSet result = this.setsPrinted.get(setCode); if (result != null) { return result; } - throw new RuntimeException(String.format("Card '%s' was never printed in set '%s'", getName(), setCode)); + throw new RuntimeException(String.format("Card '%s' was never printed in set '%s'", this.getName(), setCode)); } @@ -292,7 +301,7 @@ public final class CardRules { * @return the rarity from latest set */ public CardRarity getRarityFromLatestSet() { - CardInSet cis = setsPrinted.get(getLatestSetPrinted()); + final CardInSet cis = this.setsPrinted.get(this.getLatestSetPrinted()); return cis.getRarity(); } @@ -302,8 +311,8 @@ public final class CardRules { * @return the ai status */ public String getAiStatus() { - return isRemovedFromAIDecks ? (isRemovedFromRandomDecks ? "AI ?" : "AI") - : (isRemovedFromRandomDecks ? "?" : ""); + return this.isRemovedFromAIDecks ? (this.isRemovedFromRandomDecks ? "AI ?" : "AI") + : (this.isRemovedFromRandomDecks ? "?" : ""); } /** @@ -312,11 +321,11 @@ public final class CardRules { * @return the ai status comparable */ public Integer getAiStatusComparable() { - if (isRemovedFromAIDecks && isRemovedFromRandomDecks) { + if (this.isRemovedFromAIDecks && this.isRemovedFromRandomDecks) { return Integer.valueOf(3); - } else if (isRemovedFromAIDecks) { + } else if (this.isRemovedFromAIDecks) { return Integer.valueOf(4); - } else if (isRemovedFromRandomDecks) { + } else if (this.isRemovedFromRandomDecks) { return Integer.valueOf(2); } else { return Integer.valueOf(1); @@ -447,8 +456,8 @@ public final class CardRules { */ public static Predicate coreType(final boolean isEqual, final String what) { try { - return coreType(isEqual, CardCoreType.valueOf(CardCoreType.class, what)); - } catch (Exception e) { + return Predicates.coreType(isEqual, Enum.valueOf(CardCoreType.class, what)); + } catch (final Exception e) { return Predicate.getFalse(CardRules.class); } } @@ -477,8 +486,8 @@ public final class CardRules { */ public static Predicate superType(final boolean isEqual, final String what) { try { - return superType(isEqual, CardSuperType.valueOf(CardSuperType.class, what)); - } catch (Exception e) { + return Predicates.superType(isEqual, Enum.valueOf(CardSuperType.class, what)); + } catch (final Exception e) { return Predicate.getFalse(CardRules.class); } } @@ -564,17 +573,19 @@ public final class CardRules { @Override public boolean isTrue(final CardRules card) { boolean shouldConatin; - switch (field) { + switch (this.field) { case NAME: - return op(card.getName(), operand); + return this.op(card.getName(), this.operand); case SUBTYPE: - shouldConatin = getOperator() == StringOp.CONTAINS || getOperator() == StringOp.EQUALS; - return shouldConatin == card.getType().subTypeContains(operand); + shouldConatin = (this.getOperator() == StringOp.CONTAINS) + || (this.getOperator() == StringOp.EQUALS); + return shouldConatin == card.getType().subTypeContains(this.operand); case RULES: - shouldConatin = getOperator() == StringOp.CONTAINS || getOperator() == StringOp.EQUALS; - return shouldConatin == card.rulesContain(operand); + shouldConatin = (this.getOperator() == StringOp.CONTAINS) + || (this.getOperator() == StringOp.EQUALS); + return shouldConatin == card.rulesContain(this.operand); case JOINED_TYPE: - return op(card.getType().toString(), operand); + return this.op(card.getType().toString(), this.operand); default: return false; } @@ -596,23 +607,23 @@ public final class CardRules { private final byte color; public LeafColor(final ColorOperator operator, final byte thatColor) { - op = operator; - color = thatColor; + this.op = operator; + this.color = thatColor; } @Override public boolean isTrue(final CardRules subject) { - switch (op) { + switch (this.op) { case CountColors: - return subject.getColor().countColors() == color; + return subject.getColor().countColors() == this.color; case CountColorsGreaterOrEqual: - return subject.getColor().countColors() >= color; + return subject.getColor().countColors() >= this.color; case Equals: - return subject.getColor().isEqual(color); + return subject.getColor().isEqual(this.color); case HasAllOf: - return subject.getColor().hasAllColors(color); + return subject.getColor().hasAllColors(this.color); case HasAnyOf: - return subject.getColor().hasAnyColor(color); + return subject.getColor().hasAnyColor(this.color); default: return false; } @@ -630,29 +641,29 @@ public final class CardRules { public LeafNumber(final CardField field, final ComparableOp op, final int what) { this.field = field; - operand = what; - operator = op; + this.operand = what; + this.operator = op; } @Override public boolean isTrue(final CardRules card) { int value; - switch (field) { + switch (this.field) { case CMC: - return op(card.getManaCost().getCMC(), operand); + return this.op(card.getManaCost().getCMC(), this.operand); case POWER: value = card.getIntPower(); - return value >= 0 ? op(value, operand) : false; + return value >= 0 ? this.op(value, this.operand) : false; case TOUGHNESS: value = card.getIntToughness(); - return value >= 0 ? op(value, operand) : false; + return value >= 0 ? this.op(value, this.operand) : false; default: return false; } } private boolean op(final int op1, final int op2) { - switch (operator) { + switch (this.operator) { case EQUALS: return op1 == op2; case GREATER_THAN: @@ -677,12 +688,12 @@ public final class CardRules { @Override public boolean isTrue(final CardRules card) { - return shouldBeEqual == card.getType().typeContains(operand); + return this.shouldBeEqual == card.getType().typeContains(this.operand); } public PredicateCoreType(final CardCoreType type, final boolean wantEqual) { - operand = type; - shouldBeEqual = wantEqual; + this.operand = type; + this.shouldBeEqual = wantEqual; } } @@ -692,12 +703,12 @@ public final class CardRules { @Override public boolean isTrue(final CardRules card) { - return shouldBeEqual == card.getType().superTypeContains(operand); + return this.shouldBeEqual == card.getType().superTypeContains(this.operand); } public PredicateSuperType(final CardSuperType type, final boolean wantEqual) { - operand = type; - shouldBeEqual = wantEqual; + this.operand = type; + this.shouldBeEqual = wantEqual; } } @@ -707,12 +718,12 @@ public final class CardRules { @Override public boolean isTrue(final CardRules card) { - return card.getRarityFromLatestSet().equals(operand) == shouldBeEqual; + return card.getRarityFromLatestSet().equals(this.operand) == this.shouldBeEqual; } public PredicateLastesSetRarity(final CardRarity type, final boolean wantEqual) { - operand = type; - shouldBeEqual = wantEqual; + this.operand = type; + this.shouldBeEqual = wantEqual; } } @@ -720,12 +731,12 @@ public final class CardRules { private final List sets; public PredicateExitsInSets(final List wantSets) { - sets = wantSets; // maybe should make a copy here? + this.sets = wantSets; // maybe should make a copy here? } @Override public boolean isTrue(final CardRules subject) { - for (String s : sets) { + for (final String s : this.sets) { if (subject.setsPrinted.containsKey(s)) { return true; } @@ -740,13 +751,13 @@ public final class CardRules { public static class Presets { /** The Constant isCreature. */ - public static final Predicate IS_CREATURE = coreType(true, CardCoreType.Creature); + public static final Predicate IS_CREATURE = Predicates.coreType(true, CardCoreType.Creature); /** The Constant isArtifact. */ - public static final Predicate IS_ARTIFACT = coreType(true, CardCoreType.Artifact); + public static final Predicate IS_ARTIFACT = Predicates.coreType(true, CardCoreType.Artifact); /** The Constant isLand. */ - public static final Predicate IS_LAND = coreType(true, CardCoreType.Land); + public static final Predicate IS_LAND = Predicates.coreType(true, CardCoreType.Land); /** The Constant isBasicLand. */ public static final Predicate IS_BASIC_LAND = new Predicate() { @@ -757,54 +768,56 @@ public final class CardRules { }; /** The Constant isPlaneswalker. */ - public static final Predicate IS_PLANESWALKER = coreType(true, CardCoreType.Planeswalker); + public static final Predicate IS_PLANESWALKER = Predicates.coreType(true, + CardCoreType.Planeswalker); /** The Constant isInstant. */ - public static final Predicate IS_INSTANT = coreType(true, CardCoreType.Instant); + public static final Predicate IS_INSTANT = Predicates.coreType(true, CardCoreType.Instant); /** The Constant isSorcery. */ - public static final Predicate IS_SORCERY = coreType(true, CardCoreType.Sorcery); + public static final Predicate IS_SORCERY = Predicates.coreType(true, CardCoreType.Sorcery); /** The Constant isEnchantment. */ - public static final Predicate IS_ENCHANTMENT = coreType(true, CardCoreType.Enchantment); + public static final Predicate IS_ENCHANTMENT = Predicates.coreType(true, + CardCoreType.Enchantment); /** The Constant isNonLand. */ - public static final Predicate IS_NON_LAND = coreType(false, CardCoreType.Land); + public static final Predicate IS_NON_LAND = Predicates.coreType(false, CardCoreType.Land); /** The Constant isNonCreatureSpell. */ - public static final Predicate IS_NON_CREATURE_SPELL = Predicate.compose(IS_CREATURE, - PredicatesOp.NOR, IS_LAND); + public static final Predicate IS_NON_CREATURE_SPELL = Predicate.compose(Presets.IS_CREATURE, + PredicatesOp.NOR, Presets.IS_LAND); /** The Constant isWhite. */ - public static final Predicate IS_WHITE = isColor(CardColor.WHITE); + public static final Predicate IS_WHITE = Predicates.isColor(CardColor.WHITE); /** The Constant isBlue. */ - public static final Predicate IS_BLUE = isColor(CardColor.BLUE); + public static final Predicate IS_BLUE = Predicates.isColor(CardColor.BLUE); /** The Constant isBlack. */ - public static final Predicate IS_BLACK = isColor(CardColor.BLACK); + public static final Predicate IS_BLACK = Predicates.isColor(CardColor.BLACK); /** The Constant isRed. */ - public static final Predicate IS_RED = isColor(CardColor.RED); + public static final Predicate IS_RED = Predicates.isColor(CardColor.RED); /** The Constant isGreen. */ - public static final Predicate IS_GREEN = isColor(CardColor.GREEN); + public static final Predicate IS_GREEN = Predicates.isColor(CardColor.GREEN); /** The Constant isColorless. */ - public static final Predicate IS_COLORLESS = hasCntColors((byte) 0); + public static final Predicate IS_COLORLESS = Predicates.hasCntColors((byte) 0); /** The Constant isMulticolor. */ - public static final Predicate IS_MULTICOLOR = hasAtLeastCntColors((byte) 2); + public static final Predicate IS_MULTICOLOR = Predicates.hasAtLeastCntColors((byte) 2); /** The Constant colors. */ public static final List> COLORS = new ArrayList>(); static { - COLORS.add(IS_WHITE); - COLORS.add(IS_BLUE); - COLORS.add(IS_BLACK); - COLORS.add(IS_RED); - COLORS.add(IS_GREEN); - COLORS.add(IS_COLORLESS); + Presets.COLORS.add(Presets.IS_WHITE); + Presets.COLORS.add(Presets.IS_BLUE); + Presets.COLORS.add(Presets.IS_BLACK); + Presets.COLORS.add(Presets.IS_RED); + Presets.COLORS.add(Presets.IS_GREEN); + Presets.COLORS.add(Presets.IS_COLORLESS); } /** The Constant constantTrue. */ @@ -813,22 +826,23 @@ public final class CardRules { // Think twice before using these, since rarity is a prop of printed // card. /** The Constant isInLatestSetCommon. */ - public static final Predicate IS_IN_LATEST_SET_COMMON = rarityInCardsLatestSet(true, + public static final Predicate IS_IN_LATEST_SET_COMMON = Predicates.rarityInCardsLatestSet(true, CardRarity.Common); /** The Constant isInLatestSetUncommon. */ - public static final Predicate IS_IN_LATEST_SET_UNCOMMON = rarityInCardsLatestSet(true, - CardRarity.Uncommon); + public static final Predicate IS_IN_LATEST_SET_UNCOMMON = Predicates.rarityInCardsLatestSet( + true, CardRarity.Uncommon); /** The Constant isInLatestSetRare. */ - public static final Predicate IS_IN_LATEST_SET_RARE = rarityInCardsLatestSet(true, CardRarity.Rare); + public static final Predicate IS_IN_LATEST_SET_RARE = Predicates.rarityInCardsLatestSet(true, + CardRarity.Rare); /** The Constant isInLatestSetMythicRare. */ - public static final Predicate IS_IN_LATEST_SET_MYTHIC_RARE = rarityInCardsLatestSet(true, - CardRarity.MythicRare); + public static final Predicate IS_IN_LATEST_SET_MYTHIC_RARE = Predicates.rarityInCardsLatestSet( + true, CardRarity.MythicRare); /** The Constant isInLatestSetSpecial. */ - public static final Predicate IS_IN_LATEST_SET_SPECIAL = rarityInCardsLatestSet(true, + public static final Predicate IS_IN_LATEST_SET_SPECIAL = Predicates.rarityInCardsLatestSet(true, CardRarity.Special); } } diff --git a/src/main/java/forge/card/CardRulesReader.java b/src/main/java/forge/card/CardRulesReader.java index ed096838cd1..313511feabb 100644 --- a/src/main/java/forge/card/CardRulesReader.java +++ b/src/main/java/forge/card/CardRulesReader.java @@ -48,7 +48,7 @@ public class CardRulesReader { */ public final CardRules getCard() { boolean hasOtherPart = this.characteristics[1] != null; - CardRules otherPart = hasOtherPart + CardRules otherPart = hasOtherPart ? new CardRules(this.characteristics[1], true, null, this.removedFromRandomDecks, this.removedFromAIDecks) : null; diff --git a/src/main/java/forge/card/MtgDataParser.java b/src/main/java/forge/card/MtgDataParser.java index 5f6d7d12744..e52d4077c41 100644 --- a/src/main/java/forge/card/MtgDataParser.java +++ b/src/main/java/forge/card/MtgDataParser.java @@ -131,7 +131,7 @@ public final class MtgDataParser implements Iterator { return null; } - CardRules otherPart = hasOtherPart ? new CardRules(this.chars[1], hasOtherPart, null, false, false) : null; + CardRules otherPart = hasOtherPart ? new CardRules(this.chars[1], hasOtherPart, null, false, false) : null; return new CardRules(this.chars[0], hasOtherPart, otherPart, false, false); } diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryChoose.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryChoose.java index e60fd8d2469..996c40ee268 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryChoose.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryChoose.java @@ -1411,7 +1411,7 @@ public final class AbilityFactoryChoose { // still missing a listener to display the card preview // in the right name = choice.getSelectedValue(); - if(AllZone.getCardFactory().getCard(name, p).isValid(valid, host.getController(), host)) { + if (AllZone.getCardFactory().getCard(name, p).isValid(valid, host.getController(), host)) { host.setNamedCard(choice.getSelectedValue()); ok = true; } diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryDealDamage.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryDealDamage.java index c759656a060..31e7098bc00 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryDealDamage.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryDealDamage.java @@ -63,8 +63,8 @@ public class AbilityFactoryDealDamage { * @return a {@link forge.card.spellability.SpellAbility} object. */ public final SpellAbility getAbilityDealDamage() { - final SpellAbility abDamage = new AbilityActivated(this.abilityFactory.getHostCard(), this.abilityFactory.getAbCost(), - this.abilityFactory.getAbTgt()) { + final SpellAbility abDamage = new AbilityActivated(this.abilityFactory.getHostCard(), + this.abilityFactory.getAbCost(), this.abilityFactory.getAbTgt()) { private static final long serialVersionUID = -7560349014757367722L; @Override @@ -74,7 +74,8 @@ public class AbilityFactoryDealDamage { @Override public String getStackDescription() { - return AbilityFactoryDealDamage.this.dealDamageStackDescription(AbilityFactoryDealDamage.this.abilityFactory, this); + return AbilityFactoryDealDamage.this.dealDamageStackDescription( + AbilityFactoryDealDamage.this.abilityFactory, this); } @Override @@ -84,8 +85,8 @@ public class AbilityFactoryDealDamage { @Override public boolean doTrigger(final boolean mandatory) { - return AbilityFactoryDealDamage.this.dealDamageDoTriggerAI(AbilityFactoryDealDamage.this.abilityFactory, this, - mandatory); + return AbilityFactoryDealDamage.this.dealDamageDoTriggerAI( + AbilityFactoryDealDamage.this.abilityFactory, this, mandatory); } }; // Ability_Activated @@ -100,7 +101,8 @@ public class AbilityFactoryDealDamage { * @return a {@link forge.card.spellability.SpellAbility} object. */ public final SpellAbility getSpellDealDamage() { - final SpellAbility spDealDamage = new Spell(this.abilityFactory.getHostCard(), this.abilityFactory.getAbCost(), this.abilityFactory.getAbTgt()) { + final SpellAbility spDealDamage = new Spell(this.abilityFactory.getHostCard(), this.abilityFactory.getAbCost(), + this.abilityFactory.getAbTgt()) { private static final long serialVersionUID = 7239608350643325111L; @Override @@ -111,7 +113,8 @@ public class AbilityFactoryDealDamage { @Override public String getStackDescription() { - return AbilityFactoryDealDamage.this.dealDamageStackDescription(AbilityFactoryDealDamage.this.abilityFactory, this); + return AbilityFactoryDealDamage.this.dealDamageStackDescription( + AbilityFactoryDealDamage.this.abilityFactory, this); } @Override @@ -132,7 +135,8 @@ public class AbilityFactoryDealDamage { * @return a {@link forge.card.spellability.SpellAbility} object. */ public final SpellAbility getDrawbackDealDamage() { - final SpellAbility dbDealDamage = new AbilitySub(this.abilityFactory.getHostCard(), this.abilityFactory.getAbTgt()) { + final SpellAbility dbDealDamage = new AbilitySub(this.abilityFactory.getHostCard(), + this.abilityFactory.getAbTgt()) { private static final long serialVersionUID = 7239608350643325111L; @Override @@ -143,7 +147,8 @@ public class AbilityFactoryDealDamage { @Override public String getStackDescription() { - return AbilityFactoryDealDamage.this.dealDamageStackDescription(AbilityFactoryDealDamage.this.abilityFactory, this); + return AbilityFactoryDealDamage.this.dealDamageStackDescription( + AbilityFactoryDealDamage.this.abilityFactory, this); } @Override @@ -153,8 +158,8 @@ public class AbilityFactoryDealDamage { @Override public boolean doTrigger(final boolean mandatory) { - return AbilityFactoryDealDamage.this.dealDamageDoTriggerAI(AbilityFactoryDealDamage.this.abilityFactory, this, - mandatory); + return AbilityFactoryDealDamage.this.dealDamageDoTriggerAI( + AbilityFactoryDealDamage.this.abilityFactory, this, mandatory); } }; // Drawback @@ -428,7 +433,8 @@ public class AbilityFactoryDealDamage { * a boolean. * @return a {@link forge.Card} object. */ - private Card dealDamageChooseTgtC(final SpellAbility saMe, final int d, final boolean noPrevention, final Player pl, final boolean mandatory) { + private Card dealDamageChooseTgtC(final SpellAbility saMe, final int d, final boolean noPrevention, + final Player pl, final boolean mandatory) { final Target tgt = this.abilityFactory.getAbTgt(); final Card source = this.abilityFactory.getHostCard(); CardList hPlay = pl.getCardsIn(Zone.Battlefield); @@ -594,8 +600,8 @@ public class AbilityFactoryDealDamage { */ private boolean damageChooseNontargeted(final SpellAbility saMe, final int dmg) { // TODO: Improve circumstances where the Defined Damage is unwanted - final ArrayList objects = AbilityFactory.getDefinedObjects(saMe.getSourceCard(), this.abilityFactory.getMapParams() - .get("Defined"), saMe); + final ArrayList objects = AbilityFactory.getDefinedObjects(saMe.getSourceCard(), this.abilityFactory + .getMapParams().get("Defined"), saMe); for (final Object o : objects) { if (o instanceof Card) { @@ -643,7 +649,8 @@ public class AbilityFactoryDealDamage { while (tgt.getNumTargeted() < tgt.getMinTargets(saMe.getSourceCard(), saMe)) { // TODO: Consider targeting the planeswalker if (tgt.canTgtCreature()) { - final Card c = this.dealDamageChooseTgtC(saMe, dmg, noPrevention, AllZone.getComputerPlayer(), mandatory); + final Card c = this.dealDamageChooseTgtC(saMe, dmg, noPrevention, AllZone.getComputerPlayer(), + mandatory); if (c != null) { tgt.addTarget(c); continue; @@ -757,7 +764,7 @@ public class AbilityFactoryDealDamage { break; } } - // Can't radiate from a player + // Can't radiate from a player if (origin != null) { for (final Card c : CardUtil.getRadiance(this.abilityFactory.getHostCard(), origin, params.get("ValidTgts").split(","))) { @@ -806,8 +813,8 @@ public class AbilityFactoryDealDamage { */ public final SpellAbility getAbilityDamageAll() { - final SpellAbility abDamageAll = new AbilityActivated(this.abilityFactory.getHostCard(), this.abilityFactory.getAbCost(), - this.abilityFactory.getAbTgt()) { + final SpellAbility abDamageAll = new AbilityActivated(this.abilityFactory.getHostCard(), + this.abilityFactory.getAbCost(), this.abilityFactory.getAbTgt()) { private static final long serialVersionUID = -1831356710492849854L; private final AbilityFactory af = AbilityFactoryDealDamage.this.abilityFactory; @@ -828,8 +835,8 @@ public class AbilityFactoryDealDamage { @Override public boolean doTrigger(final boolean mandatory) { - return AbilityFactoryDealDamage.this.damageAllDoTriggerAI(AbilityFactoryDealDamage.this.abilityFactory, this, - mandatory); + return AbilityFactoryDealDamage.this.damageAllDoTriggerAI(AbilityFactoryDealDamage.this.abilityFactory, + this, mandatory); } }; @@ -844,7 +851,8 @@ public class AbilityFactoryDealDamage { * @return a {@link forge.card.spellability.SpellAbility} object. */ public final SpellAbility getSpellDamageAll() { - final SpellAbility spDamageAll = new Spell(this.abilityFactory.getHostCard(), this.abilityFactory.getAbCost(), this.abilityFactory.getAbTgt()) { + final SpellAbility spDamageAll = new Spell(this.abilityFactory.getHostCard(), this.abilityFactory.getAbCost(), + this.abilityFactory.getAbTgt()) { private static final long serialVersionUID = 8004957182752984818L; private final AbilityFactory af = AbilityFactoryDealDamage.this.abilityFactory; private final HashMap params = this.af.getMapParams(); @@ -881,7 +889,8 @@ public class AbilityFactoryDealDamage { * @return a {@link forge.card.spellability.SpellAbility} object. */ public final SpellAbility getDrawbackDamageAll() { - final SpellAbility dbDamageAll = new AbilitySub(this.abilityFactory.getHostCard(), this.abilityFactory.getAbTgt()) { + final SpellAbility dbDamageAll = new AbilitySub(this.abilityFactory.getHostCard(), + this.abilityFactory.getAbTgt()) { private static final long serialVersionUID = -6169562107675964474L; private final AbilityFactory af = AbilityFactoryDealDamage.this.abilityFactory; @@ -903,8 +912,8 @@ public class AbilityFactoryDealDamage { @Override public boolean doTrigger(final boolean mandatory) { - return AbilityFactoryDealDamage.this.damageAllDoTriggerAI(AbilityFactoryDealDamage.this.abilityFactory, this, - mandatory); + return AbilityFactoryDealDamage.this.damageAllDoTriggerAI(AbilityFactoryDealDamage.this.abilityFactory, + this, mandatory); } }; @@ -1207,7 +1216,7 @@ public class AbilityFactoryDealDamage { targetPlayer.addDamage(dmg, card); } } - + // ************************************************************************* // ***************************** EachDamage ******************************** // ************************************************************************* @@ -1220,8 +1229,8 @@ public class AbilityFactoryDealDamage { */ public final SpellAbility getAbilityEachDamage() { - final SpellAbility abEachDamage = new AbilityActivated(this.abilityFactory.getHostCard(), this.abilityFactory.getAbCost(), - this.abilityFactory.getAbTgt()) { + final SpellAbility abEachDamage = new AbilityActivated(this.abilityFactory.getHostCard(), + this.abilityFactory.getAbCost(), this.abilityFactory.getAbTgt()) { private static final long serialVersionUID = -1831356710492849854L; private final AbilityFactory af = AbilityFactoryDealDamage.this.abilityFactory; @@ -1242,8 +1251,8 @@ public class AbilityFactoryDealDamage { @Override public boolean doTrigger(final boolean mandatory) { - return AbilityFactoryDealDamage.this.eachDamageDoTriggerAI(AbilityFactoryDealDamage.this.abilityFactory, this, - mandatory); + return AbilityFactoryDealDamage.this.eachDamageDoTriggerAI( + AbilityFactoryDealDamage.this.abilityFactory, this, mandatory); } }; @@ -1258,7 +1267,8 @@ public class AbilityFactoryDealDamage { * @return a {@link forge.card.spellability.SpellAbility} object. */ public final SpellAbility getSpellEachDamage() { - final SpellAbility spEachDamage = new Spell(this.abilityFactory.getHostCard(), this.abilityFactory.getAbCost(), this.abilityFactory.getAbTgt()) { + final SpellAbility spEachDamage = new Spell(this.abilityFactory.getHostCard(), this.abilityFactory.getAbCost(), + this.abilityFactory.getAbTgt()) { private static final long serialVersionUID = 8004957182752984818L; private final AbilityFactory af = AbilityFactoryDealDamage.this.abilityFactory; private final HashMap params = this.af.getMapParams(); @@ -1295,7 +1305,8 @@ public class AbilityFactoryDealDamage { * @return a {@link forge.card.spellability.SpellAbility} object. */ public final SpellAbility getDrawbackEachDamage() { - final SpellAbility dbEachDamage = new AbilitySub(this.abilityFactory.getHostCard(), this.abilityFactory.getAbTgt()) { + final SpellAbility dbEachDamage = new AbilitySub(this.abilityFactory.getHostCard(), + this.abilityFactory.getAbTgt()) { private static final long serialVersionUID = -6169562107675964474L; private final AbilityFactory af = AbilityFactoryDealDamage.this.abilityFactory; @@ -1317,8 +1328,8 @@ public class AbilityFactoryDealDamage { @Override public boolean doTrigger(final boolean mandatory) { - return AbilityFactoryDealDamage.this.eachDamageDoTriggerAI(AbilityFactoryDealDamage.this.abilityFactory, this, - mandatory); + return AbilityFactoryDealDamage.this.eachDamageDoTriggerAI( + AbilityFactoryDealDamage.this.abilityFactory, this, mandatory); } }; @@ -1339,36 +1350,36 @@ public class AbilityFactoryDealDamage { private String eachDamageStackDescription(final AbilityFactory af, final SpellAbility sa) { final StringBuilder sb = new StringBuilder(); final HashMap params = af.getMapParams(); - + if (sa instanceof AbilitySub) { sb.append(" "); } else { sb.append(sa.getSourceCard()).append(" - "); } - + ArrayList tgtPlayers; - Target tgt = af.getAbTgt(); + final Target tgt = af.getAbTgt(); if (tgt != null) { tgtPlayers = tgt.getTargetPlayers(); } else { tgtPlayers = AbilityFactory.getDefinedPlayers(sa.getSourceCard(), params.get("DefinedPlayers"), sa); } - + String desc = params.get("ValidCards"); if (params.containsKey("ValidDescription")) { desc = params.get("ValidDescription"); } - + String dmg = ""; if (params.containsKey("DamageDesc")) { dmg = params.get("DamageDesc"); } else { - dmg += getNumDamage(sa) + " damage"; + dmg += this.getNumDamage(sa) + " damage"; } sb.append("Each ").append(desc).append(" deals ").append(dmg).append(" to "); - for (Player p : tgtPlayers) { + for (final Player p : tgtPlayers) { sb.append(p); } if (params.containsKey("DefinedCards")) { @@ -1394,8 +1405,8 @@ public class AbilityFactoryDealDamage { tgt.resetTargets(); sa.getTarget().addTarget(AllZone.getHumanPlayer()); } - - return shouldTgtP(sa, getNumDamage(sa), false); + + return this.shouldTgtP(sa, this.getNumDamage(sa), false); } private boolean eachDamageDoTriggerAI(final AbilityFactory af, final SpellAbility sa, final boolean mandatory) { @@ -1407,7 +1418,7 @@ public class AbilityFactoryDealDamage { return sa.getSubAbility().doTrigger(mandatory); } - return eachDamageCanPlayAI(af, sa); + return this.eachDamageCanPlayAI(af, sa); } private void eachDamageResolve(final AbilityFactory af, final SpellAbility sa) { @@ -1418,7 +1429,7 @@ public class AbilityFactoryDealDamage { if (params.containsKey("ValidCards")) { sources = sources.getValidCards(params.get("ValidCards"), card.getController(), card); } - + ArrayList tgts = new ArrayList(); if (sa.getTarget() == null) { tgts = AbilityFactory.getDefinedObjects(sa.getSourceCard(), params.get("DefinedPlayers"), sa); @@ -1429,9 +1440,9 @@ public class AbilityFactoryDealDamage { final boolean targeted = (this.abilityFactory.getAbTgt() != null); for (final Object o : tgts) { - for (Card source : sources) { - int dmg = CardFactoryUtil.xCount(source, card.getSVar("X")); - //System.out.println(source+" deals "+dmg+" damage to "+o.toString()); + for (final Card source : sources) { + final int dmg = CardFactoryUtil.xCount(source, card.getSVar("X")); + // System.out.println(source+" deals "+dmg+" damage to "+o.toString()); if (o instanceof Card) { final Card c = (Card) o; if (AllZoneUtil.isCardInPlay(c) && (!targeted || c.canBeTargetedBy(sa))) { @@ -1448,12 +1459,12 @@ public class AbilityFactoryDealDamage { } if (params.containsKey("DefinedCards") && params.get("DefinedCards").equals("Self")) { - for (Card source : sources) { - int dmg = CardFactoryUtil.xCount(source, card.getSVar("X")); - //System.out.println(source+" deals "+dmg+" damage to "+source); + for (final Card source : sources) { + final int dmg = CardFactoryUtil.xCount(source, card.getSVar("X")); + // System.out.println(source+" deals "+dmg+" damage to "+source); source.addDamage(dmg, source); } } } - -} //end class AbilityFactoryDealDamage + +} // end class AbilityFactoryDealDamage diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryDestroy.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryDestroy.java index 378c1eefb6c..82aa35d3a11 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryDestroy.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryDestroy.java @@ -414,11 +414,11 @@ public class AbilityFactoryDestroy { } else { sb.append(host).append(" - "); } - - if(params.containsKey("Sacrifice")) { + + if (params.containsKey("Sacrifice")) { sb.append("Sacrifice "); } - else { + else { sb.append("Destroy "); } diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryGainControl.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryGainControl.java index 11d45f76670..0244756501e 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryGainControl.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryGainControl.java @@ -403,7 +403,7 @@ public class AbilityFactoryGainControl { if (this.params.containsKey("NewController")) { tgtC.addController(newController.get(0)); - } else if (tgt != null && tgt.getTargetPlayers() != null){ + } else if (tgt != null && tgt.getTargetPlayers() != null) { tgtC.addController(newController.get(0)); } else { tgtC.addController(this.hostCard); diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryPump.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryPump.java index d141bf1abf2..d6fe48e7830 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryPump.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryPump.java @@ -93,7 +93,8 @@ public class AbilityFactoryPump { * @return a {@link forge.card.spellability.SpellAbility} object. */ public final SpellAbility getSpellPump() { - final SpellAbility spPump = new Spell(this.hostCard, this.abilityFactory.getAbCost(), this.abilityFactory.getAbTgt()) { + final SpellAbility spPump = new Spell(this.hostCard, this.abilityFactory.getAbCost(), + this.abilityFactory.getAbTgt()) { private static final long serialVersionUID = 42244224L; @Override @@ -123,7 +124,8 @@ public class AbilityFactoryPump { * @return a {@link forge.card.spellability.SpellAbility} object. */ public final SpellAbility getAbilityPump() { - final SpellAbility abPump = new AbilityActivated(this.hostCard, this.abilityFactory.getAbCost(), this.abilityFactory.getAbTgt()) { + final SpellAbility abPump = new AbilityActivated(this.hostCard, this.abilityFactory.getAbCost(), + this.abilityFactory.getAbTgt()) { private static final long serialVersionUID = -1118592153328758083L; @Override @@ -360,7 +362,7 @@ public class AbilityFactoryPump { if (!this.containsCombatRelevantKeyword(this.keywords) && AllZone.getPhase().isBefore(Constant.Phase.MAIN2)) { list.clear(); // this keyword is not combat relevenat - } else if (this.keywords.get(0).equals("HIDDEN CARDNAME attacks each turn if able.") + } else if (this.keywords.get(0).equals("HIDDEN CARDNAME attacks each turn if able.") && AllZone.getPhase().isPlayerTurn(AllZone.getComputerPlayer())) { list.clear(); } @@ -368,8 +370,9 @@ public class AbilityFactoryPump { list = list.filter(new CardListFilter() { @Override public boolean addCard(final Card c) { - return !c.hasAnyKeyword(keywords); // don't add duplicate - // negative keywords + return !c.hasAnyKeyword(keywords); // don't add + // duplicate + // negative keywords } }); } @@ -530,8 +533,10 @@ public class AbilityFactoryPump { * @return a boolean. */ private boolean pumpTgtAI(final SpellAbility sa, final int defense, final int attack, final boolean mandatory) { - if (!mandatory && AllZone.getPhase().isAfter(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY) - && !(this.abilityFactory.isCurse() && ((defense < 0) || !this.containsCombatRelevantKeyword(this.keywords)))) { + if (!mandatory + && AllZone.getPhase().isAfter(Constant.Phase.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY) + && !(this.abilityFactory.isCurse() && ((defense < 0) || !this + .containsCombatRelevantKeyword(this.keywords)))) { return false; } @@ -970,7 +975,8 @@ public class AbilityFactoryPump { * @return a {@link forge.card.spellability.SpellAbility} object. */ public final SpellAbility getAbilityPumpAll() { - final SpellAbility abPumpAll = new AbilityActivated(this.hostCard, this.abilityFactory.getAbCost(), this.abilityFactory.getAbTgt()) { + final SpellAbility abPumpAll = new AbilityActivated(this.hostCard, this.abilityFactory.getAbCost(), + this.abilityFactory.getAbTgt()) { private static final long serialVersionUID = -8299417521903307630L; @Override @@ -990,7 +996,8 @@ public class AbilityFactoryPump { @Override public boolean doTrigger(final boolean mandatory) { - return AbilityFactoryPump.this.pumpAllTriggerAI(AbilityFactoryPump.this.abilityFactory, this, mandatory); + return AbilityFactoryPump.this + .pumpAllTriggerAI(AbilityFactoryPump.this.abilityFactory, this, mandatory); } }; // SpellAbility @@ -1006,7 +1013,8 @@ public class AbilityFactoryPump { * @return a {@link forge.card.spellability.SpellAbility} object. */ public final SpellAbility getSpellPumpAll() { - final SpellAbility spPumpAll = new Spell(this.hostCard, this.abilityFactory.getAbCost(), this.abilityFactory.getAbTgt()) { + final SpellAbility spPumpAll = new Spell(this.hostCard, this.abilityFactory.getAbCost(), + this.abilityFactory.getAbTgt()) { private static final long serialVersionUID = -4055467978660824703L; @Override @@ -1056,7 +1064,8 @@ public class AbilityFactoryPump { @Override public boolean doTrigger(final boolean mandatory) { - return AbilityFactoryPump.this.pumpAllTriggerAI(AbilityFactoryPump.this.abilityFactory, this, mandatory); + return AbilityFactoryPump.this + .pumpAllTriggerAI(AbilityFactoryPump.this.abilityFactory, this, mandatory); } }; // SpellAbility @@ -1165,29 +1174,26 @@ public class AbilityFactoryPump { // use it tgtPlayers = AbilityFactory.getDefinedPlayers(sa.getSourceCard(), this.params.get("Defined"), sa); } - - if(this.params.containsKey("PumpZone")) { - for(String zone : this.params.get("PumpZone").split(",")) { + + if (this.params.containsKey("PumpZone")) { + for (final String zone : this.params.get("PumpZone").split(",")) { affectedZones.add(Zone.valueOf(zone)); } - } - else { + } else { affectedZones.add(Zone.Battlefield); } list = new CardList(); if ((tgtPlayers == null) || tgtPlayers.isEmpty()) { - for(Zone zone : affectedZones) { + for (final Zone zone : affectedZones) { list.addAll(AllZoneUtil.getCardsIn(zone)); } - + } else { - for(Zone zone : affectedZones) { + for (final Zone zone : affectedZones) { list.addAll(tgtPlayers.get(0).getCardsIn(zone)); } } - - String valid = ""; if (this.params.containsKey("ValidCards")) { @@ -1204,8 +1210,8 @@ public class AbilityFactoryPump { // only pump things in the affected zones. boolean found = false; - for(Zone z : affectedZones) { - if(c.isInZone(z)) { + for (final Zone z : affectedZones) { + if (c.isInZone(z)) { found = true; break; } diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryReveal.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryReveal.java index 783b401d4fb..b9c1e92af7f 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryReveal.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryReveal.java @@ -373,14 +373,14 @@ public final class AbilityFactoryReveal { // - for when it exists } else if (params.containsKey("RevealOptional")) { String question = "Reveal: "; - for (Card c : top) { + for (final Card c : top) { question += c + " "; } if (p.isHuman() && GameActionUtil.showYesNoDialog(host, question)) { GuiUtils.getChoice("Revealing cards from library", top.toArray()); // AllZone.getGameAction().revealToCopmuter(top.toArray()); if (params.containsKey("RememberRevealed")) { - for (Card one : top) { + for (final Card one : top) { host.addRemembered(one); } } @@ -947,8 +947,8 @@ public final class AbilityFactoryReveal { final Card c = itr.next(); AllZone.getGameAction().moveTo(revealedDest, c, revealedLibPos); } - - if(params.containsKey("Shuffle")) { + + if (params.containsKey("Shuffle")) { p.shuffle(); } } // end foreach player diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactorySetState.java b/src/main/java/forge/card/abilityfactory/AbilityFactorySetState.java index 8cfd1201f05..c3ff3d142d4 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactorySetState.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactorySetState.java @@ -193,30 +193,23 @@ public class AbilityFactorySetState { continue; } } - if(abilityFactory.getMapParams().containsKey("Transform")) - { - if(tgt.getCurState().equals("Transformed")) { + if (abilityFactory.getMapParams().containsKey("Transform")) { + if (tgt.getCurState().equals("Transformed")) { tgt.setState("Original"); - } - else if(tgt.hasAlternateState() && tgt.getCurState().equals("Original")) { - if(tgt.isDoubleFaced()) { + } else if (tgt.hasAlternateState() && tgt.getCurState().equals("Original")) { + if (tgt.isDoubleFaced()) { tgt.setState("Transformed"); } } - } - else if(abilityFactory.getMapParams().containsKey("Flip")) - { - if(tgt.getCurState().equals("Flipped")) { + } else if (abilityFactory.getMapParams().containsKey("Flip")) { + if (tgt.getCurState().equals("Flipped")) { tgt.setState("Original"); - } - else if(tgt.hasAlternateState()) { - if(tgt.isFlip() && tgt.getCurState().equals("Original")) { + } else if (tgt.hasAlternateState()) { + if (tgt.isFlip() && tgt.getCurState().equals("Original")) { tgt.setState("Flipped"); } } - } - else - { + } else { tgt.setState(abilityFactory.getMapParams().get("NewState")); } } @@ -364,38 +357,32 @@ public class AbilityFactorySetState { for (int i = 0; i < list.size(); i++) { String mode = list.get(i).getCurState(); - if(list.get(i).isDoubleFaced()) { - if(list.get(i).getCurState().equals("Original")) - { + if (list.get(i).isDoubleFaced()) { + if (list.get(i).getCurState().equals("Original")) { mode = "Transformed"; - } - else { + } else { mode = "Original"; } - - if(list.get(i).setState(mode) && remChanged) { + + if (list.get(i).setState(mode) && remChanged) { card.addRemembered(list.get(i)); } - } - else if(list.get(i).isFlip()) { - if(list.get(i).getCurState().equals("Original")) - { + } else if (list.get(i).isFlip()) { + if (list.get(i).getCurState().equals("Original")) { mode = "Flipped"; - } - else if(list.get(i).getCurState().equals("Flipped")){ + } else if (list.get(i).getCurState().equals("Flipped")) { mode = "Original"; } - - if(list.get(i).setState(mode) && remChanged) { + + if (list.get(i).setState(mode) && remChanged) { + card.addRemembered(list.get(i)); + } + } else { + if (list.get(i).setState(abilityFactory.getMapParams().get("NewState")) && remChanged) { card.addRemembered(list.get(i)); } } - else { - if(list.get(i).setState(abilityFactory.getMapParams().get("NewState")) && remChanged) { - card.addRemembered(list.get(i)); - } - } - + } } diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryZoneAffecting.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryZoneAffecting.java index 57719d7a9a0..ffcc5c7aeb5 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryZoneAffecting.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryZoneAffecting.java @@ -1098,8 +1098,9 @@ public class AbilityFactoryZoneAffecting { for (final Player p : tgtPlayers) { if ((tgt == null) || p.canBeTargetedBy(sa)) { if (mode.equals("Defined")) { - final ArrayList toDiscard = AbilityFactory.getDefinedCards(host, params.get("DefinedCards"), sa); - for (Card c : toDiscard) { + final ArrayList toDiscard = AbilityFactory.getDefinedCards(host, params.get("DefinedCards"), + sa); + for (final Card c : toDiscard) { discarded.addAll(p.discard(c, sa)); } if (params.containsKey("RememberDiscarded")) { @@ -1109,7 +1110,7 @@ public class AbilityFactoryZoneAffecting { } continue; } - + if (mode.equals("Hand")) { final CardList list = p.discardHand(sa); if (params.containsKey("RememberDiscarded")) { @@ -1316,7 +1317,7 @@ public class AbilityFactoryZoneAffecting { } sb.append(" of type: ").append(valid); } - + if (mode.equals("Defined")) { sb.append(" defined cards"); } diff --git a/src/main/java/forge/card/cardfactory/AbstractCardFactory.java b/src/main/java/forge/card/cardfactory/AbstractCardFactory.java index 03bbb9fb75c..73a2335c675 100644 --- a/src/main/java/forge/card/cardfactory/AbstractCardFactory.java +++ b/src/main/java/forge/card/cardfactory/AbstractCardFactory.java @@ -171,8 +171,8 @@ public abstract class AbstractCardFactory implements CardFactoryInterface { CardFactoryUtil.copyCharacteristics(in, out); if (in.hasAlternateState()) { - String curState = in.getCurState(); - for(String state : in.getStates()) { + final String curState = in.getCurState(); + for (final String state : in.getStates()) { in.setState(state); out.setState(state); CardFactoryUtil.copyCharacteristics(in, out); @@ -483,7 +483,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface { card.addColor(card.getManaCost()); } // may have to change the spell - + // this is so permanents like creatures and artifacts have a "default" // spell if (card.isPermanent() && !card.isLand() && !card.isAura()) { @@ -503,7 +503,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface { } if (card.hasAlternateState()) { - for(String state : card.getStates()) { + for (final String state : card.getStates()) { card.setState(state); this.addAbilityFactoryAbilities(card); stAbs = card.getStaticAbilityStrings(); @@ -513,7 +513,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface { } } } - + card.setState("Original"); } @@ -644,8 +644,8 @@ public abstract class AbstractCardFactory implements CardFactoryInterface { sb.append("As Sarpadian Empires, Vol. VII enters the battlefield, "); sb.append("choose white Citizen, blue Camarid, black Thrull, red Goblin, or green Saproling.\r\n"); sb.append("3, Tap: Put a 1/1 creature token of the chosen color and type onto the battlefield.\r\n"); - sb.append(card.getText()); // In the slight chance that there may be - // a need to add a note to this card. + sb.append(card.getText()); // In the slight chance that there may be + // a need to add a note to this card. card.setText(sb.toString()); card.addComesIntoPlayCommand(intoPlay); @@ -1252,57 +1252,44 @@ public abstract class AbstractCardFactory implements CardFactoryInterface { } // *************** END ************ END ************************** // *************** START *********** START ************************** - /*else if (cardName.equals("Pithing Needle")) { - final SpellAbility ability = new AbilityStatic(card, "0") { - @Override - public void resolve() { - String cardName = ""; - if (card.getController().isHuman()) { - final List cards = new ArrayList(); - for (final CardPrinted c : CardDb.instance().getAllUniqueCards()) { - cards.add(c.getName()); - } - Collections.sort(cards); - - // use standard forge's list selection dialog - final ListChooser c = new ListChooser( - "Name a card to disable activation of its non-mana abilities", 1, 1, cards); - c.show(); - // still missing a listener to display the card preview - // in the right - cardName = c.getSelectedValue(); - } else { - // AI CODE WILL EVENTUALLY GO HERE! - } - card.setSVar("PithingTarget", cardName); - card.setChosenType(cardName); - } - }; // ability - ability.setStackDescription("As Pithing Needle enters the battlefield, name a card."); - final Command intoPlay = new Command() { - - private static final long serialVersionUID = 2266471224097876143L; - - @Override - public void execute() { - AllZone.getStack().addSimultaneousStackEntry(ability); - - } - }; - - final Command leavesPlay = new Command() { - - private static final long serialVersionUID = 7079781778752377760L; - - @Override - public void execute() { - card.setSVar("Pithing Target", ""); - } - }; - - card.addComesIntoPlayCommand(intoPlay); - card.addLeavesPlayCommand(leavesPlay); - }*/ // *************** END ************ END ************************** + /* + * else if (cardName.equals("Pithing Needle")) { final SpellAbility + * ability = new AbilityStatic(card, "0") { + * + * @Override public void resolve() { String cardName = ""; if + * (card.getController().isHuman()) { final List cards = new + * ArrayList(); for (final CardPrinted c : + * CardDb.instance().getAllUniqueCards()) { cards.add(c.getName()); } + * Collections.sort(cards); + * + * // use standard forge's list selection dialog final + * ListChooser c = new ListChooser( + * "Name a card to disable activation of its non-mana abilities", 1, 1, + * cards); c.show(); // still missing a listener to display the card + * preview // in the right cardName = c.getSelectedValue(); } else { // + * AI CODE WILL EVENTUALLY GO HERE! } card.setSVar("PithingTarget", + * cardName); card.setChosenType(cardName); } }; // ability + * ability.setStackDescription + * ("As Pithing Needle enters the battlefield, name a card."); final + * Command intoPlay = new Command() { + * + * private static final long serialVersionUID = 2266471224097876143L; + * + * @Override public void execute() { + * AllZone.getStack().addSimultaneousStackEntry(ability); + * + * } }; + * + * final Command leavesPlay = new Command() { + * + * private static final long serialVersionUID = 7079781778752377760L; + * + * @Override public void execute() { card.setSVar("Pithing Target", ""); + * } }; + * + * card.addComesIntoPlayCommand(intoPlay); + * card.addLeavesPlayCommand(leavesPlay); } + */// *************** END ************ END ************************** // *************** START *********** START ************************** else if (cardName.equals("Phyrexian Processor")) { diff --git a/src/main/java/forge/card/cardfactory/CardFactoryCreatures.java b/src/main/java/forge/card/cardfactory/CardFactoryCreatures.java index 46491384277..cd0b7bab957 100644 --- a/src/main/java/forge/card/cardfactory/CardFactoryCreatures.java +++ b/src/main/java/forge/card/cardfactory/CardFactoryCreatures.java @@ -536,8 +536,8 @@ public class CardFactoryCreatures { @Override public boolean canPlayAI() { - return (!AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield).getType("Artifact").isEmpty() - && AllZone.getZoneOf(this.getSourceCard()).is(Constant.Zone.Hand)); + return (!AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield).getType("Artifact").isEmpty() && AllZone + .getZoneOf(this.getSourceCard()).is(Constant.Zone.Hand)); } }); card.addComesIntoPlayCommand(intoPlay); @@ -740,19 +740,19 @@ public class CardFactoryCreatures { sb.append("Adarkar Valkyrie - Return ").append(target[0]); sb.append(" from graveyard to the battlefield"); AllZone.getStack().addSimultaneousStackEntry(new Ability(card, "0", sb.toString()) { - @Override - public void resolve() { - final PlayerZone grave = AllZone.getZoneOf(target[0]); - // checks to see if card is still in the - // graveyard + @Override + public void resolve() { + final PlayerZone grave = AllZone.getZoneOf(target[0]); + // checks to see if card is still in the + // graveyard - if ((grave != null) && grave.contains(target[0])) { - final PlayerZone play = card.getController().getZone(Constant.Zone.Battlefield); - target[0].addController(card.getController()); - AllZone.getGameAction().moveTo(play, target[0]); - } - } - }); + if ((grave != null) && grave.contains(target[0])) { + final PlayerZone play = card.getController().getZone(Constant.Zone.Battlefield); + target[0].addController(card.getController()); + AllZone.getGameAction().moveTo(play, target[0]); + } + } + }); } // execute() }; @@ -2244,77 +2244,80 @@ public class CardFactoryCreatures { if (copyTarget[0] != null) { Card cloned; - + cloned = cfact.getCard(copyTarget[0].getState("Original").getName(), card.getOwner()); - card.addAlternateState("Cloner"); + card.addAlternateState("Cloner"); card.switchStates("Original", "Cloner"); card.setState("Original"); - - if(copyTarget[0].getCurState().equals("Transformed") && copyTarget[0].isDoubleFaced()) { + + if (copyTarget[0].getCurState().equals("Transformed") && copyTarget[0].isDoubleFaced()) { cloned.setState("Transformed"); } - - CardFactoryUtil.copyCharacteristics(cloned,card); - this.grantExtras(); - - //If target is a flipped card, also copy the flipped state. - if(copyTarget[0].isFlip()) { + CardFactoryUtil.copyCharacteristics(cloned, card); + this.grantExtras(); + + // If target is a flipped card, also copy the flipped + // state. + if (copyTarget[0].isFlip()) { cloned.setState("Flipped"); cloned.setImageFilename(CardUtil.buildFilename(cloned)); card.addAlternateState("Flipped"); card.setState("Flipped"); - CardFactoryUtil.copyCharacteristics(cloned,card); + CardFactoryUtil.copyCharacteristics(cloned, card); this.grantExtras(); - + card.setFlip(true); - + card.setState("Original"); - } - else { + } else { card.setFlip(false); } - - + } - + AllZone.getGameAction().moveToPlay(card); } - + private void grantExtras() { - //Grant stuff from specific cloners - if(cardName.equals("Vesuvan Doppelganger")) { + // Grant stuff from specific cloners + if (cardName.equals("Vesuvan Doppelganger")) { final String keyword = "At the beginning of your upkeep, you may have this " + "creature become a copy of target creature except it doesn't copy that " - + "creature's color. If you do, this creature gains this ability."; + + "creature's color. If you do, this creature gains this ability."; card.addIntrinsicKeyword(keyword); card.addColor("U"); - } - else if(cardName.equals("Quicksilver Gargantuan")) { + } else if (cardName.equals("Quicksilver Gargantuan")) { card.setBaseAttack(7); card.setBaseDefense(7); - } - else if(cardName.equals("Phyrexian Metamorph")) { + } else if (cardName.equals("Phyrexian Metamorph")) { card.addType("Artifact"); - } - else if(cardName.equals("Phantasmal Image")) { - Trigger t = forge.card.trigger.TriggerHandler.parseTrigger("Mode$ BecomesTarget | ValidTarget$ Card.Self | Execute$ TrigSac | TriggerDescription$ When this creature becomes the target of a spell or ability, sacrifice it.", card, true); + } else if (cardName.equals("Phantasmal Image")) { + final Trigger t = forge.card.trigger.TriggerHandler + .parseTrigger( + "Mode$ BecomesTarget | ValidTarget$ Card.Self | Execute$ TrigSac | TriggerDescription$ When this creature becomes the target of a spell or ability, sacrifice it.", + card, true); card.addTrigger(t); card.setSVar("TrigSac", "AB$Sacrifice | Cost$ 0 | Defined$ Self"); - } - else if(cardName.equals("Evil Twin")) { - AbilityFactory af = new AbilityFactory(); - - SpellAbility ab = af.getAbility("AB$Destroy | Cost$ U B T | ValidTgts$ Creature.sameName | TgtPrompt$ Select target creature with the same name. | SpellDescription$ Destroy target creature with the same name as this creature.", card); - + } else if (cardName.equals("Evil Twin")) { + final AbilityFactory af = new AbilityFactory(); + + final SpellAbility ab = af + .getAbility( + "AB$Destroy | Cost$ U B T | ValidTgts$ Creature.sameName | TgtPrompt$ Select target creature with the same name. | SpellDescription$ Destroy target creature with the same name as this creature.", + card); + card.addSpellAbility(ab); - } - else if(cardName.equals("Sakashima the Impostor")) { - AbilityFactory af = new AbilityFactory(); - SpellAbility ab = af.getAbility("AB$DelayedTrigger | Cost$ 2 U U | Mode$ Phase | Phase$ End of Turn | Execute$ TrigReturnSak | TriggerDescription$ Return CARDNAME to it's owners hand at the beginning of the next end step.",card); - + } else if (cardName.equals("Sakashima the Impostor")) { + final AbilityFactory af = new AbilityFactory(); + final SpellAbility ab = af + .getAbility( + "AB$DelayedTrigger | Cost$ 2 U U | Mode$ Phase | Phase$ End of Turn | Execute$ TrigReturnSak | TriggerDescription$ Return CARDNAME to it's owners hand at the beginning of the next end step.", + card); + card.addSpellAbility(ab); - card.setSVar("TrigReturnSak","AB$ChangeZone | Cost$ 0 | Defined$ Self | Origin$ Battlefield | Destination$ Hand"); + card.setSVar("TrigReturnSak", + "AB$ChangeZone | Cost$ 0 | Defined$ Self | Origin$ Battlefield | Destination$ Hand"); card.setName("Sakashima the Impostor"); card.addType("Legendary"); } @@ -2609,8 +2612,8 @@ public class CardFactoryCreatures { theCost = "R"; } - final SpellAbility finalAb = new AbilityActivated(card, new Cost(theCost, cardName, true), new Target( - card, "Select target creature.", "Creature")) { + final SpellAbility finalAb = new AbilityActivated(card, new Cost(theCost, cardName, true), new Target(card, + "Select target creature.", "Creature")) { private static final long serialVersionUID = 2391351140880148283L; @Override @@ -2694,35 +2697,36 @@ public class CardFactoryCreatures { ability.setStackDescription(sbStack.toString()); } // *************** END ************ END ************************** - - // *************** START *********** START ************************** else if (cardName.equals("Ixidron")) { - Trigger tfdTrigger = forge.card.trigger.TriggerHandler.parseTrigger("Mode$ ChangesZone | Destination$ Battlefield | ValidCard$ Card.Self | Static$ True | TriggerDescription$ As CARDNAME enters the battlefield, turn all other nontoken creatures face down. (They're 2/2 creatures.)", card, true); - + final Trigger tfdTrigger = forge.card.trigger.TriggerHandler + .parseTrigger( + "Mode$ ChangesZone | Destination$ Battlefield | ValidCard$ Card.Self | Static$ True | TriggerDescription$ As CARDNAME enters the battlefield, turn all other nontoken creatures face down. (They're 2/2 creatures.)", + card, true); + final SpellAbility triggeredAbility = new Ability(card, "0") { @Override public void resolve() { CardList creatsInPlay = AllZoneUtil.getCreaturesInPlay(); - + creatsInPlay = creatsInPlay.filter(new CardListFilter() { @Override - public boolean addCard(Card c) { + public boolean addCard(final Card c) { return !c.isToken() && !c.equals(card); } }); - - for(Card c : creatsInPlay) { + + for (final Card c : creatsInPlay) { c.turnFaceDown(); } } }; - + tfdTrigger.setOverridingAbility(triggeredAbility); - + card.addTrigger(tfdTrigger); } // *************** END ************ END ************************** - + // *************************************************** // end of card specific code // *************************************************** diff --git a/src/main/java/forge/card/cardfactory/CardFactoryUtil.java b/src/main/java/forge/card/cardfactory/CardFactoryUtil.java index 64b2dcc230f..1fd9f357b83 100644 --- a/src/main/java/forge/card/cardfactory/CardFactoryUtil.java +++ b/src/main/java/forge/card/cardfactory/CardFactoryUtil.java @@ -15,7 +15,6 @@ import forge.AllZone; import forge.AllZoneUtil; import forge.ButtonUtil; import forge.Card; -import forge.CardColor; import forge.CardList; import forge.CardListFilter; import forge.CardUtil; @@ -919,7 +918,7 @@ public class CardFactoryUtil { @Override public void resolve() { sourceCard.turnFaceDown(); - + sourceCard.comesIntoPlay(); AllZone.getGameAction().moveToPlay(sourceCard); @@ -958,18 +957,13 @@ public class CardFactoryUtil { */ public static AbilityActivated abilityMorphUp(final Card sourceCard, final Cost cost, final String orgManaCost, final int a, final int d) { - // final String player = sourceCard.getController(); - // final String manaCost = cost; - final int attack = a; - final int defense = d; - final String origManaCost = orgManaCost; final AbilityActivated morphUp = new AbilityActivated(sourceCard, cost, null) { private static final long serialVersionUID = -3663857013937085953L; @Override public void resolve() { sourceCard.turnFaceUp(); - + // Run triggers final Map runParams = new TreeMap(); runParams.put("Card", sourceCard); @@ -978,9 +972,6 @@ public class CardFactoryUtil { @Override public boolean canPlay() { - // unMorphing a card is a Special Action, and not affected by - // Linvala - Card c = sourceCard; return sourceCard.getController().equals(this.getActivatingPlayer()) && sourceCard.isFaceDown() && AllZoneUtil.isCardInPlay(sourceCard); } @@ -2305,16 +2296,14 @@ public class CardFactoryUtil { *

* canBeTargetedBy. *

- * - * @param ability - * a {@link forge.card.spellability.SpellAbility} object. - * @param target - * a {@link forge.Card} object. + * + * @param c the c * @return a boolean. */ - /*public static boolean canBeTargetedBy(final SpellAbility ability, final Card target) { - return target.canBeTargetedBy(ability); - }*/ + /* + * public static boolean canBeTargetedBy(final SpellAbility ability, final + * Card target) { return target.canBeTargetedBy(ability); } + */ /** *

@@ -2333,91 +2322,57 @@ public class CardFactoryUtil { *

* canBeTargetedBy. *

- * - * @param spell - * a {@link forge.Card} object. - * @param target - * a {@link forge.Card} object. + * + * @param card the card + * @param target a {@link forge.Card} object. * @return a boolean. */ - /*public static boolean canBeTargetedBy(final Card spell, final Card target) { - if (target == null) { - return true; - } - - if (target.isImmutable()) { - return false; - } - - final PlayerZone zone = AllZone.getZoneOf(target); - // if zone is null, it means its on the stack - if ((zone == null) || !zone.is(Constant.Zone.Battlefield)) { - // targets not in play, can normally be targeted - return true; - } - - if (AllZoneUtil.isCardInPlay("Spellbane Centaur", target.getController()) && target.isCreature() - && spell.isBlue()) { - return false; - } - - if (target.getName().equals("Gaea's Revenge") && !spell.isGreen()) { - return false; - } - - if (CardFactoryUtil.hasProtectionFrom(spell, target)) { - return false; - } - - if (target.getKeyword() != null) { - final ArrayList list = target.getKeyword(); - - String kw = ""; - for (int i = 0; i < list.size(); i++) { - kw = list.get(i); - if (kw.equals("Shroud")) { - return false; - } - - if (kw.equals("Hexproof")) { - if (!spell.getController().equals(target.getController())) { - return false; - } - } - - if (kw.equals("CARDNAME can't be the target of Aura spells.") || kw.equals("CARDNAME can't be enchanted.")) { - if (spell.isAura() && spell.isSpell()) { - return false; - } - } - - if (kw.equals("CARDNAME can't be the target of red spells or abilities from red sources.")) { - if (spell.isRed()) { - return false; - } - } - - if (kw.equals("CARDNAME can't be the target of black spells.")) { - if (spell.isBlack() && spell.isSpell()) { - return false; - } - } - - if (kw.equals("CARDNAME can't be the target of blue spells.")) { - if (spell.isBlue() && spell.isSpell()) { - return false; - } - } - - if (kw.equals("CARDNAME can't be the target of spells.")) { - if (spell.isSpell()) { - return false; - } - } - } - } - return true; - }*/ + /* + * public static boolean canBeTargetedBy(final Card spell, final Card + * target) { if (target == null) { return true; } + * + * if (target.isImmutable()) { return false; } + * + * final PlayerZone zone = AllZone.getZoneOf(target); // if zone is null, it + * means its on the stack if ((zone == null) || + * !zone.is(Constant.Zone.Battlefield)) { // targets not in play, can + * normally be targeted return true; } + * + * if (AllZoneUtil.isCardInPlay("Spellbane Centaur", target.getController()) + * && target.isCreature() && spell.isBlue()) { return false; } + * + * if (target.getName().equals("Gaea's Revenge") && !spell.isGreen()) { + * return false; } + * + * if (CardFactoryUtil.hasProtectionFrom(spell, target)) { return false; } + * + * if (target.getKeyword() != null) { final ArrayList list = + * target.getKeyword(); + * + * String kw = ""; for (int i = 0; i < list.size(); i++) { kw = list.get(i); + * if (kw.equals("Shroud")) { return false; } + * + * if (kw.equals("Hexproof")) { if + * (!spell.getController().equals(target.getController())) { return false; } + * } + * + * if (kw.equals("CARDNAME can't be the target of Aura spells.") || + * kw.equals("CARDNAME can't be enchanted.")) { if (spell.isAura() && + * spell.isSpell()) { return false; } } + * + * if (kw.equals( + * "CARDNAME can't be the target of red spells or abilities from red sources." + * )) { if (spell.isRed()) { return false; } } + * + * if (kw.equals("CARDNAME can't be the target of black spells.")) { if + * (spell.isBlack() && spell.isSpell()) { return false; } } + * + * if (kw.equals("CARDNAME can't be the target of blue spells.")) { if + * (spell.isBlue() && spell.isSpell()) { return false; } } + * + * if (kw.equals("CARDNAME can't be the target of spells.")) { if + * (spell.isSpell()) { return false; } } } } return true; } + */ // does "target" have protection from "card"? /** @@ -2544,9 +2499,10 @@ public class CardFactoryUtil { return true; } - if (sa.isSpell() && !zone.is(Zone.Battlefield) && (c.hasStartOfKeyword("May be played") - || (c.hasStartOfKeyword("Flashback") && zone.is(Zone.Graveyard))) - && restrictZone.equals(Zone.Hand)) { + if (sa.isSpell() + && !zone.is(Zone.Battlefield) + && (c.hasStartOfKeyword("May be played") || (c.hasStartOfKeyword("Flashback") && zone + .is(Zone.Graveyard))) && restrictZone.equals(Zone.Hand)) { return true; } } @@ -2640,7 +2596,7 @@ public class CardFactoryUtil { } if (sq[0].contains("DomainPlayer")) { - CardList someCards = new CardList(); + final CardList someCards = new CardList(); someCards.addAll(players.get(0).getCardsIn(Zone.Battlefield)); final String[] basic = { "Forest", "Plains", "Mountain", "Island", "Swamp" }; @@ -2698,7 +2654,6 @@ public class CardFactoryUtil { return CardFactoryUtil.doXMath(n, m, source); } - /** * parseSVar TODO - flesh out javadoc for this method. * @@ -4218,14 +4173,14 @@ public class CardFactoryUtil { CardFactoryUtil.copyCharacteristics(sim, c); if (sim.hasAlternateState()) { - String origState = sim.getCurState(); - for(String state : sim.getStates()) { + final String origState = sim.getCurState(); + for (final String state : sim.getStates()) { c.addAlternateState(state); c.setState(state); sim.setState(state); CardFactoryUtil.copyCharacteristics(sim, c); } - + sim.setState(origState); c.setState(origState); } @@ -4265,7 +4220,7 @@ public class CardFactoryUtil { to.setImageFilename(from.getImageFilename()); to.setTriggers(from.getTriggers()); to.setStaticAbilityStrings(from.getStaticAbilityStrings()); - + } /** @@ -4720,8 +4675,8 @@ public class CardFactoryUtil { sbHaunter.append("Destination$ Graveyard | ValidCard$ Card.Self | "); sbHaunter.append("Static$ True | Secondary$ True | TriggerDescription$ Blank"); - final Trigger haunterDies = forge.card.trigger.TriggerHandler.parseTrigger( - sbHaunter.toString(), card, true); + final Trigger haunterDies = forge.card.trigger.TriggerHandler + .parseTrigger(sbHaunter.toString(), card, true); final Ability haunterDiesWork = new Ability(card, "0") { @Override @@ -4796,8 +4751,7 @@ public class CardFactoryUtil { sbDies.append("ValidCard$ Creature.HauntedBy | Execute$ ").append(hauntSVarName); sbDies.append(" | TriggerDescription$ ").append(hauntDescription); - final Trigger hauntedDies = forge.card.trigger.TriggerHandler.parseTrigger( - sbDies.toString(), card, true); + final Trigger hauntedDies = forge.card.trigger.TriggerHandler.parseTrigger(sbDies.toString(), card, true); // Third, create the trigger that runs when the haunting creature // enters the battlefield @@ -4806,8 +4760,7 @@ public class CardFactoryUtil { sbETB.append(hauntSVarName).append(" | Secondary$ True | TriggerDescription$ "); sbETB.append(hauntDescription); - final Trigger haunterETB = forge.card.trigger.TriggerHandler.parseTrigger( - sbETB.toString(), card, true); + final Trigger haunterETB = forge.card.trigger.TriggerHandler.parseTrigger(sbETB.toString(), card, true); // Fourth, create a trigger that removes the haunting status if the // haunter leaves the exile @@ -4816,8 +4769,8 @@ public class CardFactoryUtil { sbUnExiled.append("ValidCard$ Card.Self | Static$ True | Secondary$ True | "); sbUnExiled.append("TriggerDescription$ Blank"); - final Trigger haunterUnExiled = forge.card.trigger.TriggerHandler.parseTrigger( - sbUnExiled.toString(), card, true); + final Trigger haunterUnExiled = forge.card.trigger.TriggerHandler.parseTrigger(sbUnExiled.toString(), card, + true); final Ability haunterUnExiledWork = new Ability(card, "0") { @Override @@ -5112,11 +5065,11 @@ public class CardFactoryUtil { final String orgManaCost = card.getManaCost(); card.addSpellAbility(CardFactoryUtil.abilityMorphDown(card)); - + card.turnFaceDown(); - + card.addSpellAbility(CardFactoryUtil.abilityMorphUp(card, cost, orgManaCost, attack, defense)); - + card.turnFaceUp(); } } // Morph diff --git a/src/main/java/forge/card/cost/CostMana.java b/src/main/java/forge/card/cost/CostMana.java index 6e34f650130..bc8a24f254b 100644 --- a/src/main/java/forge/card/cost/CostMana.java +++ b/src/main/java/forge/card/cost/CostMana.java @@ -271,8 +271,8 @@ public class CostMana extends CostPart { this.manaCost = InputPayManaCostUtil.activateManaAbility(sa, card, this.manaCost); if (this.manaCost.isPaid()) { - if (!colorsPaid.contains(this.manaCost.getColorsPaid())) { - colorsPaid += this.manaCost.getColorsPaid(); + if (!this.colorsPaid.contains(this.manaCost.getColorsPaid())) { + this.colorsPaid += this.manaCost.getColorsPaid(); } this.manaCost = new ManaCost(Integer.toString(numX)); this.xPaid++; @@ -295,8 +295,8 @@ public class CostMana extends CostPart { this.stop(); payment.getCard().setXManaCostPaid(this.xPaid); payment.paidCost(costMana); - payment.getCard().setColorsPaid(colorsPaid); - payment.getCard().setSunburstValue(colorsPaid.length()); + payment.getCard().setColorsPaid(this.colorsPaid); + payment.getCard().setSunburstValue(this.colorsPaid.length()); } }; @@ -393,16 +393,19 @@ public class CostMana extends CostPart { source.setXManaCostPaid(0); CostUtil.setInput(CostMana.inputPayXMana(sa, payment, costMana, costMana.getXMana())); } - - //If this is a spell with convoke, re-tap all creatures used for it. - //This is done to make sure Taps triggers go off at the right time - //(i.e. AFTER cost payment, they are tapped previously as well so that - //any mana tapabilities can't be used in payment as well as being tapped for convoke) - - if(sa.getTappedForConvoke() != null) - { + + // If this is a spell with convoke, re-tap all creatures used + // for it. + // This is done to make sure Taps triggers go off at the right + // time + // (i.e. AFTER cost payment, they are tapped previously as well + // so that + // any mana tapabilities can't be used in payment as well as + // being tapped for convoke) + + if (sa.getTappedForConvoke() != null) { AllZone.getTriggerHandler().suppressMode("Untaps"); - for(Card c : sa.getTappedForConvoke()) { + for (final Card c : sa.getTappedForConvoke()) { c.untap(); c.tap(); } @@ -414,17 +417,17 @@ public class CostMana extends CostPart { @Override public void selectButtonCancel() { - //If we're paying for a spell with convoke, untap all creatures used for it. - if(sa.getTappedForConvoke() != null) - { + // If we're paying for a spell with convoke, untap all creatures + // used for it. + if (sa.getTappedForConvoke() != null) { AllZone.getTriggerHandler().suppressMode("Untaps"); - for(Card c : sa.getTappedForConvoke()) { + for (final Card c : sa.getTappedForConvoke()) { c.untap(); } AllZone.getTriggerHandler().clearSuppression("Untaps"); sa.clearTappedForConvoke(); } - + this.stop(); this.resetManaCost(); payment.cancelCost(); diff --git a/src/main/java/forge/card/spellability/AbilityActivated.java b/src/main/java/forge/card/spellability/AbilityActivated.java index 4ac12010e0e..cc17f2e8956 100644 --- a/src/main/java/forge/card/spellability/AbilityActivated.java +++ b/src/main/java/forge/card/spellability/AbilityActivated.java @@ -7,7 +7,6 @@ import forge.AllZoneUtil; import forge.Card; import forge.CardList; import forge.Constant.Zone; -import forge.Player; import forge.card.cost.Cost; import forge.card.cost.CostPayment; import forge.card.staticability.StaticAbility; diff --git a/src/main/java/forge/card/spellability/SpellAbility.java b/src/main/java/forge/card/spellability/SpellAbility.java index 16abf285e2c..153c3e98edb 100644 --- a/src/main/java/forge/card/spellability/SpellAbility.java +++ b/src/main/java/forge/card/spellability/SpellAbility.java @@ -108,7 +108,7 @@ public abstract class SpellAbility { public void execute(final Object o) { } }; - + private CardList tappedForConvoke = null; /** @@ -700,8 +700,7 @@ public abstract class SpellAbility { * Getter for the field restrictions. *

* - * @return a {@link forge.card.spellability.SpellAbilityRestriction} - * object. + * @return a {@link forge.card.spellability.SpellAbilityRestriction} object. */ public SpellAbilityRestriction getRestrictions() { return this.restrictions; @@ -1051,6 +1050,7 @@ public abstract class SpellAbility { *

* * Extrinsic or Intrinsic: + * * @param s * a {@link java.lang.String} object. */ @@ -1066,7 +1066,7 @@ public abstract class SpellAbility { * @return a {@link java.lang.String} object. */ public String getType() { - // Extrinsic or Intrinsic: + // Extrinsic or Intrinsic: return this.type; } @@ -1682,53 +1682,69 @@ public abstract class SpellAbility { } /** + * Gets the ability. + * * @return the ability */ public static int getAbility() { - return ABILITY; + return SpellAbility.ABILITY; } /** + * Gets the spell. + * * @return the spell */ public static int getSpell() { - return SPELL; + return SpellAbility.SPELL; } /** + * Gets the chosen target. + * * @return the chosenTarget */ public Target getChosenTarget() { - return chosenTarget; + return this.chosenTarget; } /** + * Sets the chosen target. + * * @param chosenTarget the chosenTarget to set */ - public void setChosenTarget(Target chosenTarget) { + public void setChosenTarget(final Target chosenTarget) { this.chosenTarget = chosenTarget; // TODO: Add 0 to parameter's name. } - - public void addTappedForConvoke(Card c) - { - if(tappedForConvoke == null) - { - tappedForConvoke = new CardList(); + + /** + * Adds the tapped for convoke. + * + * @param c the c + */ + public void addTappedForConvoke(final Card c) { + if (this.tappedForConvoke == null) { + this.tappedForConvoke = new CardList(); } - - tappedForConvoke.add(c); + + this.tappedForConvoke.add(c); } - - public CardList getTappedForConvoke() - { - return tappedForConvoke; + + /** + * Gets the tapped for convoke. + * + * @return the tapped for convoke + */ + public CardList getTappedForConvoke() { + return this.tappedForConvoke; } - - public void clearTappedForConvoke() - { - if(tappedForConvoke != null) - { - tappedForConvoke.clear(); + + /** + * Clear tapped for convoke. + */ + public void clearTappedForConvoke() { + if (this.tappedForConvoke != null) { + this.tappedForConvoke.clear(); } } diff --git a/src/main/java/forge/card/spellability/SpellAbilityRestriction.java b/src/main/java/forge/card/spellability/SpellAbilityRestriction.java index 149010b752a..90210a2f4ff 100644 --- a/src/main/java/forge/card/spellability/SpellAbilityRestriction.java +++ b/src/main/java/forge/card/spellability/SpellAbilityRestriction.java @@ -182,7 +182,7 @@ public class SpellAbilityRestriction extends SpellAbilityVariables { // Not a Spell, or on Battlefield, return false if (!sa.isSpell() || cardZone.is(Zone.Battlefield) || !this.getZone().equals(Zone.Hand)) { return false; - } else if (!c.hasStartOfKeyword("May be played") + } else if (!c.hasStartOfKeyword("May be played") && !(c.hasStartOfKeyword("Flashback") && cardZone.is(Zone.Graveyard))) { return false; } diff --git a/src/main/java/forge/card/spellability/Target.java b/src/main/java/forge/card/spellability/Target.java index 95d21b52aed..38464b4bef3 100644 --- a/src/main/java/forge/card/spellability/Target.java +++ b/src/main/java/forge/card/spellability/Target.java @@ -613,10 +613,9 @@ public class Target { *

* hasCandidates. *

- * - * @param isTargeted - * Check Valid Candidates and Targeting - * + * + * @param sa the sa + * @param isTargeted Check Valid Candidates and Targeting * @return a boolean. */ public final boolean hasCandidates(final SpellAbility sa, final boolean isTargeted) { diff --git a/src/main/java/forge/card/staticability/StaticAbility.java b/src/main/java/forge/card/staticability/StaticAbility.java index f5748a8ba2a..3c230e2dccd 100644 --- a/src/main/java/forge/card/staticability/StaticAbility.java +++ b/src/main/java/forge/card/staticability/StaticAbility.java @@ -25,7 +25,7 @@ public class StaticAbility { private boolean temporarilySuppressed = false; /** The suppressed. */ - private boolean suppressed = false; + private final boolean suppressed = false; /** *

@@ -285,7 +285,7 @@ public class StaticAbility { return false; } - + /** * Apply ability. * @@ -293,13 +293,11 @@ public class StaticAbility { * the mode * @param card * the card - * @param activator - * the activator - * @param sa + * @param spellAbility * the ability * @return true, if successful */ - public final boolean applyAbility(final String mode, final Card card, SpellAbility sa) { + public final boolean applyAbility(final String mode, final Card card, final SpellAbility spellAbility) { // don't apply the ability if it hasn't got the right mode if (!this.mapParams.get("Mode").equals(mode)) { @@ -311,11 +309,11 @@ public class StaticAbility { } if (mode.equals("CantBeActivated")) { - return StaticAbilityCantBeCast.applyCantBeActivatedAbility(this, card, sa); + return StaticAbilityCantBeCast.applyCantBeActivatedAbility(this, card, spellAbility); } - + if (mode.equals("CantTarget")) { - return StaticAbilityCantTarget.applyCantTargetAbility(this, card, sa); + return StaticAbilityCantTarget.applyCantTargetAbility(this, card, spellAbility); } return false; @@ -331,36 +329,36 @@ public class StaticAbility { Zone effectZone = Zone.Battlefield; // default - if (mapParams.containsKey("EffectZone")) { + if (this.mapParams.containsKey("EffectZone")) { effectZone = Zone.smartValueOf(this.mapParams.get("EffectZone")); } - if ((effectZone != null) && (!hostCard.isInZone(effectZone) || hostCard.isPhasedOut())) { + if ((effectZone != null) && (!this.hostCard.isInZone(effectZone) || this.hostCard.isPhasedOut())) { return false; } - if (mapParams.containsKey("Threshold") && !controller.hasThreshold()) { + if (this.mapParams.containsKey("Threshold") && !controller.hasThreshold()) { return false; } - if (mapParams.containsKey("Hellbent") && !controller.hasHellbent()) { + if (this.mapParams.containsKey("Hellbent") && !controller.hasHellbent()) { return false; } - if (mapParams.containsKey("Metalcraft") && !controller.hasMetalcraft()) { + if (this.mapParams.containsKey("Metalcraft") && !controller.hasMetalcraft()) { return false; } - if (mapParams.containsKey("PlayerTurn") && !AllZone.getPhase().isPlayerTurn(controller)) { + if (this.mapParams.containsKey("PlayerTurn") && !AllZone.getPhase().isPlayerTurn(controller)) { return false; } - if (mapParams.containsKey("OpponentTurn") && !AllZone.getPhase().isPlayerTurn(controller.getOpponent())) { + if (this.mapParams.containsKey("OpponentTurn") && !AllZone.getPhase().isPlayerTurn(controller.getOpponent())) { return false; } - - if (mapParams.containsKey("Phases")) { - String phases = mapParams.get("Phases"); + + if (this.mapParams.containsKey("Phases")) { + String phases = this.mapParams.get("Phases"); if (phases.contains("->")) { // If phases lists a Range, split and Build Activate String diff --git a/src/main/java/forge/card/staticability/StaticAbilityCantBeCast.java b/src/main/java/forge/card/staticability/StaticAbilityCantBeCast.java index 4b4c85fd0c9..d5e6f51435f 100644 --- a/src/main/java/forge/card/staticability/StaticAbilityCantBeCast.java +++ b/src/main/java/forge/card/staticability/StaticAbilityCantBeCast.java @@ -46,20 +46,20 @@ public class StaticAbilityCantBeCast { } /** - * TODO Write javadoc for this method. + * Applies Cant Be Activated ability. * - * @param stAb + * @param staticAbility * a StaticAbility * @param card * the card - * @param activator - * the activator + * @param spellAbility + * a SpellAbility * @return true, if successful */ - public static boolean applyCantBeActivatedAbility(final StaticAbility stAb, final Card card, SpellAbility sa) { - final HashMap params = stAb.getMapParams(); - final Card hostCard = stAb.getHostCard(); - final Player activator = sa.getActivatingPlayer(); + public static boolean applyCantBeActivatedAbility(final StaticAbility staticAbility, final Card card, final SpellAbility spellAbility) { + final HashMap params = staticAbility.getMapParams(); + final Card hostCard = staticAbility.getHostCard(); + final Player activator = spellAbility.getActivatingPlayer(); if (params.containsKey("ValidCard") && !card.isValid(params.get("ValidCard").split(","), hostCard.getController(), hostCard)) { @@ -70,8 +70,8 @@ public class StaticAbilityCantBeCast { && !activator.isValid(params.get("Activator"), hostCard.getController(), hostCard)) { return false; } - - if (params.containsKey("NonMana") && sa instanceof AbilityMana) { + + if (params.containsKey("NonMana") && (spellAbility instanceof AbilityMana)) { return false; } diff --git a/src/main/java/forge/card/staticability/StaticAbilityCantTarget.java b/src/main/java/forge/card/staticability/StaticAbilityCantTarget.java index b7049f818a1..e365585f916 100644 --- a/src/main/java/forge/card/staticability/StaticAbilityCantTarget.java +++ b/src/main/java/forge/card/staticability/StaticAbilityCantTarget.java @@ -4,8 +4,8 @@ import java.util.HashMap; import forge.Card; import forge.Constant; -import forge.Player; import forge.Constant.Zone; +import forge.Player; import forge.card.spellability.SpellAbility; /** @@ -13,14 +13,22 @@ import forge.card.spellability.SpellAbility; */ public class StaticAbilityCantTarget { - public static boolean applyCantTargetAbility(final StaticAbility stAb, final Card card, SpellAbility sa) { - final HashMap params = stAb.getMapParams(); - final Card hostCard = stAb.getHostCard(); - final Card source = sa.getSourceCard(); - final Player activator = sa.getActivatingPlayer(); - + /** + * Apply can't target ability. + * + * @param staticAbility the static ability + * @param card the card + * @param spellAbility the spell Ability + * @return true, if successful + */ + public static boolean applyCantTargetAbility(final StaticAbility staticAbility, final Card card, final SpellAbility spellAbility) { + final HashMap params = staticAbility.getMapParams(); + final Card hostCard = staticAbility.getHostCard(); + final Card source = spellAbility.getSourceCard(); + final Player activator = spellAbility.getActivatingPlayer(); + if (params.containsKey("AffectedZone")) { - if(!card.isInZone(Zone.smartValueOf(params.get("AffectedZone")))) { + if (!card.isInZone(Zone.smartValueOf(params.get("AffectedZone")))) { return false; } } else { // default zone is battlefield @@ -28,8 +36,8 @@ public class StaticAbilityCantTarget { return false; } } - - if (params.containsKey("Spell") && !sa.isSpell()) { + + if (params.containsKey("Spell") && !spellAbility.isSpell()) { return false; } @@ -37,7 +45,7 @@ public class StaticAbilityCantTarget { && !card.isValid(params.get("ValidCard").split(","), hostCard.getController(), hostCard)) { return false; } - + if (params.containsKey("ValidSource") && !source.isValid(params.get("ValidSource").split(","), hostCard.getController(), hostCard)) { return false; @@ -48,7 +56,6 @@ public class StaticAbilityCantTarget { return false; } - return true; } diff --git a/src/main/java/forge/card/trigger/TriggerHandler.java b/src/main/java/forge/card/trigger/TriggerHandler.java index bc4141999e7..ef7cd6f37fe 100644 --- a/src/main/java/forge/card/trigger/TriggerHandler.java +++ b/src/main/java/forge/card/trigger/TriggerHandler.java @@ -75,7 +75,7 @@ public class TriggerHandler { public final void registerDelayedTrigger(final Trigger trig) { this.delayedTriggers.add(trig); } - + /** *

* clearDelayedTrigger. diff --git a/src/main/java/forge/deck/generate/Generate2ColorDeck.java b/src/main/java/forge/deck/generate/Generate2ColorDeck.java index 2ab806e2d94..ca989cd1ba6 100644 --- a/src/main/java/forge/deck/generate/Generate2ColorDeck.java +++ b/src/main/java/forge/deck/generate/Generate2ColorDeck.java @@ -63,9 +63,9 @@ public class Generate2ColorDeck { this.notColors.add("black"); this.notColors.add("red"); this.notColors.add("green"); - - if(Singletons.getModel().getPreferences().isDeckGenSingletons()) { - maxDuplicates = 1; + + if (Singletons.getModel().getPreferences().isDeckGenSingletons()) { + this.maxDuplicates = 1; } if (clr1.equals("AI")) { @@ -128,7 +128,7 @@ public class Generate2ColorDeck { // reduce to cards that match the colors CardList cl1 = allCards.getColor(this.color1); - if(!Singletons.getModel().getPreferences().isDeckGenRmvArtifacts()) { + if (!Singletons.getModel().getPreferences().isDeckGenRmvArtifacts()) { cl1.addAll(allCards.getColor(Constant.Color.COLORLESS)); } CardList cl2 = allCards.getColor(this.color2); @@ -226,7 +226,7 @@ public class Generate2ColorDeck { Card c = cr12.get(this.r.nextInt(cr12.size())); lc = 0; - while ((this.cardCounts.get(c.getName()) > maxDuplicates - 1) || (lc > 100)) { + while ((this.cardCounts.get(c.getName()) > (this.maxDuplicates - 1)) || (lc > 100)) { c = cr12.get(this.r.nextInt(cr12.size())); lc++; } @@ -244,7 +244,7 @@ public class Generate2ColorDeck { Card c = sp12.get(this.r.nextInt(sp12.size())); lc = 0; - while ((this.cardCounts.get(c.getName()) > maxDuplicates - 1) || (lc > 100)) { + while ((this.cardCounts.get(c.getName()) > (this.maxDuplicates - 1)) || (lc > 100)) { c = sp12.get(this.r.nextInt(sp12.size())); lc++; } @@ -292,7 +292,7 @@ public class Generate2ColorDeck { numLands -= nDLands; if (numLands > 0) { - // attempt to optimize basic land counts according to + // attempt to optimize basic land counts according to // color representation final CCnt[] clrCnts = { new CCnt("Plains", 0), new CCnt("Island", 0), new CCnt("Swamp", 0), new CCnt("Mountain", 0), new CCnt("Forest", 0) }; @@ -393,7 +393,7 @@ public class Generate2ColorDeck { } private class CCnt { - private String color; + private final String color; private int count; public CCnt(final String clr, final int cnt) { diff --git a/src/main/java/forge/deck/generate/Generate3ColorDeck.java b/src/main/java/forge/deck/generate/Generate3ColorDeck.java index 7df4edfe9d4..0ee7df61e7a 100644 --- a/src/main/java/forge/deck/generate/Generate3ColorDeck.java +++ b/src/main/java/forge/deck/generate/Generate3ColorDeck.java @@ -66,9 +66,9 @@ public class Generate3ColorDeck { this.notColors.add("black"); this.notColors.add("red"); this.notColors.add("green"); - - if(Singletons.getModel().getPreferences().isDeckGenSingletons()) { - maxDuplicates = 1; + + if (Singletons.getModel().getPreferences().isDeckGenSingletons()) { + this.maxDuplicates = 1; } if (clr1.equals("AI")) { @@ -140,7 +140,7 @@ public class Generate3ColorDeck { // reduce to cards that match the colors CardList cl1 = allCards.getColor(this.color1); - if(!Singletons.getModel().getPreferences().isDeckGenRmvArtifacts()) { + if (!Singletons.getModel().getPreferences().isDeckGenRmvArtifacts()) { cl1.addAll(allCards.getColor(Constant.Color.COLORLESS)); } CardList cl2 = allCards.getColor(this.color2); @@ -252,7 +252,7 @@ public class Generate3ColorDeck { Card c = cr123.get(this.r.nextInt(cr123.size())); lc = 0; - while ((this.cardCounts.get(c.getName()) > maxDuplicates - 1) || (lc > 100)) { + while ((this.cardCounts.get(c.getName()) > (this.maxDuplicates - 1)) || (lc > 100)) { c = cr123.get(this.r.nextInt(cr123.size())); lc++; } @@ -270,7 +270,7 @@ public class Generate3ColorDeck { Card c = sp123.get(this.r.nextInt(sp123.size())); lc = 0; - while ((this.cardCounts.get(c.getName()) > maxDuplicates - 1) || (lc > 100)) { + while ((this.cardCounts.get(c.getName()) > (this.maxDuplicates - 1)) || (lc > 100)) { c = sp123.get(this.r.nextInt(sp123.size())); lc++; } @@ -318,7 +318,7 @@ public class Generate3ColorDeck { numLands -= ndLands; if (numLands > 0) { - // attempt to optimize basic land counts according to + // attempt to optimize basic land counts according to // color representation final CCnt[] clrCnts = { new CCnt("Plains", 0), new CCnt("Island", 0), new CCnt("Swamp", 0), new CCnt("Mountain", 0), new CCnt("Forest", 0) }; @@ -420,7 +420,7 @@ public class Generate3ColorDeck { } private class CCnt { - private String color; + private final String color; private int count; public CCnt(final String clr, final int cnt) { diff --git a/src/main/java/forge/deck/generate/Generate5ColorDeck.java b/src/main/java/forge/deck/generate/Generate5ColorDeck.java index fb6e8191063..4dddeff0664 100644 --- a/src/main/java/forge/deck/generate/Generate5ColorDeck.java +++ b/src/main/java/forge/deck/generate/Generate5ColorDeck.java @@ -92,9 +92,9 @@ public class Generate5ColorDeck { this.notColors.remove(this.color3); this.notColors.remove(this.color4); this.notColors.remove(this.color5); - - if(Singletons.getModel().getPreferences().isDeckGenSingletons()) { - maxDuplicates = 1; + + if (Singletons.getModel().getPreferences().isDeckGenSingletons()) { + this.maxDuplicates = 1; } this.dl = GenerateDeckUtil.getDualLandList("WUBRG"); @@ -138,7 +138,7 @@ public class Generate5ColorDeck { // reduce to cards that match the colors CardList cL1 = allCards.getColor(this.color1); - if(!Singletons.getModel().getPreferences().isDeckGenRmvArtifacts()) { + if (!Singletons.getModel().getPreferences().isDeckGenRmvArtifacts()) { cL1.addAll(allCards.getColor(Constant.Color.COLORLESS)); } CardList cL2 = allCards.getColor(this.color2); @@ -278,7 +278,7 @@ public class Generate5ColorDeck { Card c = cr12345.get(this.r.nextInt(cr12345.size())); lc = 0; - while ((this.cardCounts.get(c.getName()) > maxDuplicates - 1) || (lc > 100)) { + while ((this.cardCounts.get(c.getName()) > (this.maxDuplicates - 1)) || (lc > 100)) { c = cr12345.get(this.r.nextInt(cr12345.size())); lc++; } @@ -296,7 +296,7 @@ public class Generate5ColorDeck { Card c = sp12345.get(this.r.nextInt(sp12345.size())); lc = 0; - while ((this.cardCounts.get(c.getName()) > maxDuplicates - 1) || (lc > 100)) { + while ((this.cardCounts.get(c.getName()) > (this.maxDuplicates - 1)) || (lc > 100)) { c = sp12345.get(this.r.nextInt(sp12345.size())); lc++; } @@ -344,7 +344,7 @@ public class Generate5ColorDeck { numLands -= nDLands; if (numLands > 0) { - // attempt to optimize basic land counts according to + // attempt to optimize basic land counts according to // color representation final CCnt[] clrCnts = { new CCnt("Plains", 0), new CCnt("Island", 0), new CCnt("Swamp", 0), new CCnt("Mountain", 0), new CCnt("Forest", 0) }; diff --git a/src/main/java/forge/deck/generate/GenerateThemeDeck.java b/src/main/java/forge/deck/generate/GenerateThemeDeck.java index 833cadad78c..5efd6683a7e 100644 --- a/src/main/java/forge/deck/generate/GenerateThemeDeck.java +++ b/src/main/java/forge/deck/generate/GenerateThemeDeck.java @@ -169,7 +169,7 @@ public class GenerateThemeDeck { int lc = 0; while ((cardCounts.get(s) >= g.maxCnt) || (lc > size)) { - // looping + // looping // forever s = g.cardnames.get(r.nextInt(cnSize)); lc++; @@ -199,7 +199,7 @@ public class GenerateThemeDeck { tmpDeck += "numBLands:" + numBLands + "\n"; if (numBLands > 0) { - // attempt to optimize basic land counts according to + // attempt to optimize basic land counts according to // color representation final CCnt[] clrCnts = { new CCnt("Plains", 0), new CCnt("Island", 0), new CCnt("Swamp", 0), new CCnt("Mountain", 0), new CCnt("Forest", 0) }; @@ -317,7 +317,7 @@ public class GenerateThemeDeck { class CCnt { /** The Color. */ - private String color; + private final String color; /** The Count. */ private int count; @@ -344,7 +344,7 @@ public class GenerateThemeDeck { class Grp { /** The Cardnames. */ - private ArrayList cardnames = new ArrayList(); + private final ArrayList cardnames = new ArrayList(); /** The Max cnt. */ private int maxCnt; diff --git a/src/main/java/forge/gui/deckeditor/CardPanelHeavy.java b/src/main/java/forge/gui/deckeditor/CardPanelHeavy.java index d01c0dbe099..87ac0dbec2c 100644 --- a/src/main/java/forge/gui/deckeditor/CardPanelHeavy.java +++ b/src/main/java/forge/gui/deckeditor/CardPanelHeavy.java @@ -2,7 +2,6 @@ package forge.gui.deckeditor; import java.awt.event.ActionEvent; import java.io.File; -import java.io.IOException; import javax.swing.JButton; import javax.swing.JFileChooser; @@ -38,13 +37,13 @@ public class CardPanelHeavy extends CardPanelBase { // Controls to show card details /** The detail. */ - private CardDetailPanel detail = new CardDetailPanel(null); + private final CardDetailPanel detail = new CardDetailPanel(null); /** The picture. */ - private CardPanel picture = new CardPanel(null); + private final CardPanel picture = new CardPanel(null); /** The picture view panel. */ - private ViewPanel pictureViewPanel = new ViewPanel(); + private final ViewPanel pictureViewPanel = new ViewPanel(); // fake card to allow picture changes /** The c card hq. */ @@ -149,14 +148,13 @@ public class CardPanelHeavy extends CardPanelBase { */ final void changeStateButtonActionPerformed(final ActionEvent e) { final Card cur = this.picture.getCard(); - if(cur.isInAlternateState()) { + if (cur.isInAlternateState()) { cur.setState("Original"); - } - else { - if(cur.isFlip()) { + } else { + if (cur.isFlip()) { cur.setState("Flipped"); } - if(cur.isDoubleFaced()) { + if (cur.isDoubleFaced()) { cur.setState("Transformed"); } } @@ -165,35 +163,6 @@ public class CardPanelHeavy extends CardPanelBase { this.detail.setCard(cur); } - /** - *

- * changePictureButton_actionPerformed. Removed Oct 25 2011 - Hellfish - *

- * - * @param e - * a {@link java.awt.event.ActionEvent} object. - */ - private void changePictureButtonActionPerformed(final ActionEvent e) { - if (this.cCardHQ != null) { - final File file = this.getImportFilename(); - if (file != null) { - final String fileName = GuiDisplayUtil.cleanString(this.cCardHQ.getName()) + ".jpg"; - final File base = ForgeProps.getFile(NewConstants.IMAGE_BASE); - final File f = new File(base, fileName); - f.delete(); - - try { - org.apache.commons.io.FileUtils.copyFile(file, f); - } catch (final IOException e1) { - // TODO Auto-generated catch block ignores the exception, - // but sends it to System.err and probably forge.log. - e1.printStackTrace(); - } - this.setCard(this.cCardHQ); - } - } - } - /** *

* getImportFilename. @@ -220,7 +189,7 @@ public class CardPanelHeavy extends CardPanelBase { } /** The dck filter. */ - private FileFilter dckFilter = new FileFilter() { + private final FileFilter dckFilter = new FileFilter() { @Override public boolean accept(final File f) { diff --git a/src/main/java/forge/gui/deckeditor/CardPanelLite.java b/src/main/java/forge/gui/deckeditor/CardPanelLite.java index e9f9be5c5ad..30588489aff 100644 --- a/src/main/java/forge/gui/deckeditor/CardPanelLite.java +++ b/src/main/java/forge/gui/deckeditor/CardPanelLite.java @@ -23,7 +23,7 @@ public class CardPanelLite extends CardPanelBase { // Controls to show card details /** The detail. */ - private CardDetailPanel detail = new CardDetailPanel(null); + private final CardDetailPanel detail = new CardDetailPanel(null); private final CardPicturePanel picture = new CardPicturePanel(null); private final JButton bChangeState = new JButton(); @@ -110,12 +110,10 @@ public class CardPanelLite extends CardPanelBase { private void bChangeStateActionPerformed(final ActionEvent e) { final Card cur = this.detail.getCard(); if (cur != null) { - if(cur.isDoubleFaced()) { - if(cur.getCurState().equals("Transformed")) - { + if (cur.isDoubleFaced()) { + if (cur.getCurState().equals("Transformed")) { cur.setState("Original"); - } - else { + } else { cur.setState("Transformed"); } } diff --git a/src/main/java/forge/gui/deckeditor/DeckEditorCommon.java b/src/main/java/forge/gui/deckeditor/DeckEditorCommon.java index d88b898d28e..cbde8982c35 100644 --- a/src/main/java/forge/gui/deckeditor/DeckEditorCommon.java +++ b/src/main/java/forge/gui/deckeditor/DeckEditorCommon.java @@ -282,8 +282,8 @@ public final class DeckEditorCommon extends DeckEditorBase { */ @Override protected Predicate buildFilter() { - final Predicate cardFilter = - Predicate.and(this.getFilterBoxes().buildFilter(), this.filterNameTypeSet.buildFilter()); + final Predicate cardFilter = Predicate.and(this.getFilterBoxes().buildFilter(), + this.filterNameTypeSet.buildFilter()); return Predicate.instanceOf(cardFilter, CardPrinted.class); } @@ -400,17 +400,20 @@ public final class DeckEditorCommon extends DeckEditorBase { } /** + * Gets the custom menu. + * * @return the customMenu */ public DeckEditorCommonMenu getCustomMenu() { - return customMenu; + return this.customMenu; } /** - * @param customMenu - * the customMenu to set + * Sets the custom menu. + * + * @param customMenu the customMenu to set */ - public void setCustomMenu(DeckEditorCommonMenu customMenu) { + public void setCustomMenu(final DeckEditorCommonMenu customMenu) { this.customMenu = customMenu; // TODO: Add 0 to parameter's name. } diff --git a/src/main/java/forge/gui/deckeditor/DeckEditorShop.java b/src/main/java/forge/gui/deckeditor/DeckEditorShop.java index 4714feb262c..3b1f2851597 100644 --- a/src/main/java/forge/gui/deckeditor/DeckEditorShop.java +++ b/src/main/java/forge/gui/deckeditor/DeckEditorShop.java @@ -55,12 +55,12 @@ public final class DeckEditorShop extends DeckEditorBase { private double multiplier; private final QuestData questData; - + // get pricelist: private final ReadPriceList r = new ReadPriceList(); private final Map mapPrices = this.r.getPriceList(); private Map decksUsingMyCards; - + /** * Show. * @@ -77,7 +77,7 @@ public final class DeckEditorShop extends DeckEditorBase { exitCommand.execute(); } }; - + // do not change this!!!! this.addWindowListener(new WindowAdapter() { @Override @@ -98,7 +98,7 @@ public final class DeckEditorShop extends DeckEditorBase { forSale = this.questData.getCards().getShopList(); } final ItemPoolView owned = this.questData.getCards().getCardpool().getView(); - //newCardsList = questData.getCards().getNewCards(); + // newCardsList = questData.getCards().getNewCards(); this.setItems(forSale, owned, GameType.Quest); @@ -131,7 +131,7 @@ public final class DeckEditorShop extends DeckEditorBase { } return result; } - + /** *

* setup. @@ -156,7 +156,7 @@ public final class DeckEditorShop extends DeckEditorBase { columns.add(new TableColumnInfo("Set", 35, PresetColumns.FN_SET_COMPARE, PresetColumns.FN_SET_GET)); columns.get(2).setCellRenderer(new ManaCostRenderer()); - + final List> columnsBelow = new ArrayList>(columns); columns.add(new TableColumnInfo("Price", 36, this.fnPriceCompare, this.fnPriceGet)); this.getTopTableWithCards().setup(columns, this.getCardView()); @@ -212,7 +212,7 @@ public final class DeckEditorShop extends DeckEditorBase { // removeButton.setIcon(upIcon); if (!Singletons.getModel().getPreferences().isLafFonts()) { this.sellButton.setFont(new java.awt.Font("Dialog", 0, 13)); - } + } this.sellButton.setText("Sell Card"); this.sellButton.addActionListener(new java.awt.event.ActionListener() { @Override @@ -250,7 +250,7 @@ public final class DeckEditorShop extends DeckEditorBase { } this.jLabel1.setText("Click on the column name (like name or color) to sort the cards"); this.jLabel1.setBounds(new Rectangle(20, 1, 400, 19)); - + this.getContentPane().add(this.getCardView(), null); this.getContentPane().add(this.getTopTableWithCards().getTableDecorated(), null); this.getContentPane().add(this.getBottomTableWithCards().getTableDecorated(), null); @@ -265,7 +265,7 @@ public final class DeckEditorShop extends DeckEditorBase { private Integer getCardValue(final InventoryItem card) { if (this.mapPrices.containsKey(card.getName())) { return this.mapPrices.get(card.getName()); - } else if (card instanceof CardPrinted) { + } else if (card instanceof CardPrinted) { switch (((CardPrinted) card).getRarity()) { case BasicLand: return Integer.valueOf(4); @@ -366,20 +366,20 @@ public final class DeckEditorShop extends DeckEditorBase { return (int) (DeckEditorShop.this.multiplier * DeckEditorShop.this.getCardValue(from.getKey())); } }; - + @SuppressWarnings("rawtypes") private final Lambda1> fnDeckCompare = new Lambda1>() { @Override - public Comparable apply(final Entry from) { + public Comparable apply(final Entry from) { final Integer iValue = DeckEditorShop.this.decksUsingMyCards.get(from.getKey()); - return iValue == null ? Integer.valueOf(0) : iValue; + return iValue == null ? Integer.valueOf(0) : iValue; } }; private final Lambda1> fnDeckGet = new Lambda1>() { @Override - public Object apply(final Entry from) { + public Object apply(final Entry from) { final Integer iValue = DeckEditorShop.this.decksUsingMyCards.get(from.getKey()); - return iValue == null ? "" : iValue.toString(); + return iValue == null ? "" : iValue.toString(); } }; diff --git a/src/main/java/forge/gui/input/InputPayManaCost.java b/src/main/java/forge/gui/input/InputPayManaCost.java index fbd41c0f992..4a8fdbd524d 100644 --- a/src/main/java/forge/gui/input/InputPayManaCost.java +++ b/src/main/java/forge/gui/input/InputPayManaCost.java @@ -76,12 +76,12 @@ public class InputPayManaCost extends Input { *

* Constructor for Input_PayManaCost. *

- * + * * @param sa - * a {@link forge.card.spellability.SpellAbility} object. + * a {@link forge.card.spellability.SpellAbility} object. */ public InputPayManaCost(final SpellAbility sa) { - this(sa,new ManaCost(sa.getManaCost())); + this(sa, new ManaCost(sa.getManaCost())); } /** @@ -91,7 +91,7 @@ public class InputPayManaCost extends Input { * * @param sa * a {@link forge.card.spellability.SpellAbility} object. - * + * * @param manaCostToPay * a {@link forge.card.mana.ManaCost} object. */ @@ -110,7 +110,9 @@ public class InputPayManaCost extends Input { AllZone.getStack().add(this.spell); } } else { - this.manaCost = manaCostToPay;//AllZone.getGameAction().getSpellCostChange(sa, new ManaCost(this.originalManaCost)); + this.manaCost = manaCostToPay; // AllZone.getGameAction().getSpellCostChange(sa, + // new + // ManaCost(this.originalManaCost)); } } else { this.manaCost = new ManaCost(sa.getManaCost()); @@ -211,21 +213,23 @@ public class InputPayManaCost extends Input { } AllZone.getInputControl().resetInput(); } - - //If this is a spell with convoke, re-tap all creatures used for it. - //This is done to make sure Taps triggers go off at the right time - //(i.e. AFTER cost payment, they are tapped previously as well so that - //any mana tapabilities can't be used in payment as well as being tapped for convoke) - - if(spell.getTappedForConvoke() != null) - { + + // If this is a spell with convoke, re-tap all creatures used for + // it. + // This is done to make sure Taps triggers go off at the right time + // (i.e. AFTER cost payment, they are tapped previously as well so + // that + // any mana tapabilities can't be used in payment as well as being + // tapped for convoke) + + if (this.spell.getTappedForConvoke() != null) { AllZone.getTriggerHandler().suppressMode("Untaps"); - for(Card c : spell.getTappedForConvoke()) { + for (final Card c : this.spell.getTappedForConvoke()) { c.untap(); c.tap(); } AllZone.getTriggerHandler().clearSuppression("Untaps"); - spell.clearTappedForConvoke(); + this.spell.clearTappedForConvoke(); } } } @@ -233,21 +237,20 @@ public class InputPayManaCost extends Input { /** {@inheritDoc} */ @Override public final void selectButtonCancel() { - //If this is a spell with convoke, untap all creatures used for it. - if(spell.getTappedForConvoke() != null) - { + // If this is a spell with convoke, untap all creatures used for it. + if (this.spell.getTappedForConvoke() != null) { AllZone.getTriggerHandler().suppressMode("Untaps"); - for(Card c : spell.getTappedForConvoke()) { + for (final Card c : this.spell.getTappedForConvoke()) { c.untap(); } AllZone.getTriggerHandler().clearSuppression("Untaps"); - spell.clearTappedForConvoke(); + this.spell.clearTappedForConvoke(); } - + this.resetManaCost(); AllZone.getHumanPlayer().getManaPool().unpaid(this.spell, true); AllZone.getHumanPlayer().getZone(Zone.Battlefield).updateObservers(); // DO - + this.stop(); } diff --git a/src/main/java/forge/gui/skin/FPanel.java b/src/main/java/forge/gui/skin/FPanel.java index 6f6738853ae..076270fdfea 100644 --- a/src/main/java/forge/gui/skin/FPanel.java +++ b/src/main/java/forge/gui/skin/FPanel.java @@ -78,16 +78,34 @@ public class FPanel extends JPanel { this.setOpaque(false); } } - - public void setPreferredSize(int w, int h) { - setPreferredSize(new Dimension(w,h)); + + /** + * Sets the preferred size. + * + * @param w the w + * @param h the h + */ + public void setPreferredSize(final int w, final int h) { + this.setPreferredSize(new Dimension(w, h)); } - - public void setMaximumSize(int w, int h) { - setMaximumSize(new Dimension(w,h)); + + /** + * Sets the maximum size. + * + * @param w the w + * @param h the h + */ + public void setMaximumSize(final int w, final int h) { + this.setMaximumSize(new Dimension(w, h)); } - - public void setMinimumSize(int w, int h) { - setMinimumSize(new Dimension(w,h)); + + /** + * Sets the minimum size. + * + * @param w the w + * @param h the h + */ + public void setMinimumSize(final int w, final int h) { + this.setMinimumSize(new Dimension(w, h)); } } diff --git a/src/main/java/forge/gui/skin/FSkin.java b/src/main/java/forge/gui/skin/FSkin.java index e1a9e2e712a..f28c74b7a28 100644 --- a/src/main/java/forge/gui/skin/FSkin.java +++ b/src/main/java/forge/gui/skin/FSkin.java @@ -415,7 +415,7 @@ public class FSkin { /** * Background of progress bar, "unfilled" state. - * @return {@link javax.awt.Color} clrProgress1 + * @return {@link java.awt.Color} clrProgress1 */ public Color getClrProgress1() { return clrProgress1; @@ -431,7 +431,7 @@ public class FSkin { /** * Text of progress bar, "unfilled" state. - * @return {@link javax.awt.Color} clrProgress1 + * @return {@link java.awt.Color} clrProgress1 */ public Color getClrProgress2() { return clrProgress2; @@ -447,7 +447,7 @@ public class FSkin { /** * Background of progress bar, "filled" state. - * @return {@link javax.awt.Color} clrProgress1 + * @return {@link java.awt.Color} clrProgress1 */ public Color getClrProgress3() { return clrProgress3; @@ -463,7 +463,7 @@ public class FSkin { /** * Text of progress bar, "filled" state. - * @return {@link javax.awt.Color} clrProgress1 + * @return {@link java.awt.Color} clrProgress1 */ public Color getClrProgress4() { return clrProgress4; diff --git a/src/main/java/forge/item/CardPrinted.java b/src/main/java/forge/item/CardPrinted.java index 32740976202..21db528f6b4 100644 --- a/src/main/java/forge/item/CardPrinted.java +++ b/src/main/java/forge/item/CardPrinted.java @@ -176,10 +176,6 @@ public final class CardPrinted implements Comparable, InventoryItem * the rare * @param index * the index - * @param isAlt - * the is alt - * @param isDF - * the is df * @return the card printed */ static CardPrinted build(final CardRules c, final String set, final CardRarity rare, final int index) { diff --git a/src/main/java/forge/properties/ForgePreferences.java b/src/main/java/forge/properties/ForgePreferences.java index e41b3e3f151..b2a86719f24 100644 --- a/src/main/java/forge/properties/ForgePreferences.java +++ b/src/main/java/forge/properties/ForgePreferences.java @@ -19,7 +19,7 @@ import java.util.List; public class ForgePreferences extends Preferences { /** The new gui. */ - private boolean newGui; + private final boolean newGui; /** The stack ai land. */ private boolean stackAiLand; @@ -59,7 +59,7 @@ public class ForgePreferences extends Preferences { /** The scale larger than original. */ private boolean scaleLargerThanOriginal; - + /** The deck gen rmv artifacts. */ private boolean deckGenSingletons; @@ -246,388 +246,515 @@ public class ForgePreferences extends Preferences { } /** + * Checks if is stack ai land. + * * @return the stackAiLand */ public boolean isStackAiLand() { - return stackAiLand; + return this.stackAiLand; } /** + * Sets the stack ai land. + * * @param stackAiLand the stackAiLand to set */ - public void setStackAiLand(boolean stackAiLand) { + public void setStackAiLand(final boolean stackAiLand) { this.stackAiLand = stackAiLand; // TODO: Add 0 to parameter's name. } /** + * Checks if is milling loss condition. + * * @return the millingLossCondition */ public boolean isMillingLossCondition() { - return millingLossCondition; + return this.millingLossCondition; } /** + * Sets the milling loss condition. + * * @param millingLossCondition the millingLossCondition to set */ - public void setMillingLossCondition(boolean millingLossCondition) { - this.millingLossCondition = millingLossCondition; // TODO: Add 0 to parameter's name. + public void setMillingLossCondition(final boolean millingLossCondition) { + this.millingLossCondition = millingLossCondition; // TODO: Add 0 to + // parameter's name. } /** + * Checks if is b ai begin combat. + * * @return the bAIBeginCombat */ public boolean isbAIBeginCombat() { - return bAIBeginCombat; + return this.bAIBeginCombat; } /** + * Sets the b ai begin combat. + * * @param bAIBeginCombat the bAIBeginCombat to set */ - public void setbAIBeginCombat(boolean bAIBeginCombat) { - this.bAIBeginCombat = bAIBeginCombat; // TODO: Add 0 to parameter's name. + public void setbAIBeginCombat(final boolean bAIBeginCombat) { + this.bAIBeginCombat = bAIBeginCombat; // TODO: Add 0 to parameter's + // name. } /** + * Checks if is b ai end combat. + * * @return the bAIEndCombat */ public boolean isbAIEndCombat() { - return bAIEndCombat; + return this.bAIEndCombat; } /** + * Sets the b ai end combat. + * * @param bAIEndCombat the bAIEndCombat to set */ - public void setbAIEndCombat(boolean bAIEndCombat) { + public void setbAIEndCombat(final boolean bAIEndCombat) { this.bAIEndCombat = bAIEndCombat; // TODO: Add 0 to parameter's name. } /** + * Checks if is b ai upkeep. + * * @return the bAIUpkeep */ public boolean isbAIUpkeep() { - return bAIUpkeep; + return this.bAIUpkeep; } /** + * Sets the b ai upkeep. + * * @param bAIUpkeep the bAIUpkeep to set */ - public void setbAIUpkeep(boolean bAIUpkeep) { + public void setbAIUpkeep(final boolean bAIUpkeep) { this.bAIUpkeep = bAIUpkeep; // TODO: Add 0 to parameter's name. } /** + * Checks if is b ai draw. + * * @return the bAIDraw */ public boolean isbAIDraw() { - return bAIDraw; + return this.bAIDraw; } /** + * Sets the b ai draw. + * * @param bAIDraw the bAIDraw to set */ - public void setbAIDraw(boolean bAIDraw) { + public void setbAIDraw(final boolean bAIDraw) { this.bAIDraw = bAIDraw; // TODO: Add 0 to parameter's name. } /** + * Checks if is b aieot. + * * @return the bAIEOT */ public boolean isbAIEOT() { - return bAIEOT; + return this.bAIEOT; } /** + * Sets the b aieot. + * * @param bAIEOT the bAIEOT to set */ - public void setbAIEOT(boolean bAIEOT) { + public void setbAIEOT(final boolean bAIEOT) { this.bAIEOT = bAIEOT; // TODO: Add 0 to parameter's name. } /** + * Checks if is b human begin combat. + * * @return the bHumanBeginCombat */ public boolean isbHumanBeginCombat() { - return bHumanBeginCombat; + return this.bHumanBeginCombat; } /** + * Sets the b human begin combat. + * * @param bHumanBeginCombat the bHumanBeginCombat to set */ - public void setbHumanBeginCombat(boolean bHumanBeginCombat) { - this.bHumanBeginCombat = bHumanBeginCombat; // TODO: Add 0 to parameter's name. + public void setbHumanBeginCombat(final boolean bHumanBeginCombat) { + this.bHumanBeginCombat = bHumanBeginCombat; // TODO: Add 0 to + // parameter's name. } /** + * Checks if is b human draw. + * * @return the bHumanDraw */ public boolean isbHumanDraw() { - return bHumanDraw; + return this.bHumanDraw; } /** + * Sets the b human draw. + * * @param bHumanDraw the bHumanDraw to set */ - public void setbHumanDraw(boolean bHumanDraw) { + public void setbHumanDraw(final boolean bHumanDraw) { this.bHumanDraw = bHumanDraw; // TODO: Add 0 to parameter's name. } /** + * Checks if is upload draft ai. + * * @return the uploadDraftAI */ public boolean isUploadDraftAI() { - return uploadDraftAI; + return this.uploadDraftAI; } /** + * Sets the upload draft ai. + * * @param uploadDraftAI the uploadDraftAI to set */ - public void setUploadDraftAI(boolean uploadDraftAI) { + public void setUploadDraftAI(final boolean uploadDraftAI) { this.uploadDraftAI = uploadDraftAI; // TODO: Add 0 to parameter's name. } /** + * Checks if is b human end combat. + * * @return the bHumanEndCombat */ public boolean isbHumanEndCombat() { - return bHumanEndCombat; + return this.bHumanEndCombat; } /** + * Sets the b human end combat. + * * @param bHumanEndCombat the bHumanEndCombat to set */ - public void setbHumanEndCombat(boolean bHumanEndCombat) { - this.bHumanEndCombat = bHumanEndCombat; // TODO: Add 0 to parameter's name. + public void setbHumanEndCombat(final boolean bHumanEndCombat) { + this.bHumanEndCombat = bHumanEndCombat; // TODO: Add 0 to parameter's + // name. } /** + * Checks if is b human eot. + * * @return the bHumanEOT */ public boolean isbHumanEOT() { - return bHumanEOT; + return this.bHumanEOT; } /** + * Sets the b human eot. + * * @param bHumanEOT the bHumanEOT to set */ - public void setbHumanEOT(boolean bHumanEOT) { + public void setbHumanEOT(final boolean bHumanEOT) { this.bHumanEOT = bHumanEOT; // TODO: Add 0 to parameter's name. } /** + * Checks if is b human upkeep. + * * @return the bHumanUpkeep */ public boolean isbHumanUpkeep() { - return bHumanUpkeep; + return this.bHumanUpkeep; } /** + * Sets the b human upkeep. + * * @param bHumanUpkeep the bHumanUpkeep to set */ - public void setbHumanUpkeep(boolean bHumanUpkeep) { + public void setbHumanUpkeep(final boolean bHumanUpkeep) { this.bHumanUpkeep = bHumanUpkeep; // TODO: Add 0 to parameter's name. } /** + * Gets the bugz name. + * * @return the bugzName */ public String getBugzName() { - return bugzName; + return this.bugzName; } /** + * Sets the bugz name. + * * @param bugzName the bugzName to set */ - public void setBugzName(String bugzName) { + public void setBugzName(final String bugzName) { this.bugzName = bugzName; // TODO: Add 0 to parameter's name. } /** + * Gets the bugz pwd. + * * @return the bugzPwd */ public String getBugzPwd() { - return bugzPwd; + return this.bugzPwd; } /** + * Sets the bugz pwd. + * * @param bugzPwd the bugzPwd to set */ - public void setBugzPwd(String bugzPwd) { + public void setBugzPwd(final String bugzPwd) { this.bugzPwd = bugzPwd; // TODO: Add 0 to parameter's name. } /** + * Checks if is rand c foil. + * * @return the randCFoil */ public boolean isRandCFoil() { - return randCFoil; + return this.randCFoil; } /** + * Sets the rand c foil. + * * @param randCFoil the randCFoil to set */ - public void setRandCFoil(boolean randCFoil) { + public void setRandCFoil(final boolean randCFoil) { this.randCFoil = randCFoil; // TODO: Add 0 to parameter's name. } /** + * Checks if is developer mode. + * * @return the developerMode */ public boolean isDeveloperMode() { - return developerMode; + return this.developerMode; } /** + * Sets the developer mode. + * * @param developerMode the developerMode to set */ - public void setDeveloperMode(boolean developerMode) { + public void setDeveloperMode(final boolean developerMode) { this.developerMode = developerMode; // TODO: Add 0 to parameter's name. } /** + * Gets the laf. + * * @return the laf */ public String getLaf() { - return laf; + return this.laf; } /** + * Sets the laf. + * * @param laf the laf to set */ - public void setLaf(String laf) { + public void setLaf(final String laf) { this.laf = laf; // TODO: Add 0 to parameter's name. } /** + * Gets the skin. + * * @return the skin */ public String getSkin() { - return skin; + return this.skin; } /** + * Sets the skin. + * * @param skin the skin to set */ - public void setSkin(String skin) { + public void setSkin(final String skin) { this.skin = skin; // TODO: Add 0 to parameter's name. } /** + * Checks if is laf fonts. + * * @return the lafFonts */ public boolean isLafFonts() { - return lafFonts; + return this.lafFonts; } /** + * Sets the laf fonts. + * * @param lafFonts the lafFonts to set */ - public void setLafFonts(boolean lafFonts) { + public void setLafFonts(final boolean lafFonts) { this.lafFonts = lafFonts; // TODO: Add 0 to parameter's name. } /** + * Checks if is scale larger than original. + * * @return the scaleLargerThanOriginal */ public boolean isScaleLargerThanOriginal() { - return scaleLargerThanOriginal; + return this.scaleLargerThanOriginal; } /** + * Sets the scale larger than original. + * * @param scaleLargerThanOriginal the scaleLargerThanOriginal to set */ - public void setScaleLargerThanOriginal(boolean scaleLargerThanOriginal) { - this.scaleLargerThanOriginal = scaleLargerThanOriginal; // TODO: Add 0 to parameter's name. + public void setScaleLargerThanOriginal(final boolean scaleLargerThanOriginal) { + this.scaleLargerThanOriginal = scaleLargerThanOriginal; // TODO: Add 0 + // to + // parameter's + // name. } /** + * Checks if is card overlay. + * * @return the cardOverlay */ public boolean isCardOverlay() { - return cardOverlay; + return this.cardOverlay; } /** + * Sets the card overlay. + * * @param cardOverlay the cardOverlay to set */ - public void setCardOverlay(boolean cardOverlay) { + public void setCardOverlay(final boolean cardOverlay) { this.cardOverlay = cardOverlay; // TODO: Add 0 to parameter's name. } - + + /** + * Checks if is deck gen singletons. + * + * @return true, if is deck gen singletons + */ public boolean isDeckGenSingletons() { - return deckGenSingletons; + return this.deckGenSingletons; } - public void setDeckGenSingletons(boolean deckSingletons) { + /** + * Sets the deck gen singletons. + * + * @param deckSingletons the new deck gen singletons + */ + public void setDeckGenSingletons(final boolean deckSingletons) { this.deckGenSingletons = deckSingletons; } /** + * Checks if is deck gen rmv artifacts. + * * @return the deckGenRmvArtifacts */ public boolean isDeckGenRmvArtifacts() { - return deckGenRmvArtifacts; + return this.deckGenRmvArtifacts; } /** + * Sets the deck gen rmv artifacts. + * * @param deckGenRmvArtifacts the deckGenRmvArtifacts to set */ - public void setDeckGenRmvArtifacts(boolean deckGenRmvArtifacts) { - this.deckGenRmvArtifacts = deckGenRmvArtifacts; // TODO: Add 0 to parameter's name. + public void setDeckGenRmvArtifacts(final boolean deckGenRmvArtifacts) { + this.deckGenRmvArtifacts = deckGenRmvArtifacts; // TODO: Add 0 to + // parameter's name. } /** + * Checks if is deck gen rmv small. + * * @return the deckGenRmvSmall */ public boolean isDeckGenRmvSmall() { - return deckGenRmvSmall; + return this.deckGenRmvSmall; } /** + * Sets the deck gen rmv small. + * * @param deckGenRmvSmall the deckGenRmvSmall to set */ - public void setDeckGenRmvSmall(boolean deckGenRmvSmall) { - this.deckGenRmvSmall = deckGenRmvSmall; // TODO: Add 0 to parameter's name. + public void setDeckGenRmvSmall(final boolean deckGenRmvSmall) { + this.deckGenRmvSmall = deckGenRmvSmall; // TODO: Add 0 to parameter's + // name. } /** + * Gets the card size. + * * @return the cardSize */ public CardSizeType getCardSize() { - return cardSize; + return this.cardSize; } /** + * Sets the card size. + * * @param cardSize the cardSize to set */ - public void setCardSize(CardSizeType cardSize) { + public void setCardSize(final CardSizeType cardSize) { this.cardSize = cardSize; // TODO: Add 0 to parameter's name. } /** + * Gets the stack offset. + * * @return the stackOffset */ public StackOffsetType getStackOffset() { - return stackOffset; + return this.stackOffset; } /** + * Sets the stack offset. + * * @param stackOffset the stackOffset to set */ - public void setStackOffset(StackOffsetType stackOffset) { + public void setStackOffset(final StackOffsetType stackOffset) { this.stackOffset = stackOffset; // TODO: Add 0 to parameter's name. } /** + * Gets the max stack size. + * * @return the maxStackSize */ public int getMaxStackSize() { - return maxStackSize; + return this.maxStackSize; } /** + * Sets the max stack size. + * * @param maxStackSize the maxStackSize to set */ - public void setMaxStackSize(int maxStackSize) { + public void setMaxStackSize(final int maxStackSize) { this.maxStackSize = maxStackSize; // TODO: Add 0 to parameter's name. } diff --git a/src/main/java/forge/properties/NewConstants.java b/src/main/java/forge/properties/NewConstants.java index ed8fd9418be..dece320b55a 100644 --- a/src/main/java/forge/properties/NewConstants.java +++ b/src/main/java/forge/properties/NewConstants.java @@ -856,7 +856,8 @@ public final class NewConstants { /** The TITLE. */ public static final String TITLE = "%s/NewGame/options/generate/title"; - + + /** The Constant SINGLETONS. */ public static final String SINGLETONS = "%s/NewGame/options/generate/singletons"; /** The REMOV e_ small. */ diff --git a/src/main/java/forge/quest/data/QuestData.java b/src/main/java/forge/quest/data/QuestData.java index 5efb5088a4b..0fd9756f823 100644 --- a/src/main/java/forge/quest/data/QuestData.java +++ b/src/main/java/forge/quest/data/QuestData.java @@ -184,7 +184,7 @@ public final class QuestData { public void newGame(final int diff, final String m0de, final boolean standardStart) { this.setDifficulty(diff); - final Predicate filter = standardStart + final Predicate filter = standardStart ? SetUtils.getStandard().getFilterPrinted() : CardPrinted.Predicates.Presets.IS_TRUE; diff --git a/src/main/java/forge/quest/gui/QuestWinLoseHandler.java b/src/main/java/forge/quest/gui/QuestWinLoseHandler.java index 2e81bd00474..e0259891351 100644 --- a/src/main/java/forge/quest/gui/QuestWinLoseHandler.java +++ b/src/main/java/forge/quest/gui/QuestWinLoseHandler.java @@ -336,7 +336,7 @@ public class QuestWinLoseHandler extends WinLoseModeHandler { default: break; } - if (estateValue > 0){ + if (estateValue > 0) { credEstates = (int) (estateValue * credTotal); sb.append("Estates bonus: ").append((int) (100 * estateValue)).append("%.
"); credTotal += credEstates; diff --git a/src/main/java/forge/view/swing/OldGuiNewGame.java b/src/main/java/forge/view/swing/OldGuiNewGame.java index 334d33ab4cc..30ce46b684e 100644 --- a/src/main/java/forge/view/swing/OldGuiNewGame.java +++ b/src/main/java/forge/view/swing/OldGuiNewGame.java @@ -49,12 +49,12 @@ import forge.Command; import forge.Constant; import forge.ConstantStringArrayList; import forge.FileUtil; -import forge.GuiImportPicture; import forge.GuiDisplay; -import forge.GuiDownloadQuestImages; import forge.GuiDownloadPicturesLQ; import forge.GuiDownloadPrices; +import forge.GuiDownloadQuestImages; import forge.GuiDownloadSetPicturesLQ; +import forge.GuiImportPicture; import forge.ImageCache; import forge.MyRandom; import forge.PlayerType; @@ -139,7 +139,7 @@ public class OldGuiNewGame extends JFrame { private static JCheckBoxMenuItem singletons = new JCheckBoxMenuItem( ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.MenuBar.Options.Generate.SINGLETONS)); - + /** Constant removeSmallCreatures. */ private static JCheckBoxMenuItem removeSmallCreatures = new JCheckBoxMenuItem( ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.MenuBar.Options.Generate.REMOVE_SMALL)); @@ -148,7 +148,8 @@ public class OldGuiNewGame extends JFrame { private static JCheckBoxMenuItem removeArtifacts = new JCheckBoxMenuItem( ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.MenuBar.Options.Generate.REMOVE_ARTIFACTS)); /** Constant useLAFFonts. */ - private static JCheckBoxMenuItem useLAFFonts = new JCheckBoxMenuItem(ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.MenuBar.Options.FONT)); + private static JCheckBoxMenuItem useLAFFonts = new JCheckBoxMenuItem( + ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.MenuBar.Options.FONT)); /** Constant cardOverlay. */ private static JCheckBoxMenuItem cardOverlay = new JCheckBoxMenuItem( ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.MenuBar.Options.CARD_OVERLAY)); @@ -245,8 +246,8 @@ public class OldGuiNewGame extends JFrame { // CARD_SIZES_ACTION, lookAndFeelAction, this.dnldPricesAction, this.downloadActionLQ, this.downloadActionSetLQ, this.downloadActionQuest, this.importPicture, this.cardSizesAction, this.cardStackAction, - this.cardStackOffsetAction, this.bugzReporterAction, ErrorViewer.ALL_THREADS_ACTION, - this.aboutAction, this.exitAction }; + this.cardStackOffsetAction, this.bugzReporterAction, ErrorViewer.ALL_THREADS_ACTION, this.aboutAction, + this.exitAction }; final JMenu menu = new JMenu(ForgeProps.getLocalized(Menu.TITLE)); for (final Action a : actions) { menu.add(a); @@ -259,18 +260,18 @@ public class OldGuiNewGame extends JFrame { // useLAFFonts.setSelected(false); // new stuff - final JMenu generatedDeck = new JMenu(ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.MenuBar.Options.Generate.TITLE)); - + final JMenu generatedDeck = new JMenu( + ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.MenuBar.Options.Generate.TITLE)); + generatedDeck.add(OldGuiNewGame.singletons); OldGuiNewGame.singletons.setSelected(Singletons.getModel().getPreferences().isDeckGenSingletons()); OldGuiNewGame.singletons.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent arg0) { - Singletons.getModel().getPreferences() - .setDeckGenSingletons(OldGuiNewGame.singletons.isSelected()); + Singletons.getModel().getPreferences().setDeckGenSingletons(OldGuiNewGame.singletons.isSelected()); } }); - + generatedDeck.add(OldGuiNewGame.removeSmallCreatures); OldGuiNewGame.removeSmallCreatures.setSelected(Singletons.getModel().getPreferences().isDeckGenRmvSmall()); OldGuiNewGame.removeSmallCreatures.addActionListener(new ActionListener() { @@ -416,7 +417,8 @@ public class OldGuiNewGame extends JFrame { final String sDeckName = JOptionPane.showInputDialog(null, ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.NewGameText.SAVE_SEALED_MSG), - ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.NewGameText.SAVE_SEALED_TTL), JOptionPane.QUESTION_MESSAGE); + ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.NewGameText.SAVE_SEALED_TTL), + JOptionPane.QUESTION_MESSAGE); deck.setName(sDeckName); deck.setPlayerType(PlayerType.HUMAN); @@ -501,10 +503,12 @@ public class OldGuiNewGame extends JFrame { */ /* jPanel2.setBorder(titledBorder1); */ - this.setCustomBorder(this.jPanel2, ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.NewGameText.GAMETYPE)); + this.setCustomBorder(this.jPanel2, + ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.NewGameText.GAMETYPE)); this.jPanel2.setLayout(new MigLayout("align center")); - this.singleRadioButton.setText(ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.NewGameText.CONSTRUCTED_TEXT)); + this.singleRadioButton.setText(ForgeProps + .getLocalized(NewConstants.Lang.OldGuiNewGame.NewGameText.CONSTRUCTED_TEXT)); this.singleRadioButton.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(final ActionEvent e) { @@ -513,7 +517,8 @@ public class OldGuiNewGame extends JFrame { }); // sealedRadioButton.setToolTipText(""); - this.sealedRadioButton.setText(ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.NewGameText.SEALED_TEXT)); + this.sealedRadioButton + .setText(ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.NewGameText.SEALED_TEXT)); this.sealedRadioButton.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(final ActionEvent e) { @@ -522,7 +527,8 @@ public class OldGuiNewGame extends JFrame { }); // draftRadioButton.setToolTipText(""); - this.draftRadioButton.setText(ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.NewGameText.BOOSTER_TEXT)); + this.draftRadioButton + .setText(ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.NewGameText.BOOSTER_TEXT)); this.draftRadioButton.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(final ActionEvent e) { @@ -546,13 +552,16 @@ public class OldGuiNewGame extends JFrame { */ /* jPanel3.setBorder(titledBorder3); */ - this.setCustomBorder(this.jPanel3, ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.NewGameText.SETTINGS)); + this.setCustomBorder(this.jPanel3, + ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.NewGameText.SETTINGS)); this.jPanel3.setLayout(new MigLayout("align center")); // newGuiCheckBox.setText(ForgeProps.getLocalized(NEW_GAME_TEXT.NEW_GUI)); - OldGuiNewGame.getSmoothLandCheckBox().setText(ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.NewGameText.AI_LAND)); + OldGuiNewGame.getSmoothLandCheckBox().setText( + ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.NewGameText.AI_LAND)); - OldGuiNewGame.getDevModeCheckBox().setText(ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.NewGameText.DEV_MODE)); + OldGuiNewGame.getDevModeCheckBox().setText( + ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.NewGameText.DEV_MODE)); OldGuiNewGame.getDevModeCheckBox().addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(final ActionEvent e) { @@ -563,9 +572,8 @@ public class OldGuiNewGame extends JFrame { OldGuiNewGame.getUpldDrftCheckBox().setText("Upload Draft Picks"); - OldGuiNewGame.getUpldDrftCheckBox() - .setToolTipText("Your picks and all other participants' picks will help the Forge AI" - + " make better draft picks."); + OldGuiNewGame.getUpldDrftCheckBox().setToolTipText( + "Your picks and all other participants' picks will help the Forge AI" + " make better draft picks."); OldGuiNewGame.getUpldDrftCheckBox().addActionListener(new java.awt.event.ActionListener() { @Override @@ -576,8 +584,8 @@ public class OldGuiNewGame extends JFrame { }); OldGuiNewGame.getFoilRandomCheckBox().setText("Random Foiling"); - OldGuiNewGame.getFoilRandomCheckBox() - .setToolTipText("Approximately 1:20 cards will appear with foiling effects applied."); + OldGuiNewGame.getFoilRandomCheckBox().setToolTipText( + "Approximately 1:20 cards will appear with foiling effects applied."); OldGuiNewGame.getFoilRandomCheckBox().addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(final ActionEvent e) { @@ -1601,8 +1609,8 @@ public class OldGuiNewGame extends JFrame { area.setEditable(false); area.setOpaque(false); - JOptionPane.showMessageDialog(null, new JScrollPane(area), ForgeProps.getLocalized(NewConstants.Lang.HowTo.TITLE), - JOptionPane.INFORMATION_MESSAGE); + JOptionPane.showMessageDialog(null, new JScrollPane(area), + ForgeProps.getLocalized(NewConstants.Lang.HowTo.TITLE), JOptionPane.INFORMATION_MESSAGE); } } @@ -1883,27 +1891,30 @@ public class OldGuiNewGame extends JFrame { * @return the cardOverlay */ public static JCheckBoxMenuItem getCardOverlay() { - return cardOverlay; + return OldGuiNewGame.cardOverlay; } /** - * @param cardOverlay the cardOverlay to set + * @param cardOverlay + * the cardOverlay to set */ - public static void setCardOverlay(JCheckBoxMenuItem cardOverlay) { - OldGuiNewGame.cardOverlay = cardOverlay; // TODO: Add 0 to parameter's name. + public static void setCardOverlay(final JCheckBoxMenuItem cardOverlay) { + OldGuiNewGame.cardOverlay = cardOverlay; // TODO: Add 0 to parameter's + // name. } /** * @return the cardScale */ public static JCheckBoxMenuItem getCardScale() { - return cardScale; + return OldGuiNewGame.cardScale; } /** - * @param cardScale the cardScale to set + * @param cardScale + * the cardScale to set */ - public static void setCardScale(JCheckBoxMenuItem cardScale) { + public static void setCardScale(final JCheckBoxMenuItem cardScale) { OldGuiNewGame.cardScale = cardScale; // TODO: Add 0 to parameter's name. } @@ -1911,70 +1922,82 @@ public class OldGuiNewGame extends JFrame { * @return the useLAFFonts */ public static JCheckBoxMenuItem getUseLAFFonts() { - return useLAFFonts; + return OldGuiNewGame.useLAFFonts; } /** - * @param useLAFFonts the useLAFFonts to set + * @param useLAFFonts + * the useLAFFonts to set */ - public static void setUseLAFFonts(JCheckBoxMenuItem useLAFFonts) { - OldGuiNewGame.useLAFFonts = useLAFFonts; // TODO: Add 0 to parameter's name. + public static void setUseLAFFonts(final JCheckBoxMenuItem useLAFFonts) { + OldGuiNewGame.useLAFFonts = useLAFFonts; // TODO: Add 0 to parameter's + // name. } /** * @return the smoothLandCheckBox */ static JCheckBox getSmoothLandCheckBox() { - return smoothLandCheckBox; + return OldGuiNewGame.smoothLandCheckBox; } /** - * @param smoothLandCheckBox the smoothLandCheckBox to set + * @param smoothLandCheckBox + * the smoothLandCheckBox to set */ - static void setSmoothLandCheckBox(JCheckBox smoothLandCheckBox) { - OldGuiNewGame.smoothLandCheckBox = smoothLandCheckBox; // TODO: Add 0 to parameter's name. + static void setSmoothLandCheckBox(final JCheckBox smoothLandCheckBox) { + OldGuiNewGame.smoothLandCheckBox = smoothLandCheckBox; // TODO: Add 0 to + // parameter's + // name. } /** * @return the devModeCheckBox */ public static JCheckBox getDevModeCheckBox() { - return devModeCheckBox; + return OldGuiNewGame.devModeCheckBox; } /** - * @param devModeCheckBox the devModeCheckBox to set + * @param devModeCheckBox + * the devModeCheckBox to set */ - public static void setDevModeCheckBox(JCheckBox devModeCheckBox) { - OldGuiNewGame.devModeCheckBox = devModeCheckBox; // TODO: Add 0 to parameter's name. + public static void setDevModeCheckBox(final JCheckBox devModeCheckBox) { + OldGuiNewGame.devModeCheckBox = devModeCheckBox; // TODO: Add 0 to + // parameter's name. } /** * @return the upldDrftCheckBox */ public static JCheckBox getUpldDrftCheckBox() { - return upldDrftCheckBox; + return OldGuiNewGame.upldDrftCheckBox; } /** - * @param upldDrftCheckBox the upldDrftCheckBox to set + * @param upldDrftCheckBox + * the upldDrftCheckBox to set */ - public static void setUpldDrftCheckBox(JCheckBox upldDrftCheckBox) { - OldGuiNewGame.upldDrftCheckBox = upldDrftCheckBox; // TODO: Add 0 to parameter's name. + public static void setUpldDrftCheckBox(final JCheckBox upldDrftCheckBox) { + OldGuiNewGame.upldDrftCheckBox = upldDrftCheckBox; // TODO: Add 0 to + // parameter's name. } /** * @return the foilRandomCheckBox */ public static JCheckBox getFoilRandomCheckBox() { - return foilRandomCheckBox; + return OldGuiNewGame.foilRandomCheckBox; } /** - * @param foilRandomCheckBox the foilRandomCheckBox to set + * @param foilRandomCheckBox + * the foilRandomCheckBox to set */ - public static void setFoilRandomCheckBox(JCheckBox foilRandomCheckBox) { - OldGuiNewGame.foilRandomCheckBox = foilRandomCheckBox; // TODO: Add 0 to parameter's name. + public static void setFoilRandomCheckBox(final JCheckBox foilRandomCheckBox) { + OldGuiNewGame.foilRandomCheckBox = foilRandomCheckBox; // 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 6956bdc91b1..9759aea282e 100644 --- a/src/main/java/forge/view/swing/WinLoseFrame.java +++ b/src/main/java/forge/view/swing/WinLoseFrame.java @@ -49,10 +49,10 @@ public class WinLoseFrame extends JFrame { private FButton btnRestart; /** The lbl title. */ - private JLabel lblTitle; + private final JLabel lblTitle; /** The lbl stats. */ - private JLabel lblStats; + private final JLabel lblStats; /** The pnl custom. */ private JPanel pnlCustom; @@ -283,60 +283,62 @@ public class WinLoseFrame extends JFrame { * @return {@link forge.gui.skin.FButton} btnContinue */ public FButton getBtnContinue() { - return btnContinue; + return this.btnContinue; } /** - * @param {@link forge.gui.skin.FButton} btnContinue + * @param btnContinue {@link forge.gui.skin.FButton} */ - public void setBtnContinue(FButton btnContinue0) { - this.btnContinue = btnContinue0; + public void setBtnContinue(final FButton btnContinue) { + this.btnContinue = btnContinue; } /** * @return {@link forge.gui.skin.FButton} btnRestart */ public FButton getBtnRestart() { - return btnRestart; + return this.btnRestart; } /** - * @param {@link forge.gui.skin.FButton} btnRestart + * @param btnRestart {@link forge.gui.skin.FButton} */ - public void setBtnRestart(FButton btnRestart0) { - this.btnRestart = btnRestart0; + public void setBtnRestart(final FButton btnRestart) { + this.btnRestart = btnRestart; } /** * @return {@link forge.gui.skin.FButton} btnQuit */ public FButton getBtnQuit() { - return btnQuit; + return this.btnQuit; } /** - * @param {@link forge.gui.skin.FButton} btnQuit + * @param btnQuit {@link forge.gui.skin.FButton} */ - public void setBtnQuit(FButton btnQuit0) { - this.btnQuit = btnQuit0; + public void setBtnQuit(final FButton btnQuit) { + this.btnQuit = btnQuit; } /** - * The central panel in the win/lose screen, used for - * presenting customized messages and rewards. + * The central panel in the win/lose screen, used for presenting customized + * messages and rewards. + * * @return {@link javax.swing.JPanel} pnlCustom */ public JPanel getPnlCustom() { - return pnlCustom; + return this.pnlCustom; } /** - * The central panel in the win/lose screen, used for - * presenting customized messages and rewards. - * @param {@link javax.swing.JPanel} pnlCustom + * The central panel in the win/lose screen, used for presenting customized + * messages and rewards. + * + * @param pnlCustom {@link javax.swing.JPanel} */ - public void setPnlCustom(JPanel pnlCustom0) { - this.pnlCustom = pnlCustom0; + public void setPnlCustom(final JPanel pnlCustom) { + this.pnlCustom = pnlCustom; } private class WinLoseBorder extends AbstractBorder {