From ad7f49d808a1a98eb7661222b662c8431d6a4405 Mon Sep 17 00:00:00 2001 From: jendave Date: Mon, 31 Oct 2011 14:49:15 +0000 Subject: [PATCH] checkstyle and refactor --- .../card/cardFactory/AbstractCardFactory.java | 2 +- .../cardFactory/CardFactory_Creatures.java | 2 +- .../java/forge/card/spellability/Ability.java | 17 +- .../card/spellability/Ability_Activated.java | 36 +- .../forge/card/spellability/Ability_Mana.java | 60 +-- .../forge/card/spellability/Ability_Sub.java | 2 +- .../card/spellability/Ability_Triggered.java | 52 +-- .../java/forge/card/spellability/Spell.java | 42 +- .../forge/card/spellability/SpellAbility.java | 366 ++++++++++-------- .../card/spellability/SpellAbilityList.java | 36 +- .../spellability/SpellAbility_Condition.java | 123 +++--- .../SpellAbility_Requirements.java | 98 ++--- .../SpellAbility_Restriction.java | 134 +++---- .../SpellAbility_StackInstance.java | 77 ++-- .../spellability/SpellAbility_Variables.java | 42 +- .../card/spellability/Spell_Permanent.java | 127 +++--- .../java/forge/card/spellability/Target.java | 128 +++--- .../card/spellability/Target_Choices.java | 58 +-- .../card/spellability/Target_Selection.java | 157 ++++---- .../gui/input/Input_PayManaCost_Ability.java | 2 +- 20 files changed, 802 insertions(+), 759 deletions(-) diff --git a/src/main/java/forge/card/cardFactory/AbstractCardFactory.java b/src/main/java/forge/card/cardFactory/AbstractCardFactory.java index 7eee8363aae..05ee47bebed 100644 --- a/src/main/java/forge/card/cardFactory/AbstractCardFactory.java +++ b/src/main/java/forge/card/cardFactory/AbstractCardFactory.java @@ -94,7 +94,7 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn * a {@link java.io.File} object. */ protected AbstractCardFactory(final File file) { - final SpellAbility spell = new SpellAbility(SpellAbility.Spell, this.blankCard) { + final SpellAbility spell = new SpellAbility(SpellAbility.getSpell(), this.blankCard) { // neither computer nor human play can play this card @Override public boolean canPlay() { diff --git a/src/main/java/forge/card/cardFactory/CardFactory_Creatures.java b/src/main/java/forge/card/cardFactory/CardFactory_Creatures.java index 4930606a761..81b31010233 100644 --- a/src/main/java/forge/card/cardFactory/CardFactory_Creatures.java +++ b/src/main/java/forge/card/cardFactory/CardFactory_Creatures.java @@ -2638,7 +2638,7 @@ public class CardFactory_Creatures { abilityBuilder.append(" | SpellDescription$ Target creature can't block CARDNAME this turn."); final SpellAbility myAb = createAb.getAbility(abilityBuilder.toString(), card); - myAb.getTarget().setTargetChoices(this.chosenTarget.getTargetChoices()); + myAb.getTarget().setTargetChoices(this.getChosenTarget().getTargetChoices()); myAb.resolve(); } diff --git a/src/main/java/forge/card/spellability/Ability.java b/src/main/java/forge/card/spellability/Ability.java index cff8606ef03..275d3727f81 100644 --- a/src/main/java/forge/card/spellability/Ability.java +++ b/src/main/java/forge/card/spellability/Ability.java @@ -19,7 +19,7 @@ import forge.Constant.Zone; */ public abstract class Ability extends SpellAbility { // Slight hack for Pithing Needle - private String sourceCardName; + private final String sourceCardName; /** *

@@ -32,9 +32,9 @@ public abstract class Ability extends SpellAbility { * a {@link java.lang.String} object. */ public Ability(final Card sourceCard, final String manaCost) { - super(SpellAbility.Ability, sourceCard); - setManaCost(manaCost); - sourceCardName = sourceCard.getName(); + super(SpellAbility.getAbility(), sourceCard); + this.setManaCost(manaCost); + this.sourceCardName = sourceCard.getName(); } /** @@ -51,7 +51,7 @@ public abstract class Ability extends SpellAbility { */ public Ability(final Card sourceCard, final String manaCost, final String stackDescription) { this(sourceCard, manaCost); - setStackDescription(stackDescription); + this.setStackDescription(stackDescription); Log.debug("an ability is being played from" + sourceCard.getName()); } @@ -66,12 +66,13 @@ public abstract class Ability extends SpellAbility { pithing.addAll(AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield)); pithing = pithing.getName("Pithing Needle"); pithing = pithing.filter(new CardListFilter() { + @Override public boolean addCard(final Card c) { - return c.getSVar("PithingTarget").equals(sourceCardName); + return c.getSVar("PithingTarget").equals(Ability.this.sourceCardName); } }); - return AllZoneUtil.isCardInPlay(getSourceCard()) && !getSourceCard().isFaceDown() - && !getSourceCard().getName().equals("Spreading Seas") && pithing.size() == 0; + return AllZoneUtil.isCardInPlay(this.getSourceCard()) && !this.getSourceCard().isFaceDown() + && !this.getSourceCard().getName().equals("Spreading Seas") && (pithing.size() == 0); } } diff --git a/src/main/java/forge/card/spellability/Ability_Activated.java b/src/main/java/forge/card/spellability/Ability_Activated.java index 2e13f2e8023..ca86b7f2648 100644 --- a/src/main/java/forge/card/spellability/Ability_Activated.java +++ b/src/main/java/forge/card/spellability/Ability_Activated.java @@ -52,11 +52,11 @@ public abstract class Ability_Activated extends SpellAbility implements java.io. * a {@link forge.card.spellability.Target} object. */ public Ability_Activated(final Card sourceCard, final Cost abCost, final Target tgt) { - super(SpellAbility.Ability, sourceCard); - setManaCost(abCost.getTotalMana()); - setPayCosts(abCost); - if (tgt != null && tgt.doesTarget()) { - setTarget(tgt); + super(SpellAbility.getAbility(), sourceCard); + this.setManaCost(abCost.getTotalMana()); + this.setPayCosts(abCost); + if ((tgt != null) && tgt.doesTarget()) { + this.setTarget(tgt); } } @@ -67,26 +67,27 @@ public abstract class Ability_Activated extends SpellAbility implements java.io. return false; } - final Card c = getSourceCard(); - if (c.isFaceDown() && isIntrinsic()) { // Intrinsic abilities can't be - // activated by face down cards + final Card c = this.getSourceCard(); + if (c.isFaceDown() && this.isIntrinsic()) { // Intrinsic abilities can't + // be + // activated by face down cards return false; } - Player activator = getActivatingPlayer(); + final Player activator = this.getActivatingPlayer(); // CantBeActivated 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) { if (stAb.applyAbility("CantBeActivated", c, activator)) { return false; } } } - if (c.hasKeyword("CARDNAME's activated abilities can't be activated.") || isSuppressed()) { + if (c.hasKeyword("CARDNAME's activated abilities can't be activated.") || this.isSuppressed()) { return false; } @@ -94,19 +95,20 @@ public abstract class Ability_Activated extends SpellAbility implements java.io. pithing.addAll(AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield)); pithing = pithing.getName("Pithing Needle"); pithing = pithing.filter(new CardListFilter() { + @Override public boolean addCard(final Card crd) { return crd.getSVar("PithingTarget").equals(c.getName()); } }); - if (pithing.size() != 0 && !(this instanceof Ability_Mana)) { + if ((pithing.size() != 0) && !(this instanceof Ability_Mana)) { return false; } - if (!(getRestrictions().canPlay(c, this))) { + if (!(this.getRestrictions().canPlay(c, this))) { return false; } - return Cost_Payment.canPayAdditionalCosts(payCosts, this); + return Cost_Payment.canPayAdditionalCosts(this.getPayCosts(), this); } } diff --git a/src/main/java/forge/card/spellability/Ability_Mana.java b/src/main/java/forge/card/spellability/Ability_Mana.java index b78409a47c8..5bb18d3beab 100644 --- a/src/main/java/forge/card/spellability/Ability_Mana.java +++ b/src/main/java/forge/card/spellability/Ability_Mana.java @@ -100,8 +100,8 @@ public abstract class Ability_Mana extends Ability_Activated implements java.io. public Ability_Mana(final Card sourceCard, final Cost cost, final String produced, final int num) { super(sourceCard, cost, null); - origProduced = produced; - amount = num; + this.origProduced = produced; + this.amount = num; } /** {@inheritDoc} */ @@ -113,7 +113,7 @@ public abstract class Ability_Mana extends Ability_Activated implements java.io. /** {@inheritDoc} */ @Override public void resolve() { - produceMana(); + this.produceMana(); } /** @@ -122,25 +122,25 @@ public abstract class Ability_Mana extends Ability_Activated implements java.io. *

*/ public final void produceMana() { - StringBuilder sb = new StringBuilder(); - if (amount == 0) { + final StringBuilder sb = new StringBuilder(); + if (this.amount == 0) { sb.append("0"); } else { try { // if baseMana is an integer(colorless), just multiply amount // and baseMana - int base = Integer.parseInt(origProduced); - sb.append(base * amount); - } catch (NumberFormatException e) { - for (int i = 0; i < amount; i++) { + final int base = Integer.parseInt(this.origProduced); + sb.append(base * this.amount); + } catch (final NumberFormatException e) { + for (int i = 0; i < this.amount; i++) { if (i != 0) { sb.append(" "); } - sb.append(origProduced); + sb.append(this.origProduced); } } } - produceMana(sb.toString(), this.getSourceCard().getController()); + this.produceMana(sb.toString(), this.getSourceCard().getController()); } /** @@ -155,7 +155,7 @@ public abstract class Ability_Mana extends Ability_Activated implements java.io. */ public final void produceMana(final String produced, final Player player) { final Card source = this.getSourceCard(); - ManaPool manaPool = player.getManaPool(); + final ManaPool manaPool = player.getManaPool(); // change this, once ManaPool moves to the Player // this.getActivatingPlayer().ManaPool.addManaToFloating(origProduced, // getSourceCard()); @@ -175,7 +175,7 @@ public abstract class Ability_Mana extends Ability_Activated implements java.io. } // Run triggers - HashMap runParams = new HashMap(); + final HashMap runParams = new HashMap(); runParams.put("Card", source); runParams.put("Player", player); @@ -193,7 +193,7 @@ public abstract class Ability_Mana extends Ability_Activated implements java.io. * @return a {@link java.lang.String} object. */ public final String mana() { - return origProduced; + return this.origProduced; } /** @@ -205,7 +205,7 @@ public abstract class Ability_Mana extends Ability_Activated implements java.io. * a {@link java.lang.String} object. */ public final void setMana(final String s) { - origProduced = s; + this.origProduced = s; } /** @@ -217,7 +217,7 @@ public abstract class Ability_Mana extends Ability_Activated implements java.io. * a boolean. */ public final void setReflectedMana(final boolean bReflect) { - reflected = bReflect; + this.reflected = bReflect; } /** @@ -239,7 +239,7 @@ public abstract class Ability_Mana extends Ability_Activated implements java.io. * @return a boolean. */ public final boolean isSacrifice() { - return payCosts.getSacCost(); + return this.getPayCosts().getSacCost(); } /** @@ -250,7 +250,7 @@ public abstract class Ability_Mana extends Ability_Activated implements java.io. * @return a boolean. */ public final boolean isReflectedMana() { - return reflected; + return this.reflected; } /** @@ -263,7 +263,7 @@ public abstract class Ability_Mana extends Ability_Activated implements java.io. * @return a boolean. */ public final boolean canProduce(final String s) { - return origProduced.contains(s); + return this.origProduced.contains(s); } /** @@ -274,11 +274,11 @@ public abstract class Ability_Mana extends Ability_Activated implements java.io. * @return a boolean. */ public final boolean isBasic() { - if (origProduced.length() != 1) { + if (this.origProduced.length() != 1) { return false; } - if (amount > 1) { + if (this.amount > 1) { return false; } @@ -293,7 +293,7 @@ public abstract class Ability_Mana extends Ability_Activated implements java.io. * @return a boolean. */ public final boolean isUndoable() { - return undoable && getPayCosts().isUndoable() && AllZoneUtil.isCardInPlay(getSourceCard()); + return this.undoable && this.getPayCosts().isUndoable() && AllZoneUtil.isCardInPlay(this.getSourceCard()); } /** @@ -305,7 +305,7 @@ public abstract class Ability_Mana extends Ability_Activated implements java.io. * a boolean. */ public final void setUndoable(final boolean bUndo) { - undoable = bUndo; + this.undoable = bUndo; } /** @@ -317,7 +317,7 @@ public abstract class Ability_Mana extends Ability_Activated implements java.io. * a boolean. */ public final void setCanceled(final boolean bCancel) { - canceled = bCancel; + this.canceled = bCancel; } /** @@ -328,7 +328,7 @@ public abstract class Ability_Mana extends Ability_Activated implements java.io. * @return a boolean. */ public final boolean getCanceled() { - return canceled; + return this.canceled; } /** @@ -337,8 +337,8 @@ public abstract class Ability_Mana extends Ability_Activated implements java.io. *

*/ public final void undo() { - if (isUndoable()) { - getPayCosts().refundPaidCost(getSourceCard()); + if (this.isUndoable()) { + this.getPayCosts().refundPaidCost(this.getSourceCard()); } } @@ -346,13 +346,13 @@ public abstract class Ability_Mana extends Ability_Activated implements java.io. @Override public final boolean equals(final Object o) { // Mana abilities with same Descriptions are "equal" - if (o == null || !(o instanceof Ability_Mana)) { + if ((o == null) || !(o instanceof Ability_Mana)) { return false; } - Ability_Mana abm = (Ability_Mana) o; + final Ability_Mana abm = (Ability_Mana) o; - if (abm.getType() != getType()) { + if (abm.getType() != this.getType()) { return false; } diff --git a/src/main/java/forge/card/spellability/Ability_Sub.java b/src/main/java/forge/card/spellability/Ability_Sub.java index 6dfd5c6dee0..5b2584159d3 100644 --- a/src/main/java/forge/card/spellability/Ability_Sub.java +++ b/src/main/java/forge/card/spellability/Ability_Sub.java @@ -27,7 +27,7 @@ public abstract class Ability_Sub extends SpellAbility implements java.io.Serial * a {@link forge.card.spellability.Target} object. */ public Ability_Sub(final Card sourceCard, final Target tgt) { - super(SpellAbility.Ability, sourceCard); + super(SpellAbility.getAbility(), sourceCard); this.setTarget(tgt); } diff --git a/src/main/java/forge/card/spellability/Ability_Triggered.java b/src/main/java/forge/card/spellability/Ability_Triggered.java index 29962560cc5..57483de6eda 100644 --- a/src/main/java/forge/card/spellability/Ability_Triggered.java +++ b/src/main/java/forge/card/spellability/Ability_Triggered.java @@ -30,24 +30,25 @@ public class Ability_Triggered extends Ability implements Command { /** * Gets the trigger. - * + * * @return the trigger */ public final ZCTrigger getTrigger() { - return trigger; + return this.trigger; } /** * Sets the trigger. - * - * @param trigger the new trigger + * + * @param trigger + * the new trigger */ public final void setTrigger(final ZCTrigger trigger) { - this.trigger = trigger; + this.trigger = trigger; } /** The todo. */ - private Command todo; + private final Command todo; /** *

@@ -63,15 +64,15 @@ public class Ability_Triggered extends Ability implements Command { */ public Ability_Triggered(final Card sourceCard, final Command sourceCommand, final ZCTrigger situation) { super(sourceCard, "0"); - setTrigger(true); - todo = sourceCommand; - trigger = situation; - if (todo instanceof Ability_Triggered) { - setStackDescription(((SpellAbility) todo).getStackDescription()); - restrictions = ((Ability_Triggered) todo).restrictions; + this.setTrigger(true); + this.todo = sourceCommand; + this.trigger = situation; + if (this.todo instanceof Ability_Triggered) { + this.setStackDescription(((SpellAbility) this.todo).getStackDescription()); + this.restrictions = ((Ability_Triggered) this.todo).restrictions; } else { - setStackDescription("Triggered ability: " + sourceCard + " " + situation); - restrictions = new String[] {"named " + sourceCard.getName()}; + this.setStackDescription("Triggered ability: " + sourceCard + " " + situation); + this.restrictions = new String[] { "named " + sourceCard.getName() }; } } @@ -90,7 +91,7 @@ public class Ability_Triggered extends Ability implements Command { /** {@inheritDoc} */ @Override public final void resolve() { - todo.execute(); + this.todo.execute(); } /** @@ -98,8 +99,9 @@ public class Ability_Triggered extends Ability implements Command { * execute. *

*/ + @Override public final void execute() { - resolve(); + this.resolve(); } /** @@ -112,7 +114,7 @@ public class Ability_Triggered extends Ability implements Command { * @return a boolean. */ public final boolean triggerFor(final Card c) { - return !(new CardList(c)).getValidCards(restrictions, c.getController(), c).isEmpty(); + return !(new CardList(c)).getValidCards(this.restrictions, c.getController(), c).isEmpty(); } /** @@ -127,19 +129,20 @@ public class Ability_Triggered extends Ability implements Command { * @return a boolean. */ public final boolean triggerOnZoneChange(final String sourceZone, final String destinationZone) { - return trigger.triggerOn(sourceZone, destinationZone); + return this.trigger.triggerOn(sourceZone, destinationZone); } /** {@inheritDoc} */ @Override - public final boolean equals(final Object o) // TODO triggers affecting other cards - { + public final boolean equals(final Object o) { + // TODO triggers affecting other + // cards if (!(o instanceof Ability_Triggered)) { return false; } - Ability_Triggered tmp = (Ability_Triggered) o; - return tmp.getSourceCard().equals(getSourceCard()) && tmp.trigger.equals(trigger) && tmp.todo.equals(todo) - && Arrays.equals(tmp.restrictions, restrictions); + final Ability_Triggered tmp = (Ability_Triggered) o; + return tmp.getSourceCard().equals(this.getSourceCard()) && tmp.trigger.equals(this.trigger) + && tmp.todo.equals(this.todo) && Arrays.equals(tmp.restrictions, this.restrictions); } /** @@ -150,6 +153,7 @@ public class Ability_Triggered extends Ability implements Command { * @return a boolean. */ public final boolean isBasic() { - return restrictions.length == 1 && restrictions[0].equals("named " + getSourceCard().getName()); + return (this.restrictions.length == 1) + && this.restrictions[0].equals("named " + this.getSourceCard().getName()); } } diff --git a/src/main/java/forge/card/spellability/Spell.java b/src/main/java/forge/card/spellability/Spell.java index 7dc019dbc5d..aa1db02e3a0 100644 --- a/src/main/java/forge/card/spellability/Spell.java +++ b/src/main/java/forge/card/spellability/Spell.java @@ -37,11 +37,11 @@ public abstract class Spell extends SpellAbility implements java.io.Serializable * a {@link forge.Card} object. */ public Spell(final Card sourceCard) { - super(SpellAbility.Spell, sourceCard); + super(SpellAbility.getSpell(), sourceCard); - setManaCost(sourceCard.getManaCost()); - setStackDescription(sourceCard.getSpellText()); - getRestrictions().setZone(Constant.Zone.Hand); + this.setManaCost(sourceCard.getManaCost()); + this.setStackDescription(sourceCard.getSpellText()); + this.getRestrictions().setZone(Constant.Zone.Hand); } /** @@ -57,14 +57,14 @@ public abstract class Spell extends SpellAbility implements java.io.Serializable * a {@link forge.card.spellability.Target} object. */ public Spell(final Card sourceCard, final Cost abCost, final Target abTgt) { - super(SpellAbility.Spell, sourceCard); + super(SpellAbility.getSpell(), sourceCard); - setManaCost(sourceCard.getManaCost()); + this.setManaCost(sourceCard.getManaCost()); - setPayCosts(abCost); - setTarget(abTgt); - setStackDescription(sourceCard.getSpellText()); - getRestrictions().setZone(Constant.Zone.Hand); + this.setPayCosts(abCost); + this.setTarget(abTgt); + this.setStackDescription(sourceCard.getSpellText()); + this.getRestrictions().setZone(Constant.Zone.Hand); } /** {@inheritDoc} */ @@ -74,16 +74,16 @@ public abstract class Spell extends SpellAbility implements java.io.Serializable return false; } - Card card = getSourceCard(); + final Card card = this.getSourceCard(); - Player activator = getActivatingPlayer(); + final Player activator = this.getActivatingPlayer(); // CantBeCast static abilities - CardList allp = AllZoneUtil.getCardsIn(Zone.Battlefield); + final CardList allp = AllZoneUtil.getCardsIn(Zone.Battlefield); allp.add(card); - for (Card ca : allp) { - ArrayList staticAbilities = ca.getStaticAbilities(); - for (StaticAbility stAb : staticAbilities) { + for (final Card ca : allp) { + final ArrayList staticAbilities = ca.getStaticAbilities(); + for (final StaticAbility stAb : staticAbilities) { if (stAb.applyAbility("CantBeCast", card, activator)) { return false; } @@ -94,8 +94,8 @@ public abstract class Spell extends SpellAbility implements java.io.Serializable return false; } - if (payCosts != null) { - if (!Cost_Payment.canPayAdditionalCosts(payCosts, this)) { + if (this.getPayCosts() != null) { + if (!Cost_Payment.canPayAdditionalCosts(this.getPayCosts(), this)) { return false; } } @@ -110,9 +110,9 @@ public abstract class Spell extends SpellAbility implements java.io.Serializable /** {@inheritDoc} */ @Override public boolean canPlayAI() { - Card card = getSourceCard(); + final Card card = this.getSourceCard(); if (card.getSVar("NeedsToPlay").length() > 0) { - String needsToPlay = card.getSVar("NeedsToPlay"); + final String needsToPlay = card.getSVar("NeedsToPlay"); CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield); list = list.getValidCards(needsToPlay.split(","), card.getController(), card); @@ -135,7 +135,7 @@ public abstract class Spell extends SpellAbility implements java.io.Serializable public final Object clone() { try { return super.clone(); - } catch (Exception ex) { + } catch (final Exception ex) { ErrorViewer.showError(ex); throw new RuntimeException("Spell : clone() error, " + ex); } diff --git a/src/main/java/forge/card/spellability/SpellAbility.java b/src/main/java/forge/card/spellability/SpellAbility.java index c258dca0c92..72308eb800b 100644 --- a/src/main/java/forge/card/spellability/SpellAbility.java +++ b/src/main/java/forge/card/spellability/SpellAbility.java @@ -27,13 +27,13 @@ import forge.gui.input.Input; public abstract class SpellAbility { /** The choices_made. */ - public Object[] choices_made; // open ended Casting choice storage + private Object[] choicesMade; // open ended Casting choice storage // choices for constructor isPermanent argument /** Constant Spell=0. */ - public static final int Spell = 0; + private static final int SPELL = 0; /** Constant Ability=1. */ - public static final int Ability = 1; + private static final int ABILITY = 1; private String description = ""; private Player targetPlayer = null; @@ -74,7 +74,7 @@ public abstract class SpellAbility { private int charmNumber; private int minCharmNumber; - private ArrayList charmChoices = new ArrayList(); + private final ArrayList charmChoices = new ArrayList(); // private ArrayList charmChoicesMade = new // ArrayList(); @@ -83,10 +83,10 @@ public abstract class SpellAbility { private Input afterPayMana; /** The pay costs. */ - protected Cost payCosts = null; + private Cost payCosts = null; /** The chosen target. */ - protected Target chosenTarget = null; + private Target chosenTarget = null; private SpellAbility_Restriction restrictions = new SpellAbility_Restriction(); private SpellAbility_Condition conditions = new SpellAbility_Condition(); @@ -94,8 +94,8 @@ public abstract class SpellAbility { private AbilityFactory abilityFactory = null; - private ArrayList payingMana = new ArrayList(); - private ArrayList paidAbilities = new ArrayList(); + private final ArrayList payingMana = new ArrayList(); + private final ArrayList paidAbilities = new ArrayList(); private HashMap paidLists = new HashMap(); @@ -108,6 +108,7 @@ public abstract class SpellAbility { private static final long serialVersionUID = 1795025064923737374L; + @Override public void execute(final Object o) { } }; @@ -119,20 +120,20 @@ public abstract class SpellAbility { * * @param spellOrAbility * a int. - * @param i_sourceCard + * @param iSourceCard * a {@link forge.Card} object. */ - public SpellAbility(final int spellOrAbility, final Card i_sourceCard) { - if (spellOrAbility == Spell) { - spell = true; - } else if (spellOrAbility == Ability) { - spell = false; + public SpellAbility(final int spellOrAbility, final Card iSourceCard) { + if (spellOrAbility == SpellAbility.getSpell()) { + this.spell = true; + } else if (spellOrAbility == SpellAbility.getAbility()) { + this.spell = false; } else { throw new RuntimeException("SpellAbility : constructor error, invalid spellOrAbility argument = " + spellOrAbility); } - sourceCard = i_sourceCard; + this.sourceCard = iSourceCard; } // Spell, and Ability, and other Ability objects override this method @@ -165,7 +166,7 @@ public abstract class SpellAbility { * @return true, if successful */ public final boolean canPlayAndAfford() { - return canPlay() && canAfford(); + return this.canPlay() && this.canAfford(); } // all Spell's and Abilities must override this method @@ -207,7 +208,7 @@ public abstract class SpellAbility { *

*/ public void chooseTargetAI() { - randomTarget.execute(this); + this.randomTarget.execute(this); } /** @@ -219,7 +220,7 @@ public abstract class SpellAbility { * a {@link forge.CommandArgs} object. */ public void setChooseTargetAI(final CommandArgs c) { - randomTarget = c; + this.randomTarget = c; } /** @@ -230,7 +231,7 @@ public abstract class SpellAbility { * @return a {@link forge.CommandArgs} object. */ public CommandArgs getChooseTargetAI() { - return randomTarget; + return this.randomTarget; } /** @@ -241,7 +242,7 @@ public abstract class SpellAbility { * @return a {@link java.lang.String} object. */ public String getManaCost() { - return manaCost; + return this.manaCost; } /** @@ -253,7 +254,7 @@ public abstract class SpellAbility { * a {@link java.lang.String} object. */ public void setManaCost(final String cost) { - manaCost = cost; + this.manaCost = cost; } /** @@ -264,7 +265,7 @@ public abstract class SpellAbility { * @return a {@link java.lang.String} object. */ public String getAdditionalManaCost() { - return additionalManaCost; + return this.additionalManaCost; } /** @@ -276,7 +277,7 @@ public abstract class SpellAbility { * a {@link java.lang.String} object. */ public void setAdditionalManaCost(final String cost) { - additionalManaCost = cost; + this.additionalManaCost = cost; } /** @@ -287,7 +288,7 @@ public abstract class SpellAbility { * @return a {@link java.lang.String} object. */ public String getMultiKickerManaCost() { - return multiKickerManaCost; + return this.multiKickerManaCost; } /** @@ -299,7 +300,7 @@ public abstract class SpellAbility { * a {@link java.lang.String} object. */ public void setMultiKickerManaCost(final String cost) { - multiKickerManaCost = cost; + this.multiKickerManaCost = cost; } /** @@ -310,7 +311,7 @@ public abstract class SpellAbility { * @return a {@link java.lang.String} object. */ public String getReplicateManaCost() { - return replicateManaCost; + return this.replicateManaCost; } /** @@ -322,7 +323,7 @@ public abstract class SpellAbility { * a {@link java.lang.String} object. */ public void setReplicateManaCost(final String cost) { - replicateManaCost = cost; + this.replicateManaCost = cost; } /** @@ -333,7 +334,7 @@ public abstract class SpellAbility { * @return a {@link java.lang.String} object. */ public String getXManaCost() { - return xManaCost; + return this.xManaCost; } /** @@ -345,7 +346,7 @@ public abstract class SpellAbility { * a {@link java.lang.String} object. */ public void setXManaCost(final String cost) { - xManaCost = cost; + this.xManaCost = cost; } /** @@ -356,7 +357,7 @@ public abstract class SpellAbility { * @return a {@link forge.Player} object. */ public Player getActivatingPlayer() { - return activatingPlayer; + return this.activatingPlayer; } /** @@ -369,9 +370,9 @@ public abstract class SpellAbility { */ public void setActivatingPlayer(final Player player) { // trickle down activating player - activatingPlayer = player; - if (subAbility != null) { - subAbility.setActivatingPlayer(player); + this.activatingPlayer = player; + if (this.subAbility != null) { + this.subAbility.setActivatingPlayer(player); } } @@ -383,7 +384,7 @@ public abstract class SpellAbility { * @return a boolean. */ public boolean isSpell() { - return spell; + return this.spell; } /** @@ -394,7 +395,7 @@ public abstract class SpellAbility { * @return a boolean. */ public boolean isAbility() { - return !isSpell(); + return !this.isSpell(); } /** @@ -405,7 +406,7 @@ public abstract class SpellAbility { * @return a boolean. */ public boolean isTapAbility() { - return tapAbility; + return this.tapAbility; } /** @@ -416,7 +417,7 @@ public abstract class SpellAbility { * @return a boolean. */ public boolean isUntapAbility() { - return untapAbility; + return this.untapAbility; } /** @@ -425,8 +426,8 @@ public abstract class SpellAbility { *

*/ public void makeUntapAbility() { - untapAbility = true; - tapAbility = false; + this.untapAbility = true; + this.tapAbility = false; } /** @@ -438,7 +439,7 @@ public abstract class SpellAbility { * a boolean. */ public void setIsBuyBackAbility(final boolean b) { - buyBackAbility = b; + this.buyBackAbility = b; } /** @@ -449,7 +450,7 @@ public abstract class SpellAbility { * @return a boolean. */ public boolean isBuyBackAbility() { - return buyBackAbility; + return this.buyBackAbility; } /** @@ -461,7 +462,7 @@ public abstract class SpellAbility { * a boolean. */ public void setIsMultiKicker(final boolean b) { - multiKicker = b; + this.multiKicker = b; } /** @@ -472,7 +473,7 @@ public abstract class SpellAbility { * @return a boolean. */ public boolean isMultiKicker() { - return multiKicker; + return this.multiKicker; } /** @@ -484,7 +485,7 @@ public abstract class SpellAbility { * a boolean. */ public void setIsReplicate(final boolean b) { - replicate = b; + this.replicate = b; } /** @@ -495,7 +496,7 @@ public abstract class SpellAbility { * @return a boolean. */ public boolean isReplicate() { - return replicate; + return this.replicate; } /** @@ -507,7 +508,7 @@ public abstract class SpellAbility { * a boolean. */ public void setIsXCost(final boolean b) { - xCost = b; + this.xCost = b; } /** @@ -518,7 +519,7 @@ public abstract class SpellAbility { * @return a boolean. */ public boolean isXCost() { - return xCost; + return this.xCost; } /** @@ -530,7 +531,7 @@ public abstract class SpellAbility { * a boolean. */ public void setIsCycling(final boolean b) { - cycling = b; + this.cycling = b; } /** @@ -540,8 +541,8 @@ public abstract class SpellAbility { * * @return a boolean. */ - public boolean isCycling() { - return cycling; + public boolean isCycling() { + return this.cycling; } /** @@ -552,8 +553,8 @@ public abstract class SpellAbility { * @param c * a {@link forge.Card} object. */ - public void setSourceCard(final Card c) { - sourceCard = c; + public void setSourceCard(final Card c) { + this.sourceCard = c; } /** @@ -564,7 +565,7 @@ public abstract class SpellAbility { * @return a {@link forge.Card} object. */ public Card getSourceCard() { - return sourceCard; + return this.sourceCard; } /** @@ -575,7 +576,7 @@ public abstract class SpellAbility { * @return a {@link forge.Command} object. */ public Command getBeforePayManaAI() { - return beforePayManaAI; + return this.beforePayManaAI; } /** @@ -587,7 +588,7 @@ public abstract class SpellAbility { * a {@link forge.Command} object. */ public void setBeforePayManaAI(final Command c) { - beforePayManaAI = c; + this.beforePayManaAI = c; } // begin - Input methods @@ -599,7 +600,7 @@ public abstract class SpellAbility { * @return a {@link forge.gui.input.Input} object. */ public Input getBeforePayMana() { - return beforePayMana; + return this.beforePayMana; } /** @@ -611,7 +612,7 @@ public abstract class SpellAbility { * a {@link forge.gui.input.Input} object. */ public void setBeforePayMana(final Input in) { - beforePayMana = in; + this.beforePayMana = in; } /** @@ -622,7 +623,7 @@ public abstract class SpellAbility { * @return a {@link forge.gui.input.Input} object. */ public Input getAfterPayMana() { - return afterPayMana; + return this.afterPayMana; } /** @@ -634,7 +635,7 @@ public abstract class SpellAbility { * a {@link forge.gui.input.Input} object. */ public void setAfterPayMana(final Input in) { - afterPayMana = in; + this.afterPayMana = in; } /** @@ -645,7 +646,7 @@ public abstract class SpellAbility { * @return a {@link forge.card.cost.Cost} object. */ public Cost getPayCosts() { - return payCosts; + return this.payCosts; } /** @@ -657,7 +658,7 @@ public abstract class SpellAbility { * a {@link forge.card.cost.Cost} object. */ public void setPayCosts(final Cost abCost) { - payCosts = abCost; + this.payCosts = abCost; } /** @@ -668,7 +669,7 @@ public abstract class SpellAbility { * @return a {@link forge.card.spellability.Target} object. */ public Target getTarget() { - return chosenTarget; + return this.getChosenTarget(); } /** @@ -680,7 +681,7 @@ public abstract class SpellAbility { * a {@link forge.card.spellability.Target} object. */ public void setTarget(final Target tgt) { - chosenTarget = tgt; + this.setChosenTarget(tgt); } /** @@ -693,7 +694,7 @@ public abstract class SpellAbility { * object. */ public void setRestrictions(final SpellAbility_Restriction restrict) { - restrictions = restrict; + this.restrictions = restrict; } /** @@ -705,7 +706,7 @@ public abstract class SpellAbility { * object. */ public SpellAbility_Restriction getRestrictions() { - return restrictions; + return this.restrictions; } /** @@ -716,7 +717,7 @@ public abstract class SpellAbility { * @return the activations this turn */ public int getActivationsThisTurn() { - return restrictions.getNumberTurnActivations(); + return this.restrictions.getNumberTurnActivations(); } /** @@ -730,7 +731,7 @@ public abstract class SpellAbility { * @since 1.0.15 */ public void setConditions(final SpellAbility_Condition condition) { - conditions = condition; + this.conditions = condition; } /** @@ -742,7 +743,7 @@ public abstract class SpellAbility { * @since 1.0.15 */ public SpellAbility_Condition getConditions() { - return conditions; + return this.conditions; } /** @@ -754,7 +755,7 @@ public abstract class SpellAbility { * a {@link forge.card.abilityFactory.AbilityFactory} object. */ public void setAbilityFactory(final AbilityFactory af) { - abilityFactory = af; + this.abilityFactory = af; } /** @@ -765,7 +766,7 @@ public abstract class SpellAbility { * @return a {@link forge.card.abilityFactory.AbilityFactory} object. */ public AbilityFactory getAbilityFactory() { - return abilityFactory; + return this.abilityFactory; } /** @@ -776,7 +777,7 @@ public abstract class SpellAbility { * @return a {@link java.util.ArrayList} object. */ public ArrayList getPayingMana() { - return payingMana; + return this.payingMana; } /** @@ -787,7 +788,7 @@ public abstract class SpellAbility { * @return a {@link java.util.ArrayList} object. */ public ArrayList getPayingManaAbilities() { - return paidAbilities; + return this.paidAbilities; } // Combined PaidLists @@ -800,7 +801,7 @@ public abstract class SpellAbility { * a {@link java.util.HashMap} object. */ public void setPaidHash(final HashMap hash) { - paidLists = hash; + this.paidLists = hash; } /** @@ -811,7 +812,7 @@ public abstract class SpellAbility { * @return a {@link java.util.HashMap} object. */ public HashMap getPaidHash() { - return paidLists; + return this.paidLists; } // Paid List are for things ca @@ -826,7 +827,7 @@ public abstract class SpellAbility { * a {@link java.lang.String} object. */ public void setPaidList(final CardList list, final String str) { - paidLists.put(str, list); + this.paidLists.put(str, list); } /** @@ -839,7 +840,7 @@ public abstract class SpellAbility { * @return a {@link forge.CardList} object. */ public CardList getPaidList(final String str) { - return paidLists.get(str); + return this.paidLists.get(str); } /** @@ -853,11 +854,11 @@ public abstract class SpellAbility { * a {@link java.lang.String} object. */ public void addCostToHashList(final Card c, final String str) { - if (!paidLists.containsKey(str)) { - paidLists.put(str, new CardList()); + if (!this.paidLists.containsKey(str)) { + this.paidLists.put(str, new CardList()); } - paidLists.get(str).add(c); + this.paidLists.get(str).add(c); } /** @@ -866,7 +867,7 @@ public abstract class SpellAbility { *

*/ public void resetPaidHash() { - paidLists = new HashMap(); + this.paidLists = new HashMap(); } /** @@ -878,7 +879,7 @@ public abstract class SpellAbility { * @since 1.0.15 */ public HashMap getTriggeringObjects() { - return triggeringObjects; + return this.triggeringObjects; } /** @@ -920,7 +921,7 @@ public abstract class SpellAbility { * @since 1.0.15 */ public Object getTriggeringObject(final String type) { - return triggeringObjects.get(type); + return this.triggeringObjects.get(type); } /** @@ -934,7 +935,7 @@ public abstract class SpellAbility { * @since 1.0.15 */ public boolean hasTriggeringObject(final String type) { - return triggeringObjects.containsKey(type); + return this.triggeringObjects.containsKey(type); } /** @@ -945,7 +946,7 @@ public abstract class SpellAbility { * @since 1.0.15 */ public void resetTriggeringObjects() { - triggeringObjects = new HashMap(); + this.triggeringObjects = new HashMap(); } /** @@ -954,19 +955,19 @@ public abstract class SpellAbility { *

*/ public void resetOnceResolved() { - resetPaidHash(); + this.resetPaidHash(); - if (chosenTarget != null) { - chosenTarget.resetTargets(); + if (this.getChosenTarget() != null) { + this.getChosenTarget().resetTargets(); } - resetTriggeringObjects(); + this.resetTriggeringObjects(); // Clear SVars - for (String store : Card.getStorableSVars()) { - String value = sourceCard.getSVar(store); + for (final String store : Card.getStorableSVars()) { + final String value = this.sourceCard.getSVar(store); if (value.length() > 0) { - sourceCard.setSVar(store, ""); + this.sourceCard.setSVar(store, ""); } } } @@ -979,7 +980,7 @@ public abstract class SpellAbility { * @return a {@link forge.gui.input.Input} object. */ public Input getAfterResolve() { - return afterResolve; + return this.afterResolve; } /** @@ -991,7 +992,7 @@ public abstract class SpellAbility { * a {@link forge.gui.input.Input} object. */ public void setAfterResolve(final Input in) { - afterResolve = in; + this.afterResolve = in; } /** @@ -1003,9 +1004,9 @@ public abstract class SpellAbility { * a {@link java.lang.String} object. */ public void setStackDescription(final String s) { - stackDescription = s; - if (description == "" && sourceCard.getText().equals("")) { - description = s; + this.stackDescription = s; + if ((this.description == "") && this.sourceCard.getText().equals("")) { + this.description = s; } } @@ -1017,11 +1018,11 @@ public abstract class SpellAbility { * @return a {@link java.lang.String} object. */ public String getStackDescription() { - if (stackDescription.equals(getSourceCard().getText().trim())) { - return getSourceCard().getName() + " - " + getSourceCard().getText(); + if (this.stackDescription.equals(this.getSourceCard().getText().trim())) { + return this.getSourceCard().getName() + " - " + this.getSourceCard().getText(); } - return stackDescription.replaceAll("CARDNAME", this.getSourceCard().getName()); + return this.stackDescription.replaceAll("CARDNAME", this.getSourceCard().getName()); } /** @@ -1032,7 +1033,7 @@ public abstract class SpellAbility { * @return a boolean. */ public boolean isIntrinsic() { - return type.equals("Intrinsic"); + return this.type.equals("Intrinsic"); } /** @@ -1043,7 +1044,7 @@ public abstract class SpellAbility { * @return a boolean. */ public boolean isExtrinsic() { - return type.equals("Extrinsic"); + return this.type.equals("Extrinsic"); } /** @@ -1051,12 +1052,12 @@ public abstract class SpellAbility { * Setter for the field type. *

* + * Extrinsic or Intrinsic: * @param s * a {@link java.lang.String} object. */ - public void setType(final String s) // Extrinsic or Intrinsic: - { - type = s; + public void setType(final String s) { + this.type = s; } /** @@ -1066,9 +1067,9 @@ public abstract class SpellAbility { * * @return a {@link java.lang.String} object. */ - public String getType() // Extrinsic or Intrinsic: - { - return type; + public String getType() { + // Extrinsic or Intrinsic: + return this.type; } // setDescription() includes mana cost and everything like @@ -1082,7 +1083,7 @@ public abstract class SpellAbility { * a {@link java.lang.String} object. */ public void setDescription(final String s) { - description = s; + this.description = s; } /** @@ -1093,18 +1094,18 @@ public abstract class SpellAbility { * @return a {@link java.lang.String} object. */ public String getDescription() { - return description; + return this.description; } /** {@inheritDoc} */ @Override public final String toString() { - if (isSuppressed()) { + if (this.isSuppressed()) { return ""; } - return toUnsuppressedString(); + return this.toUnsuppressedString(); } /** @@ -1114,7 +1115,7 @@ public abstract class SpellAbility { */ public String toUnsuppressedString() { - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); SpellAbility node = this; while (node != null) { @@ -1162,11 +1163,11 @@ public abstract class SpellAbility { * * @return a {@link forge.Card} object. */ - public Card getTargetCard() { - if (targetCard == null) { - Target tgt = this.getTarget(); + public Card getTargetCard() { + if (this.targetCard == null) { + final Target tgt = this.getTarget(); if (tgt != null) { - ArrayList list = tgt.getTargetCards(); + final ArrayList list = tgt.getTargetCards(); if (!list.isEmpty()) { return list.get(0); @@ -1175,7 +1176,7 @@ public abstract class SpellAbility { return null; } - return targetCard; + return this.targetCard; } /** @@ -1188,25 +1189,26 @@ public abstract class SpellAbility { */ public void setTargetCard(final Card card) { if (card == null) { - System.out.println(getSourceCard() + " - SpellAbility.setTargetCard() called with null for target card."); + System.out.println(this.getSourceCard() + + " - SpellAbility.setTargetCard() called with null for target card."); return; } - Target tgt = this.getTarget(); + final Target tgt = this.getTarget(); if (tgt != null) { tgt.addTarget(card); } else { - targetPlayer = null; // reset setTargetPlayer() - targetCard = card; + this.targetPlayer = null; // reset setTargetPlayer() + this.targetCard = card; } String desc = ""; if (null != card) { if (!card.isFaceDown()) { - desc = getSourceCard().getName() + " - targeting " + card; + desc = this.getSourceCard().getName() + " - targeting " + card; } else { - desc = getSourceCard().getName() + " - targeting Morph(" + card.getUniqueNumber() + ")"; + desc = this.getSourceCard().getName() + " - targeting Morph(" + card.getUniqueNumber() + ")"; } - setStackDescription(desc); + this.setStackDescription(desc); } } @@ -1218,7 +1220,7 @@ public abstract class SpellAbility { * @return a {@link forge.CardList} object. */ public CardList getTargetList() { - return targetList; + return this.targetList; } /** @@ -1236,22 +1238,22 @@ public abstract class SpellAbility { // not result in other bugs. :) // targetPlayer = null;//reset setTargetPlayer() - targetList = list; - StringBuilder sb = new StringBuilder(); - sb.append(getSourceCard().getName()).append(" - targeting "); - for (int i = 0; i < targetList.size(); i++) { + this.targetList = list; + final StringBuilder sb = new StringBuilder(); + sb.append(this.getSourceCard().getName()).append(" - targeting "); + for (int i = 0; i < this.targetList.size(); i++) { - if (!targetList.get(i).isFaceDown()) { - sb.append(targetList.get(i)); + if (!this.targetList.get(i).isFaceDown()) { + sb.append(this.targetList.get(i)); } else { - sb.append("Morph(").append(targetList.get(i).getUniqueNumber()).append(")"); + sb.append("Morph(").append(this.targetList.get(i).getUniqueNumber()).append(")"); } - if (i < targetList.size() - 1) { + if (i < (this.targetList.size() - 1)) { sb.append(", "); } } - setStackDescription(sb.toString()); + this.setStackDescription(sb.toString()); } /** @@ -1263,19 +1265,19 @@ public abstract class SpellAbility { * a {@link forge.Player} object. */ public void setTargetPlayer(final Player p) { - if (p == null || (!(p.isHuman() || p.isComputer()))) { + if ((p == null) || (!(p.isHuman() || p.isComputer()))) { throw new RuntimeException("SpellAbility : setTargetPlayer() error, argument is " + p + " source card is " - + getSourceCard()); + + this.getSourceCard()); } - Target tgt = this.getTarget(); + final Target tgt = this.getTarget(); if (tgt != null) { tgt.addTarget(p); } else { - targetCard = null; // reset setTargetCard() - targetPlayer = p; + this.targetCard = null; // reset setTargetCard() + this.targetPlayer = p; } - setStackDescription(getSourceCard().getName() + " - targeting " + p); + this.setStackDescription(this.getSourceCard().getName() + " - targeting " + p); } /** @@ -1286,10 +1288,10 @@ public abstract class SpellAbility { * @return a {@link forge.Player} object. */ public Player getTargetPlayer() { - if (targetPlayer == null) { - Target tgt = this.getTarget(); + if (this.targetPlayer == null) { + final Target tgt = this.getTarget(); if (tgt != null) { - ArrayList list = tgt.getTargetPlayers(); + final ArrayList list = tgt.getTargetPlayers(); if (!list.isEmpty()) { return list.get(0); @@ -1297,7 +1299,7 @@ public abstract class SpellAbility { } return null; } - return targetPlayer; + return this.targetPlayer; } /** @@ -1308,7 +1310,7 @@ public abstract class SpellAbility { * @return a {@link forge.Command} object. */ public Command getCancelCommand() { - return cancelCommand; + return this.cancelCommand; } /** @@ -1343,7 +1345,7 @@ public abstract class SpellAbility { * @return a boolean. */ public boolean isFlashBackAbility() { - return flashBackAbility; + return this.flashBackAbility; } /** @@ -1366,7 +1368,7 @@ public abstract class SpellAbility { * @return a boolean. */ public boolean isKickerAbility() { - return kickerAbility; + return this.kickerAbility; } // Only used by Ability_Reflected_Mana, because the user has an option to @@ -1395,7 +1397,7 @@ public abstract class SpellAbility { SpellAbility clone = null; try { clone = (SpellAbility) this.clone(); - } catch (CloneNotSupportedException e) { + } catch (final CloneNotSupportedException e) { System.err.println(e); } return clone; @@ -1421,7 +1423,7 @@ public abstract class SpellAbility { * @return a boolean. */ public boolean isTrigger() { - return trigger; + return this.trigger; } /** @@ -1448,11 +1450,11 @@ public abstract class SpellAbility { * setSourceTrigger. *

* - * @param ID + * @param id * a int. */ - public void setSourceTrigger(final int ID) { - sourceTrigger = ID; + public void setSourceTrigger(final int id) { + this.sourceTrigger = id; } /** @@ -1463,7 +1465,7 @@ public abstract class SpellAbility { * @return a int. */ public int getSourceTrigger() { - return sourceTrigger; + return this.sourceTrigger; } /** @@ -1486,7 +1488,7 @@ public abstract class SpellAbility { * @return a boolean. */ public final boolean isMandatory() { - return mandatory; + return this.mandatory; } /** @@ -1499,7 +1501,7 @@ public abstract class SpellAbility { */ public final SpellAbility getRootSpellAbility() { if (this instanceof Ability_Sub) { - SpellAbility parent = ((Ability_Sub) this).getParent(); + final SpellAbility parent = ((Ability_Sub) this).getParent(); if (parent != null) { return parent.getRootSpellAbility(); } @@ -1517,9 +1519,9 @@ public abstract class SpellAbility { * @since 1.0.15 */ public final ArrayList getAllTargetChoices() { - ArrayList res = new ArrayList(); + final ArrayList res = new ArrayList(); - SpellAbility sa = getRootSpellAbility(); + SpellAbility sa = this.getRootSpellAbility(); if (sa.getTarget() != null) { res.add(sa.getTarget().getTargetChoices()); } @@ -1554,7 +1556,7 @@ public abstract class SpellAbility { * the new temporarily suppressed */ public final void setTemporarilySuppressed(final boolean supp) { - temporarilySuppressed = supp; + this.temporarilySuppressed = supp; } /** @@ -1563,7 +1565,7 @@ public abstract class SpellAbility { * @return true, if is suppressed */ public final boolean isSuppressed() { - return (temporarilySuppressed); + return (this.temporarilySuppressed); } /** @@ -1575,7 +1577,7 @@ public abstract class SpellAbility { * a boolean. */ public final void setIsCharm(final boolean b) { - isCharm = b; + this.isCharm = b; } /** @@ -1586,7 +1588,7 @@ public abstract class SpellAbility { * @return a boolean. */ public final boolean isCharm() { - return isCharm; + return this.isCharm; } /** @@ -1598,7 +1600,7 @@ public abstract class SpellAbility { * an int */ public final void setCharmNumber(final int i) { - charmNumber = i; + this.charmNumber = i; } /** @@ -1609,7 +1611,7 @@ public abstract class SpellAbility { * @return an int */ public final int getCharmNumber() { - return charmNumber; + return this.charmNumber; } /** @@ -1622,7 +1624,7 @@ public abstract class SpellAbility { * @since 1.1.6 */ public final void setMinCharmNumber(final int i) { - minCharmNumber = i; + this.minCharmNumber = i; } /** @@ -1634,7 +1636,7 @@ public abstract class SpellAbility { * @since 1.1.6 */ public final int getMinCharmNumber() { - return minCharmNumber; + return this.minCharmNumber; } /** @@ -1647,7 +1649,7 @@ public abstract class SpellAbility { * @since 1.1.6 */ public final void addCharmChoice(final SpellAbility sa) { - charmChoices.add(sa); + this.charmChoices.add(sa); } /** @@ -1659,7 +1661,7 @@ public abstract class SpellAbility { * @since 1.1.6 */ public final ArrayList getCharmChoices() { - return charmChoices; + return this.charmChoices; } /** @@ -1668,7 +1670,7 @@ public abstract class SpellAbility { * @return the isDelve */ public final boolean getIsDelve() { - return isDelve; + return this.isDelve; } /** @@ -1681,4 +1683,32 @@ public abstract class SpellAbility { this.isDelve = isDelve0; // TODO Add 0 to parameter's name. } + /** + * @return the ability + */ + public static int getAbility() { + return ABILITY; + } + + /** + * @return the spell + */ + public static int getSpell() { + return SPELL; + } + + /** + * @return the chosenTarget + */ + public Target getChosenTarget() { + return chosenTarget; + } + + /** + * @param chosenTarget the chosenTarget to set + */ + public void setChosenTarget(Target chosenTarget) { + this.chosenTarget = chosenTarget; // TODO: Add 0 to parameter's name. + } + } diff --git a/src/main/java/forge/card/spellability/SpellAbilityList.java b/src/main/java/forge/card/spellability/SpellAbilityList.java index 06ff444dc3e..21c9c2edd5e 100644 --- a/src/main/java/forge/card/spellability/SpellAbilityList.java +++ b/src/main/java/forge/card/spellability/SpellAbilityList.java @@ -13,7 +13,7 @@ import forge.ComputerUtil; * @version $Id$ */ public class SpellAbilityList { - private ArrayList list = new ArrayList(); + private final ArrayList list = new ArrayList(); /** *

@@ -32,7 +32,7 @@ public class SpellAbilityList { * a {@link forge.card.spellability.SpellAbility} object. */ public SpellAbilityList(final SpellAbility s) { - add(s); + this.add(s); } /** @@ -45,8 +45,8 @@ public class SpellAbilityList { * objects. */ public SpellAbilityList(final SpellAbility[] s) { - for (int i = 0; i < s.length; i++) { - add(s[i]); + for (final SpellAbility element : s) { + this.add(element); } } @@ -59,7 +59,7 @@ public class SpellAbilityList { * a int. */ public final void remove(final int n) { - list.remove(n); + this.list.remove(n); } /** @@ -71,7 +71,7 @@ public class SpellAbilityList { * a {@link forge.card.spellability.SpellAbility} object. */ public final void add(final SpellAbility s) { - list.add(s); + this.list.add(s); } /** @@ -82,7 +82,7 @@ public class SpellAbilityList { * @return a int. */ public final int size() { - return list.size(); + return this.list.size(); } /** @@ -95,7 +95,7 @@ public class SpellAbilityList { * @return a {@link forge.card.spellability.SpellAbility} object. */ public final SpellAbility get(final int n) { - return list.get(n); + return this.list.get(n); } /** @@ -108,7 +108,7 @@ public class SpellAbilityList { */ public final void addAll(final SpellAbilityList s) { for (int i = 0; i < s.size(); i++) { - add(s.get(i)); + this.add(s.get(i)); } } @@ -119,24 +119,24 @@ public class SpellAbilityList { *

*/ public final void execute() { - for (int i = 0; i < size(); i++) { - if (!ComputerUtil.canPayCost(get(i))) { + for (int i = 0; i < this.size(); i++) { + if (!ComputerUtil.canPayCost(this.get(i))) { throw new RuntimeException("SpellAbilityList : execute() error, cannot pay for the spell " - + get(i).getSourceCard() + " - " + get(i).getStackDescription()); + + this.get(i).getSourceCard() + " - " + this.get(i).getStackDescription()); } - ComputerUtil.playNoStack(get(i)); + ComputerUtil.playNoStack(this.get(i)); } } // execute() /** {@inheritDoc} */ @Override public final String toString() { - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < size(); i++) { - sb.append(get(i).getSourceCard().toString()); + final StringBuilder sb = new StringBuilder(); + for (int i = 0; i < this.size(); i++) { + sb.append(this.get(i).getSourceCard().toString()); sb.append(" - "); - sb.append(get(i).getStackDescription()); + sb.append(this.get(i).getStackDescription()); sb.append("\r\n"); } return sb.toString(); @@ -148,6 +148,6 @@ public class SpellAbilityList { if (o == null) { return false; } - return toString().equals(o.toString()); + return this.toString().equals(o.toString()); } } diff --git a/src/main/java/forge/card/spellability/SpellAbility_Condition.java b/src/main/java/forge/card/spellability/SpellAbility_Condition.java index 92d06dd2158..9473e848d7f 100644 --- a/src/main/java/forge/card/spellability/SpellAbility_Condition.java +++ b/src/main/java/forge/card/spellability/SpellAbility_Condition.java @@ -47,32 +47,32 @@ public class SpellAbility_Condition extends SpellAbility_Variables { */ public final void setConditions(final HashMap params) { if (params.containsKey("Condition")) { - String value = params.get("Condition"); + final String value = params.get("Condition"); if (value.equals("Threshold")) { - setThreshold(true); + this.setThreshold(true); } if (value.equals("Metalcraft")) { - setMetalcraft(true); + this.setMetalcraft(true); } if (value.equals("Hellbent")) { - setHellbent(true); + this.setHellbent(true); } } if (params.containsKey("ConditionZone")) { - setZone(Zone.smartValueOf(params.get("ContitionZone"))); + this.setZone(Zone.smartValueOf(params.get("ContitionZone"))); } if (params.containsKey("ConditionSorcerySpeed")) { - setSorcerySpeed(true); + this.setSorcerySpeed(true); } if (params.containsKey("ConditionPlayerTurn")) { - setPlayerTurn(true); + this.setPlayerTurn(true); } if (params.containsKey("ConditionOpponentTurn")) { - setOpponentTurn(true); + this.setOpponentTurn(true); } if (params.containsKey("ConditionPhases")) { @@ -84,59 +84,59 @@ public class SpellAbility_Condition extends SpellAbility_Variables { // Draw-> (After Upkeep) // Upkeep->Combat_Begin (Before Declare Attackers) - String[] split = phases.split("->", 2); + final String[] split = phases.split("->", 2); phases = AllZone.getPhase().buildActivateString(split[0], split[1]); } - setPhases(phases); + this.setPhases(phases); } if (params.containsKey("ConditionAllM12Empires")) { - setAllM12Empires(true); + this.setAllM12Empires(true); } if (params.containsKey("ConditionNotAllM12Empires")) { - setNotAllM12Empires(true); + this.setNotAllM12Empires(true); } if (params.containsKey("ConditionCardsInHand")) { - setActivateCardsInHand(Integer.parseInt(params.get("ConditionCardsInHand"))); + this.setActivateCardsInHand(Integer.parseInt(params.get("ConditionCardsInHand"))); } // Condition version of IsPresent stuff if (params.containsKey("ConditionPresent")) { - setIsPresent(params.get("ConditionPresent")); + this.setIsPresent(params.get("ConditionPresent")); if (params.containsKey("ConditionCompare")) { - setPresentCompare(params.get("ConditionCompare")); + this.setPresentCompare(params.get("ConditionCompare")); } } if (params.containsKey("ConditionDefined")) { - setPresentDefined(params.get("ConditionDefined")); + this.setPresentDefined(params.get("ConditionDefined")); } if (params.containsKey("ConditionNotPresent")) { - setIsPresent(params.get("ConditionNotPresent")); - setPresentCompare("EQ0"); + this.setIsPresent(params.get("ConditionNotPresent")); + this.setPresentCompare("EQ0"); } // basically PresentCompare for life totals: if (params.containsKey("ConditionLifeTotal")) { - setLifeTotal(params.get("ConditionLifeTotal")); + this.setLifeTotal(params.get("ConditionLifeTotal")); if (params.containsKey("ConditionLifeAmount")) { - setLifeAmount(params.get("ConditionLifeAmount")); + this.setLifeAmount(params.get("ConditionLifeAmount")); } } if (params.containsKey("ConditionManaSpent")) { - setManaSpent(params.get("ConditionManaSpent")); + this.setManaSpent(params.get("ConditionManaSpent")); } if (params.containsKey("ConditionCheckSVar")) { - setSvarToCheck(params.get("ConditionCheckSVar")); + this.setSvarToCheck(params.get("ConditionCheckSVar")); } if (params.containsKey("ConditionSVarCompare")) { - setSvarOperator(params.get("ConditionSVarCompare").substring(0, 2)); - setSvarOperand(params.get("ConditionSVarCompare").substring(2)); + this.setSvarOperator(params.get("ConditionSVarCompare").substring(0, 2)); + this.setSvarOperand(params.get("ConditionSVarCompare").substring(2)); } } // setConditions @@ -159,42 +159,42 @@ public class SpellAbility_Condition extends SpellAbility_Variables { + " Did not have activator set in SpellAbility_Condition.checkConditions()"); } - if (isHellbent()) { + if (this.isHellbent()) { if (!activator.hasHellbent()) { return false; } } - if (isThreshold()) { + if (this.isThreshold()) { if (!activator.hasThreshold()) { return false; } } - if (isMetalcraft()) { + if (this.isMetalcraft()) { if (!activator.hasMetalcraft()) { return false; } } - if (isSorcerySpeed() && !Phase.canCastSorcery(activator)) { + if (this.isSorcerySpeed() && !Phase.canCastSorcery(activator)) { return false; } - if (isPlayerTurn() && !AllZone.getPhase().isPlayerTurn(activator)) { + if (this.isPlayerTurn() && !AllZone.getPhase().isPlayerTurn(activator)) { return false; } - if (isOpponentTurn() && AllZone.getPhase().isPlayerTurn(activator)) { + if (this.isOpponentTurn() && AllZone.getPhase().isPlayerTurn(activator)) { return false; } - if (getActivationLimit() != -1 && getNumberTurnActivations() >= getActivationLimit()) { + if ((this.getActivationLimit() != -1) && (this.getNumberTurnActivations() >= this.getActivationLimit())) { return false; } - if (getPhases().size() > 0) { + if (this.getPhases().size() > 0) { boolean isPhase = false; - String currPhase = AllZone.getPhase().getPhase(); - for (String s : getPhases()) { + final String currPhase = AllZone.getPhase().getPhase(); + for (final String s : this.getPhases()) { if (s.equals(currPhase)) { isPhase = true; break; @@ -206,8 +206,8 @@ public class SpellAbility_Condition extends SpellAbility_Variables { } } - if (isAllM12Empires()) { - Player p = sa.getSourceCard().getController(); + if (this.isAllM12Empires()) { + final Player p = sa.getSourceCard().getController(); boolean has = AllZoneUtil.isCardInPlay("Crown of Empires", p); has &= AllZoneUtil.isCardInPlay("Scepter of Empires", p); has &= AllZoneUtil.isCardInPlay("Throne of Empires", p); @@ -215,8 +215,8 @@ public class SpellAbility_Condition extends SpellAbility_Variables { return false; } } - if (isNotAllM12Empires()) { - Player p = sa.getSourceCard().getController(); + if (this.isNotAllM12Empires()) { + final Player p = sa.getSourceCard().getController(); boolean has = AllZoneUtil.isCardInPlay("Crown of Empires", p); has &= AllZoneUtil.isCardInPlay("Scepter of Empires", p); has &= AllZoneUtil.isCardInPlay("Throne of Empires", p); @@ -225,72 +225,73 @@ public class SpellAbility_Condition extends SpellAbility_Variables { } } - if (getCardsInHand() != -1) { + if (this.getCardsInHand() != -1) { // Can handle Library of Alexandria, or Hellbent - if (activator.getCardsIn(Zone.Hand).size() != getCardsInHand()) { + if (activator.getCardsIn(Zone.Hand).size() != this.getCardsInHand()) { return false; } } - if (getIsPresent() != null) { + if (this.getIsPresent() != null) { CardList list = new CardList(); - if (getPresentDefined() != null) { - list.addAll(AbilityFactory.getDefinedCards(sa.getSourceCard(), getPresentDefined(), sa).toArray()); + if (this.getPresentDefined() != null) { + list.addAll(AbilityFactory.getDefinedCards(sa.getSourceCard(), this.getPresentDefined(), sa).toArray()); } else { list = AllZoneUtil.getCardsIn(Zone.Battlefield); } - list = list.getValidCards(getIsPresent().split(","), sa.getActivatingPlayer(), sa.getSourceCard()); + list = list.getValidCards(this.getIsPresent().split(","), sa.getActivatingPlayer(), sa.getSourceCard()); int right; - String rightString = getPresentCompare().substring(2); + final String rightString = this.getPresentCompare().substring(2); try { // If this is an Integer, just parse it right = Integer.parseInt(rightString); - } catch (NumberFormatException e) { // Otherwise, grab it from the - // SVar + } catch (final NumberFormatException e) { // Otherwise, grab it from + // the + // SVar right = CardFactoryUtil.xCount(sa.getSourceCard(), sa.getSourceCard().getSVar(rightString)); } - int left = list.size(); + final int left = list.size(); - if (!AllZoneUtil.compare(left, getPresentCompare(), right)) { + if (!AllZoneUtil.compare(left, this.getPresentCompare(), right)) { return false; } } - if (getLifeTotal() != null) { + if (this.getLifeTotal() != null) { int life = 1; - if (getLifeTotal().equals("You")) { + if (this.getLifeTotal().equals("You")) { life = activator.getLife(); } - if (getLifeTotal().equals("Opponent")) { + if (this.getLifeTotal().equals("Opponent")) { life = activator.getOpponent().getLife(); } int right = 1; - String rightString = getLifeAmount().substring(2); + final String rightString = this.getLifeAmount().substring(2); if (rightString.equals("X")) { right = CardFactoryUtil.xCount(sa.getSourceCard(), sa.getSourceCard().getSVar("X")); } else { - right = Integer.parseInt(getLifeAmount().substring(2)); + right = Integer.parseInt(this.getLifeAmount().substring(2)); } - if (!AllZoneUtil.compare(life, getLifeAmount(), right)) { + if (!AllZoneUtil.compare(life, this.getLifeAmount(), right)) { return false; } } - if (null != getManaSpent()) { - if (!sa.getSourceCard().getColorsPaid().contains(getManaSpent())) { + if (null != this.getManaSpent()) { + if (!sa.getSourceCard().getColorsPaid().contains(this.getManaSpent())) { return false; } } - if (getsVarToCheck() != null) { - int svarValue = AbilityFactory.calculateAmount(sa.getSourceCard(), getsVarToCheck(), sa); - int operandValue = AbilityFactory.calculateAmount(sa.getSourceCard(), getsVarOperand(), sa); + if (this.getsVarToCheck() != null) { + final int svarValue = AbilityFactory.calculateAmount(sa.getSourceCard(), this.getsVarToCheck(), sa); + final int operandValue = AbilityFactory.calculateAmount(sa.getSourceCard(), this.getsVarOperand(), sa); - if (!AllZoneUtil.compare(svarValue, getsVarOperator(), operandValue)) { + if (!AllZoneUtil.compare(svarValue, this.getsVarOperator(), operandValue)) { return false; } diff --git a/src/main/java/forge/card/spellability/SpellAbility_Requirements.java b/src/main/java/forge/card/spellability/SpellAbility_Requirements.java index d37e9e0038b..58fe9eedf61 100644 --- a/src/main/java/forge/card/spellability/SpellAbility_Requirements.java +++ b/src/main/java/forge/card/spellability/SpellAbility_Requirements.java @@ -32,7 +32,7 @@ public class SpellAbility_Requirements { * a boolean. */ public final void setSkipStack(final boolean bSkip) { - skipStack = bSkip; + this.skipStack = bSkip; } /** @@ -44,7 +44,7 @@ public class SpellAbility_Requirements { * a boolean. */ public final void setFree(final boolean bFree) { - isFree = bFree; + this.isFree = bFree; } private PlayerZone fromZone = null; @@ -63,9 +63,9 @@ public class SpellAbility_Requirements { * a {@link forge.card.cost.Cost_Payment} object. */ public SpellAbility_Requirements(final SpellAbility sa, final Target_Selection ts, final Cost_Payment cp) { - ability = sa; - select = ts; - payment = cp; + this.ability = sa; + this.select = ts; + this.payment = cp; } /** @@ -74,7 +74,7 @@ public class SpellAbility_Requirements { *

*/ public final void fillRequirements() { - fillRequirements(false); + this.fillRequirements(false); } /** @@ -86,13 +86,13 @@ public class SpellAbility_Requirements { * a boolean. */ public final void fillRequirements(final boolean skipTargeting) { - if (ability instanceof Spell && !bCasting) { + if ((this.ability instanceof Spell) && !this.bCasting) { // remove from hand - bCasting = true; - if (!ability.getSourceCard().isCopiedSpell()) { - Card c = ability.getSourceCard(); + this.bCasting = true; + if (!this.ability.getSourceCard().isCopiedSpell()) { + final Card c = this.ability.getSourceCard(); - fromZone = AllZone.getZoneOf(c); + this.fromZone = AllZone.getZoneOf(c); AllZone.getGameAction().moveToStack(c); } } @@ -104,12 +104,12 @@ public class SpellAbility_Requirements { // 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(); + if (!skipTargeting && (this.select.doesTarget() || (this.ability.getSubAbility() != null))) { + this.select.setRequirements(this); + this.select.resetTargets(); + this.select.chooseTargets(); } else { - needPayment(); + this.needPayment(); } } @@ -119,19 +119,19 @@ public class SpellAbility_Requirements { *

*/ public final void finishedTargeting() { - if (select.isCanceled()) { + if (this.select.isCanceled()) { // cancel ability during target choosing - Card c = ability.getSourceCard(); - if (bCasting && !c.isCopiedSpell()) { // and not a copy + final Card c = this.ability.getSourceCard(); + if (this.bCasting && !c.isCopiedSpell()) { // and not a copy // add back to where it came from - AllZone.getGameAction().moveTo(fromZone, c); + AllZone.getGameAction().moveTo(this.fromZone, c); } - select.resetTargets(); + this.select.resetTargets(); AllZone.getStack().clearFrozen(); return; } else { - needPayment(); + this.needPayment(); } } @@ -141,10 +141,10 @@ public class SpellAbility_Requirements { *

*/ public final void needPayment() { - if (!isFree) { - startPaying(); + if (!this.isFree) { + this.startPaying(); } else { - finishPaying(); + this.finishPaying(); } } @@ -154,8 +154,8 @@ public class SpellAbility_Requirements { *

*/ public final void startPaying() { - payment.setRequirements(this); - payment.payCost(); + this.payment.setRequirements(this); + this.payment.payCost(); } /** @@ -164,28 +164,28 @@ public class SpellAbility_Requirements { *

*/ public final void finishPaying() { - if (isFree || payment.isAllPaid()) { - if (skipStack) { - AbilityFactory.resolve(ability, false); + if (this.isFree || this.payment.isAllPaid()) { + if (this.skipStack) { + AbilityFactory.resolve(this.ability, false); } else { - addAbilityToStack(); + this.addAbilityToStack(); } - select.resetTargets(); + this.select.resetTargets(); AllZone.getGameAction().checkStateEffects(); - } else if (payment.isCanceled()) { - Card c = ability.getSourceCard(); - if (bCasting && !c.isCopiedSpell()) { // and not a copy + } else if (this.payment.isCanceled()) { + final Card c = this.ability.getSourceCard(); + if (this.bCasting && !c.isCopiedSpell()) { // and not a copy // add back to Previous Zone - AllZone.getGameAction().moveTo(fromZone, c); + AllZone.getGameAction().moveTo(this.fromZone, c); } - if (select != null) { - select.resetTargets(); + if (this.select != null) { + this.select.resetTargets(); } - ability.resetOnceResolved(); - payment.cancelPayment(); + this.ability.resetOnceResolved(); + this.payment.cancelPayment(); AllZone.getStack().clearFrozen(); } } @@ -197,23 +197,23 @@ public class SpellAbility_Requirements { */ public final void addAbilityToStack() { // For older abilities that don't setStackDescription set it here - if (ability.getStackDescription().equals("")) { - StringBuilder sb = new StringBuilder(); - sb.append(ability.getSourceCard().getName()); - if (ability.getTarget() != null) { - ArrayList targets = ability.getTarget().getTargets(); + if (this.ability.getStackDescription().equals("")) { + final StringBuilder sb = new StringBuilder(); + sb.append(this.ability.getSourceCard().getName()); + if (this.ability.getTarget() != null) { + final ArrayList targets = this.ability.getTarget().getTargets(); if (targets.size() > 0) { sb.append(" - Targeting "); - for (Object o : targets) { + for (final Object o : targets) { sb.append(o.toString()).append(" "); } } } - ability.setStackDescription(sb.toString()); + this.ability.setStackDescription(sb.toString()); } - AllZone.getHumanPlayer().getManaPool().clearPay(ability, false); - AllZone.getStack().addAndUnfreeze(ability); + AllZone.getHumanPlayer().getManaPool().clearPay(this.ability, false); + AllZone.getStack().addAndUnfreeze(this.ability); } } diff --git a/src/main/java/forge/card/spellability/SpellAbility_Restriction.java b/src/main/java/forge/card/spellability/SpellAbility_Restriction.java index df2f582ba31..89dfb7a9564 100644 --- a/src/main/java/forge/card/spellability/SpellAbility_Restriction.java +++ b/src/main/java/forge/card/spellability/SpellAbility_Restriction.java @@ -51,56 +51,56 @@ public class SpellAbility_Restriction extends SpellAbility_Variables { */ public final void setRestrictions(final HashMap params) { if (params.containsKey("Activation")) { - String value = params.get("Activation"); + final String value = params.get("Activation"); if (value.equals("Threshold")) { - setThreshold(true); + this.setThreshold(true); } if (value.equals("Metalcraft")) { - setMetalcraft(true); + this.setMetalcraft(true); } if (value.equals("Hellbent")) { - setHellbent(true); + this.setHellbent(true); } if (value.startsWith("Prowl")) { - ArrayList prowlTypes = new ArrayList(); + final ArrayList prowlTypes = new ArrayList(); prowlTypes.add("Rogue"); if (value.split("Prowl").length > 1) { prowlTypes.add(value.split("Prowl")[1]); } - setProwl(prowlTypes); + this.setProwl(prowlTypes); } } if (params.containsKey("ActivationZone")) { - setZone(Zone.smartValueOf(params.get("ActivationZone"))); + this.setZone(Zone.smartValueOf(params.get("ActivationZone"))); } if (params.containsKey("Flashback")) { - setZone(Zone.Graveyard); + this.setZone(Zone.Graveyard); } if (params.containsKey("SorcerySpeed")) { - setSorcerySpeed(true); + this.setSorcerySpeed(true); } if (params.containsKey("PlayerTurn")) { - setPlayerTurn(true); + this.setPlayerTurn(true); } if (params.containsKey("OpponentTurn")) { - setOpponentTurn(true); + this.setOpponentTurn(true); } if (params.containsKey("AnyPlayer")) { - setAnyPlayer(true); + this.setAnyPlayer(true); } if (params.containsKey("ActivationLimit")) { - setActivationLimit(Integer.parseInt(params.get("ActivationLimit"))); + this.setActivationLimit(Integer.parseInt(params.get("ActivationLimit"))); } if (params.containsKey("ActivationNumberSacrifice")) { - setActivationNumberSacrifice(Integer.parseInt(params.get("ActivationNumberSacrifice"))); + this.setActivationNumberSacrifice(Integer.parseInt(params.get("ActivationNumberSacrifice"))); } if (params.containsKey("ActivationPhases")) { @@ -112,50 +112,50 @@ public class SpellAbility_Restriction extends SpellAbility_Variables { // Draw-> (After Upkeep) // Upkeep->Combat_Begin (Before Declare Attackers) - String[] split = phases.split("->", 2); + final String[] split = phases.split("->", 2); phases = AllZone.getPhase().buildActivateString(split[0], split[1]); } - setPhases(phases); + this.setPhases(phases); } if (params.containsKey("ActivationCardsInHand")) { - setActivateCardsInHand(Integer.parseInt(params.get("ActivationCardsInHand"))); + this.setActivateCardsInHand(Integer.parseInt(params.get("ActivationCardsInHand"))); } if (params.containsKey("Planeswalker")) { - setPlaneswalker(true); + this.setPlaneswalker(true); } if (params.containsKey("IsPresent")) { - setIsPresent(params.get("IsPresent")); + this.setIsPresent(params.get("IsPresent")); if (params.containsKey("PresentCompare")) { - setPresentCompare(params.get("PresentCompare")); + this.setPresentCompare(params.get("PresentCompare")); } if (params.containsKey("PresentZone")) { - setPresentZone(Zone.smartValueOf(params.get("PresentZone"))); + this.setPresentZone(Zone.smartValueOf(params.get("PresentZone"))); } } if (params.containsKey("IsNotPresent")) { - setIsPresent(params.get("IsNotPresent")); - setPresentCompare("EQ0"); + this.setIsPresent(params.get("IsNotPresent")); + this.setPresentCompare("EQ0"); } // basically PresentCompare for life totals: if (params.containsKey("ActivationLifeTotal")) { - setLifeTotal(params.get("ActivationLifeTotal")); + this.setLifeTotal(params.get("ActivationLifeTotal")); if (params.containsKey("ActivationLifeAmount")) { - setLifeAmount(params.get("ActivationLifeAmount")); + this.setLifeAmount(params.get("ActivationLifeAmount")); } } if (params.containsKey("CheckSVar")) { - setSvarToCheck(params.get("CheckSVar")); + this.setSvarToCheck(params.get("CheckSVar")); } if (params.containsKey("SVarCompare")) { - setSvarOperator(params.get("SVarCompare").substring(0, 2)); - setSvarOperand(params.get("SVarCompare").substring(2)); + this.setSvarOperator(params.get("SVarCompare").substring(0, 2)); + this.setSvarOperand(params.get("SVarCompare").substring(2)); } } // end setRestrictions() @@ -175,14 +175,14 @@ public class SpellAbility_Restriction extends SpellAbility_Variables { return false; } - PlayerZone cardZone = AllZone.getZoneOf(c); - if (!cardZone.is(getZone())) { + final PlayerZone cardZone = AllZone.getZoneOf(c); + if (!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.is(Zone.Battlefield)) { return false; - } else if (!c.hasStartOfKeyword("May be played") || !getZone().equals(Zone.Hand)) { + } else if (!c.hasStartOfKeyword("May be played") || !this.getZone().equals(Zone.Hand)) { return false; } } @@ -193,30 +193,30 @@ public class SpellAbility_Restriction extends SpellAbility_Variables { System.out.println(c.getName() + " Did not have activator set in SpellAbility_Restriction.canPlay()"); } - if (isSorcerySpeed() && !Phase.canCastSorcery(activator)) { + if (this.isSorcerySpeed() && !Phase.canCastSorcery(activator)) { return false; } - if (isPlayerTurn() && !AllZone.getPhase().isPlayerTurn(activator)) { + if (this.isPlayerTurn() && !AllZone.getPhase().isPlayerTurn(activator)) { return false; } - if (isOpponentTurn() && AllZone.getPhase().isPlayerTurn(activator)) { + if (this.isOpponentTurn() && AllZone.getPhase().isPlayerTurn(activator)) { return false; } - if (!isAnyPlayer() && !activator.equals(c.getController())) { + if (!this.isAnyPlayer() && !activator.equals(c.getController())) { return false; } - if (getActivationLimit() != -1 && getNumberTurnActivations() >= getActivationLimit()) { + if ((this.getActivationLimit() != -1) && (this.getNumberTurnActivations() >= this.getActivationLimit())) { return false; } - if (getPhases().size() > 0) { + if (this.getPhases().size() > 0) { boolean isPhase = false; - String currPhase = AllZone.getPhase().getPhase(); - for (String s : getPhases()) { + final String currPhase = AllZone.getPhase().getPhase(); + for (final String s : this.getPhases()) { if (s.equals(currPhase)) { isPhase = true; break; @@ -228,31 +228,31 @@ public class SpellAbility_Restriction extends SpellAbility_Variables { } } - if (getCardsInHand() != -1) { - if (activator.getCardsIn(Zone.Hand).size() != getCardsInHand()) { + if (this.getCardsInHand() != -1) { + if (activator.getCardsIn(Zone.Hand).size() != this.getCardsInHand()) { return false; } } - if (isHellbent()) { + if (this.isHellbent()) { if (!activator.hasHellbent()) { return false; } } - if (isThreshold()) { + if (this.isThreshold()) { if (!activator.hasThreshold()) { return false; } } - if (isMetalcraft()) { + if (this.isMetalcraft()) { if (!activator.hasMetalcraft()) { return false; } } - if (getProwl() != null) { + if (this.getProwl() != null) { // only true if the activating player has damaged the opponent with // one of the specified types boolean prowlFlag = false; - for (String type : getProwl()) { + for (final String type : this.getProwl()) { if (activator.hasProwl(type)) { prowlFlag = true; } @@ -261,68 +261,68 @@ public class SpellAbility_Restriction extends SpellAbility_Variables { return false; } } - if (getIsPresent() != null) { - CardList list = AllZoneUtil.getCardsIn(getPresentZone()); + if (this.getIsPresent() != null) { + CardList list = AllZoneUtil.getCardsIn(this.getPresentZone()); - list = list.getValidCards(getIsPresent().split(","), activator, c); + list = list.getValidCards(this.getIsPresent().split(","), activator, c); int right = 1; - String rightString = getPresentCompare().substring(2); + final String rightString = this.getPresentCompare().substring(2); if (rightString.equals("X")) { right = CardFactoryUtil.xCount(c, c.getSVar("X")); } else { - right = Integer.parseInt(getPresentCompare().substring(2)); + right = Integer.parseInt(this.getPresentCompare().substring(2)); } - int left = list.size(); + final int left = list.size(); - if (!AllZoneUtil.compare(left, getPresentCompare(), right)) { + if (!AllZoneUtil.compare(left, this.getPresentCompare(), right)) { return false; } } - if (getLifeTotal() != null) { + if (this.getLifeTotal() != null) { int life = 1; - if (getLifeTotal().equals("You")) { + if (this.getLifeTotal().equals("You")) { life = activator.getLife(); } - if (getLifeTotal().equals("Opponent")) { + if (this.getLifeTotal().equals("Opponent")) { life = activator.getOpponent().getLife(); } int right = 1; - String rightString = getLifeAmount().substring(2); + final String rightString = this.getLifeAmount().substring(2); if (rightString.equals("X")) { right = CardFactoryUtil.xCount(sa.getSourceCard(), sa.getSourceCard().getSVar("X")); } else { - right = Integer.parseInt(getLifeAmount().substring(2)); + right = Integer.parseInt(this.getLifeAmount().substring(2)); } - if (!AllZoneUtil.compare(life, getLifeAmount(), right)) { + if (!AllZoneUtil.compare(life, this.getLifeAmount(), right)) { return false; } } - if (isPwAbility()) { + if (this.isPwAbility()) { // Planeswalker abilities can only be activated as Sorceries if (!Phase.canCastSorcery(activator)) { return false; } - for (SpellAbility pwAbs : c.getAllSpellAbilities()) { + for (final SpellAbility pwAbs : c.getAllSpellAbilities()) { // check all abilities on card that have their planeswalker // restriction set to confirm they haven't been activated - SpellAbility_Restriction restrict = pwAbs.getRestrictions(); - if (restrict.getPlaneswalker() && restrict.getNumberTurnActivations() > 0) { + final SpellAbility_Restriction restrict = pwAbs.getRestrictions(); + if (restrict.getPlaneswalker() && (restrict.getNumberTurnActivations() > 0)) { return false; } } } - if (getsVarToCheck() != null) { - int svarValue = AbilityFactory.calculateAmount(c, getsVarToCheck(), sa); - int operandValue = AbilityFactory.calculateAmount(c, getsVarOperand(), sa); + if (this.getsVarToCheck() != null) { + final int svarValue = AbilityFactory.calculateAmount(c, this.getsVarToCheck(), sa); + final int operandValue = AbilityFactory.calculateAmount(c, this.getsVarOperand(), sa); - if (!AllZoneUtil.compare(svarValue, getsVarOperator(), operandValue)) { + if (!AllZoneUtil.compare(svarValue, this.getsVarOperator(), operandValue)) { return false; } diff --git a/src/main/java/forge/card/spellability/SpellAbility_StackInstance.java b/src/main/java/forge/card/spellability/SpellAbility_StackInstance.java index 607968940ab..eeba2d741cb 100644 --- a/src/main/java/forge/card/spellability/SpellAbility_StackInstance.java +++ b/src/main/java/forge/card/spellability/SpellAbility_StackInstance.java @@ -36,9 +36,6 @@ public class SpellAbility_StackInstance { /** The activating player. */ private Player activatingPlayer = null; - /** The activated from. */ - private String activatedFrom = null; - /** The stack description. */ private String stackDescription = null; @@ -60,7 +57,7 @@ public class SpellAbility_StackInstance { // Triggers private HashMap triggeringObjects = new HashMap(); - private HashMap storedSVars = new HashMap(); + private final HashMap storedSVars = new HashMap(); /** *

@@ -72,41 +69,41 @@ public class SpellAbility_StackInstance { */ public SpellAbility_StackInstance(final SpellAbility sa) { // Base SA info - ability = sa; - stackDescription = ability.getStackDescription(); - activatingPlayer = sa.getActivatingPlayer(); + this.ability = sa; + this.stackDescription = this.ability.getStackDescription(); + this.activatingPlayer = sa.getActivatingPlayer(); // Payment info - paidHash = ability.getPaidHash(); - ability.resetPaidHash(); + this.paidHash = this.ability.getPaidHash(); + this.ability.resetPaidHash(); // TODO getXManaCostPaid should be on the SA, not the Card - xManaPaid = sa.getSourceCard().getXManaCostPaid(); + this.xManaPaid = sa.getSourceCard().getXManaCostPaid(); // Triggering info - triggeringObjects = sa.getTriggeringObjects(); + this.triggeringObjects = sa.getTriggeringObjects(); - Ability_Sub subAb = ability.getSubAbility(); + final Ability_Sub subAb = this.ability.getSubAbility(); if (subAb != null) { - subInstace = new SpellAbility_StackInstance(subAb); + this.subInstace = new SpellAbility_StackInstance(subAb); } // Targeting info -- 29/06/11 Moved to after taking care of SubAbilities // because otherwise AF_DealDamage SubAbilities that use Defined$ // Targeted breaks (since it's parents target is reset) - Target target = sa.getTarget(); + final Target target = sa.getTarget(); if (target != null) { - tc = target.getTargetChoices(); - ability.getTarget().resetTargets(); + this.tc = target.getTargetChoices(); + this.ability.getTarget().resetTargets(); } - Card source = ability.getSourceCard(); + final Card source = this.ability.getSourceCard(); // Store SVars and Clear - for (String store : Card.getStorableSVars()) { - String value = source.getSVar(store); + for (final String store : Card.getStorableSVars()) { + final String value = source.getSVar(store); if (value.length() > 0) { - storedSVars.put(store, value); + this.storedSVars.put(store, value); source.setSVar(store, ""); } } @@ -120,34 +117,34 @@ public class SpellAbility_StackInstance { * @return a {@link forge.card.spellability.SpellAbility} object. */ public final SpellAbility getSpellAbility() { - if (ability.getTarget() != null) { - ability.getTarget().resetTargets(); - ability.getTarget().setTargetChoices(tc); + if (this.ability.getTarget() != null) { + this.ability.getTarget().resetTargets(); + this.ability.getTarget().setTargetChoices(this.tc); } - ability.setActivatingPlayer(activatingPlayer); + this.ability.setActivatingPlayer(this.activatingPlayer); // Saved sub-SA needs to be reset on the way out if (this.subInstace != null) { - ability.setSubAbility((Ability_Sub) this.subInstace.getSpellAbility()); + this.ability.setSubAbility((Ability_Sub) this.subInstace.getSpellAbility()); } // Set Cost specific things here - ability.setPaidHash(paidHash); - ability.getSourceCard().setXManaCostPaid(xManaPaid); + this.ability.setPaidHash(this.paidHash); + this.ability.getSourceCard().setXManaCostPaid(this.xManaPaid); // Triggered - ability.setAllTriggeringObjects(triggeringObjects); + this.ability.setAllTriggeringObjects(this.triggeringObjects); // Add SVars back in - Card source = ability.getSourceCard(); - for (String store : storedSVars.keySet()) { - String value = storedSVars.get(store); + final Card source = this.ability.getSourceCard(); + for (final String store : this.storedSVars.keySet()) { + final String value = this.storedSVars.get(store); if (value.length() > 0) { source.setSVar(store, value); } } - return ability; + return this.ability; } // A bit of SA shared abilities to restrict conflicts @@ -159,7 +156,7 @@ public class SpellAbility_StackInstance { * @return a {@link java.lang.String} object. */ public final String getStackDescription() { - return stackDescription; + return this.stackDescription; } /** @@ -170,7 +167,7 @@ public class SpellAbility_StackInstance { * @return a {@link forge.Card} object. */ public final Card getSourceCard() { - return ability.getSourceCard(); + return this.ability.getSourceCard(); } /** @@ -181,7 +178,7 @@ public class SpellAbility_StackInstance { * @return a {@link forge.Player} object. */ public final Player getActivatingPlayer() { - return activatingPlayer; + return this.activatingPlayer; } /** @@ -192,7 +189,7 @@ public class SpellAbility_StackInstance { * @return a boolean. */ public final boolean isSpell() { - return ability.isSpell(); + return this.ability.isSpell(); } /** @@ -203,7 +200,7 @@ public class SpellAbility_StackInstance { * @return a boolean. */ public final boolean isAbility() { - return ability.isAbility(); + return this.ability.isAbility(); } /** @@ -214,7 +211,7 @@ public class SpellAbility_StackInstance { * @return a boolean. */ public final boolean isTrigger() { - return ability.isTrigger(); + return this.ability.isTrigger(); } /** @@ -227,7 +224,7 @@ public class SpellAbility_StackInstance { * @return a boolean. */ public final boolean isStateTrigger(final int id) { - return ability.getSourceTrigger() == id; + return this.ability.getSourceTrigger() == id; } /** @@ -236,6 +233,6 @@ public class SpellAbility_StackInstance { * @return true, if is optional trigger */ public final boolean isOptionalTrigger() { - return ability.isOptionalTrigger(); + return this.ability.isOptionalTrigger(); } } diff --git a/src/main/java/forge/card/spellability/SpellAbility_Variables.java b/src/main/java/forge/card/spellability/SpellAbility_Variables.java index aae4118a7d6..0e8a7f56959 100644 --- a/src/main/java/forge/card/spellability/SpellAbility_Variables.java +++ b/src/main/java/forge/card/spellability/SpellAbility_Variables.java @@ -682,7 +682,7 @@ public class SpellAbility_Variables { /** * Gets the present defined. - * + * * @return the presentDefined */ public final String getPresentDefined() { @@ -691,7 +691,7 @@ public class SpellAbility_Variables { /** * Checks if is all m12 empires. - * + * * @return the allM12Empires */ public final boolean isAllM12Empires() { @@ -700,7 +700,7 @@ public class SpellAbility_Variables { /** * Checks if is not all m12 empires. - * + * * @return the notAllM12Empires */ public final boolean isNotAllM12Empires() { @@ -709,7 +709,7 @@ public class SpellAbility_Variables { /** * Gets the s var operand. - * + * * @return the sVarOperand */ public final String getsVarOperand() { @@ -718,8 +718,9 @@ public class SpellAbility_Variables { /** * Sets the s var operand. - * - * @param sVarOperand the sVarOperand to set + * + * @param sVarOperand + * the sVarOperand to set */ public final void setsVarOperand(final String sVarOperand) { this.sVarOperand = sVarOperand; // TODO Add 0 to parameter's name. @@ -727,7 +728,7 @@ public class SpellAbility_Variables { /** * Gets the s var to check. - * + * * @return the sVarToCheck */ public final String getsVarToCheck() { @@ -736,8 +737,9 @@ public class SpellAbility_Variables { /** * Sets the s var to check. - * - * @param sVarToCheck the sVarToCheck to set + * + * @param sVarToCheck + * the sVarToCheck to set */ public final void setsVarToCheck(final String sVarToCheck) { this.sVarToCheck = sVarToCheck; @@ -745,7 +747,7 @@ public class SpellAbility_Variables { /** * Gets the s var operator. - * + * * @return the sVarOperator */ public final String getsVarOperator() { @@ -754,8 +756,9 @@ public class SpellAbility_Variables { /** * Sets the s var operator. - * - * @param sVarOperator the sVarOperator to set + * + * @param sVarOperator + * the sVarOperator to set */ public final void setsVarOperator(final String sVarOperator) { this.sVarOperator = sVarOperator; // TODO: Add 0 to parameter's name. @@ -763,7 +766,7 @@ public class SpellAbility_Variables { /** * Checks if is opponent turn. - * + * * @return the opponentTurn */ public final boolean isOpponentTurn() { @@ -772,7 +775,7 @@ public class SpellAbility_Variables { /** * Gets the cards in hand. - * + * * @return the cardsInHand */ public final int getCardsInHand() { @@ -781,8 +784,9 @@ public class SpellAbility_Variables { /** * Sets the cards in hand. - * - * @param cardsInHand the cardsInHand to set + * + * @param cardsInHand + * the cardsInHand to set */ public final void setCardsInHand(final int cardsInHand) { this.cardsInHand = cardsInHand; // TODO: Add 0 to parameter's name. @@ -790,7 +794,7 @@ public class SpellAbility_Variables { /** * Gets the checks if is present. - * + * * @return the isPresent */ public final String getIsPresent() { @@ -799,11 +803,11 @@ public class SpellAbility_Variables { /** * Checks if is any player. - * + * * @return the anyPlayer */ public final boolean isAnyPlayer() { - return anyPlayer; + return this.anyPlayer; } } // end class SpellAbility_Variables diff --git a/src/main/java/forge/card/spellability/Spell_Permanent.java b/src/main/java/forge/card/spellability/Spell_Permanent.java index 2fdfc1be0b9..1e313f5f33c 100644 --- a/src/main/java/forge/card/spellability/Spell_Permanent.java +++ b/src/main/java/forge/card/spellability/Spell_Permanent.java @@ -41,94 +41,99 @@ public class Spell_Permanent extends Spell { @Override public void showMessage() { - CardList choice = (CardList) championGetCreature.execute(); + final CardList choice = (CardList) Spell_Permanent.this.championGetCreature.execute(); - stopSetNext(CardFactoryUtil.inputTargetChampionSac(getSourceCard(), championAbilityComes, choice, - "Select another " + championValidDesc + " you control to exile", false, false)); + this.stopSetNext(CardFactoryUtil.inputTargetChampionSac(Spell_Permanent.this.getSourceCard(), + Spell_Permanent.this.championAbilityComes, choice, "Select another " + + Spell_Permanent.this.championValidDesc + " you control to exile", false, false)); ButtonUtil.disableAll(); // target this card means: sacrifice this // card } }; private final CommandReturn championGetCreature = new CommandReturn() { + @Override public Object execute() { - CardList cards = getSourceCard().getController().getCardsIn(Zone.Battlefield); - return cards.getValidCards(championValid, getSourceCard().getController(), getSourceCard()); + final CardList cards = Spell_Permanent.this.getSourceCard().getController().getCardsIn(Zone.Battlefield); + return cards.getValidCards(Spell_Permanent.this.championValid, Spell_Permanent.this.getSourceCard() + .getController(), Spell_Permanent.this.getSourceCard()); } }; // CommandReturn /** The champion ability comes. */ - private final SpellAbility championAbilityComes = new Ability(getSourceCard(), "0") { + private final SpellAbility championAbilityComes = new Ability(this.getSourceCard(), "0") { @Override public void resolve() { - Card source = getSourceCard(); - Player controller = source.getController(); + final Card source = this.getSourceCard(); + final Player controller = source.getController(); - CardList creature = (CardList) championGetCreature.execute(); + final CardList creature = (CardList) Spell_Permanent.this.championGetCreature.execute(); if (creature.size() == 0) { AllZone.getGameAction().sacrifice(source); return; } else if (controller.isHuman()) { - AllZone.getInputControl().setInput(championInputComes); + AllZone.getInputControl().setInput(Spell_Permanent.this.championInputComes); } else { // Computer CardList computer = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); - computer = computer.getValidCards(championValid, controller, source); + computer = computer.getValidCards(Spell_Permanent.this.championValid, controller, source); computer.remove(source); computer.shuffle(); if (computer.size() != 0) { - Card c = computer.get(0); + final Card c = computer.get(0); source.setChampionedCard(c); if (AllZoneUtil.isCardInPlay(c)) { AllZone.getGameAction().exile(c); } // Run triggers - HashMap runParams = new HashMap(); + final HashMap runParams = new HashMap(); runParams.put("Card", source); runParams.put("Championed", source.getChampionedCard()); AllZone.getTriggerHandler().runTrigger("Championed", runParams); } else { - AllZone.getGameAction().sacrifice(getSourceCard()); + AllZone.getGameAction().sacrifice(this.getSourceCard()); } } // computer } // resolve() }; /** The champion command comes. */ - private Command championCommandComes = new Command() { + private final Command championCommandComes = new Command() { private static final long serialVersionUID = -3580408066322945328L; + @Override public void execute() { - StringBuilder sb = new StringBuilder(); - sb.append(getSourceCard()).append( + final StringBuilder sb = new StringBuilder(); + sb.append(Spell_Permanent.this.getSourceCard()).append( " - When CARDNAME enters the battlefield, sacrifice it unless you exile a creature you control."); - championAbilityComes.setStackDescription(sb.toString()); - AllZone.getStack().addSimultaneousStackEntry(championAbilityComes); + Spell_Permanent.this.championAbilityComes.setStackDescription(sb.toString()); + AllZone.getStack().addSimultaneousStackEntry(Spell_Permanent.this.championAbilityComes); } // execute() }; // championCommandComes /** The champion command leaves play. */ - private Command championCommandLeavesPlay = new Command() { + private final Command championCommandLeavesPlay = new Command() { private static final long serialVersionUID = -5903638227914705191L; + @Override public void execute() { - SpellAbility ability = new Ability(getSourceCard(), "0") { + final SpellAbility ability = new Ability(Spell_Permanent.this.getSourceCard(), "0") { @Override public void resolve() { - Card c = getSourceCard().getChampionedCard(); - if (c != null && !c.isToken() && AllZoneUtil.isCardExiled(c)) { + final Card c = this.getSourceCard().getChampionedCard(); + if ((c != null) && !c.isToken() && AllZoneUtil.isCardExiled(c)) { AllZone.getGameAction().moveToPlay(c); } } // resolve() }; // SpellAbility - StringBuilder sb = new StringBuilder(); - sb.append(getSourceCard()).append( + final StringBuilder sb = new StringBuilder(); + sb.append(Spell_Permanent.this.getSourceCard()).append( " - When CARDNAME leaves the battlefield, exiled card returns to the battlefield."); ability.setStackDescription(sb.toString()); @@ -184,36 +189,36 @@ public class Spell_Permanent extends Spell { super(sourceCard, cost, tgt); if (CardFactoryUtil.hasKeyword(sourceCard, "Champion") != -1) { - int n = CardFactoryUtil.hasKeyword(sourceCard, "Champion"); + final int n = CardFactoryUtil.hasKeyword(sourceCard, "Champion"); - String toParse = sourceCard.getKeyword().get(n).toString(); - String[] parsed = toParse.split(":"); - willChampion = true; - championValid = parsed[1]; + final String toParse = sourceCard.getKeyword().get(n).toString(); + final String[] parsed = toParse.split(":"); + this.willChampion = true; + this.championValid = parsed[1]; if (parsed.length > 2) { - championValidDesc = parsed[2]; + this.championValidDesc = parsed[2]; } else { - championValidDesc = championValid; + this.championValidDesc = this.championValid; } } if (sourceCard.isCreature()) { - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); sb.append(sourceCard.getName()).append(" - Creature ").append(sourceCard.getNetAttack()); sb.append(" / ").append(sourceCard.getNetDefense()); - setStackDescription(sb.toString()); + this.setStackDescription(sb.toString()); } else { - setStackDescription(sourceCard.getName()); + this.setStackDescription(sourceCard.getName()); } if (setDesc) { - setDescription(getStackDescription()); + this.setDescription(this.getStackDescription()); } - if (willChampion) { - sourceCard.addComesIntoPlayCommand(championCommandComes); - sourceCard.addLeavesPlayCommand(championCommandLeavesPlay); + if (this.willChampion) { + sourceCard.addComesIntoPlayCommand(this.championCommandComes); + sourceCard.addLeavesPlayCommand(this.championCommandLeavesPlay); } } // Spell_Permanent() @@ -221,12 +226,12 @@ public class Spell_Permanent extends Spell { /** {@inheritDoc} */ @Override public boolean canPlay() { - Card source = getSourceCard(); + final Card source = this.getSourceCard(); - Player turn = AllZone.getPhase().getPlayerTurn(); + final Player turn = AllZone.getPhase().getPlayerTurn(); if (source.getName().equals("Serra Avenger")) { - if (turn.equals(source.getController()) && turn.getTurn() <= 3) { + if (turn.equals(source.getController()) && (turn.getTurn() <= 3)) { return false; } } @@ -239,11 +244,11 @@ public class Spell_Permanent extends Spell { @Override public boolean canPlayAI() { - Card card = getSourceCard(); + final Card card = this.getSourceCard(); // check on legendary if (card.isType("Legendary")) { - CardList list = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); + final CardList list = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); if (list.containsName(card.getName())) { return false; } @@ -253,8 +258,8 @@ public class Spell_Permanent extends Spell { list = list.getType("Planeswalker"); for (int i = 0; i < list.size(); i++) { - String subtype = card.getType().get(card.getType().size() - 1); - CardList cl = list.getType(subtype); + final String subtype = card.getType().get(card.getType().size() - 1); + final CardList cl = list.getType(subtype); if (cl.size() > 0) { return false; @@ -269,24 +274,24 @@ public class Spell_Permanent extends Spell { } } - if (card.isCreature() && card.getNetDefense() <= 0 && !card.hasStartOfKeyword("etbCounter") + if (card.isCreature() && (card.getNetDefense() <= 0) && !card.hasStartOfKeyword("etbCounter") && !card.getText().contains("Modular")) { return false; } - if (willChampion) { - Object o = championGetCreature.execute(); + if (this.willChampion) { + final Object o = this.championGetCreature.execute(); if (o == null) { return false; } - CardList cl = (CardList) championGetCreature.execute(); - if ((o == null) || !(cl.size() > 0) || !AllZone.getZoneOf(getSourceCard()).is(Constant.Zone.Hand)) { + final CardList cl = (CardList) this.championGetCreature.execute(); + if ((o == null) || !(cl.size() > 0) || !AllZone.getZoneOf(this.getSourceCard()).is(Constant.Zone.Hand)) { return false; } } - if (!checkETBEffects(card, this, null)) { + if (!Spell_Permanent.checkETBEffects(card, this, null)) { return false; } @@ -308,11 +313,11 @@ public class Spell_Permanent extends Spell { */ public static boolean checkETBEffects(final Card card, final SpellAbility sa, final String api) { // Trigger play improvements - ArrayList triggers = card.getTriggers(); - for (Trigger tr : triggers) { + final ArrayList triggers = card.getTriggers(); + for (final Trigger tr : triggers) { // These triggers all care for ETB effects - HashMap params = tr.getMapParams(); + final HashMap params = tr.getMapParams(); if (!params.get("Mode").equals("ChangesZone")) { continue; } @@ -335,14 +340,14 @@ public class Spell_Permanent extends Spell { } // Maybe better considerations - AbilityFactory af = new AbilityFactory(); - String execute = params.get("Execute"); + final AbilityFactory af = new AbilityFactory(); + final String execute = params.get("Execute"); if (execute == null) { continue; } - SpellAbility exSA = af.getAbility(card.getSVar(execute), card); + final SpellAbility exSA = af.getAbility(card.getSVar(execute), card); - if (api != null && !af.getAPI().equals(api)) { + if ((api != null) && !af.getAPI().equals(api)) { continue; } @@ -355,7 +360,7 @@ public class Spell_Permanent extends Spell { // Run non-mandatory trigger. // These checks only work if the Executing SpellAbility is an // Ability_Sub. - if (exSA instanceof Ability_Sub && !exSA.doTrigger(false)) { + if ((exSA instanceof Ability_Sub) && !exSA.doTrigger(false)) { // AI would not run this trigger if given the chance // if trigger is mandatory, return false @@ -373,7 +378,7 @@ public class Spell_Permanent extends Spell { /** {@inheritDoc} */ @Override public void resolve() { - Card c = getSourceCard(); + final Card c = this.getSourceCard(); AllZone.getGameAction().moveToPlay(c); } } diff --git a/src/main/java/forge/card/spellability/Target.java b/src/main/java/forge/card/spellability/Target.java index a24b899e60e..bc176675aa0 100644 --- a/src/main/java/forge/card/spellability/Target.java +++ b/src/main/java/forge/card/spellability/Target.java @@ -36,7 +36,7 @@ public class Target { * @return a {@link forge.card.spellability.Target_Choices} object. */ public final Target_Choices getTargetChoices() { - return choice; + return this.choice; } /** @@ -48,7 +48,7 @@ public class Target { * a {@link forge.card.spellability.Target_Choices} object. */ public final void setTargetChoices(final Target_Choices tc) { - choice = tc; + this.choice = tc; } private boolean bMandatory = false; @@ -61,7 +61,7 @@ public class Target { * @return a boolean. */ public final boolean getMandatory() { - return bMandatory; + return this.bMandatory; } /** @@ -73,11 +73,11 @@ public class Target { * a boolean. */ public final void setMandatory(final boolean m) { - bMandatory = m; + this.bMandatory = m; } private boolean tgtValid = false; - private String[] ValidTgts; + private String[] validTgts; private String vtSelection = ""; /** @@ -88,7 +88,7 @@ public class Target { * @return a boolean. */ public final boolean doesTarget() { - return tgtValid; + return this.tgtValid; } /** @@ -99,7 +99,7 @@ public class Target { * @return an array of {@link java.lang.String} objects. */ public final String[] getValidTgts() { - return ValidTgts; + return this.validTgts; } /** @@ -110,7 +110,7 @@ public class Target { * @return a {@link java.lang.String} object. */ public final String getVTSelection() { - return vtSelection; + return this.vtSelection; } private String minTargets; @@ -128,7 +128,7 @@ public class Target { * @return a int. */ public final int getMinTargets(final Card c, final SpellAbility sa) { - return AbilityFactory.calculateAmount(c, minTargets, sa); + return AbilityFactory.calculateAmount(c, this.minTargets, sa); } /** @@ -143,7 +143,7 @@ public class Target { * @return a int. */ public final int getMaxTargets(final Card c, final SpellAbility sa) { - return AbilityFactory.calculateAmount(c, maxTargets, sa); + return AbilityFactory.calculateAmount(c, this.maxTargets, sa); } /** @@ -158,7 +158,7 @@ public class Target { * @return a boolean. */ public final boolean isMaxTargetsChosen(final Card c, final SpellAbility sa) { - return choice != null && getMaxTargets(c, sa) == choice.getNumTargeted(); + return (this.choice != null) && (this.getMaxTargets(c, sa) == this.choice.getNumTargeted()); } /** @@ -173,10 +173,10 @@ public class Target { * @return a boolean. */ public final boolean isMinTargetsChosen(final Card c, final SpellAbility sa) { - if (getMinTargets(c, sa) == 0) { + if (this.getMinTargets(c, sa) == 0) { return true; } - return choice != null && getMinTargets(c, sa) <= choice.getNumTargeted(); + return (this.choice != null) && (this.getMinTargets(c, sa) <= this.choice.getNumTargeted()); } private List tgtZone = Arrays.asList(Constant.Zone.Battlefield); @@ -190,7 +190,7 @@ public class Target { * a {@link java.lang.String} object. */ public final void setZone(final Constant.Zone tZone) { - tgtZone = Arrays.asList(tZone); + this.tgtZone = Arrays.asList(tZone); } /** @@ -200,7 +200,7 @@ public class Target { * the new zone */ public final void setZone(final List tZone) { - tgtZone = tZone; + this.tgtZone = tZone; } /** @@ -211,7 +211,7 @@ public class Target { * @return a {@link java.lang.String} object. */ public final List getZone() { - return tgtZone; + return this.tgtZone; } // Used for Counters. Currently, Spell,Activated,Triggered can be @@ -227,7 +227,7 @@ public class Target { * a {@link java.lang.String} object. */ public final void setTargetSpellAbilityType(final String tgtSAType) { - targetSpellAbilityType = tgtSAType; + this.targetSpellAbilityType = tgtSAType; } /** @@ -238,7 +238,7 @@ public class Target { * @return a {@link java.lang.String} object. */ public final String getTargetSpellAbilityType() { - return targetSpellAbilityType; + return this.targetSpellAbilityType; } // Used for Counters. The target SA of this SA must be targeting a Valid X @@ -253,7 +253,7 @@ public class Target { * a {@link java.lang.String} object. */ public final void setSAValidTargeting(final String saValidTgting) { - saValidTargeting = saValidTgting; + this.saValidTargeting = saValidTgting; } /** @@ -264,7 +264,7 @@ public class Target { * @return a {@link java.lang.String} object. */ public final String getSAValidTargeting() { - return saValidTargeting; + return this.saValidTargeting; } // Leaving old structure behind for compatibility. @@ -278,20 +278,20 @@ public class Target { * @return a boolean. */ public final boolean addTarget(final Object o) { - if (choice == null) { - choice = new Target_Choices(); + if (this.choice == null) { + this.choice = new Target_Choices(); } if (o instanceof Card) { - return choice.addTarget((Card) o); + return this.choice.addTarget((Card) o); } if (o instanceof Player) { - return choice.addTarget((Player) o); + return this.choice.addTarget((Player) o); } if (o instanceof SpellAbility) { - return choice.addTarget((SpellAbility) o); + return this.choice.addTarget((SpellAbility) o); } return false; @@ -305,11 +305,11 @@ public class Target { * @return a {@link java.util.ArrayList} object. */ public final ArrayList getTargetCards() { - if (choice == null) { + if (this.choice == null) { return new ArrayList(); } - return choice.getTargetCards(); + return this.choice.getTargetCards(); } /** @@ -320,11 +320,11 @@ public class Target { * @return a {@link java.util.ArrayList} object. */ public final ArrayList getTargetPlayers() { - if (choice == null) { + if (this.choice == null) { return new ArrayList(); } - return choice.getTargetPlayers(); + return this.choice.getTargetPlayers(); } /** @@ -335,11 +335,11 @@ public class Target { * @return a {@link java.util.ArrayList} object. */ public final ArrayList getTargetSAs() { - if (choice == null) { + if (this.choice == null) { return new ArrayList(); } - return choice.getTargetSAs(); + return this.choice.getTargetSAs(); } /** @@ -350,11 +350,11 @@ public class Target { * @return a {@link java.util.ArrayList} object. */ public final ArrayList getTargets() { - if (choice == null) { + if (this.choice == null) { return new ArrayList(); } - return choice.getTargets(); + return this.choice.getTargets(); } /** @@ -365,10 +365,10 @@ public class Target { * @return a int. */ public final int getNumTargeted() { - if (choice == null) { + if (this.choice == null) { return 0; } - return choice.getNumTargeted(); + return this.choice.getNumTargeted(); } /** @@ -377,7 +377,7 @@ public class Target { *

*/ public final void resetTargets() { - choice = null; + this.choice = null; } /** @@ -413,8 +413,8 @@ public class Target { // C = Creature P=Player/Planeswalker // CP = All three - tgtValid = true; - srcCard = src; + this.tgtValid = true; + this.srcCard = src; if (parse.contains("Tgt")) { parse = parse.replace("Tgt", ""); @@ -422,7 +422,7 @@ public class Target { String valid; String prompt; - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); if (parse.equals("CP")) { valid = "Creature,Planeswalker.YouDontCtrl,Player"; @@ -442,11 +442,11 @@ public class Target { sb.append(src + " - "); } sb.append(prompt); - vtSelection = sb.toString(); - ValidTgts = valid.split(","); + this.vtSelection = sb.toString(); + this.validTgts = valid.split(","); - minTargets = min; - maxTargets = max; + this.minTargets = min; + this.maxTargets = max; } /** @@ -498,13 +498,13 @@ public class Target { * a {@link java.lang.String} object. */ public Target(final Card src, final String select, final String[] valid, final String min, final String max) { - srcCard = src; - tgtValid = true; - vtSelection = select; - ValidTgts = valid; + this.srcCard = src; + this.tgtValid = true; + this.vtSelection = select; + this.validTgts = valid; - minTargets = min; - maxTargets = max; + this.minTargets = min; + this.maxTargets = max; } /** @@ -515,15 +515,15 @@ public class Target { * @return a {@link java.lang.String} object. */ public final String getTargetedString() { - ArrayList tgts = getTargets(); - StringBuilder sb = new StringBuilder(""); - for (Object o : tgts) { + final ArrayList tgts = this.getTargets(); + final StringBuilder sb = new StringBuilder(""); + for (final Object o : tgts) { if (o instanceof Player) { - Player p = (Player) o; + final Player p = (Player) o; sb.append(p.getName()); } if (o instanceof Card) { - Card c = (Card) o; + final Card c = (Card) o; sb.append(c); } sb.append(" "); @@ -542,7 +542,7 @@ public class Target { public final boolean canOnlyTgtOpponent() { boolean player = false; boolean opponent = false; - for (String s : ValidTgts) { + for (final String s : this.validTgts) { if (s.equals("Opponent")) { opponent = true; } else if (s.equals("Player")) { @@ -560,7 +560,7 @@ public class Target { * @return a boolean. */ public final boolean canTgtPlayer() { - for (String s : ValidTgts) { + for (final String s : this.validTgts) { if (s.equals("Player") || s.equals("Opponent")) { return true; } @@ -577,7 +577,7 @@ public class Target { */ public final boolean canTgtPermanent() { - for (String s : ValidTgts) { + for (final String s : this.validTgts) { if (s.contains("Permanent")) { return true; } @@ -591,7 +591,7 @@ public class Target { * @return true, if successful */ public final boolean canTgtCreature() { - for (String s : ValidTgts) { + for (final String s : this.validTgts) { if (s.contains("Creature") && !s.contains("nonCreature")) { return true; } @@ -607,7 +607,7 @@ public class Target { * @return a boolean. */ public final boolean canTgtCreatureAndPlayer() { - return canTgtPlayer() && canTgtCreature(); + return this.canTgtPlayer() && this.canTgtCreature(); } /** @@ -621,13 +621,13 @@ public class Target { * @return a boolean. */ public final boolean hasCandidates(final boolean isTargeted) { - if (canTgtPlayer()) { + if (this.canTgtPlayer()) { return true; } - for (Card c : AllZoneUtil.getCardsIn(tgtZone)) { - if (c.isValid(ValidTgts, srcCard.getController(), srcCard) - && (!isTargeted || CardFactoryUtil.canTarget(srcCard, c))) { + for (final Card c : AllZoneUtil.getCardsIn(this.tgtZone)) { + if (c.isValid(this.validTgts, this.srcCard.getController(), this.srcCard) + && (!isTargeted || CardFactoryUtil.canTarget(this.srcCard, c))) { return true; } } @@ -641,7 +641,7 @@ public class Target { * @return true, if is unique targets */ public final boolean isUniqueTargets() { - return uniqueTargets; + return this.uniqueTargets; } /** diff --git a/src/main/java/forge/card/spellability/Target_Choices.java b/src/main/java/forge/card/spellability/Target_Choices.java index 1eaec834fad..19af10746a8 100644 --- a/src/main/java/forge/card/spellability/Target_Choices.java +++ b/src/main/java/forge/card/spellability/Target_Choices.java @@ -24,13 +24,13 @@ public class Target_Choices { * @return a int. */ public final int getNumTargeted() { - return numTargeted; + return this.numTargeted; } // Card or Player are legal targets. - private ArrayList targetCards = new ArrayList(); - private ArrayList targetPlayers = new ArrayList(); - private ArrayList targetSAs = new ArrayList(); + private final ArrayList targetCards = new ArrayList(); + private final ArrayList targetPlayers = new ArrayList(); + private final ArrayList targetSAs = new ArrayList(); /** *

@@ -43,11 +43,11 @@ public class Target_Choices { */ public final boolean addTarget(final Object o) { if (o instanceof Player) { - return addTarget((Player) o); + return this.addTarget((Player) o); } else if (o instanceof Card) { - return addTarget((Card) o); + return this.addTarget((Card) o); } else if (o instanceof SpellAbility) { - return addTarget((SpellAbility) o); + return this.addTarget((SpellAbility) o); } return false; @@ -63,9 +63,9 @@ public class Target_Choices { * @return a boolean. */ public final boolean addTarget(final Card c) { - if (!targetCards.contains(c)) { - targetCards.add(c); - numTargeted++; + if (!this.targetCards.contains(c)) { + this.targetCards.add(c); + this.numTargeted++; return true; } return false; @@ -81,9 +81,9 @@ public class Target_Choices { * @return a boolean. */ public final boolean addTarget(final Player p) { - if (!targetPlayers.contains(p)) { - targetPlayers.add(p); - numTargeted++; + if (!this.targetPlayers.contains(p)) { + this.targetPlayers.add(p); + this.numTargeted++; return true; } return false; @@ -99,9 +99,9 @@ public class Target_Choices { * @return a boolean. */ public final boolean addTarget(final SpellAbility sa) { - if (!targetSAs.contains(sa)) { - targetSAs.add(sa); - numTargeted++; + if (!this.targetSAs.contains(sa)) { + this.targetSAs.add(sa); + this.numTargeted++; return true; } return false; @@ -115,7 +115,7 @@ public class Target_Choices { * @return a {@link java.util.ArrayList} object. */ public final ArrayList getTargetCards() { - return targetCards; + return this.targetCards; } /** @@ -126,7 +126,7 @@ public class Target_Choices { * @return a {@link java.util.ArrayList} object. */ public final ArrayList getTargetPlayers() { - return targetPlayers; + return this.targetPlayers; } /** @@ -137,7 +137,7 @@ public class Target_Choices { * @return a {@link java.util.ArrayList} object. */ public final ArrayList getTargetSAs() { - return targetSAs; + return this.targetSAs; } /** @@ -148,10 +148,10 @@ public class Target_Choices { * @return a {@link java.util.ArrayList} object. */ public final ArrayList getTargets() { - ArrayList tgts = new ArrayList(); - tgts.addAll(targetPlayers); - tgts.addAll(targetCards); - tgts.addAll(targetSAs); + final ArrayList tgts = new ArrayList(); + tgts.addAll(this.targetPlayers); + tgts.addAll(this.targetCards); + tgts.addAll(this.targetSAs); return tgts; } @@ -164,19 +164,19 @@ public class Target_Choices { * @return a {@link java.lang.String} object. */ public final String getTargetedString() { - ArrayList tgts = getTargets(); - StringBuilder sb = new StringBuilder(""); - for (Object o : tgts) { + final ArrayList tgts = this.getTargets(); + final StringBuilder sb = new StringBuilder(""); + for (final Object o : tgts) { if (o instanceof Player) { - Player p = (Player) o; + final Player p = (Player) o; sb.append(p.getName()); } if (o instanceof Card) { - Card c = (Card) o; + final Card c = (Card) o; sb.append(c); } if (o instanceof SpellAbility) { - SpellAbility sa = (SpellAbility) o; + final SpellAbility sa = (SpellAbility) o; sb.append(sa); } sb.append(" "); diff --git a/src/main/java/forge/card/spellability/Target_Selection.java b/src/main/java/forge/card/spellability/Target_Selection.java index 75c8c63b1ff..b6497b403f0 100644 --- a/src/main/java/forge/card/spellability/Target_Selection.java +++ b/src/main/java/forge/card/spellability/Target_Selection.java @@ -39,7 +39,7 @@ public class Target_Selection { * @return a {@link forge.card.spellability.Target} object. */ public final Target getTgt() { - return target; + return this.target; } /** @@ -50,7 +50,7 @@ public class Target_Selection { * @return a {@link forge.card.spellability.SpellAbility} object. */ public final SpellAbility getAbility() { - return ability; + return this.ability; } /** @@ -61,7 +61,7 @@ public class Target_Selection { * @return a {@link forge.Card} object. */ public final Card getCard() { - return card; + return this.card; } private SpellAbility_Requirements req = null; @@ -76,7 +76,7 @@ public class Target_Selection { * object. */ public final void setRequirements(final SpellAbility_Requirements reqs) { - req = reqs; + this.req = reqs; } private boolean bCancel = false; @@ -90,7 +90,7 @@ public class Target_Selection { * a boolean. */ public final void setCancel(final boolean done) { - bCancel = done; + this.bCancel = done; } /** @@ -101,15 +101,15 @@ public class Target_Selection { * @return a boolean. */ public final boolean isCanceled() { - if (bCancel) { - return bCancel; + if (this.bCancel) { + return this.bCancel; } - if (subSelection == null) { + if (this.subSelection == null) { return false; } - return subSelection.isCanceled(); + return this.subSelection.isCanceled(); } private boolean bDoneTarget = false; @@ -123,7 +123,7 @@ public class Target_Selection { * a boolean. */ public final void setDoneTarget(final boolean done) { - bDoneTarget = done; + this.bDoneTarget = done; } /** @@ -137,9 +137,9 @@ public class Target_Selection { * a {@link forge.card.spellability.SpellAbility} object. */ public Target_Selection(final Target tgt, final SpellAbility sa) { - target = tgt; - ability = sa; - card = sa.getSourceCard(); + this.target = tgt; + this.ability = sa; + this.card = sa.getSourceCard(); } /** @@ -150,10 +150,10 @@ public class Target_Selection { * @return a boolean. */ public final boolean doesTarget() { - if (target == null) { + if (this.target == null) { return false; } - return target.doesTarget(); + return this.target.doesTarget(); } /** @@ -162,8 +162,8 @@ public class Target_Selection { *

*/ public final void resetTargets() { - if (target != null) { - target.resetTargets(); + if (this.target != null) { + this.target.resetTargets(); } } @@ -176,28 +176,28 @@ public class Target_Selection { */ public final boolean chooseTargets() { // if not enough targets chosen, reset and cancel Ability - if (bCancel || (bDoneTarget && !target.isMinTargetsChosen(card, ability))) { - bCancel = true; - req.finishedTargeting(); + if (this.bCancel || (this.bDoneTarget && !this.target.isMinTargetsChosen(this.card, this.ability))) { + this.bCancel = true; + this.req.finishedTargeting(); return false; - } else if (!doesTarget() || bDoneTarget && target.isMinTargetsChosen(card, ability) - || target.isMaxTargetsChosen(card, ability)) { - Ability_Sub abSub = ability.getSubAbility(); + } else if (!this.doesTarget() || (this.bDoneTarget && this.target.isMinTargetsChosen(this.card, this.ability)) + || this.target.isMaxTargetsChosen(this.card, this.ability)) { + final Ability_Sub abSub = this.ability.getSubAbility(); if (abSub == null) { // if no more SubAbilities finish targeting - req.finishedTargeting(); + this.req.finishedTargeting(); return true; } else { // Has Sub Ability - subSelection = new Target_Selection(abSub.getTarget(), abSub); - subSelection.setRequirements(req); - subSelection.resetTargets(); - return subSelection.chooseTargets(); + this.subSelection = new Target_Selection(abSub.getTarget(), abSub); + this.subSelection.setRequirements(this.req); + this.subSelection.resetTargets(); + return this.subSelection.chooseTargets(); } } - chooseValidInput(); + this.chooseValidInput(); return false; } @@ -210,7 +210,7 @@ public class Target_Selection { * @return the unique targets */ public final ArrayList getUniqueTargets(final SpellAbility ability) { - ArrayList targets = new ArrayList(); + final ArrayList targets = new ArrayList(); SpellAbility child = ability; while (child instanceof Ability_Sub) { child = ((Ability_Sub) child).getParent(); @@ -231,43 +231,43 @@ public class Target_Selection { *

*/ public final void chooseValidInput() { - Target tgt = this.getTgt(); - List zone = tgt.getZone(); - final boolean mandatory = target.getMandatory() ? target.hasCandidates(true) : false; + final Target tgt = this.getTgt(); + final List zone = tgt.getZone(); + final boolean mandatory = this.target.getMandatory() ? this.target.hasCandidates(true) : false; - if (zone.contains(Constant.Zone.Stack) && zone.size() == 1) { + if (zone.contains(Constant.Zone.Stack) && (zone.size() == 1)) { // If Zone is Stack, the choices are handled slightly differently - chooseCardFromStack(mandatory); + this.chooseCardFromStack(mandatory); return; } - CardList choices = AllZoneUtil.getCardsIn(zone).getValidCards(target.getValidTgts(), - ability.getActivatingPlayer(), ability.getSourceCard()); + final CardList choices = AllZoneUtil.getCardsIn(zone).getValidCards(this.target.getValidTgts(), + this.ability.getActivatingPlayer(), this.ability.getSourceCard()); ArrayList objects = new ArrayList(); if (tgt.isUniqueTargets()) { - objects = getUniqueTargets(ability); - for (Object o : objects) { - if (o instanceof Card && objects.contains(o)) { + objects = this.getUniqueTargets(this.ability); + for (final Object o : objects) { + if ((o instanceof Card) && objects.contains(o)) { choices.remove((Card) o); } } } // Remove cards already targeted - ArrayList targeted = tgt.getTargetCards(); - for (Card c : targeted) { + final ArrayList targeted = tgt.getTargetCards(); + for (final Card c : targeted) { if (choices.contains(c)) { choices.remove(c); } } if (zone.contains(Constant.Zone.Battlefield)) { - AllZone.getInputControl().setInput(input_targetSpecific(choices, true, mandatory, objects)); + AllZone.getInputControl().setInput(this.inputTargetSpecific(choices, true, mandatory, objects)); } else { - chooseCardFromList(choices, true, mandatory); + this.chooseCardFromList(choices, true, mandatory); } - }// input_targetValid + } // input_targetValid // CardList choices are the only cards the user can successful select /** @@ -285,22 +285,21 @@ public class Target_Selection { * the already targeted * @return a {@link forge.gui.input.Input} object. */ - public final Input input_targetSpecific(final CardList choices, - final boolean targeted, final boolean mandatory, + public final Input inputTargetSpecific(final CardList choices, final boolean targeted, final boolean mandatory, final ArrayList alreadyTargeted) { final SpellAbility sa = this.ability; final Target_Selection select = this; final Target tgt = this.target; final SpellAbility_Requirements req = this.req; - Input target = new Input() { + final Input target = new Input() { private static final long serialVersionUID = -1091595663541356356L; @Override public void showMessage() { - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); sb.append("Targeted: "); - for (Object o : alreadyTargeted) { + for (final Object o : alreadyTargeted) { sb.append(o).append(" "); } sb.append(tgt.getTargetedString()); @@ -324,14 +323,14 @@ public class Target_Selection { @Override public void selectButtonCancel() { select.setCancel(true); - stop(); + this.stop(); req.finishedTargeting(); } @Override public void selectButtonOK() { select.setDoneTarget(true); - done(); + this.done(); } @Override @@ -342,7 +341,7 @@ public class Target_Selection { AllZone.getDisplay().showMessage("Cannot target this card (Shroud? Protection? Restrictions?)."); } else if (choices.contains(card)) { tgt.addTarget(card); - done(); + this.done(); } } // selectCard() @@ -355,12 +354,12 @@ public class Target_Selection { if ((tgt.canTgtPlayer() || (tgt.canOnlyTgtOpponent() && player.equals(sa.getActivatingPlayer() .getOpponent()))) && player.canTarget(sa)) { tgt.addTarget(player); - done(); + this.done(); } } void done() { - stop(); + this.stop(); select.chooseTargets(); } @@ -388,16 +387,16 @@ public class Target_Selection { final SpellAbility sa = this.ability; final String message = this.target.getVTSelection(); - Target tgt = this.getTgt(); + final Target tgt = this.getTgt(); - CardList choicesWithDone = choices; + final CardList choicesWithDone = choices; if (tgt.isMinTargetsChosen(sa.getSourceCard(), sa)) { // is there a more elegant way of doing this? choicesWithDone.add(dummy); } - Object check = GuiUtils.getChoiceOptional(message, choicesWithDone.toArray()); + final Object check = GuiUtils.getChoiceOptional(message, choicesWithDone.toArray()); if (check != null) { - Card c = (Card) check; + final Card c = (Card) check; if (c.equals(dummy)) { this.setDoneTarget(true); } else { @@ -419,16 +418,16 @@ public class Target_Selection { * a boolean. */ public final void chooseCardFromStack(final boolean mandatory) { - Target tgt = this.target; - String message = tgt.getVTSelection(); - Target_Selection select = this; + final Target tgt = this.target; + final String message = tgt.getVTSelection(); + final Target_Selection select = this; // Find what's targetable, then allow human to choose - ArrayList choosables = getTargetableOnStack(this.ability, select.getTgt()); + final ArrayList choosables = Target_Selection.getTargetableOnStack(this.ability, select.getTgt()); - HashMap map = new HashMap(); + final HashMap map = new HashMap(); - for (SpellAbility sa : choosables) { + for (final SpellAbility sa : choosables) { map.put(sa.getStackDescription(), sa); } @@ -438,7 +437,7 @@ public class Target_Selection { if (choices.length == 0) { select.setCancel(true); } else { - String madeChoice = GuiUtils.getChoiceOptional(message, choices); + final String madeChoice = GuiUtils.getChoiceOptional(message, choices); if (madeChoice != null) { tgt.addTarget(map.get(madeChoice)); @@ -465,14 +464,14 @@ public class Target_Selection { * @return a {@link java.util.ArrayList} object. */ public static ArrayList getTargetableOnStack(final SpellAbility sa, final Target tgt) { - ArrayList choosables = new ArrayList(); + final ArrayList choosables = new ArrayList(); for (int i = 0; i < AllZone.getStack().size(); i++) { choosables.add(AllZone.getStack().peekAbility(i)); } for (int i = 0; i < choosables.size(); i++) { - if (!matchSpellAbility(sa, choosables.get(i), tgt)) { + if (!Target_Selection.matchSpellAbility(sa, choosables.get(i), tgt)) { choosables.remove(i); } } @@ -493,7 +492,7 @@ public class Target_Selection { * @return a boolean. */ public static boolean matchSpellAbility(final SpellAbility sa, final SpellAbility topSA, final Target tgt) { - String saType = tgt.getTargetSpellAbilityType(); + final String saType = tgt.getTargetSpellAbilityType(); if (null == saType) { // just take this to mean no restrictions - carry on. @@ -511,11 +510,11 @@ public class Target_Selection { } } - String splitTargetRestrictions = tgt.getSAValidTargeting(); + final String splitTargetRestrictions = tgt.getSAValidTargeting(); if (splitTargetRestrictions != null) { // TODO What about spells with SubAbilities with Targets? - Target matchTgt = topSA.getTarget(); + final Target matchTgt = topSA.getTarget(); if (matchTgt == null) { return false; @@ -523,8 +522,8 @@ public class Target_Selection { boolean result = false; - for (Object o : matchTgt.getTargets()) { - if (matchesValid(o, splitTargetRestrictions.split(","), sa)) { + for (final Object o : matchTgt.getTargets()) { + if (Target_Selection.matchesValid(o, splitTargetRestrictions.split(","), sa)) { result = true; break; } @@ -535,7 +534,7 @@ public class Target_Selection { } } - if (!matchesValid(topSA, tgt.getValidTgts(), sa)) { + if (!Target_Selection.matchesValid(topSA, tgt.getValidTgts(), sa)) { return false; } @@ -556,15 +555,15 @@ public class Target_Selection { * @return a boolean. */ private static boolean matchesValid(final Object o, final String[] valids, final SpellAbility sa) { - Card srcCard = sa.getSourceCard(); - Player activatingPlayer = sa.getActivatingPlayer(); + final Card srcCard = sa.getSourceCard(); + final Player activatingPlayer = sa.getActivatingPlayer(); if (o instanceof Card) { - Card c = (Card) o; + final Card c = (Card) o; return c.isValid(valids, activatingPlayer, srcCard); } if (o instanceof Player) { - for (String v : valids) { + for (final String v : valids) { if (v.equalsIgnoreCase("Player")) { return true; } @@ -581,7 +580,7 @@ public class Target_Selection { } if (o instanceof SpellAbility) { - Card c = ((SpellAbility) o).getSourceCard(); + final Card c = ((SpellAbility) o).getSourceCard(); return c.isValid(valids, activatingPlayer, srcCard); } diff --git a/src/main/java/forge/gui/input/Input_PayManaCost_Ability.java b/src/main/java/forge/gui/input/Input_PayManaCost_Ability.java index 2be1766e2f0..fedf87700dd 100644 --- a/src/main/java/forge/gui/input/Input_PayManaCost_Ability.java +++ b/src/main/java/forge/gui/input/Input_PayManaCost_Ability.java @@ -104,7 +104,7 @@ public class Input_PayManaCost_Ability extends Input { public Input_PayManaCost_Ability(final String m, final String manaCost_2, final Command paidCommand_2, final Command unpaidCommand_2, final boolean showOKButton) { - fakeAbility = new SpellAbility(SpellAbility.Ability, null) { + fakeAbility = new SpellAbility(SpellAbility.getAbility(), null) { @Override public void resolve() { }