checkstyle and refactoring

This commit is contained in:
jendave
2011-10-28 21:39:49 +00:00
parent 0945c9e739
commit 57a72484cd
5 changed files with 198 additions and 64 deletions

View File

@@ -1326,7 +1326,7 @@ public class AbilityFactory {
if (sa.isSpell()) { if (sa.isSpell()) {
return sa.getSourceCard().isSorcery(); return sa.getSourceCard().isSorcery();
} else if (sa.isAbility()) { } else if (sa.isAbility()) {
return sa.getRestrictions().getSorcerySpeed(); return sa.getRestrictions().isSorcerySpeed();
} }
return false; return false;

View File

@@ -653,8 +653,7 @@ public class AbilityFactory_Destroy {
* @return a {@link java.lang.String} object. * @return a {@link java.lang.String} object.
*/ */
private static String destroyAllStackDescription(final AbilityFactory af, private static String destroyAllStackDescription(final AbilityFactory af,
final SpellAbility sa, final boolean noRegen) final SpellAbility sa, final boolean noRegen) {
{
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
String name = af.getHostCard().getName(); String name = af.getHostCard().getName();

View File

@@ -121,9 +121,9 @@ public class SpellAbility_Condition extends SpellAbility_Variables {
// basically PresentCompare for life totals: // basically PresentCompare for life totals:
if (params.containsKey("ConditionLifeTotal")) { if (params.containsKey("ConditionLifeTotal")) {
lifeTotal = params.get("ConditionLifeTotal"); setLifeTotal(params.get("ConditionLifeTotal"));
if (params.containsKey("ConditionLifeAmount")) { if (params.containsKey("ConditionLifeAmount")) {
lifeAmount = params.get("ConditionLifeAmount"); setLifeAmount(params.get("ConditionLifeAmount"));
} }
} }
@@ -159,27 +159,27 @@ public class SpellAbility_Condition extends SpellAbility_Variables {
+ " Did not have activator set in SpellAbility_Condition.checkConditions()"); + " Did not have activator set in SpellAbility_Condition.checkConditions()");
} }
if (hellbent) { if (isHellbent()) {
if (!activator.hasHellbent()) { if (!activator.hasHellbent()) {
return false; return false;
} }
} }
if (threshold) { if (isThreshold()) {
if (!activator.hasThreshold()) { if (!activator.hasThreshold()) {
return false; return false;
} }
} }
if (metalcraft) { if (isMetalcraft()) {
if (!activator.hasMetalcraft()) { if (!activator.hasMetalcraft()) {
return false; return false;
} }
} }
if (bSorcerySpeed && !Phase.canCastSorcery(activator)) { if (isSorcerySpeed() && !Phase.canCastSorcery(activator)) {
return false; return false;
} }
if (bPlayerTurn && !AllZone.getPhase().isPlayerTurn(activator)) { if (isPlayerTurn() && !AllZone.getPhase().isPlayerTurn(activator)) {
return false; return false;
} }
@@ -187,14 +187,14 @@ public class SpellAbility_Condition extends SpellAbility_Variables {
return false; return false;
} }
if (activationLimit != -1 && numberTurnActivations >= activationLimit) { if (getActivationLimit() != -1 && getNumberTurnActivations() >= getActivationLimit()) {
return false; return false;
} }
if (phases.size() > 0) { if (getPhases().size() > 0) {
boolean isPhase = false; boolean isPhase = false;
String currPhase = AllZone.getPhase().getPhase(); String currPhase = AllZone.getPhase().getPhase();
for (String s : phases) { for (String s : getPhases()) {
if (s.equals(currPhase)) { if (s.equals(currPhase)) {
isPhase = true; isPhase = true;
break; break;
@@ -243,7 +243,7 @@ public class SpellAbility_Condition extends SpellAbility_Variables {
list = list.getValidCards(sIsPresent.split(","), sa.getActivatingPlayer(), sa.getSourceCard()); list = list.getValidCards(sIsPresent.split(","), sa.getActivatingPlayer(), sa.getSourceCard());
int right; int right;
String rightString = presentCompare.substring(2); String rightString = getPresentCompare().substring(2);
try { // If this is an Integer, just parse it try { // If this is an Integer, just parse it
right = Integer.parseInt(rightString); right = Integer.parseInt(rightString);
} catch (NumberFormatException e) { // Otherwise, grab it from the } catch (NumberFormatException e) { // Otherwise, grab it from the
@@ -253,29 +253,29 @@ public class SpellAbility_Condition extends SpellAbility_Variables {
int left = list.size(); int left = list.size();
if (!AllZoneUtil.compare(left, presentCompare, right)) { if (!AllZoneUtil.compare(left, getPresentCompare(), right)) {
return false; return false;
} }
} }
if (lifeTotal != null) { if (getLifeTotal() != null) {
int life = 1; int life = 1;
if (lifeTotal.equals("You")) { if (getLifeTotal().equals("You")) {
life = activator.getLife(); life = activator.getLife();
} }
if (lifeTotal.equals("Opponent")) { if (getLifeTotal().equals("Opponent")) {
life = activator.getOpponent().getLife(); life = activator.getOpponent().getLife();
} }
int right = 1; int right = 1;
String rightString = lifeAmount.substring(2); String rightString = getLifeAmount().substring(2);
if (rightString.equals("X")) { if (rightString.equals("X")) {
right = CardFactoryUtil.xCount(sa.getSourceCard(), sa.getSourceCard().getSVar("X")); right = CardFactoryUtil.xCount(sa.getSourceCard(), sa.getSourceCard().getSVar("X"));
} else { } else {
right = Integer.parseInt(lifeAmount.substring(2)); right = Integer.parseInt(getLifeAmount().substring(2));
} }
if (!AllZoneUtil.compare(life, lifeAmount, right)) { if (!AllZoneUtil.compare(life, getLifeAmount(), right)) {
return false; return false;
} }
} }

View File

@@ -144,9 +144,9 @@ public class SpellAbility_Restriction extends SpellAbility_Variables {
// basically PresentCompare for life totals: // basically PresentCompare for life totals:
if (params.containsKey("ActivationLifeTotal")) { if (params.containsKey("ActivationLifeTotal")) {
lifeTotal = params.get("ActivationLifeTotal"); setLifeTotal(params.get("ActivationLifeTotal"));
if (params.containsKey("ActivationLifeAmount")) { if (params.containsKey("ActivationLifeAmount")) {
lifeAmount = params.get("ActivationLifeAmount"); setLifeAmount(params.get("ActivationLifeAmount"));
} }
} }
@@ -193,11 +193,11 @@ public class SpellAbility_Restriction extends SpellAbility_Variables {
System.out.println(c.getName() + " Did not have activator set in SpellAbility_Restriction.canPlay()"); System.out.println(c.getName() + " Did not have activator set in SpellAbility_Restriction.canPlay()");
} }
if (bSorcerySpeed && !Phase.canCastSorcery(activator)) { if (isSorcerySpeed() && !Phase.canCastSorcery(activator)) {
return false; return false;
} }
if (bPlayerTurn && !AllZone.getPhase().isPlayerTurn(activator)) { if (isPlayerTurn() && !AllZone.getPhase().isPlayerTurn(activator)) {
return false; return false;
} }
@@ -209,14 +209,14 @@ public class SpellAbility_Restriction extends SpellAbility_Variables {
return false; return false;
} }
if (activationLimit != -1 && numberTurnActivations >= activationLimit) { if (getActivationLimit() != -1 && getNumberTurnActivations() >= getActivationLimit()) {
return false; return false;
} }
if (phases.size() > 0) { if (getPhases().size() > 0) {
boolean isPhase = false; boolean isPhase = false;
String currPhase = AllZone.getPhase().getPhase(); String currPhase = AllZone.getPhase().getPhase();
for (String s : phases) { for (String s : getPhases()) {
if (s.equals(currPhase)) { if (s.equals(currPhase)) {
isPhase = true; isPhase = true;
break; break;
@@ -233,26 +233,26 @@ public class SpellAbility_Restriction extends SpellAbility_Variables {
return false; return false;
} }
} }
if (hellbent) { if (isHellbent()) {
if (!activator.hasHellbent()) { if (!activator.hasHellbent()) {
return false; return false;
} }
} }
if (threshold) { if (isThreshold()) {
if (!activator.hasThreshold()) { if (!activator.hasThreshold()) {
return false; return false;
} }
} }
if (metalcraft) { if (isMetalcraft()) {
if (!activator.hasMetalcraft()) { if (!activator.hasMetalcraft()) {
return false; return false;
} }
} }
if (prowl != null) { if (getProwl() != null) {
// only true if the activating player has damaged the opponent with // only true if the activating player has damaged the opponent with
// one of the specified types // one of the specified types
boolean prowlFlag = false; boolean prowlFlag = false;
for (String type : prowl) { for (String type : getProwl()) {
if (activator.hasProwl(type)) { if (activator.hasProwl(type)) {
prowlFlag = true; prowlFlag = true;
} }
@@ -267,42 +267,42 @@ public class SpellAbility_Restriction extends SpellAbility_Variables {
list = list.getValidCards(sIsPresent.split(","), activator, c); list = list.getValidCards(sIsPresent.split(","), activator, c);
int right = 1; int right = 1;
String rightString = presentCompare.substring(2); String rightString = getPresentCompare().substring(2);
if (rightString.equals("X")) { if (rightString.equals("X")) {
right = CardFactoryUtil.xCount(c, c.getSVar("X")); right = CardFactoryUtil.xCount(c, c.getSVar("X"));
} else { } else {
right = Integer.parseInt(presentCompare.substring(2)); right = Integer.parseInt(getPresentCompare().substring(2));
} }
int left = list.size(); int left = list.size();
if (!AllZoneUtil.compare(left, presentCompare, right)) { if (!AllZoneUtil.compare(left, getPresentCompare(), right)) {
return false; return false;
} }
} }
if (lifeTotal != null) { if (getLifeTotal() != null) {
int life = 1; int life = 1;
if (lifeTotal.equals("You")) { if (getLifeTotal().equals("You")) {
life = activator.getLife(); life = activator.getLife();
} }
if (lifeTotal.equals("Opponent")) { if (getLifeTotal().equals("Opponent")) {
life = activator.getOpponent().getLife(); life = activator.getOpponent().getLife();
} }
int right = 1; int right = 1;
String rightString = lifeAmount.substring(2); String rightString = getLifeAmount().substring(2);
if (rightString.equals("X")) { if (rightString.equals("X")) {
right = CardFactoryUtil.xCount(sa.getSourceCard(), sa.getSourceCard().getSVar("X")); right = CardFactoryUtil.xCount(sa.getSourceCard(), sa.getSourceCard().getSVar("X"));
} else { } else {
right = Integer.parseInt(lifeAmount.substring(2)); right = Integer.parseInt(getLifeAmount().substring(2));
} }
if (!AllZoneUtil.compare(life, lifeAmount, right)) { if (!AllZoneUtil.compare(life, getLifeAmount(), right)) {
return false; return false;
} }
} }
if (pwAbility) { if (isPwAbility()) {
// Planeswalker abilities can only be activated as Sorceries // Planeswalker abilities can only be activated as Sorceries
if (!Phase.canCastSorcery(activator)) { if (!Phase.canCastSorcery(activator)) {
return false; return false;

View File

@@ -33,10 +33,10 @@ public class SpellAbility_Variables {
protected Constant.Zone zone = Constant.Zone.Battlefield; protected Constant.Zone zone = Constant.Zone.Battlefield;
/** The phases. */ /** The phases. */
protected ArrayList<String> phases = new ArrayList<String>(); private ArrayList<String> phases = new ArrayList<String>();
/** The b sorcery speed. */ /** The b sorcery speed. */
protected boolean bSorcerySpeed = false; private boolean sorcerySpeed = false;
/** The b any player. */ /** The b any player. */
protected boolean bAnyPlayer = false; protected boolean bAnyPlayer = false;
@@ -45,37 +45,37 @@ public class SpellAbility_Variables {
protected boolean bOpponentTurn = false; protected boolean bOpponentTurn = false;
/** The b player turn. */ /** The b player turn. */
protected boolean bPlayerTurn = false; private boolean playerTurn = false;
/** The activation limit. */ /** The activation limit. */
protected int activationLimit = -1; private int activationLimit = -1;
/** The number turn activations. */ /** The number turn activations. */
protected int numberTurnActivations = 0; private int numberTurnActivations = 0;
/** The activation number sacrifice. */ /** The activation number sacrifice. */
protected int activationNumberSacrifice = -1; private int activationNumberSacrifice = -1;
/** The n cards in hand. */ /** The n cards in hand. */
protected int nCardsInHand = -1; protected int nCardsInHand = -1;
/** The threshold. */ /** The threshold. */
protected boolean threshold = false; private boolean threshold = false;
/** The metalcraft. */ /** The metalcraft. */
protected boolean metalcraft = false; private boolean metalcraft = false;
/** The hellbent. */ /** The hellbent. */
protected boolean hellbent = false; private boolean hellbent = false;
/** The prowl. */ /** The prowl. */
protected ArrayList<String> prowl = null; private ArrayList<String> prowl = null;
/** The s is present. */ /** The s is present. */
protected String sIsPresent = null; protected String sIsPresent = null;
/** The present compare. */ /** The present compare. */
protected String presentCompare = "GE1"; // Default Compare to Greater or private String presentCompare = "GE1"; // Default Compare to Greater or
// Equal to 1 // Equal to 1
/** The present defined. */ /** The present defined. */
@@ -94,16 +94,16 @@ public class SpellAbility_Variables {
protected String svarOperand = "1"; protected String svarOperand = "1";
/** The life total. */ /** The life total. */
protected String lifeTotal = null; private String lifeTotal = null;
/** The life amount. */ /** The life amount. */
protected String lifeAmount = "GE1"; private String lifeAmount = "GE1";
/** The mana spent. */ /** The mana spent. */
protected String manaSpent = ""; protected String manaSpent = "";
/** The pw ability. */ /** The pw ability. */
protected boolean pwAbility = false; private boolean pwAbility = false;
/** The all m12 empires. */ /** The all m12 empires. */
protected boolean allM12Empires = false; protected boolean allM12Empires = false;
@@ -212,7 +212,7 @@ public class SpellAbility_Variables {
* a boolean. * a boolean.
*/ */
public final void setSorcerySpeed(final boolean bSpeed) { public final void setSorcerySpeed(final boolean bSpeed) {
bSorcerySpeed = bSpeed; sorcerySpeed = bSpeed;
} }
/** /**
@@ -222,8 +222,8 @@ public class SpellAbility_Variables {
* *
* @return a boolean. * @return a boolean.
*/ */
public final boolean getSorcerySpeed() { public final boolean isSorcerySpeed() {
return bSorcerySpeed; return sorcerySpeed;
} }
/** /**
@@ -258,7 +258,7 @@ public class SpellAbility_Variables {
* a boolean. * a boolean.
*/ */
public final void setPlayerTurn(final boolean bTurn) { public final void setPlayerTurn(final boolean bTurn) {
bPlayerTurn = bTurn; playerTurn = bTurn;
} }
/** /**
@@ -269,7 +269,7 @@ public class SpellAbility_Variables {
* @return a boolean. * @return a boolean.
*/ */
public final boolean getPlayerTurn() { public final boolean getPlayerTurn() {
return bPlayerTurn; return isPlayerTurn();
} }
/** /**
@@ -501,7 +501,7 @@ public class SpellAbility_Variables {
* a boolean. * a boolean.
*/ */
public final void setPlaneswalker(final boolean bPlaneswalker) { public final void setPlaneswalker(final boolean bPlaneswalker) {
pwAbility = bPlaneswalker; setPwAbility(bPlaneswalker);
} }
/** /**
@@ -512,7 +512,7 @@ public class SpellAbility_Variables {
* @return a boolean. * @return a boolean.
*/ */
public final boolean getPlaneswalker() { public final boolean getPlaneswalker() {
return pwAbility; return isPwAbility();
} }
// Checking the values of SVars (Mostly for Traps) // Checking the values of SVars (Mostly for Traps)
@@ -552,4 +552,139 @@ public class SpellAbility_Variables {
svarOperand = operand; svarOperand = operand;
} }
/**
* Gets the activation limit.
*
* @return the activationLimit
*/
public int getActivationLimit() {
return activationLimit;
}
/**
* Checks if is threshold.
*
* @return the threshold
*/
public final boolean isThreshold() {
return threshold;
}
/**
* Checks if is metalcraft.
*
* @return the metalcraft
*/
public final boolean isMetalcraft() {
return metalcraft;
}
/**
* Checks if is hellbent.
*
* @return the hellbent
*/
public final boolean isHellbent() {
return hellbent;
}
/**
* Checks if is pw ability.
*
* @return the pwAbility
*/
public final boolean isPwAbility() {
return pwAbility;
}
/**
* Sets the pw ability.
*
* @param pwAbility the new pw ability
*/
public final void setPwAbility(final boolean pwAbility) {
this.pwAbility = pwAbility; // TODO Add 0 to parameter's name.
}
/**
* Checks if is player turn.
*
* @return the playerTurn
*/
public boolean isPlayerTurn() {
return playerTurn;
}
/**
* Gets the prowl.
*
* @return the prowl
*/
public ArrayList<String> getProwl() {
return prowl;
}
/**
* Gets the present compare.
*
* @return the presentCompare
*/
public String getPresentCompare() {
return presentCompare;
}
/**
* Gets the life total.
*
* @return the lifeTotal
*/
public final String getLifeTotal() {
return lifeTotal;
}
/**
* Sets the life total.
*
* @param lifeTotal the lifeTotal to set
*/
public final void setLifeTotal(final String lifeTotal) {
this.lifeTotal = lifeTotal; // TODO Add 0 to parameter's name.
}
/**
* Gets the life amount.
*
* @return the lifeAmount
*/
public final String getLifeAmount() {
return lifeAmount;
}
/**
* Sets the life amount.
*
* @param lifeAmount the lifeAmount to set
*/
public final void setLifeAmount(final String lifeAmount) {
this.lifeAmount = lifeAmount; // TODO Add 0 to parameter's name.
}
/**
* Gets the phases.
*
* @return the phases
*/
public final ArrayList<String> getPhases() {
return phases;
}
/**
* Sets the phases.
*
* @param phases the new phases
*/
public final void setPhases(final ArrayList<String> phases) {
this.phases = phases; // TODO Add 0 to parameter's name.
}
} // end class SpellAbility_Variables } // end class SpellAbility_Variables