- CheckStyle.

This commit is contained in:
Chris
2012-11-22 14:34:10 +00:00
parent 60e0f2bd7f
commit 946da55f9a
21 changed files with 100 additions and 86 deletions

View File

@@ -778,7 +778,7 @@ public class CardFactoryCreatures {
Zone zone = Singletons.getModel().getGame().getZoneOf(c);
return zone.is(ZoneType.Battlefield) && c.getController() == ability.getTargetPlayer() && c.canBeTargetedBy(ability);
}
@Override
protected Input onDone() {
final StringBuilder sb = new StringBuilder();
@@ -791,7 +791,7 @@ public class CardFactoryCreatures {
return null;
}
};
targetInput.setMessage("Select up to 5 target permanents. Selected (%d) so far. Click OK when done.");
Predicate<Player> canTarget = new Predicate<Player>() {

View File

@@ -130,7 +130,7 @@ public class CostDiscard extends CostPartWithList {
return handList.contains(c);
} else {
if (ability.isSpell()) {
handList.remove(source);// can't pay for itself
handList.remove(source); // can't pay for itself
}
boolean sameName = false;
if (type.contains("+WithSameName")) {
@@ -385,14 +385,14 @@ public class CostDiscard extends CostPartWithList {
public void selectCard(final Card card) {
Zone zone = Singletons.getModel().getGame().getZoneOf(card);
if (zone.is(ZoneType.Hand) && handList.contains(card)) {
if (!sameName || part.getList().isEmpty()
if (!sameName || part.getList().isEmpty()
|| part.getList().get(0).getName().equals(card.getName())) {
// send in List<Card> for Typing
card.getController().discard(card, sp);
part.addToList(card);
handList.remove(card);
this.nDiscard++;
// in case no more cards in hand
if (this.nDiscard == nNeeded) {
this.done();

View File

@@ -98,7 +98,7 @@ public class CostExile extends CostPartWithList {
} else if (this.getType().equals("All")) {
sb.append(" all cards from your ").append(this.from);
return sb.toString();
}
}
if (this.from.equals(ZoneType.Battlefield)) {
final String desc = this.getTypeDescription() == null ? this.getType() : this.getTypeDescription();
@@ -150,7 +150,7 @@ public class CostExile extends CostPartWithList {
List<Card> typeList = new ArrayList<Card>();
if (this.getType().equals("All")) {
return true; // this will always work
}
}
if (this.getFrom().equals(ZoneType.Stack)) {
for (int i = 0; i < Singletons.getModel().getGame().getStack().size(); i++) {
typeList.add(Singletons.getModel().getGame().getStack().peekAbility(i).getSourceCard());
@@ -213,7 +213,7 @@ public class CostExile extends CostPartWithList {
Singletons.getModel().getGame().getAction().exile(card);
}
payment.paidCost(this);
}
}
list = CardLists.getValidCards(list, this.getType().split(";"), activator, source);
if (c == null) {
final String sVar = ability.getSVar(amount);

View File

@@ -494,7 +494,7 @@ public class ManaCost {
}
String manaColor = mana.getColor();
if (choice.isOr2Colorless() && !this.isColor(InputPayManaCostUtil.getShortColorString(manaColor))) {
this.increaseColorlessMana(1);
}

View File

@@ -362,10 +362,14 @@ public class ManaCostShard {
*/
public boolean canBePaidWithManaOfColor(CardColor color) {
// can pay with life?
if ( (this.shard & Atom.OR_2_LIFE) != 0 ) return true;
if ((this.shard & Atom.OR_2_LIFE) != 0) {
return true;
}
// can pay with any color?
if ( (this.shard & Atom.OR_2_COLORLESS) != 0 || 0 != ( this.shard & Atom.COLORLESS ) ) return true;
if ((this.shard & Atom.OR_2_COLORLESS) != 0 || 0 != (this.shard & Atom.COLORLESS)) {
return true;
}
// either colored part is empty, or there are same colors in shard and mana source
return ( 0xFF & this.shard ) == 0 || ( color.getColor() & this.shard ) > 0;
return (0xFF & this.shard) == 0 || (color.getColor() & this.shard) > 0;
}
}

View File

@@ -178,9 +178,9 @@ public class ManaPool {
*/
public final int clearPool(boolean isEndOfPhase) {
int numRemoved = 0;
if (isEndOfPhase &&
Singletons.getModel().getGame().getStaticEffects().getGlobalRuleChange(GlobalRuleChange.manapoolsDontEmpty)) {
if (isEndOfPhase
&& Singletons.getModel().getGame().getStaticEffects().getGlobalRuleChange(GlobalRuleChange.manapoolsDontEmpty)) {
return numRemoved;
}

View File

@@ -41,7 +41,7 @@ import forge.util.Expressions;
public abstract class ReplacementEffect extends TriggerReplacementBase {
private ReplacementLayer layer = ReplacementLayer.None;
/** The has run. */
private boolean hasRun = false;
@@ -102,7 +102,7 @@ public abstract class ReplacementEffect extends TriggerReplacementBase {
if (Expressions.compare(left, comparator, compareTo)) {
return true;
}
} else if (sa != null && sa.doTrigger(false)){
} else if (sa != null && sa.doTrigger(false)) {
return true;
}
@@ -204,7 +204,7 @@ public abstract class ReplacementEffect extends TriggerReplacementBase {
return false;
}
}
if (this.getMapParams().containsKey("PlayerTurn")) {
if (this.getMapParams().get("PlayerTurn").equals("True") && !Singletons.getModel().getGame().getPhaseHandler().isPlayerTurn(this.getHostCard().getController())) {
return false;

View File

@@ -89,7 +89,7 @@ public class ReplacementHandler {
* the run params,same as for triggers.
* @return true if the event was replaced.
*/
public ReplacementResult run(final HashMap<String, Object> runParams, final ReplacementLayer layer,final Player decider) {
public ReplacementResult run(final HashMap<String, Object> runParams, final ReplacementLayer layer, final Player decider) {
final List<ReplacementEffect> possibleReplacers = new ArrayList<ReplacementEffect>();
// Round up Non-static replacement effects ("Until EOT," or
@@ -283,7 +283,7 @@ public class ReplacementHandler {
} else if (eventToReplace.equals("Moved")) {
ret = new ReplaceMoved(mapParams, host);
}
String activeZones = mapParams.get("ActiveZones");
if (null != activeZones) {
ret.setActiveZone(EnumSet.copyOf(ZoneType.listValueOf(activeZones)));

View File

@@ -10,7 +10,7 @@ public enum ReplacementLayer {
Copy,
Other,
None;
/**
* TODO: Write javadoc for this method.
* @param substring

View File

@@ -106,7 +106,7 @@ public abstract class AbilityActivated extends SpellAbility implements java.io.S
return false;
}
if (this.isCycling()
if (this.isCycling()
&& Singletons.getModel().getGame().getStaticEffects().getGlobalRuleChange(GlobalRuleChange.noCycling)) {
return false;
}
@@ -117,7 +117,7 @@ public abstract class AbilityActivated extends SpellAbility implements java.io.S
return CostPayment.canPayAdditionalCosts(this.getPayCosts(), this);
}
/* (non-Javadoc)
* @see forge.card.spellability.SpellAbility#resolve()
*/

View File

@@ -45,7 +45,7 @@ public class AbilityManaPart implements java.io.Serializable {
private String origProduced;
private String lastExpressChoice = "";
private String manaRestrictions = "";
transient private ArrayList<Mana> lastProduced = new ArrayList<Mana>();
private transient ArrayList<Mana> lastProduced = new ArrayList<Mana>();
private int amount = 1;
/** The reflected. */
@@ -54,13 +54,13 @@ public class AbilityManaPart implements java.io.Serializable {
/** The canceled. */
private boolean canceled = false;
transient private final Card sourceCard;
private final transient Card sourceCard;
transient private Cost cost;
private transient Cost cost;
// Spells paid with this mana spell can't be countered.
private boolean cannotCounterSpell;
/**
* <p>
* Constructor for AbilityMana.
@@ -77,12 +77,12 @@ public class AbilityManaPart implements java.io.Serializable {
*/
public AbilityManaPart(final Card sourceCard, final Map<String, String> params) {
this.sourceCard = sourceCard;
origProduced = params.containsKey("Produced") ? params.get("Produced") : "1";
if (params.containsKey("RestrictValid")) {
this.manaRestrictions = params.get("RestrictValid");
}
this.cannotCounterSpell = params.containsKey("AddsNoCounter");
}
@@ -91,7 +91,7 @@ public class AbilityManaPart implements java.io.Serializable {
* <p>
* produceMana.
* </p>
* @param ability
* @param ability
*/
public final void produceMana(SpellAbility sa) {
this.produceMana(this.getManaProduced(), this.getSourceCard().getController(), sa);
@@ -106,7 +106,7 @@ public class AbilityManaPart implements java.io.Serializable {
* a {@link java.lang.String} object.
* @param player
* a {@link forge.game.player.Player} object.
* @param sa
* @param sa
*/
public final void produceMana(final String produced, final Player player, SpellAbility sa) {
final Card source = this.getSourceCard();
@@ -448,8 +448,8 @@ public class AbilityManaPart implements java.io.Serializable {
// if (abm.getType() != this.getType()) {
// return false;
// }
return cost.equals(abm.cost) && sourceCard.equals(abm.sourceCard);
return cost.equals(abm.cost) && sourceCard.equals(abm.sourceCard);
// return abm.toUnsuppressedString().equals(this.toUnsuppressedString());
}

View File

@@ -180,7 +180,7 @@ public class AbilityTriggered extends Ability implements Command {
return (this.restrictions.length == 1)
&& this.restrictions[0].equals("named " + this.getSourceCard().getName());
}
@Override
public final boolean isTrigger() {
return true;

View File

@@ -1,7 +1,7 @@
package forge.card.spellability;
/**
* Will collect here essential methods needed to hold ability on stack and resolve
* Will collect here essential methods needed to hold ability on stack and resolve.
*
*/
public interface ISpellAbility {

View File

@@ -45,7 +45,7 @@ public abstract class Spell extends SpellAbility implements java.io.Serializable
/** Constant <code>serialVersionUID=-7930920571482203460L</code>. */
private static final long serialVersionUID = -7930920571482203460L;
private boolean castFaceDown = false;
/**
@@ -187,8 +187,8 @@ public abstract class Spell extends SpellAbility implements java.io.Serializable
public boolean isSpell() { return true; }
@Override
public boolean isAbility() { return false; }
/**
* <p>
* canPlayFromEffectAI.
@@ -215,7 +215,7 @@ public abstract class Spell extends SpellAbility implements java.io.Serializable
* @param faceDown the castFaceDown to set
*/
public void setCastFaceDown(boolean faceDown) {
this.castFaceDown = faceDown;
this.castFaceDown = faceDown;
}
}

View File

@@ -113,7 +113,7 @@ public abstract class SpellAbility implements ISpellAbility {
private List<Card> tappedForConvoke = new ArrayList<Card>();
private HashMap<String, String> sVars = new HashMap<String, String>();
private AbilityManaPart manaPart = null;
private boolean undoable;
@@ -124,7 +124,7 @@ public abstract class SpellAbility implements ISpellAbility {
public final boolean isManaAbility() {
return manaPart != null && isAbility();
}
public final void setManaPart(AbilityManaPart manaPart) {
this.manaPart = manaPart;
@@ -141,7 +141,7 @@ public abstract class SpellAbility implements ISpellAbility {
public Set<String> getSVars() {
return sVars.keySet();
}
/**
* <p>
* Constructor for SpellAbility.
@@ -342,7 +342,7 @@ public abstract class SpellAbility implements ISpellAbility {
public boolean isBuyBackAbility() {
return this.optionalAdditionalCosts.contains("Buyback");
}
/**
* <p>
* isKicked.
@@ -353,7 +353,7 @@ public abstract class SpellAbility implements ISpellAbility {
public boolean isKicked() {
return isOptionalAdditionalCostPaid("Kicker");
}
/**
* <p>
* isOptionalAdditionalCostPaid.
@@ -512,7 +512,7 @@ public abstract class SpellAbility implements ISpellAbility {
return params == null ? null : params.get(key);
}
public boolean hasParam(String key) {
return params == null ? false: params.containsKey(key);
return params == null ? false : params.containsKey(key);
}
/**
@@ -520,18 +520,19 @@ public abstract class SpellAbility implements ISpellAbility {
* @param mapParams
*/
public void copyParamsToMap(Map<String, String> mapParams) {
if ( null != params )
if (null != params) {
mapParams.putAll(params);
}
}
}
// If this is not null, then ability was made in a factory
public ApiType getApi() {
return api;
}
public final boolean isCurse() {
return this.hasParam("IsCurse");
}
}
/**
* <p>
@@ -1664,7 +1665,7 @@ public abstract class SpellAbility implements ISpellAbility {
public List<Card> knownDetermineDefined(final String defined) {
final List<Card> ret = new ArrayList<Card>();
final ArrayList<Card> list = AbilityFactory.getDefinedCards(getSourceCard(), defined, this);
for (final Card c : list) {
final Card actualCard = Singletons.getModel().getGame().getCardState(c);
ret.add(actualCard);
@@ -1684,7 +1685,7 @@ public abstract class SpellAbility implements ISpellAbility {
while (null != parent.getParent()) {
parent = parent.getParent();
}
return parent;
}
@@ -1701,11 +1702,13 @@ public abstract class SpellAbility implements ISpellAbility {
*/
public SpellAbility getParentTargetingCard() {
SpellAbility parent = this;
while( parent.getParent() != null)
{
while (parent.getParent() != null) {
Target tgt = parent.getTarget();
if ( tgt != null && tgt.getTargetCards() != null && !tgt.getTargetCards().isEmpty() ) break;
if (tgt != null && tgt.getTargetCards() != null && !tgt.getTargetCards().isEmpty()) {
break;
}
parent = parent.getParent();
}
return parent;
@@ -1720,10 +1723,12 @@ public abstract class SpellAbility implements ISpellAbility {
*/
public SpellAbility getParentTargetingSA() {
SpellAbility parent = this;
while( parent.getParent() != null)
{
while (parent.getParent() != null) {
Target tgt = parent.getTarget();
if ( tgt != null && tgt.getTargetSAs() != null && !tgt.getTargetSAs().isEmpty() ) break;
if (tgt != null && tgt.getTargetSAs() != null && !tgt.getTargetSAs().isEmpty()) {
break;
}
parent = parent.getParent();
}
return parent;
@@ -1738,10 +1743,12 @@ public abstract class SpellAbility implements ISpellAbility {
*/
public SpellAbility getParentTargetingPlayer() {
SpellAbility parent = this;
while( parent.getParent() != null)
{
while (parent.getParent() != null) {
Target tgt = parent.getTarget();
if ( tgt != null && tgt.getTargetPlayers() != null && !tgt.getTargetPlayers().isEmpty() ) break;
if (tgt != null && tgt.getTargetPlayers() != null && !tgt.getTargetPlayers().isEmpty()) {
break;
}
parent = parent.getParent();
}
return parent;
@@ -1759,8 +1766,9 @@ public abstract class SpellAbility implements ISpellAbility {
* TODO: Write javadoc for this method.
*/
public void undo() {
if ( isUndoable() )
if (isUndoable()) {
this.payCosts.refundPaidCost(sourceCard);
}
}
/**

View File

@@ -190,7 +190,7 @@ public class SpellAbilityRestriction extends SpellAbilityVariables {
if (cardZone == null || !cardZone.is(this.getZone())) {
// If Card is not in the default activating zone, do some additional checks
// Not a Spell, or on Battlefield, return false
if (!sa.isSpell() || (cardZone != null && ZoneType.Battlefield.equals(cardZone.getZoneType()))
if (!sa.isSpell() || (cardZone != null && ZoneType.Battlefield.equals(cardZone.getZoneType()))
|| !this.getZone().equals(ZoneType.Hand)) {
return false;
}

View File

@@ -513,7 +513,7 @@ public class SpellAbilityVariables {
public void setKicked(boolean kicked) {
this.kicked = kicked;
}
/**
* <p>

View File

@@ -104,7 +104,7 @@ public class SpellPermanent extends Spell {
} else if (controller.isHuman()) {
Singletons.getModel().getMatch().getInput().setInput(SpellPermanent.this.championInputComes);
} else { // Computer
List<Card> computer =
List<Card> computer =
CardLists.getValidCards(controller.getCardsIn(ZoneType.Battlefield), SpellPermanent.this.championValid, controller, source);
computer.remove(source);
@@ -248,10 +248,10 @@ public class SpellPermanent extends Spell {
sourceCard.addComesIntoPlayCommand(this.championCommandComes);
sourceCard.addLeavesPlayCommand(this.championCommandLeavesPlay);
}
if(this.getManaCost().contains("X"))
{
if(!this.getSourceCard().getSVar("X").equals("")) {
if (this.getManaCost().contains("X")) {
if (!this.getSourceCard().getSVar("X").equals("")) {
this.setSVar("X", this.getSourceCard().getSVar("X"));
}
}
@@ -324,11 +324,11 @@ public class SpellPermanent extends Spell {
if (mandatory) {
return true;
}
final Player ai = getActivatingPlayer();
final Player ai = getActivatingPlayer();
final Card card = this.getSourceCard();
String mana = this.getPayCosts().getTotalMana();
final Cost cost = this.getPayCosts();
if (cost != null) {
// AI currently disabled for these costs
if (!CostUtil.checkLifeCost(ai, cost, card, 4, null)) {
@@ -347,10 +347,10 @@ public class SpellPermanent extends Spell {
return false;
}
}
// check on legendary
if (card.isType("Legendary") &&
!Singletons.getModel().getGame().getStaticEffects().getGlobalRuleChange(GlobalRuleChange.noLegendRule)) {
if (card.isType("Legendary")
&& !Singletons.getModel().getGame().getStaticEffects().getGlobalRuleChange(GlobalRuleChange.noLegendRule)) {
final List<Card> list = ai.getCardsIn(ZoneType.Battlefield);
if (Iterables.any(list, CardPredicates.nameEquals(card.getName()))) {
return false;
@@ -391,7 +391,7 @@ public class SpellPermanent extends Spell {
}
final List<Card> cl = this.championGetCreature.get();
if ( !(cl.size() > 0) || !this.getSourceCard().isInZone(ZoneType.Hand)) {
if (!(cl.size() > 0) || !this.getSourceCard().isInZone(ZoneType.Hand)) {
return false;
}
}
@@ -411,7 +411,7 @@ public class SpellPermanent extends Spell {
private static boolean checkETBEffects(final Card card, final SpellAbility sa, final ApiType api, final Player ai) {
if (card.isCreature()
if (card.isCreature()
&& Singletons.getModel().getGame().getStaticEffects().getGlobalRuleChange(GlobalRuleChange.noCreatureETBTriggers)) {
return true;
}
@@ -564,12 +564,12 @@ public class SpellPermanent extends Spell {
else {
throw new InvalidParameterException("Either ai or sa must be not null!");
}
if (exSA.getActivatingPlayer() == null) {
throw new InvalidParameterException("Executing SpellAbility for Replacement Effect has no activating player");
}
}
// ETBReplacement uses overriding abilities.
// These checks only work if the Executing SpellAbility is an
// Ability_Sub.

View File

@@ -716,9 +716,11 @@ public class Target {
for (final Card c : Singletons.getModel().getGame().getCardsIn(this.tgtZone)) {
boolean isValidTarget = c.isValid(this.validTgts, this.srcCard.getController(), this.srcCard);
boolean canTarget = (!isTargeted || c.canBeTargetedBy(sa));
boolean isAlreadyTargeted = this.getTargetCards().contains(c);
boolean isAlreadyTargeted = this.getTargetCards().contains(c);
//System.out.print(c);
if ( isValidTarget && canTarget && !isAlreadyTargeted ) return true;
if (isValidTarget && canTarget && !isAlreadyTargeted) {
return true;
}
}
}

View File

@@ -153,7 +153,7 @@ public class TargetChoices {
}
return false;
}
/**
* <p>
* removeTarget.
@@ -172,7 +172,7 @@ public class TargetChoices {
}
return false;
}
/**
* <p>
* removeTarget.
@@ -191,7 +191,7 @@ public class TargetChoices {
}
return false;
}
/**
* <p>
* Getter for the field <code>targetCards</code>.

View File

@@ -698,7 +698,7 @@ public class TargetSelection {
return false;
}
/**
* <p>
* matchesValidSA.