mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
Checkstyle fixes in SA_Condition and SA_Requirements
This commit is contained in:
@@ -1,7 +1,11 @@
|
||||
package forge.card.spellability;
|
||||
|
||||
|
||||
import forge.*;
|
||||
import forge.AllZone;
|
||||
import forge.AllZoneUtil;
|
||||
import forge.CardList;
|
||||
import forge.Phase;
|
||||
import forge.Player;
|
||||
import forge.card.abilityFactory.AbilityFactory;
|
||||
import forge.card.cardFactory.CardFactoryUtil;
|
||||
|
||||
@@ -32,25 +36,35 @@ public class SpellAbility_Condition extends SpellAbility_Variables {
|
||||
*
|
||||
* @param params a {@link java.util.HashMap} object.
|
||||
*/
|
||||
public void setConditions(HashMap<String, String> params) {
|
||||
public final void setConditions(final HashMap<String, String> params) {
|
||||
if (params.containsKey("Condition")) {
|
||||
String value = params.get("Condition");
|
||||
if (value.equals("Threshold")) setThreshold(true);
|
||||
if (value.equals("Metalcraft")) setMetalcraft(true);
|
||||
if (value.equals("Hellbent")) setHellbent(true);
|
||||
if (value.equals("Threshold")) {
|
||||
setThreshold(true);
|
||||
}
|
||||
if (value.equals("Metalcraft")) {
|
||||
setMetalcraft(true);
|
||||
}
|
||||
if (value.equals("Hellbent")) {
|
||||
setHellbent(true);
|
||||
}
|
||||
}
|
||||
|
||||
if (params.containsKey("ConditionZone"))
|
||||
if (params.containsKey("ConditionZone")) {
|
||||
setZone(params.get("ContitionZone"));
|
||||
}
|
||||
|
||||
if (params.containsKey("ConditionSorcerySpeed"))
|
||||
if (params.containsKey("ConditionSorcerySpeed")) {
|
||||
setSorcerySpeed(true);
|
||||
}
|
||||
|
||||
if (params.containsKey("ConditionPlayerTurn"))
|
||||
if (params.containsKey("ConditionPlayerTurn")) {
|
||||
setPlayerTurn(true);
|
||||
}
|
||||
|
||||
if (params.containsKey("ConditionOpponentTurn"))
|
||||
if (params.containsKey("ConditionOpponentTurn")) {
|
||||
setOpponentTurn(true);
|
||||
}
|
||||
|
||||
if (params.containsKey("ConditionPhases")) {
|
||||
String phases = params.get("ConditionPhases");
|
||||
@@ -68,15 +82,17 @@ public class SpellAbility_Condition extends SpellAbility_Variables {
|
||||
setPhases(phases);
|
||||
}
|
||||
|
||||
if (params.containsKey("ConditionCardsInHand"))
|
||||
if (params.containsKey("ConditionCardsInHand")) {
|
||||
setActivateCardsInHand(Integer.parseInt(params.get("ConditionCardsInHand")));
|
||||
}
|
||||
|
||||
//Condition version of IsPresent stuff
|
||||
if (params.containsKey("ConditionPresent")) {
|
||||
setIsPresent(params.get("ConditionPresent"));
|
||||
if (params.containsKey("ConditionCompare"))
|
||||
if (params.containsKey("ConditionCompare")) {
|
||||
setPresentCompare(params.get("ConditionCompare"));
|
||||
}
|
||||
}
|
||||
|
||||
if (params.containsKey("ConditionDefined")) {
|
||||
setPresentDefined(params.get("ConditionDefined"));
|
||||
@@ -115,38 +131,46 @@ public class SpellAbility_Condition extends SpellAbility_Variables {
|
||||
* @param sa a {@link forge.card.spellability.SpellAbility} object.
|
||||
* @return a boolean.
|
||||
*/
|
||||
public boolean checkConditions(SpellAbility sa) {
|
||||
public final boolean checkConditions(final SpellAbility sa) {
|
||||
|
||||
Player activator = sa.getActivatingPlayer();
|
||||
if (activator == null) {
|
||||
activator = sa.getSourceCard().getController();
|
||||
System.out.println(sa.getSourceCard().getName() + " Did not have activator set in SpellAbility_Condition.checkConditions()");
|
||||
System.out.println(sa.getSourceCard().getName()
|
||||
+ " Did not have activator set in SpellAbility_Condition.checkConditions()");
|
||||
}
|
||||
|
||||
if (hellbent) {
|
||||
if (!activator.hasHellbent())
|
||||
if (!activator.hasHellbent()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (threshold) {
|
||||
if (!activator.hasThreshold())
|
||||
if (!activator.hasThreshold()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (metalcraft) {
|
||||
if (!activator.hasMetalcraft())
|
||||
if (!activator.hasMetalcraft()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (bSorcerySpeed && !Phase.canCastSorcery(activator)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (bSorcerySpeed && !Phase.canCastSorcery(activator))
|
||||
if (bPlayerTurn && !AllZone.getPhase().isPlayerTurn(activator)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (bPlayerTurn && !AllZone.getPhase().isPlayerTurn(activator))
|
||||
if (bOpponentTurn && AllZone.getPhase().isPlayerTurn(activator)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (bOpponentTurn && AllZone.getPhase().isPlayerTurn(activator))
|
||||
return false;
|
||||
|
||||
if (activationLimit != -1 && numberTurnActivations >= activationLimit)
|
||||
if (activationLimit != -1 && numberTurnActivations >= activationLimit) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (phases.size() > 0) {
|
||||
boolean isPhase = false;
|
||||
@@ -158,15 +182,17 @@ public class SpellAbility_Condition extends SpellAbility_Variables {
|
||||
}
|
||||
}
|
||||
|
||||
if (!isPhase)
|
||||
if (!isPhase) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (nCardsInHand != -1) {
|
||||
// Can handle Library of Alexandria, or Hellbent
|
||||
if (AllZoneUtil.getPlayerHand(activator).size() != nCardsInHand)
|
||||
if (AllZoneUtil.getPlayerHand(activator).size() != nCardsInHand) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (sIsPresent != null) {
|
||||
CardList list = new CardList();
|
||||
@@ -188,9 +214,10 @@ public class SpellAbility_Condition extends SpellAbility_Variables {
|
||||
|
||||
int left = list.size();
|
||||
|
||||
if (!AllZoneUtil.compare(left, presentCompare, right))
|
||||
if (!AllZoneUtil.compare(left, presentCompare, right)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (lifeTotal != null) {
|
||||
int life = 1;
|
||||
@@ -224,8 +251,9 @@ public class SpellAbility_Condition extends SpellAbility_Variables {
|
||||
int svarValue = AbilityFactory.calculateAmount(sa.getSourceCard(), svarToCheck, sa);
|
||||
int operandValue = AbilityFactory.calculateAmount(sa.getSourceCard(), svarOperand, sa);
|
||||
|
||||
if (!AllZoneUtil.compare(svarValue, svarOperator, operandValue))
|
||||
if (!AllZoneUtil.compare(svarValue, svarOperator, operandValue)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ public class SpellAbility_Requirements {
|
||||
*
|
||||
* @param bSkip a boolean.
|
||||
*/
|
||||
public void setSkipStack(boolean bSkip) {
|
||||
public final void setSkipStack(final boolean bSkip) {
|
||||
skipStack = bSkip;
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public class SpellAbility_Requirements {
|
||||
*
|
||||
* @param bFree a boolean.
|
||||
*/
|
||||
public void setFree(boolean bFree) {
|
||||
public final void setFree(final boolean bFree) {
|
||||
isFree = bFree;
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ public class SpellAbility_Requirements {
|
||||
* @param ts a {@link forge.card.spellability.Target_Selection} object.
|
||||
* @param cp a {@link forge.card.cost.Cost_Payment} object.
|
||||
*/
|
||||
public SpellAbility_Requirements(SpellAbility sa, Target_Selection ts, Cost_Payment cp) {
|
||||
public SpellAbility_Requirements(final SpellAbility sa, final Target_Selection ts, final Cost_Payment cp) {
|
||||
ability = sa;
|
||||
select = ts;
|
||||
payment = cp;
|
||||
@@ -58,7 +58,7 @@ public class SpellAbility_Requirements {
|
||||
/**
|
||||
* <p>fillRequirements.</p>
|
||||
*/
|
||||
public void fillRequirements() {
|
||||
public final void fillRequirements() {
|
||||
fillRequirements(false);
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ public class SpellAbility_Requirements {
|
||||
*
|
||||
* @param skipTargeting a boolean.
|
||||
*/
|
||||
public void fillRequirements(boolean skipTargeting) {
|
||||
public final void fillRequirements(final boolean skipTargeting) {
|
||||
if (ability instanceof Spell && !bCasting) {
|
||||
// remove from hand
|
||||
bCasting = true;
|
||||
@@ -82,19 +82,21 @@ public class SpellAbility_Requirements {
|
||||
// freeze Stack. No abilities should go onto the stack while I'm filling requirements.
|
||||
AllZone.getStack().freezeStack();
|
||||
|
||||
// Skip to paying if parent ability doesn't target and has no subAbilities. (or trigger case where its already targeted)
|
||||
// Skip to paying if parent ability doesn't target and has no subAbilities.
|
||||
// (or trigger case where its already targeted)
|
||||
if (!skipTargeting && (select.doesTarget() || ability.getSubAbility() != null)) {
|
||||
select.setRequirements(this);
|
||||
select.resetTargets();
|
||||
select.chooseTargets();
|
||||
} else
|
||||
} else {
|
||||
needPayment();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>finishedTargeting.</p>
|
||||
*/
|
||||
public void finishedTargeting() {
|
||||
public final void finishedTargeting() {
|
||||
if (select.isCanceled()) {
|
||||
// cancel ability during target choosing
|
||||
Card c = ability.getSourceCard();
|
||||
@@ -106,24 +108,26 @@ public class SpellAbility_Requirements {
|
||||
select.resetTargets();
|
||||
AllZone.getStack().clearFrozen();
|
||||
return;
|
||||
} else
|
||||
} else {
|
||||
needPayment();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>needPayment.</p>
|
||||
*/
|
||||
public void needPayment() {
|
||||
if (!isFree)
|
||||
public final void needPayment() {
|
||||
if (!isFree) {
|
||||
startPaying();
|
||||
else
|
||||
} else {
|
||||
finishPaying();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>startPaying.</p>
|
||||
*/
|
||||
public void startPaying() {
|
||||
public final void startPaying() {
|
||||
payment.setRequirements(this);
|
||||
payment.payCost();
|
||||
}
|
||||
@@ -131,12 +135,13 @@ public class SpellAbility_Requirements {
|
||||
/**
|
||||
* <p>finishPaying.</p>
|
||||
*/
|
||||
public void finishPaying() {
|
||||
public final void finishPaying() {
|
||||
if (isFree || payment.isAllPaid()) {
|
||||
if (skipStack)
|
||||
if (skipStack) {
|
||||
AbilityFactory.resolve(ability, false);
|
||||
else
|
||||
} else {
|
||||
addAbilityToStack();
|
||||
}
|
||||
|
||||
select.resetTargets();
|
||||
AllZone.getGameAction().checkStateEffects();
|
||||
@@ -147,8 +152,9 @@ public class SpellAbility_Requirements {
|
||||
AllZone.getGameAction().moveTo(fromZone, c);
|
||||
}
|
||||
|
||||
if (select != null)
|
||||
if (select != null) {
|
||||
select.resetTargets();
|
||||
}
|
||||
|
||||
ability.resetOnceResolved();
|
||||
payment.cancelPayment();
|
||||
@@ -159,7 +165,7 @@ public class SpellAbility_Requirements {
|
||||
/**
|
||||
* <p>addAbilityToStack.</p>
|
||||
*/
|
||||
public void addAbilityToStack() {
|
||||
public final void addAbilityToStack() {
|
||||
// For older abilities that don't setStackDescription set it here
|
||||
if (ability.getStackDescription().equals("")) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
@@ -168,10 +174,11 @@ public class SpellAbility_Requirements {
|
||||
ArrayList<Object> targets = ability.getTarget().getTargets();
|
||||
if (targets.size() > 0) {
|
||||
sb.append(" - Targeting ");
|
||||
for (Object o : targets)
|
||||
for (Object o : targets) {
|
||||
sb.append(o.toString()).append(" ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ability.setStackDescription(sb.toString());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user