checkstyle and refactor

This commit is contained in:
jendave
2011-10-31 14:49:15 +00:00
parent c3c4e4584e
commit ad7f49d808
20 changed files with 802 additions and 759 deletions

View File

@@ -94,7 +94,7 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn
* a {@link java.io.File} object. * a {@link java.io.File} object.
*/ */
protected AbstractCardFactory(final File file) { 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 // neither computer nor human play can play this card
@Override @Override
public boolean canPlay() { public boolean canPlay() {

View File

@@ -2638,7 +2638,7 @@ public class CardFactory_Creatures {
abilityBuilder.append(" | SpellDescription$ Target creature can't block CARDNAME this turn."); abilityBuilder.append(" | SpellDescription$ Target creature can't block CARDNAME this turn.");
final SpellAbility myAb = createAb.getAbility(abilityBuilder.toString(), card); final SpellAbility myAb = createAb.getAbility(abilityBuilder.toString(), card);
myAb.getTarget().setTargetChoices(this.chosenTarget.getTargetChoices()); myAb.getTarget().setTargetChoices(this.getChosenTarget().getTargetChoices());
myAb.resolve(); myAb.resolve();
} }

View File

@@ -19,7 +19,7 @@ import forge.Constant.Zone;
*/ */
public abstract class Ability extends SpellAbility { public abstract class Ability extends SpellAbility {
// Slight hack for Pithing Needle // Slight hack for Pithing Needle
private String sourceCardName; private final String sourceCardName;
/** /**
* <p> * <p>
@@ -32,9 +32,9 @@ public abstract class Ability extends SpellAbility {
* a {@link java.lang.String} object. * a {@link java.lang.String} object.
*/ */
public Ability(final Card sourceCard, final String manaCost) { public Ability(final Card sourceCard, final String manaCost) {
super(SpellAbility.Ability, sourceCard); super(SpellAbility.getAbility(), sourceCard);
setManaCost(manaCost); this.setManaCost(manaCost);
sourceCardName = sourceCard.getName(); 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) { public Ability(final Card sourceCard, final String manaCost, final String stackDescription) {
this(sourceCard, manaCost); this(sourceCard, manaCost);
setStackDescription(stackDescription); this.setStackDescription(stackDescription);
Log.debug("an ability is being played from" + sourceCard.getName()); 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.addAll(AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield));
pithing = pithing.getName("Pithing Needle"); pithing = pithing.getName("Pithing Needle");
pithing = pithing.filter(new CardListFilter() { pithing = pithing.filter(new CardListFilter() {
@Override
public boolean addCard(final Card c) { 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() return AllZoneUtil.isCardInPlay(this.getSourceCard()) && !this.getSourceCard().isFaceDown()
&& !getSourceCard().getName().equals("Spreading Seas") && pithing.size() == 0; && !this.getSourceCard().getName().equals("Spreading Seas") && (pithing.size() == 0);
} }
} }

View File

@@ -52,11 +52,11 @@ public abstract class Ability_Activated extends SpellAbility implements java.io.
* a {@link forge.card.spellability.Target} object. * a {@link forge.card.spellability.Target} object.
*/ */
public Ability_Activated(final Card sourceCard, final Cost abCost, final Target tgt) { public Ability_Activated(final Card sourceCard, final Cost abCost, final Target tgt) {
super(SpellAbility.Ability, sourceCard); super(SpellAbility.getAbility(), sourceCard);
setManaCost(abCost.getTotalMana()); this.setManaCost(abCost.getTotalMana());
setPayCosts(abCost); this.setPayCosts(abCost);
if (tgt != null && tgt.doesTarget()) { if ((tgt != null) && tgt.doesTarget()) {
setTarget(tgt); this.setTarget(tgt);
} }
} }
@@ -67,26 +67,27 @@ public abstract class Ability_Activated extends SpellAbility implements java.io.
return false; return false;
} }
final Card c = getSourceCard(); final Card c = this.getSourceCard();
if (c.isFaceDown() && isIntrinsic()) { // Intrinsic abilities can't be if (c.isFaceDown() && this.isIntrinsic()) { // Intrinsic abilities can't
// activated by face down cards // be
// activated by face down cards
return false; return false;
} }
Player activator = getActivatingPlayer(); final Player activator = this.getActivatingPlayer();
// CantBeActivated static abilities // CantBeActivated static abilities
CardList allp = AllZoneUtil.getCardsIn(Zone.Battlefield); final CardList allp = AllZoneUtil.getCardsIn(Zone.Battlefield);
for (Card ca : allp) { for (final Card ca : allp) {
ArrayList<StaticAbility> staticAbilities = ca.getStaticAbilities(); final ArrayList<StaticAbility> staticAbilities = ca.getStaticAbilities();
for (StaticAbility stAb : staticAbilities) { for (final StaticAbility stAb : staticAbilities) {
if (stAb.applyAbility("CantBeActivated", c, activator)) { if (stAb.applyAbility("CantBeActivated", c, activator)) {
return false; 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; return false;
} }
@@ -94,19 +95,20 @@ public abstract class Ability_Activated extends SpellAbility implements java.io.
pithing.addAll(AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield)); pithing.addAll(AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield));
pithing = pithing.getName("Pithing Needle"); pithing = pithing.getName("Pithing Needle");
pithing = pithing.filter(new CardListFilter() { pithing = pithing.filter(new CardListFilter() {
@Override
public boolean addCard(final Card crd) { public boolean addCard(final Card crd) {
return crd.getSVar("PithingTarget").equals(c.getName()); 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; return false;
} }
if (!(getRestrictions().canPlay(c, this))) { if (!(this.getRestrictions().canPlay(c, this))) {
return false; return false;
} }
return Cost_Payment.canPayAdditionalCosts(payCosts, this); return Cost_Payment.canPayAdditionalCosts(this.getPayCosts(), this);
} }
} }

View File

@@ -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) { public Ability_Mana(final Card sourceCard, final Cost cost, final String produced, final int num) {
super(sourceCard, cost, null); super(sourceCard, cost, null);
origProduced = produced; this.origProduced = produced;
amount = num; this.amount = num;
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@@ -113,7 +113,7 @@ public abstract class Ability_Mana extends Ability_Activated implements java.io.
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public void resolve() { public void resolve() {
produceMana(); this.produceMana();
} }
/** /**
@@ -122,25 +122,25 @@ public abstract class Ability_Mana extends Ability_Activated implements java.io.
* </p> * </p>
*/ */
public final void produceMana() { public final void produceMana() {
StringBuilder sb = new StringBuilder(); final StringBuilder sb = new StringBuilder();
if (amount == 0) { if (this.amount == 0) {
sb.append("0"); sb.append("0");
} else { } else {
try { try {
// if baseMana is an integer(colorless), just multiply amount // if baseMana is an integer(colorless), just multiply amount
// and baseMana // and baseMana
int base = Integer.parseInt(origProduced); final int base = Integer.parseInt(this.origProduced);
sb.append(base * amount); sb.append(base * this.amount);
} catch (NumberFormatException e) { } catch (final NumberFormatException e) {
for (int i = 0; i < amount; i++) { for (int i = 0; i < this.amount; i++) {
if (i != 0) { if (i != 0) {
sb.append(" "); 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) { public final void produceMana(final String produced, final Player player) {
final Card source = this.getSourceCard(); final Card source = this.getSourceCard();
ManaPool manaPool = player.getManaPool(); final ManaPool manaPool = player.getManaPool();
// change this, once ManaPool moves to the Player // change this, once ManaPool moves to the Player
// this.getActivatingPlayer().ManaPool.addManaToFloating(origProduced, // this.getActivatingPlayer().ManaPool.addManaToFloating(origProduced,
// getSourceCard()); // getSourceCard());
@@ -175,7 +175,7 @@ public abstract class Ability_Mana extends Ability_Activated implements java.io.
} }
// Run triggers // Run triggers
HashMap<String, Object> runParams = new HashMap<String, Object>(); final HashMap<String, Object> runParams = new HashMap<String, Object>();
runParams.put("Card", source); runParams.put("Card", source);
runParams.put("Player", player); 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. * @return a {@link java.lang.String} object.
*/ */
public final String mana() { 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. * a {@link java.lang.String} object.
*/ */
public final void setMana(final String s) { 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. * a boolean.
*/ */
public final void setReflectedMana(final boolean bReflect) { 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. * @return a boolean.
*/ */
public final boolean isSacrifice() { 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. * @return a boolean.
*/ */
public final boolean isReflectedMana() { 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. * @return a boolean.
*/ */
public final boolean canProduce(final String s) { 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. * @return a boolean.
*/ */
public final boolean isBasic() { public final boolean isBasic() {
if (origProduced.length() != 1) { if (this.origProduced.length() != 1) {
return false; return false;
} }
if (amount > 1) { if (this.amount > 1) {
return false; return false;
} }
@@ -293,7 +293,7 @@ public abstract class Ability_Mana extends Ability_Activated implements java.io.
* @return a boolean. * @return a boolean.
*/ */
public final boolean isUndoable() { 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. * a boolean.
*/ */
public final void setUndoable(final boolean bUndo) { 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. * a boolean.
*/ */
public final void setCanceled(final boolean bCancel) { 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. * @return a boolean.
*/ */
public final boolean getCanceled() { public final boolean getCanceled() {
return canceled; return this.canceled;
} }
/** /**
@@ -337,8 +337,8 @@ public abstract class Ability_Mana extends Ability_Activated implements java.io.
* </p> * </p>
*/ */
public final void undo() { public final void undo() {
if (isUndoable()) { if (this.isUndoable()) {
getPayCosts().refundPaidCost(getSourceCard()); this.getPayCosts().refundPaidCost(this.getSourceCard());
} }
} }
@@ -346,13 +346,13 @@ public abstract class Ability_Mana extends Ability_Activated implements java.io.
@Override @Override
public final boolean equals(final Object o) { public final boolean equals(final Object o) {
// Mana abilities with same Descriptions are "equal" // Mana abilities with same Descriptions are "equal"
if (o == null || !(o instanceof Ability_Mana)) { if ((o == null) || !(o instanceof Ability_Mana)) {
return false; 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; return false;
} }

View File

@@ -27,7 +27,7 @@ public abstract class Ability_Sub extends SpellAbility implements java.io.Serial
* a {@link forge.card.spellability.Target} object. * a {@link forge.card.spellability.Target} object.
*/ */
public Ability_Sub(final Card sourceCard, final Target tgt) { public Ability_Sub(final Card sourceCard, final Target tgt) {
super(SpellAbility.Ability, sourceCard); super(SpellAbility.getAbility(), sourceCard);
this.setTarget(tgt); this.setTarget(tgt);
} }

View File

@@ -30,24 +30,25 @@ public class Ability_Triggered extends Ability implements Command {
/** /**
* Gets the trigger. * Gets the trigger.
* *
* @return the trigger * @return the trigger
*/ */
public final ZCTrigger getTrigger() { public final ZCTrigger getTrigger() {
return trigger; return this.trigger;
} }
/** /**
* Sets the trigger. * Sets the trigger.
* *
* @param trigger the new trigger * @param trigger
* the new trigger
*/ */
public final void setTrigger(final ZCTrigger trigger) { public final void setTrigger(final ZCTrigger trigger) {
this.trigger = trigger; this.trigger = trigger;
} }
/** The todo. */ /** The todo. */
private Command todo; private final Command todo;
/** /**
* <p> * <p>
@@ -63,15 +64,15 @@ public class Ability_Triggered extends Ability implements Command {
*/ */
public Ability_Triggered(final Card sourceCard, final Command sourceCommand, final ZCTrigger situation) { public Ability_Triggered(final Card sourceCard, final Command sourceCommand, final ZCTrigger situation) {
super(sourceCard, "0"); super(sourceCard, "0");
setTrigger(true); this.setTrigger(true);
todo = sourceCommand; this.todo = sourceCommand;
trigger = situation; this.trigger = situation;
if (todo instanceof Ability_Triggered) { if (this.todo instanceof Ability_Triggered) {
setStackDescription(((SpellAbility) todo).getStackDescription()); this.setStackDescription(((SpellAbility) this.todo).getStackDescription());
restrictions = ((Ability_Triggered) todo).restrictions; this.restrictions = ((Ability_Triggered) this.todo).restrictions;
} else { } else {
setStackDescription("Triggered ability: " + sourceCard + " " + situation); this.setStackDescription("Triggered ability: " + sourceCard + " " + situation);
restrictions = new String[] {"named " + sourceCard.getName()}; this.restrictions = new String[] { "named " + sourceCard.getName() };
} }
} }
@@ -90,7 +91,7 @@ public class Ability_Triggered extends Ability implements Command {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public final void resolve() { public final void resolve() {
todo.execute(); this.todo.execute();
} }
/** /**
@@ -98,8 +99,9 @@ public class Ability_Triggered extends Ability implements Command {
* execute. * execute.
* </p> * </p>
*/ */
@Override
public final void execute() { public final void execute() {
resolve(); this.resolve();
} }
/** /**
@@ -112,7 +114,7 @@ public class Ability_Triggered extends Ability implements Command {
* @return a boolean. * @return a boolean.
*/ */
public final boolean triggerFor(final Card c) { 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. * @return a boolean.
*/ */
public final boolean triggerOnZoneChange(final String sourceZone, final String destinationZone) { public final boolean triggerOnZoneChange(final String sourceZone, final String destinationZone) {
return trigger.triggerOn(sourceZone, destinationZone); return this.trigger.triggerOn(sourceZone, destinationZone);
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @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)) { if (!(o instanceof Ability_Triggered)) {
return false; return false;
} }
Ability_Triggered tmp = (Ability_Triggered) o; final Ability_Triggered tmp = (Ability_Triggered) o;
return tmp.getSourceCard().equals(getSourceCard()) && tmp.trigger.equals(trigger) && tmp.todo.equals(todo) return tmp.getSourceCard().equals(this.getSourceCard()) && tmp.trigger.equals(this.trigger)
&& Arrays.equals(tmp.restrictions, restrictions); && 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. * @return a boolean.
*/ */
public final boolean isBasic() { 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());
} }
} }

View File

@@ -37,11 +37,11 @@ public abstract class Spell extends SpellAbility implements java.io.Serializable
* a {@link forge.Card} object. * a {@link forge.Card} object.
*/ */
public Spell(final Card sourceCard) { public Spell(final Card sourceCard) {
super(SpellAbility.Spell, sourceCard); super(SpellAbility.getSpell(), sourceCard);
setManaCost(sourceCard.getManaCost()); this.setManaCost(sourceCard.getManaCost());
setStackDescription(sourceCard.getSpellText()); this.setStackDescription(sourceCard.getSpellText());
getRestrictions().setZone(Constant.Zone.Hand); 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. * a {@link forge.card.spellability.Target} object.
*/ */
public Spell(final Card sourceCard, final Cost abCost, final Target abTgt) { 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); this.setPayCosts(abCost);
setTarget(abTgt); this.setTarget(abTgt);
setStackDescription(sourceCard.getSpellText()); this.setStackDescription(sourceCard.getSpellText());
getRestrictions().setZone(Constant.Zone.Hand); this.getRestrictions().setZone(Constant.Zone.Hand);
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@@ -74,16 +74,16 @@ public abstract class Spell extends SpellAbility implements java.io.Serializable
return false; return false;
} }
Card card = getSourceCard(); final Card card = this.getSourceCard();
Player activator = getActivatingPlayer(); final Player activator = this.getActivatingPlayer();
// CantBeCast static abilities // CantBeCast static abilities
CardList allp = AllZoneUtil.getCardsIn(Zone.Battlefield); final CardList allp = AllZoneUtil.getCardsIn(Zone.Battlefield);
allp.add(card); allp.add(card);
for (Card ca : allp) { for (final Card ca : allp) {
ArrayList<StaticAbility> staticAbilities = ca.getStaticAbilities(); final ArrayList<StaticAbility> staticAbilities = ca.getStaticAbilities();
for (StaticAbility stAb : staticAbilities) { for (final StaticAbility stAb : staticAbilities) {
if (stAb.applyAbility("CantBeCast", card, activator)) { if (stAb.applyAbility("CantBeCast", card, activator)) {
return false; return false;
} }
@@ -94,8 +94,8 @@ public abstract class Spell extends SpellAbility implements java.io.Serializable
return false; return false;
} }
if (payCosts != null) { if (this.getPayCosts() != null) {
if (!Cost_Payment.canPayAdditionalCosts(payCosts, this)) { if (!Cost_Payment.canPayAdditionalCosts(this.getPayCosts(), this)) {
return false; return false;
} }
} }
@@ -110,9 +110,9 @@ public abstract class Spell extends SpellAbility implements java.io.Serializable
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public boolean canPlayAI() { public boolean canPlayAI() {
Card card = getSourceCard(); final Card card = this.getSourceCard();
if (card.getSVar("NeedsToPlay").length() > 0) { if (card.getSVar("NeedsToPlay").length() > 0) {
String needsToPlay = card.getSVar("NeedsToPlay"); final String needsToPlay = card.getSVar("NeedsToPlay");
CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield); CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield);
list = list.getValidCards(needsToPlay.split(","), card.getController(), card); 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() { public final Object clone() {
try { try {
return super.clone(); return super.clone();
} catch (Exception ex) { } catch (final Exception ex) {
ErrorViewer.showError(ex); ErrorViewer.showError(ex);
throw new RuntimeException("Spell : clone() error, " + ex); throw new RuntimeException("Spell : clone() error, " + ex);
} }

File diff suppressed because it is too large Load Diff

View File

@@ -13,7 +13,7 @@ import forge.ComputerUtil;
* @version $Id$ * @version $Id$
*/ */
public class SpellAbilityList { public class SpellAbilityList {
private ArrayList<SpellAbility> list = new ArrayList<SpellAbility>(); private final ArrayList<SpellAbility> list = new ArrayList<SpellAbility>();
/** /**
* <p> * <p>
@@ -32,7 +32,7 @@ public class SpellAbilityList {
* a {@link forge.card.spellability.SpellAbility} object. * a {@link forge.card.spellability.SpellAbility} object.
*/ */
public SpellAbilityList(final SpellAbility s) { public SpellAbilityList(final SpellAbility s) {
add(s); this.add(s);
} }
/** /**
@@ -45,8 +45,8 @@ public class SpellAbilityList {
* objects. * objects.
*/ */
public SpellAbilityList(final SpellAbility[] s) { public SpellAbilityList(final SpellAbility[] s) {
for (int i = 0; i < s.length; i++) { for (final SpellAbility element : s) {
add(s[i]); this.add(element);
} }
} }
@@ -59,7 +59,7 @@ public class SpellAbilityList {
* a int. * a int.
*/ */
public final void remove(final int n) { 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. * a {@link forge.card.spellability.SpellAbility} object.
*/ */
public final void add(final SpellAbility s) { public final void add(final SpellAbility s) {
list.add(s); this.list.add(s);
} }
/** /**
@@ -82,7 +82,7 @@ public class SpellAbilityList {
* @return a int. * @return a int.
*/ */
public final int size() { 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. * @return a {@link forge.card.spellability.SpellAbility} object.
*/ */
public final SpellAbility get(final int n) { 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) { public final void addAll(final SpellAbilityList s) {
for (int i = 0; i < s.size(); i++) { for (int i = 0; i < s.size(); i++) {
add(s.get(i)); this.add(s.get(i));
} }
} }
@@ -119,24 +119,24 @@ public class SpellAbilityList {
* </p> * </p>
*/ */
public final void execute() { public final void execute() {
for (int i = 0; i < size(); i++) { for (int i = 0; i < this.size(); i++) {
if (!ComputerUtil.canPayCost(get(i))) { if (!ComputerUtil.canPayCost(this.get(i))) {
throw new RuntimeException("SpellAbilityList : execute() error, cannot pay for the spell " 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() } // execute()
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public final String toString() { public final String toString() {
StringBuilder sb = new StringBuilder(); final StringBuilder sb = new StringBuilder();
for (int i = 0; i < size(); i++) { for (int i = 0; i < this.size(); i++) {
sb.append(get(i).getSourceCard().toString()); sb.append(this.get(i).getSourceCard().toString());
sb.append(" - "); sb.append(" - ");
sb.append(get(i).getStackDescription()); sb.append(this.get(i).getStackDescription());
sb.append("\r\n"); sb.append("\r\n");
} }
return sb.toString(); return sb.toString();
@@ -148,6 +148,6 @@ public class SpellAbilityList {
if (o == null) { if (o == null) {
return false; return false;
} }
return toString().equals(o.toString()); return this.toString().equals(o.toString());
} }
} }

View File

@@ -47,32 +47,32 @@ public class SpellAbility_Condition extends SpellAbility_Variables {
*/ */
public final void setConditions(final HashMap<String, String> params) { public final void setConditions(final HashMap<String, String> params) {
if (params.containsKey("Condition")) { if (params.containsKey("Condition")) {
String value = params.get("Condition"); final String value = params.get("Condition");
if (value.equals("Threshold")) { if (value.equals("Threshold")) {
setThreshold(true); this.setThreshold(true);
} }
if (value.equals("Metalcraft")) { if (value.equals("Metalcraft")) {
setMetalcraft(true); this.setMetalcraft(true);
} }
if (value.equals("Hellbent")) { if (value.equals("Hellbent")) {
setHellbent(true); this.setHellbent(true);
} }
} }
if (params.containsKey("ConditionZone")) { if (params.containsKey("ConditionZone")) {
setZone(Zone.smartValueOf(params.get("ContitionZone"))); this.setZone(Zone.smartValueOf(params.get("ContitionZone")));
} }
if (params.containsKey("ConditionSorcerySpeed")) { if (params.containsKey("ConditionSorcerySpeed")) {
setSorcerySpeed(true); this.setSorcerySpeed(true);
} }
if (params.containsKey("ConditionPlayerTurn")) { if (params.containsKey("ConditionPlayerTurn")) {
setPlayerTurn(true); this.setPlayerTurn(true);
} }
if (params.containsKey("ConditionOpponentTurn")) { if (params.containsKey("ConditionOpponentTurn")) {
setOpponentTurn(true); this.setOpponentTurn(true);
} }
if (params.containsKey("ConditionPhases")) { if (params.containsKey("ConditionPhases")) {
@@ -84,59 +84,59 @@ public class SpellAbility_Condition extends SpellAbility_Variables {
// Draw-> (After Upkeep) // Draw-> (After Upkeep)
// Upkeep->Combat_Begin (Before Declare Attackers) // 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]); phases = AllZone.getPhase().buildActivateString(split[0], split[1]);
} }
setPhases(phases); this.setPhases(phases);
} }
if (params.containsKey("ConditionAllM12Empires")) { if (params.containsKey("ConditionAllM12Empires")) {
setAllM12Empires(true); this.setAllM12Empires(true);
} }
if (params.containsKey("ConditionNotAllM12Empires")) { if (params.containsKey("ConditionNotAllM12Empires")) {
setNotAllM12Empires(true); this.setNotAllM12Empires(true);
} }
if (params.containsKey("ConditionCardsInHand")) { if (params.containsKey("ConditionCardsInHand")) {
setActivateCardsInHand(Integer.parseInt(params.get("ConditionCardsInHand"))); this.setActivateCardsInHand(Integer.parseInt(params.get("ConditionCardsInHand")));
} }
// Condition version of IsPresent stuff // Condition version of IsPresent stuff
if (params.containsKey("ConditionPresent")) { if (params.containsKey("ConditionPresent")) {
setIsPresent(params.get("ConditionPresent")); this.setIsPresent(params.get("ConditionPresent"));
if (params.containsKey("ConditionCompare")) { if (params.containsKey("ConditionCompare")) {
setPresentCompare(params.get("ConditionCompare")); this.setPresentCompare(params.get("ConditionCompare"));
} }
} }
if (params.containsKey("ConditionDefined")) { if (params.containsKey("ConditionDefined")) {
setPresentDefined(params.get("ConditionDefined")); this.setPresentDefined(params.get("ConditionDefined"));
} }
if (params.containsKey("ConditionNotPresent")) { if (params.containsKey("ConditionNotPresent")) {
setIsPresent(params.get("ConditionNotPresent")); this.setIsPresent(params.get("ConditionNotPresent"));
setPresentCompare("EQ0"); this.setPresentCompare("EQ0");
} }
// basically PresentCompare for life totals: // basically PresentCompare for life totals:
if (params.containsKey("ConditionLifeTotal")) { if (params.containsKey("ConditionLifeTotal")) {
setLifeTotal(params.get("ConditionLifeTotal")); this.setLifeTotal(params.get("ConditionLifeTotal"));
if (params.containsKey("ConditionLifeAmount")) { if (params.containsKey("ConditionLifeAmount")) {
setLifeAmount(params.get("ConditionLifeAmount")); this.setLifeAmount(params.get("ConditionLifeAmount"));
} }
} }
if (params.containsKey("ConditionManaSpent")) { if (params.containsKey("ConditionManaSpent")) {
setManaSpent(params.get("ConditionManaSpent")); this.setManaSpent(params.get("ConditionManaSpent"));
} }
if (params.containsKey("ConditionCheckSVar")) { if (params.containsKey("ConditionCheckSVar")) {
setSvarToCheck(params.get("ConditionCheckSVar")); this.setSvarToCheck(params.get("ConditionCheckSVar"));
} }
if (params.containsKey("ConditionSVarCompare")) { if (params.containsKey("ConditionSVarCompare")) {
setSvarOperator(params.get("ConditionSVarCompare").substring(0, 2)); this.setSvarOperator(params.get("ConditionSVarCompare").substring(0, 2));
setSvarOperand(params.get("ConditionSVarCompare").substring(2)); this.setSvarOperand(params.get("ConditionSVarCompare").substring(2));
} }
} // setConditions } // setConditions
@@ -159,42 +159,42 @@ public class SpellAbility_Condition extends SpellAbility_Variables {
+ " Did not have activator set in SpellAbility_Condition.checkConditions()"); + " Did not have activator set in SpellAbility_Condition.checkConditions()");
} }
if (isHellbent()) { if (this.isHellbent()) {
if (!activator.hasHellbent()) { if (!activator.hasHellbent()) {
return false; return false;
} }
} }
if (isThreshold()) { if (this.isThreshold()) {
if (!activator.hasThreshold()) { if (!activator.hasThreshold()) {
return false; return false;
} }
} }
if (isMetalcraft()) { if (this.isMetalcraft()) {
if (!activator.hasMetalcraft()) { if (!activator.hasMetalcraft()) {
return false; return false;
} }
} }
if (isSorcerySpeed() && !Phase.canCastSorcery(activator)) { if (this.isSorcerySpeed() && !Phase.canCastSorcery(activator)) {
return false; return false;
} }
if (isPlayerTurn() && !AllZone.getPhase().isPlayerTurn(activator)) { if (this.isPlayerTurn() && !AllZone.getPhase().isPlayerTurn(activator)) {
return false; return false;
} }
if (isOpponentTurn() && AllZone.getPhase().isPlayerTurn(activator)) { if (this.isOpponentTurn() && AllZone.getPhase().isPlayerTurn(activator)) {
return false; return false;
} }
if (getActivationLimit() != -1 && getNumberTurnActivations() >= getActivationLimit()) { if ((this.getActivationLimit() != -1) && (this.getNumberTurnActivations() >= this.getActivationLimit())) {
return false; return false;
} }
if (getPhases().size() > 0) { if (this.getPhases().size() > 0) {
boolean isPhase = false; boolean isPhase = false;
String currPhase = AllZone.getPhase().getPhase(); final String currPhase = AllZone.getPhase().getPhase();
for (String s : getPhases()) { for (final String s : this.getPhases()) {
if (s.equals(currPhase)) { if (s.equals(currPhase)) {
isPhase = true; isPhase = true;
break; break;
@@ -206,8 +206,8 @@ public class SpellAbility_Condition extends SpellAbility_Variables {
} }
} }
if (isAllM12Empires()) { if (this.isAllM12Empires()) {
Player p = sa.getSourceCard().getController(); final Player p = sa.getSourceCard().getController();
boolean has = AllZoneUtil.isCardInPlay("Crown of Empires", p); boolean has = AllZoneUtil.isCardInPlay("Crown of Empires", p);
has &= AllZoneUtil.isCardInPlay("Scepter of Empires", p); has &= AllZoneUtil.isCardInPlay("Scepter of Empires", p);
has &= AllZoneUtil.isCardInPlay("Throne of Empires", p); has &= AllZoneUtil.isCardInPlay("Throne of Empires", p);
@@ -215,8 +215,8 @@ public class SpellAbility_Condition extends SpellAbility_Variables {
return false; return false;
} }
} }
if (isNotAllM12Empires()) { if (this.isNotAllM12Empires()) {
Player p = sa.getSourceCard().getController(); final Player p = sa.getSourceCard().getController();
boolean has = AllZoneUtil.isCardInPlay("Crown of Empires", p); boolean has = AllZoneUtil.isCardInPlay("Crown of Empires", p);
has &= AllZoneUtil.isCardInPlay("Scepter of Empires", p); has &= AllZoneUtil.isCardInPlay("Scepter of Empires", p);
has &= AllZoneUtil.isCardInPlay("Throne 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 // Can handle Library of Alexandria, or Hellbent
if (activator.getCardsIn(Zone.Hand).size() != getCardsInHand()) { if (activator.getCardsIn(Zone.Hand).size() != this.getCardsInHand()) {
return false; return false;
} }
} }
if (getIsPresent() != null) { if (this.getIsPresent() != null) {
CardList list = new CardList(); CardList list = new CardList();
if (getPresentDefined() != null) { if (this.getPresentDefined() != null) {
list.addAll(AbilityFactory.getDefinedCards(sa.getSourceCard(), getPresentDefined(), sa).toArray()); list.addAll(AbilityFactory.getDefinedCards(sa.getSourceCard(), this.getPresentDefined(), sa).toArray());
} else { } else {
list = AllZoneUtil.getCardsIn(Zone.Battlefield); 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; int right;
String rightString = getPresentCompare().substring(2); final String rightString = this.getPresentCompare().substring(2);
try { // If this is an Integer, just parse it try { // If this is an Integer, just parse it
right = Integer.parseInt(rightString); right = Integer.parseInt(rightString);
} catch (NumberFormatException e) { // Otherwise, grab it from the } catch (final NumberFormatException e) { // Otherwise, grab it from
// SVar // the
// SVar
right = CardFactoryUtil.xCount(sa.getSourceCard(), sa.getSourceCard().getSVar(rightString)); 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; return false;
} }
} }
if (getLifeTotal() != null) { if (this.getLifeTotal() != null) {
int life = 1; int life = 1;
if (getLifeTotal().equals("You")) { if (this.getLifeTotal().equals("You")) {
life = activator.getLife(); life = activator.getLife();
} }
if (getLifeTotal().equals("Opponent")) { if (this.getLifeTotal().equals("Opponent")) {
life = activator.getOpponent().getLife(); life = activator.getOpponent().getLife();
} }
int right = 1; int right = 1;
String rightString = getLifeAmount().substring(2); final String rightString = this.getLifeAmount().substring(2);
if (rightString.equals("X")) { if (rightString.equals("X")) {
right = CardFactoryUtil.xCount(sa.getSourceCard(), sa.getSourceCard().getSVar("X")); right = CardFactoryUtil.xCount(sa.getSourceCard(), sa.getSourceCard().getSVar("X"));
} else { } else {
right = Integer.parseInt(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; return false;
} }
} }
if (null != getManaSpent()) { if (null != this.getManaSpent()) {
if (!sa.getSourceCard().getColorsPaid().contains(getManaSpent())) { if (!sa.getSourceCard().getColorsPaid().contains(this.getManaSpent())) {
return false; return false;
} }
} }
if (getsVarToCheck() != null) { if (this.getsVarToCheck() != null) {
int svarValue = AbilityFactory.calculateAmount(sa.getSourceCard(), getsVarToCheck(), sa); final int svarValue = AbilityFactory.calculateAmount(sa.getSourceCard(), this.getsVarToCheck(), sa);
int operandValue = AbilityFactory.calculateAmount(sa.getSourceCard(), getsVarOperand(), 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; return false;
} }

View File

@@ -32,7 +32,7 @@ public class SpellAbility_Requirements {
* a boolean. * a boolean.
*/ */
public final void setSkipStack(final boolean bSkip) { public final void setSkipStack(final boolean bSkip) {
skipStack = bSkip; this.skipStack = bSkip;
} }
/** /**
@@ -44,7 +44,7 @@ public class SpellAbility_Requirements {
* a boolean. * a boolean.
*/ */
public final void setFree(final boolean bFree) { public final void setFree(final boolean bFree) {
isFree = bFree; this.isFree = bFree;
} }
private PlayerZone fromZone = null; private PlayerZone fromZone = null;
@@ -63,9 +63,9 @@ public class SpellAbility_Requirements {
* a {@link forge.card.cost.Cost_Payment} object. * a {@link forge.card.cost.Cost_Payment} object.
*/ */
public SpellAbility_Requirements(final SpellAbility sa, final Target_Selection ts, final Cost_Payment cp) { public SpellAbility_Requirements(final SpellAbility sa, final Target_Selection ts, final Cost_Payment cp) {
ability = sa; this.ability = sa;
select = ts; this.select = ts;
payment = cp; this.payment = cp;
} }
/** /**
@@ -74,7 +74,7 @@ public class SpellAbility_Requirements {
* </p> * </p>
*/ */
public final void fillRequirements() { public final void fillRequirements() {
fillRequirements(false); this.fillRequirements(false);
} }
/** /**
@@ -86,13 +86,13 @@ public class SpellAbility_Requirements {
* a boolean. * a boolean.
*/ */
public final void fillRequirements(final boolean skipTargeting) { public final void fillRequirements(final boolean skipTargeting) {
if (ability instanceof Spell && !bCasting) { if ((this.ability instanceof Spell) && !this.bCasting) {
// remove from hand // remove from hand
bCasting = true; this.bCasting = true;
if (!ability.getSourceCard().isCopiedSpell()) { if (!this.ability.getSourceCard().isCopiedSpell()) {
Card c = ability.getSourceCard(); final Card c = this.ability.getSourceCard();
fromZone = AllZone.getZoneOf(c); this.fromZone = AllZone.getZoneOf(c);
AllZone.getGameAction().moveToStack(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 // Skip to paying if parent ability doesn't target and has no
// subAbilities. // subAbilities.
// (or trigger case where its already targeted) // (or trigger case where its already targeted)
if (!skipTargeting && (select.doesTarget() || ability.getSubAbility() != null)) { if (!skipTargeting && (this.select.doesTarget() || (this.ability.getSubAbility() != null))) {
select.setRequirements(this); this.select.setRequirements(this);
select.resetTargets(); this.select.resetTargets();
select.chooseTargets(); this.select.chooseTargets();
} else { } else {
needPayment(); this.needPayment();
} }
} }
@@ -119,19 +119,19 @@ public class SpellAbility_Requirements {
* </p> * </p>
*/ */
public final void finishedTargeting() { public final void finishedTargeting() {
if (select.isCanceled()) { if (this.select.isCanceled()) {
// cancel ability during target choosing // cancel ability during target choosing
Card c = ability.getSourceCard(); final Card c = this.ability.getSourceCard();
if (bCasting && !c.isCopiedSpell()) { // and not a copy if (this.bCasting && !c.isCopiedSpell()) { // and not a copy
// add back to where it came from // 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(); AllZone.getStack().clearFrozen();
return; return;
} else { } else {
needPayment(); this.needPayment();
} }
} }
@@ -141,10 +141,10 @@ public class SpellAbility_Requirements {
* </p> * </p>
*/ */
public final void needPayment() { public final void needPayment() {
if (!isFree) { if (!this.isFree) {
startPaying(); this.startPaying();
} else { } else {
finishPaying(); this.finishPaying();
} }
} }
@@ -154,8 +154,8 @@ public class SpellAbility_Requirements {
* </p> * </p>
*/ */
public final void startPaying() { public final void startPaying() {
payment.setRequirements(this); this.payment.setRequirements(this);
payment.payCost(); this.payment.payCost();
} }
/** /**
@@ -164,28 +164,28 @@ public class SpellAbility_Requirements {
* </p> * </p>
*/ */
public final void finishPaying() { public final void finishPaying() {
if (isFree || payment.isAllPaid()) { if (this.isFree || this.payment.isAllPaid()) {
if (skipStack) { if (this.skipStack) {
AbilityFactory.resolve(ability, false); AbilityFactory.resolve(this.ability, false);
} else { } else {
addAbilityToStack(); this.addAbilityToStack();
} }
select.resetTargets(); this.select.resetTargets();
AllZone.getGameAction().checkStateEffects(); AllZone.getGameAction().checkStateEffects();
} else if (payment.isCanceled()) { } else if (this.payment.isCanceled()) {
Card c = ability.getSourceCard(); final Card c = this.ability.getSourceCard();
if (bCasting && !c.isCopiedSpell()) { // and not a copy if (this.bCasting && !c.isCopiedSpell()) { // and not a copy
// add back to Previous Zone // add back to Previous Zone
AllZone.getGameAction().moveTo(fromZone, c); AllZone.getGameAction().moveTo(this.fromZone, c);
} }
if (select != null) { if (this.select != null) {
select.resetTargets(); this.select.resetTargets();
} }
ability.resetOnceResolved(); this.ability.resetOnceResolved();
payment.cancelPayment(); this.payment.cancelPayment();
AllZone.getStack().clearFrozen(); AllZone.getStack().clearFrozen();
} }
} }
@@ -197,23 +197,23 @@ public class SpellAbility_Requirements {
*/ */
public final void addAbilityToStack() { public final void addAbilityToStack() {
// For older abilities that don't setStackDescription set it here // For older abilities that don't setStackDescription set it here
if (ability.getStackDescription().equals("")) { if (this.ability.getStackDescription().equals("")) {
StringBuilder sb = new StringBuilder(); final StringBuilder sb = new StringBuilder();
sb.append(ability.getSourceCard().getName()); sb.append(this.ability.getSourceCard().getName());
if (ability.getTarget() != null) { if (this.ability.getTarget() != null) {
ArrayList<Object> targets = ability.getTarget().getTargets(); final ArrayList<Object> targets = this.ability.getTarget().getTargets();
if (targets.size() > 0) { if (targets.size() > 0) {
sb.append(" - Targeting "); sb.append(" - Targeting ");
for (Object o : targets) { for (final Object o : targets) {
sb.append(o.toString()).append(" "); sb.append(o.toString()).append(" ");
} }
} }
} }
ability.setStackDescription(sb.toString()); this.ability.setStackDescription(sb.toString());
} }
AllZone.getHumanPlayer().getManaPool().clearPay(ability, false); AllZone.getHumanPlayer().getManaPool().clearPay(this.ability, false);
AllZone.getStack().addAndUnfreeze(ability); AllZone.getStack().addAndUnfreeze(this.ability);
} }
} }

View File

@@ -51,56 +51,56 @@ public class SpellAbility_Restriction extends SpellAbility_Variables {
*/ */
public final void setRestrictions(final HashMap<String, String> params) { public final void setRestrictions(final HashMap<String, String> params) {
if (params.containsKey("Activation")) { if (params.containsKey("Activation")) {
String value = params.get("Activation"); final String value = params.get("Activation");
if (value.equals("Threshold")) { if (value.equals("Threshold")) {
setThreshold(true); this.setThreshold(true);
} }
if (value.equals("Metalcraft")) { if (value.equals("Metalcraft")) {
setMetalcraft(true); this.setMetalcraft(true);
} }
if (value.equals("Hellbent")) { if (value.equals("Hellbent")) {
setHellbent(true); this.setHellbent(true);
} }
if (value.startsWith("Prowl")) { if (value.startsWith("Prowl")) {
ArrayList<String> prowlTypes = new ArrayList<String>(); final ArrayList<String> prowlTypes = new ArrayList<String>();
prowlTypes.add("Rogue"); prowlTypes.add("Rogue");
if (value.split("Prowl").length > 1) { if (value.split("Prowl").length > 1) {
prowlTypes.add(value.split("Prowl")[1]); prowlTypes.add(value.split("Prowl")[1]);
} }
setProwl(prowlTypes); this.setProwl(prowlTypes);
} }
} }
if (params.containsKey("ActivationZone")) { if (params.containsKey("ActivationZone")) {
setZone(Zone.smartValueOf(params.get("ActivationZone"))); this.setZone(Zone.smartValueOf(params.get("ActivationZone")));
} }
if (params.containsKey("Flashback")) { if (params.containsKey("Flashback")) {
setZone(Zone.Graveyard); this.setZone(Zone.Graveyard);
} }
if (params.containsKey("SorcerySpeed")) { if (params.containsKey("SorcerySpeed")) {
setSorcerySpeed(true); this.setSorcerySpeed(true);
} }
if (params.containsKey("PlayerTurn")) { if (params.containsKey("PlayerTurn")) {
setPlayerTurn(true); this.setPlayerTurn(true);
} }
if (params.containsKey("OpponentTurn")) { if (params.containsKey("OpponentTurn")) {
setOpponentTurn(true); this.setOpponentTurn(true);
} }
if (params.containsKey("AnyPlayer")) { if (params.containsKey("AnyPlayer")) {
setAnyPlayer(true); this.setAnyPlayer(true);
} }
if (params.containsKey("ActivationLimit")) { if (params.containsKey("ActivationLimit")) {
setActivationLimit(Integer.parseInt(params.get("ActivationLimit"))); this.setActivationLimit(Integer.parseInt(params.get("ActivationLimit")));
} }
if (params.containsKey("ActivationNumberSacrifice")) { if (params.containsKey("ActivationNumberSacrifice")) {
setActivationNumberSacrifice(Integer.parseInt(params.get("ActivationNumberSacrifice"))); this.setActivationNumberSacrifice(Integer.parseInt(params.get("ActivationNumberSacrifice")));
} }
if (params.containsKey("ActivationPhases")) { if (params.containsKey("ActivationPhases")) {
@@ -112,50 +112,50 @@ public class SpellAbility_Restriction extends SpellAbility_Variables {
// Draw-> (After Upkeep) // Draw-> (After Upkeep)
// Upkeep->Combat_Begin (Before Declare Attackers) // 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]); phases = AllZone.getPhase().buildActivateString(split[0], split[1]);
} }
setPhases(phases); this.setPhases(phases);
} }
if (params.containsKey("ActivationCardsInHand")) { if (params.containsKey("ActivationCardsInHand")) {
setActivateCardsInHand(Integer.parseInt(params.get("ActivationCardsInHand"))); this.setActivateCardsInHand(Integer.parseInt(params.get("ActivationCardsInHand")));
} }
if (params.containsKey("Planeswalker")) { if (params.containsKey("Planeswalker")) {
setPlaneswalker(true); this.setPlaneswalker(true);
} }
if (params.containsKey("IsPresent")) { if (params.containsKey("IsPresent")) {
setIsPresent(params.get("IsPresent")); this.setIsPresent(params.get("IsPresent"));
if (params.containsKey("PresentCompare")) { if (params.containsKey("PresentCompare")) {
setPresentCompare(params.get("PresentCompare")); this.setPresentCompare(params.get("PresentCompare"));
} }
if (params.containsKey("PresentZone")) { if (params.containsKey("PresentZone")) {
setPresentZone(Zone.smartValueOf(params.get("PresentZone"))); this.setPresentZone(Zone.smartValueOf(params.get("PresentZone")));
} }
} }
if (params.containsKey("IsNotPresent")) { if (params.containsKey("IsNotPresent")) {
setIsPresent(params.get("IsNotPresent")); this.setIsPresent(params.get("IsNotPresent"));
setPresentCompare("EQ0"); this.setPresentCompare("EQ0");
} }
// basically PresentCompare for life totals: // basically PresentCompare for life totals:
if (params.containsKey("ActivationLifeTotal")) { if (params.containsKey("ActivationLifeTotal")) {
setLifeTotal(params.get("ActivationLifeTotal")); this.setLifeTotal(params.get("ActivationLifeTotal"));
if (params.containsKey("ActivationLifeAmount")) { if (params.containsKey("ActivationLifeAmount")) {
setLifeAmount(params.get("ActivationLifeAmount")); this.setLifeAmount(params.get("ActivationLifeAmount"));
} }
} }
if (params.containsKey("CheckSVar")) { if (params.containsKey("CheckSVar")) {
setSvarToCheck(params.get("CheckSVar")); this.setSvarToCheck(params.get("CheckSVar"));
} }
if (params.containsKey("SVarCompare")) { if (params.containsKey("SVarCompare")) {
setSvarOperator(params.get("SVarCompare").substring(0, 2)); this.setSvarOperator(params.get("SVarCompare").substring(0, 2));
setSvarOperand(params.get("SVarCompare").substring(2)); this.setSvarOperand(params.get("SVarCompare").substring(2));
} }
} // end setRestrictions() } // end setRestrictions()
@@ -175,14 +175,14 @@ public class SpellAbility_Restriction extends SpellAbility_Variables {
return false; return false;
} }
PlayerZone cardZone = AllZone.getZoneOf(c); final PlayerZone cardZone = AllZone.getZoneOf(c);
if (!cardZone.is(getZone())) { if (!cardZone.is(this.getZone())) {
// If Card is not in the default activating zone, do some additional // If Card is not in the default activating zone, do some additional
// checks // checks
// Not a Spell, or on Battlefield, return false // Not a Spell, or on Battlefield, return false
if (!sa.isSpell() || cardZone.is(Zone.Battlefield)) { if (!sa.isSpell() || cardZone.is(Zone.Battlefield)) {
return false; 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; 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()"); 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; return false;
} }
if (isPlayerTurn() && !AllZone.getPhase().isPlayerTurn(activator)) { if (this.isPlayerTurn() && !AllZone.getPhase().isPlayerTurn(activator)) {
return false; return false;
} }
if (isOpponentTurn() && AllZone.getPhase().isPlayerTurn(activator)) { if (this.isOpponentTurn() && AllZone.getPhase().isPlayerTurn(activator)) {
return false; return false;
} }
if (!isAnyPlayer() && !activator.equals(c.getController())) { if (!this.isAnyPlayer() && !activator.equals(c.getController())) {
return false; return false;
} }
if (getActivationLimit() != -1 && getNumberTurnActivations() >= getActivationLimit()) { if ((this.getActivationLimit() != -1) && (this.getNumberTurnActivations() >= this.getActivationLimit())) {
return false; return false;
} }
if (getPhases().size() > 0) { if (this.getPhases().size() > 0) {
boolean isPhase = false; boolean isPhase = false;
String currPhase = AllZone.getPhase().getPhase(); final String currPhase = AllZone.getPhase().getPhase();
for (String s : getPhases()) { for (final String s : this.getPhases()) {
if (s.equals(currPhase)) { if (s.equals(currPhase)) {
isPhase = true; isPhase = true;
break; break;
@@ -228,31 +228,31 @@ public class SpellAbility_Restriction extends SpellAbility_Variables {
} }
} }
if (getCardsInHand() != -1) { if (this.getCardsInHand() != -1) {
if (activator.getCardsIn(Zone.Hand).size() != getCardsInHand()) { if (activator.getCardsIn(Zone.Hand).size() != this.getCardsInHand()) {
return false; return false;
} }
} }
if (isHellbent()) { if (this.isHellbent()) {
if (!activator.hasHellbent()) { if (!activator.hasHellbent()) {
return false; return false;
} }
} }
if (isThreshold()) { if (this.isThreshold()) {
if (!activator.hasThreshold()) { if (!activator.hasThreshold()) {
return false; return false;
} }
} }
if (isMetalcraft()) { if (this.isMetalcraft()) {
if (!activator.hasMetalcraft()) { if (!activator.hasMetalcraft()) {
return false; return false;
} }
} }
if (getProwl() != null) { if (this.getProwl() != null) {
// only true if the activating player has damaged the opponent with // only true if the activating player has damaged the opponent with
// one of the specified types // one of the specified types
boolean prowlFlag = false; boolean prowlFlag = false;
for (String type : getProwl()) { for (final String type : this.getProwl()) {
if (activator.hasProwl(type)) { if (activator.hasProwl(type)) {
prowlFlag = true; prowlFlag = true;
} }
@@ -261,68 +261,68 @@ public class SpellAbility_Restriction extends SpellAbility_Variables {
return false; return false;
} }
} }
if (getIsPresent() != null) { if (this.getIsPresent() != null) {
CardList list = AllZoneUtil.getCardsIn(getPresentZone()); CardList list = AllZoneUtil.getCardsIn(this.getPresentZone());
list = list.getValidCards(getIsPresent().split(","), activator, c); list = list.getValidCards(this.getIsPresent().split(","), activator, c);
int right = 1; int right = 1;
String rightString = getPresentCompare().substring(2); final String rightString = this.getPresentCompare().substring(2);
if (rightString.equals("X")) { if (rightString.equals("X")) {
right = CardFactoryUtil.xCount(c, c.getSVar("X")); right = CardFactoryUtil.xCount(c, c.getSVar("X"));
} else { } else {
right = Integer.parseInt(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; return false;
} }
} }
if (getLifeTotal() != null) { if (this.getLifeTotal() != null) {
int life = 1; int life = 1;
if (getLifeTotal().equals("You")) { if (this.getLifeTotal().equals("You")) {
life = activator.getLife(); life = activator.getLife();
} }
if (getLifeTotal().equals("Opponent")) { if (this.getLifeTotal().equals("Opponent")) {
life = activator.getOpponent().getLife(); life = activator.getOpponent().getLife();
} }
int right = 1; int right = 1;
String rightString = getLifeAmount().substring(2); final String rightString = this.getLifeAmount().substring(2);
if (rightString.equals("X")) { if (rightString.equals("X")) {
right = CardFactoryUtil.xCount(sa.getSourceCard(), sa.getSourceCard().getSVar("X")); right = CardFactoryUtil.xCount(sa.getSourceCard(), sa.getSourceCard().getSVar("X"));
} else { } else {
right = Integer.parseInt(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; return false;
} }
} }
if (isPwAbility()) { if (this.isPwAbility()) {
// Planeswalker abilities can only be activated as Sorceries // Planeswalker abilities can only be activated as Sorceries
if (!Phase.canCastSorcery(activator)) { if (!Phase.canCastSorcery(activator)) {
return false; return false;
} }
for (SpellAbility pwAbs : c.getAllSpellAbilities()) { for (final SpellAbility pwAbs : c.getAllSpellAbilities()) {
// check all abilities on card that have their planeswalker // check all abilities on card that have their planeswalker
// restriction set to confirm they haven't been activated // restriction set to confirm they haven't been activated
SpellAbility_Restriction restrict = pwAbs.getRestrictions(); final SpellAbility_Restriction restrict = pwAbs.getRestrictions();
if (restrict.getPlaneswalker() && restrict.getNumberTurnActivations() > 0) { if (restrict.getPlaneswalker() && (restrict.getNumberTurnActivations() > 0)) {
return false; return false;
} }
} }
} }
if (getsVarToCheck() != null) { if (this.getsVarToCheck() != null) {
int svarValue = AbilityFactory.calculateAmount(c, getsVarToCheck(), sa); final int svarValue = AbilityFactory.calculateAmount(c, this.getsVarToCheck(), sa);
int operandValue = AbilityFactory.calculateAmount(c, getsVarOperand(), 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; return false;
} }

View File

@@ -36,9 +36,6 @@ public class SpellAbility_StackInstance {
/** The activating player. */ /** The activating player. */
private Player activatingPlayer = null; private Player activatingPlayer = null;
/** The activated from. */
private String activatedFrom = null;
/** The stack description. */ /** The stack description. */
private String stackDescription = null; private String stackDescription = null;
@@ -60,7 +57,7 @@ public class SpellAbility_StackInstance {
// Triggers // Triggers
private HashMap<String, Object> triggeringObjects = new HashMap<String, Object>(); private HashMap<String, Object> triggeringObjects = new HashMap<String, Object>();
private HashMap<String, String> storedSVars = new HashMap<String, String>(); private final HashMap<String, String> storedSVars = new HashMap<String, String>();
/** /**
* <p> * <p>
@@ -72,41 +69,41 @@ public class SpellAbility_StackInstance {
*/ */
public SpellAbility_StackInstance(final SpellAbility sa) { public SpellAbility_StackInstance(final SpellAbility sa) {
// Base SA info // Base SA info
ability = sa; this.ability = sa;
stackDescription = ability.getStackDescription(); this.stackDescription = this.ability.getStackDescription();
activatingPlayer = sa.getActivatingPlayer(); this.activatingPlayer = sa.getActivatingPlayer();
// Payment info // Payment info
paidHash = ability.getPaidHash(); this.paidHash = this.ability.getPaidHash();
ability.resetPaidHash(); this.ability.resetPaidHash();
// TODO getXManaCostPaid should be on the SA, not the Card // TODO getXManaCostPaid should be on the SA, not the Card
xManaPaid = sa.getSourceCard().getXManaCostPaid(); this.xManaPaid = sa.getSourceCard().getXManaCostPaid();
// Triggering info // Triggering info
triggeringObjects = sa.getTriggeringObjects(); this.triggeringObjects = sa.getTriggeringObjects();
Ability_Sub subAb = ability.getSubAbility(); final Ability_Sub subAb = this.ability.getSubAbility();
if (subAb != null) { 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 // Targeting info -- 29/06/11 Moved to after taking care of SubAbilities
// because otherwise AF_DealDamage SubAbilities that use Defined$ // because otherwise AF_DealDamage SubAbilities that use Defined$
// Targeted breaks (since it's parents target is reset) // Targeted breaks (since it's parents target is reset)
Target target = sa.getTarget(); final Target target = sa.getTarget();
if (target != null) { if (target != null) {
tc = target.getTargetChoices(); this.tc = target.getTargetChoices();
ability.getTarget().resetTargets(); this.ability.getTarget().resetTargets();
} }
Card source = ability.getSourceCard(); final Card source = this.ability.getSourceCard();
// Store SVars and Clear // Store SVars and Clear
for (String store : Card.getStorableSVars()) { for (final String store : Card.getStorableSVars()) {
String value = source.getSVar(store); final String value = source.getSVar(store);
if (value.length() > 0) { if (value.length() > 0) {
storedSVars.put(store, value); this.storedSVars.put(store, value);
source.setSVar(store, ""); source.setSVar(store, "");
} }
} }
@@ -120,34 +117,34 @@ public class SpellAbility_StackInstance {
* @return a {@link forge.card.spellability.SpellAbility} object. * @return a {@link forge.card.spellability.SpellAbility} object.
*/ */
public final SpellAbility getSpellAbility() { public final SpellAbility getSpellAbility() {
if (ability.getTarget() != null) { if (this.ability.getTarget() != null) {
ability.getTarget().resetTargets(); this.ability.getTarget().resetTargets();
ability.getTarget().setTargetChoices(tc); 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 // Saved sub-SA needs to be reset on the way out
if (this.subInstace != null) { if (this.subInstace != null) {
ability.setSubAbility((Ability_Sub) this.subInstace.getSpellAbility()); this.ability.setSubAbility((Ability_Sub) this.subInstace.getSpellAbility());
} }
// Set Cost specific things here // Set Cost specific things here
ability.setPaidHash(paidHash); this.ability.setPaidHash(this.paidHash);
ability.getSourceCard().setXManaCostPaid(xManaPaid); this.ability.getSourceCard().setXManaCostPaid(this.xManaPaid);
// Triggered // Triggered
ability.setAllTriggeringObjects(triggeringObjects); this.ability.setAllTriggeringObjects(this.triggeringObjects);
// Add SVars back in // Add SVars back in
Card source = ability.getSourceCard(); final Card source = this.ability.getSourceCard();
for (String store : storedSVars.keySet()) { for (final String store : this.storedSVars.keySet()) {
String value = storedSVars.get(store); final String value = this.storedSVars.get(store);
if (value.length() > 0) { if (value.length() > 0) {
source.setSVar(store, value); source.setSVar(store, value);
} }
} }
return ability; return this.ability;
} }
// A bit of SA shared abilities to restrict conflicts // A bit of SA shared abilities to restrict conflicts
@@ -159,7 +156,7 @@ public class SpellAbility_StackInstance {
* @return a {@link java.lang.String} object. * @return a {@link java.lang.String} object.
*/ */
public final String getStackDescription() { public final String getStackDescription() {
return stackDescription; return this.stackDescription;
} }
/** /**
@@ -170,7 +167,7 @@ public class SpellAbility_StackInstance {
* @return a {@link forge.Card} object. * @return a {@link forge.Card} object.
*/ */
public final Card getSourceCard() { 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. * @return a {@link forge.Player} object.
*/ */
public final Player getActivatingPlayer() { public final Player getActivatingPlayer() {
return activatingPlayer; return this.activatingPlayer;
} }
/** /**
@@ -192,7 +189,7 @@ public class SpellAbility_StackInstance {
* @return a boolean. * @return a boolean.
*/ */
public final boolean isSpell() { public final boolean isSpell() {
return ability.isSpell(); return this.ability.isSpell();
} }
/** /**
@@ -203,7 +200,7 @@ public class SpellAbility_StackInstance {
* @return a boolean. * @return a boolean.
*/ */
public final boolean isAbility() { public final boolean isAbility() {
return ability.isAbility(); return this.ability.isAbility();
} }
/** /**
@@ -214,7 +211,7 @@ public class SpellAbility_StackInstance {
* @return a boolean. * @return a boolean.
*/ */
public final boolean isTrigger() { public final boolean isTrigger() {
return ability.isTrigger(); return this.ability.isTrigger();
} }
/** /**
@@ -227,7 +224,7 @@ public class SpellAbility_StackInstance {
* @return a boolean. * @return a boolean.
*/ */
public final boolean isStateTrigger(final int id) { 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 * @return true, if is optional trigger
*/ */
public final boolean isOptionalTrigger() { public final boolean isOptionalTrigger() {
return ability.isOptionalTrigger(); return this.ability.isOptionalTrigger();
} }
} }

View File

@@ -682,7 +682,7 @@ public class SpellAbility_Variables {
/** /**
* Gets the present defined. * Gets the present defined.
* *
* @return the presentDefined * @return the presentDefined
*/ */
public final String getPresentDefined() { public final String getPresentDefined() {
@@ -691,7 +691,7 @@ public class SpellAbility_Variables {
/** /**
* Checks if is all m12 empires. * Checks if is all m12 empires.
* *
* @return the allM12Empires * @return the allM12Empires
*/ */
public final boolean isAllM12Empires() { public final boolean isAllM12Empires() {
@@ -700,7 +700,7 @@ public class SpellAbility_Variables {
/** /**
* Checks if is not all m12 empires. * Checks if is not all m12 empires.
* *
* @return the notAllM12Empires * @return the notAllM12Empires
*/ */
public final boolean isNotAllM12Empires() { public final boolean isNotAllM12Empires() {
@@ -709,7 +709,7 @@ public class SpellAbility_Variables {
/** /**
* Gets the s var operand. * Gets the s var operand.
* *
* @return the sVarOperand * @return the sVarOperand
*/ */
public final String getsVarOperand() { public final String getsVarOperand() {
@@ -718,8 +718,9 @@ public class SpellAbility_Variables {
/** /**
* Sets the s var operand. * Sets the s var operand.
* *
* @param sVarOperand the sVarOperand to set * @param sVarOperand
* the sVarOperand to set
*/ */
public final void setsVarOperand(final String sVarOperand) { public final void setsVarOperand(final String sVarOperand) {
this.sVarOperand = sVarOperand; // TODO Add 0 to parameter's name. this.sVarOperand = sVarOperand; // TODO Add 0 to parameter's name.
@@ -727,7 +728,7 @@ public class SpellAbility_Variables {
/** /**
* Gets the s var to check. * Gets the s var to check.
* *
* @return the sVarToCheck * @return the sVarToCheck
*/ */
public final String getsVarToCheck() { public final String getsVarToCheck() {
@@ -736,8 +737,9 @@ public class SpellAbility_Variables {
/** /**
* Sets the s var to check. * 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) { public final void setsVarToCheck(final String sVarToCheck) {
this.sVarToCheck = sVarToCheck; this.sVarToCheck = sVarToCheck;
@@ -745,7 +747,7 @@ public class SpellAbility_Variables {
/** /**
* Gets the s var operator. * Gets the s var operator.
* *
* @return the sVarOperator * @return the sVarOperator
*/ */
public final String getsVarOperator() { public final String getsVarOperator() {
@@ -754,8 +756,9 @@ public class SpellAbility_Variables {
/** /**
* Sets the s var operator. * Sets the s var operator.
* *
* @param sVarOperator the sVarOperator to set * @param sVarOperator
* the sVarOperator to set
*/ */
public final void setsVarOperator(final String sVarOperator) { public final void setsVarOperator(final String sVarOperator) {
this.sVarOperator = sVarOperator; // TODO: Add 0 to parameter's name. this.sVarOperator = sVarOperator; // TODO: Add 0 to parameter's name.
@@ -763,7 +766,7 @@ public class SpellAbility_Variables {
/** /**
* Checks if is opponent turn. * Checks if is opponent turn.
* *
* @return the opponentTurn * @return the opponentTurn
*/ */
public final boolean isOpponentTurn() { public final boolean isOpponentTurn() {
@@ -772,7 +775,7 @@ public class SpellAbility_Variables {
/** /**
* Gets the cards in hand. * Gets the cards in hand.
* *
* @return the cardsInHand * @return the cardsInHand
*/ */
public final int getCardsInHand() { public final int getCardsInHand() {
@@ -781,8 +784,9 @@ public class SpellAbility_Variables {
/** /**
* Sets the cards in hand. * Sets the cards in hand.
* *
* @param cardsInHand the cardsInHand to set * @param cardsInHand
* the cardsInHand to set
*/ */
public final void setCardsInHand(final int cardsInHand) { public final void setCardsInHand(final int cardsInHand) {
this.cardsInHand = cardsInHand; // TODO: Add 0 to parameter's name. this.cardsInHand = cardsInHand; // TODO: Add 0 to parameter's name.
@@ -790,7 +794,7 @@ public class SpellAbility_Variables {
/** /**
* Gets the checks if is present. * Gets the checks if is present.
* *
* @return the isPresent * @return the isPresent
*/ */
public final String getIsPresent() { public final String getIsPresent() {
@@ -799,11 +803,11 @@ public class SpellAbility_Variables {
/** /**
* Checks if is any player. * Checks if is any player.
* *
* @return the anyPlayer * @return the anyPlayer
*/ */
public final boolean isAnyPlayer() { public final boolean isAnyPlayer() {
return anyPlayer; return this.anyPlayer;
} }
} // end class SpellAbility_Variables } // end class SpellAbility_Variables

View File

@@ -41,94 +41,99 @@ public class Spell_Permanent extends Spell {
@Override @Override
public void showMessage() { public void showMessage() {
CardList choice = (CardList) championGetCreature.execute(); final CardList choice = (CardList) Spell_Permanent.this.championGetCreature.execute();
stopSetNext(CardFactoryUtil.inputTargetChampionSac(getSourceCard(), championAbilityComes, choice, this.stopSetNext(CardFactoryUtil.inputTargetChampionSac(Spell_Permanent.this.getSourceCard(),
"Select another " + championValidDesc + " you control to exile", false, false)); 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 ButtonUtil.disableAll(); // target this card means: sacrifice this
// card // card
} }
}; };
private final CommandReturn championGetCreature = new CommandReturn() { private final CommandReturn championGetCreature = new CommandReturn() {
@Override
public Object execute() { public Object execute() {
CardList cards = getSourceCard().getController().getCardsIn(Zone.Battlefield); final CardList cards = Spell_Permanent.this.getSourceCard().getController().getCardsIn(Zone.Battlefield);
return cards.getValidCards(championValid, getSourceCard().getController(), getSourceCard()); return cards.getValidCards(Spell_Permanent.this.championValid, Spell_Permanent.this.getSourceCard()
.getController(), Spell_Permanent.this.getSourceCard());
} }
}; // CommandReturn }; // CommandReturn
/** The champion ability comes. */ /** The champion ability comes. */
private final SpellAbility championAbilityComes = new Ability(getSourceCard(), "0") { private final SpellAbility championAbilityComes = new Ability(this.getSourceCard(), "0") {
@Override @Override
public void resolve() { public void resolve() {
Card source = getSourceCard(); final Card source = this.getSourceCard();
Player controller = source.getController(); final Player controller = source.getController();
CardList creature = (CardList) championGetCreature.execute(); final CardList creature = (CardList) Spell_Permanent.this.championGetCreature.execute();
if (creature.size() == 0) { if (creature.size() == 0) {
AllZone.getGameAction().sacrifice(source); AllZone.getGameAction().sacrifice(source);
return; return;
} else if (controller.isHuman()) { } else if (controller.isHuman()) {
AllZone.getInputControl().setInput(championInputComes); AllZone.getInputControl().setInput(Spell_Permanent.this.championInputComes);
} else { // Computer } else { // Computer
CardList computer = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); 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.remove(source);
computer.shuffle(); computer.shuffle();
if (computer.size() != 0) { if (computer.size() != 0) {
Card c = computer.get(0); final Card c = computer.get(0);
source.setChampionedCard(c); source.setChampionedCard(c);
if (AllZoneUtil.isCardInPlay(c)) { if (AllZoneUtil.isCardInPlay(c)) {
AllZone.getGameAction().exile(c); AllZone.getGameAction().exile(c);
} }
// Run triggers // Run triggers
HashMap<String, Object> runParams = new HashMap<String, Object>(); final HashMap<String, Object> runParams = new HashMap<String, Object>();
runParams.put("Card", source); runParams.put("Card", source);
runParams.put("Championed", source.getChampionedCard()); runParams.put("Championed", source.getChampionedCard());
AllZone.getTriggerHandler().runTrigger("Championed", runParams); AllZone.getTriggerHandler().runTrigger("Championed", runParams);
} else { } else {
AllZone.getGameAction().sacrifice(getSourceCard()); AllZone.getGameAction().sacrifice(this.getSourceCard());
} }
} // computer } // computer
} // resolve() } // resolve()
}; };
/** The champion command comes. */ /** The champion command comes. */
private Command championCommandComes = new Command() { private final Command championCommandComes = new Command() {
private static final long serialVersionUID = -3580408066322945328L; private static final long serialVersionUID = -3580408066322945328L;
@Override
public void execute() { public void execute() {
StringBuilder sb = new StringBuilder(); final StringBuilder sb = new StringBuilder();
sb.append(getSourceCard()).append( sb.append(Spell_Permanent.this.getSourceCard()).append(
" - When CARDNAME enters the battlefield, sacrifice it unless you exile a creature you control."); " - When CARDNAME enters the battlefield, sacrifice it unless you exile a creature you control.");
championAbilityComes.setStackDescription(sb.toString()); Spell_Permanent.this.championAbilityComes.setStackDescription(sb.toString());
AllZone.getStack().addSimultaneousStackEntry(championAbilityComes); AllZone.getStack().addSimultaneousStackEntry(Spell_Permanent.this.championAbilityComes);
} // execute() } // execute()
}; // championCommandComes }; // championCommandComes
/** The champion command leaves play. */ /** The champion command leaves play. */
private Command championCommandLeavesPlay = new Command() { private final Command championCommandLeavesPlay = new Command() {
private static final long serialVersionUID = -5903638227914705191L; private static final long serialVersionUID = -5903638227914705191L;
@Override
public void execute() { public void execute() {
SpellAbility ability = new Ability(getSourceCard(), "0") { final SpellAbility ability = new Ability(Spell_Permanent.this.getSourceCard(), "0") {
@Override @Override
public void resolve() { public void resolve() {
Card c = getSourceCard().getChampionedCard(); final Card c = this.getSourceCard().getChampionedCard();
if (c != null && !c.isToken() && AllZoneUtil.isCardExiled(c)) { if ((c != null) && !c.isToken() && AllZoneUtil.isCardExiled(c)) {
AllZone.getGameAction().moveToPlay(c); AllZone.getGameAction().moveToPlay(c);
} }
} // resolve() } // resolve()
}; // SpellAbility }; // SpellAbility
StringBuilder sb = new StringBuilder(); final StringBuilder sb = new StringBuilder();
sb.append(getSourceCard()).append( sb.append(Spell_Permanent.this.getSourceCard()).append(
" - When CARDNAME leaves the battlefield, exiled card returns to the battlefield."); " - When CARDNAME leaves the battlefield, exiled card returns to the battlefield.");
ability.setStackDescription(sb.toString()); ability.setStackDescription(sb.toString());
@@ -184,36 +189,36 @@ public class Spell_Permanent extends Spell {
super(sourceCard, cost, tgt); super(sourceCard, cost, tgt);
if (CardFactoryUtil.hasKeyword(sourceCard, "Champion") != -1) { 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(); final String toParse = sourceCard.getKeyword().get(n).toString();
String[] parsed = toParse.split(":"); final String[] parsed = toParse.split(":");
willChampion = true; this.willChampion = true;
championValid = parsed[1]; this.championValid = parsed[1];
if (parsed.length > 2) { if (parsed.length > 2) {
championValidDesc = parsed[2]; this.championValidDesc = parsed[2];
} else { } else {
championValidDesc = championValid; this.championValidDesc = this.championValid;
} }
} }
if (sourceCard.isCreature()) { if (sourceCard.isCreature()) {
StringBuilder sb = new StringBuilder(); final StringBuilder sb = new StringBuilder();
sb.append(sourceCard.getName()).append(" - Creature ").append(sourceCard.getNetAttack()); sb.append(sourceCard.getName()).append(" - Creature ").append(sourceCard.getNetAttack());
sb.append(" / ").append(sourceCard.getNetDefense()); sb.append(" / ").append(sourceCard.getNetDefense());
setStackDescription(sb.toString()); this.setStackDescription(sb.toString());
} else { } else {
setStackDescription(sourceCard.getName()); this.setStackDescription(sourceCard.getName());
} }
if (setDesc) { if (setDesc) {
setDescription(getStackDescription()); this.setDescription(this.getStackDescription());
} }
if (willChampion) { if (this.willChampion) {
sourceCard.addComesIntoPlayCommand(championCommandComes); sourceCard.addComesIntoPlayCommand(this.championCommandComes);
sourceCard.addLeavesPlayCommand(championCommandLeavesPlay); sourceCard.addLeavesPlayCommand(this.championCommandLeavesPlay);
} }
} // Spell_Permanent() } // Spell_Permanent()
@@ -221,12 +226,12 @@ public class Spell_Permanent extends Spell {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public boolean canPlay() { 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 (source.getName().equals("Serra Avenger")) {
if (turn.equals(source.getController()) && turn.getTurn() <= 3) { if (turn.equals(source.getController()) && (turn.getTurn() <= 3)) {
return false; return false;
} }
} }
@@ -239,11 +244,11 @@ public class Spell_Permanent extends Spell {
@Override @Override
public boolean canPlayAI() { public boolean canPlayAI() {
Card card = getSourceCard(); final Card card = this.getSourceCard();
// check on legendary // check on legendary
if (card.isType("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())) { if (list.containsName(card.getName())) {
return false; return false;
} }
@@ -253,8 +258,8 @@ public class Spell_Permanent extends Spell {
list = list.getType("Planeswalker"); list = list.getType("Planeswalker");
for (int i = 0; i < list.size(); i++) { for (int i = 0; i < list.size(); i++) {
String subtype = card.getType().get(card.getType().size() - 1); final String subtype = card.getType().get(card.getType().size() - 1);
CardList cl = list.getType(subtype); final CardList cl = list.getType(subtype);
if (cl.size() > 0) { if (cl.size() > 0) {
return false; 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")) { && !card.getText().contains("Modular")) {
return false; return false;
} }
if (willChampion) { if (this.willChampion) {
Object o = championGetCreature.execute(); final Object o = this.championGetCreature.execute();
if (o == null) { if (o == null) {
return false; return false;
} }
CardList cl = (CardList) championGetCreature.execute(); final CardList cl = (CardList) this.championGetCreature.execute();
if ((o == null) || !(cl.size() > 0) || !AllZone.getZoneOf(getSourceCard()).is(Constant.Zone.Hand)) { if ((o == null) || !(cl.size() > 0) || !AllZone.getZoneOf(this.getSourceCard()).is(Constant.Zone.Hand)) {
return false; return false;
} }
} }
if (!checkETBEffects(card, this, null)) { if (!Spell_Permanent.checkETBEffects(card, this, null)) {
return false; 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) { public static boolean checkETBEffects(final Card card, final SpellAbility sa, final String api) {
// Trigger play improvements // Trigger play improvements
ArrayList<Trigger> triggers = card.getTriggers(); final ArrayList<Trigger> triggers = card.getTriggers();
for (Trigger tr : triggers) { for (final Trigger tr : triggers) {
// These triggers all care for ETB effects // These triggers all care for ETB effects
HashMap<String, String> params = tr.getMapParams(); final HashMap<String, String> params = tr.getMapParams();
if (!params.get("Mode").equals("ChangesZone")) { if (!params.get("Mode").equals("ChangesZone")) {
continue; continue;
} }
@@ -335,14 +340,14 @@ public class Spell_Permanent extends Spell {
} }
// Maybe better considerations // Maybe better considerations
AbilityFactory af = new AbilityFactory(); final AbilityFactory af = new AbilityFactory();
String execute = params.get("Execute"); final String execute = params.get("Execute");
if (execute == null) { if (execute == null) {
continue; 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; continue;
} }
@@ -355,7 +360,7 @@ public class Spell_Permanent extends Spell {
// Run non-mandatory trigger. // Run non-mandatory trigger.
// These checks only work if the Executing SpellAbility is an // These checks only work if the Executing SpellAbility is an
// Ability_Sub. // 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 // AI would not run this trigger if given the chance
// if trigger is mandatory, return false // if trigger is mandatory, return false
@@ -373,7 +378,7 @@ public class Spell_Permanent extends Spell {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public void resolve() { public void resolve() {
Card c = getSourceCard(); final Card c = this.getSourceCard();
AllZone.getGameAction().moveToPlay(c); AllZone.getGameAction().moveToPlay(c);
} }
} }

View File

@@ -36,7 +36,7 @@ public class Target {
* @return a {@link forge.card.spellability.Target_Choices} object. * @return a {@link forge.card.spellability.Target_Choices} object.
*/ */
public final Target_Choices getTargetChoices() { 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. * a {@link forge.card.spellability.Target_Choices} object.
*/ */
public final void setTargetChoices(final Target_Choices tc) { public final void setTargetChoices(final Target_Choices tc) {
choice = tc; this.choice = tc;
} }
private boolean bMandatory = false; private boolean bMandatory = false;
@@ -61,7 +61,7 @@ public class Target {
* @return a boolean. * @return a boolean.
*/ */
public final boolean getMandatory() { public final boolean getMandatory() {
return bMandatory; return this.bMandatory;
} }
/** /**
@@ -73,11 +73,11 @@ public class Target {
* a boolean. * a boolean.
*/ */
public final void setMandatory(final boolean m) { public final void setMandatory(final boolean m) {
bMandatory = m; this.bMandatory = m;
} }
private boolean tgtValid = false; private boolean tgtValid = false;
private String[] ValidTgts; private String[] validTgts;
private String vtSelection = ""; private String vtSelection = "";
/** /**
@@ -88,7 +88,7 @@ public class Target {
* @return a boolean. * @return a boolean.
*/ */
public final boolean doesTarget() { 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. * @return an array of {@link java.lang.String} objects.
*/ */
public final String[] getValidTgts() { public final String[] getValidTgts() {
return ValidTgts; return this.validTgts;
} }
/** /**
@@ -110,7 +110,7 @@ public class Target {
* @return a {@link java.lang.String} object. * @return a {@link java.lang.String} object.
*/ */
public final String getVTSelection() { public final String getVTSelection() {
return vtSelection; return this.vtSelection;
} }
private String minTargets; private String minTargets;
@@ -128,7 +128,7 @@ public class Target {
* @return a int. * @return a int.
*/ */
public final int getMinTargets(final Card c, final SpellAbility sa) { 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. * @return a int.
*/ */
public final int getMaxTargets(final Card c, final SpellAbility sa) { 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. * @return a boolean.
*/ */
public final boolean isMaxTargetsChosen(final Card c, final SpellAbility sa) { 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. * @return a boolean.
*/ */
public final boolean isMinTargetsChosen(final Card c, final SpellAbility sa) { public final boolean isMinTargetsChosen(final Card c, final SpellAbility sa) {
if (getMinTargets(c, sa) == 0) { if (this.getMinTargets(c, sa) == 0) {
return true; return true;
} }
return choice != null && getMinTargets(c, sa) <= choice.getNumTargeted(); return (this.choice != null) && (this.getMinTargets(c, sa) <= this.choice.getNumTargeted());
} }
private List<Constant.Zone> tgtZone = Arrays.asList(Constant.Zone.Battlefield); private List<Constant.Zone> tgtZone = Arrays.asList(Constant.Zone.Battlefield);
@@ -190,7 +190,7 @@ public class Target {
* a {@link java.lang.String} object. * a {@link java.lang.String} object.
*/ */
public final void setZone(final Constant.Zone tZone) { 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 * the new zone
*/ */
public final void setZone(final List<Constant.Zone> tZone) { public final void setZone(final List<Constant.Zone> tZone) {
tgtZone = tZone; this.tgtZone = tZone;
} }
/** /**
@@ -211,7 +211,7 @@ public class Target {
* @return a {@link java.lang.String} object. * @return a {@link java.lang.String} object.
*/ */
public final List<Constant.Zone> getZone() { public final List<Constant.Zone> getZone() {
return tgtZone; return this.tgtZone;
} }
// Used for Counters. Currently, Spell,Activated,Triggered can be // Used for Counters. Currently, Spell,Activated,Triggered can be
@@ -227,7 +227,7 @@ public class Target {
* a {@link java.lang.String} object. * a {@link java.lang.String} object.
*/ */
public final void setTargetSpellAbilityType(final String tgtSAType) { 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. * @return a {@link java.lang.String} object.
*/ */
public final String getTargetSpellAbilityType() { public final String getTargetSpellAbilityType() {
return targetSpellAbilityType; return this.targetSpellAbilityType;
} }
// Used for Counters. The target SA of this SA must be targeting a Valid X // 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. * a {@link java.lang.String} object.
*/ */
public final void setSAValidTargeting(final String saValidTgting) { 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. * @return a {@link java.lang.String} object.
*/ */
public final String getSAValidTargeting() { public final String getSAValidTargeting() {
return saValidTargeting; return this.saValidTargeting;
} }
// Leaving old structure behind for compatibility. // Leaving old structure behind for compatibility.
@@ -278,20 +278,20 @@ public class Target {
* @return a boolean. * @return a boolean.
*/ */
public final boolean addTarget(final Object o) { public final boolean addTarget(final Object o) {
if (choice == null) { if (this.choice == null) {
choice = new Target_Choices(); this.choice = new Target_Choices();
} }
if (o instanceof Card) { if (o instanceof Card) {
return choice.addTarget((Card) o); return this.choice.addTarget((Card) o);
} }
if (o instanceof Player) { if (o instanceof Player) {
return choice.addTarget((Player) o); return this.choice.addTarget((Player) o);
} }
if (o instanceof SpellAbility) { if (o instanceof SpellAbility) {
return choice.addTarget((SpellAbility) o); return this.choice.addTarget((SpellAbility) o);
} }
return false; return false;
@@ -305,11 +305,11 @@ public class Target {
* @return a {@link java.util.ArrayList} object. * @return a {@link java.util.ArrayList} object.
*/ */
public final ArrayList<Card> getTargetCards() { public final ArrayList<Card> getTargetCards() {
if (choice == null) { if (this.choice == null) {
return new ArrayList<Card>(); return new ArrayList<Card>();
} }
return choice.getTargetCards(); return this.choice.getTargetCards();
} }
/** /**
@@ -320,11 +320,11 @@ public class Target {
* @return a {@link java.util.ArrayList} object. * @return a {@link java.util.ArrayList} object.
*/ */
public final ArrayList<Player> getTargetPlayers() { public final ArrayList<Player> getTargetPlayers() {
if (choice == null) { if (this.choice == null) {
return new ArrayList<Player>(); return new ArrayList<Player>();
} }
return choice.getTargetPlayers(); return this.choice.getTargetPlayers();
} }
/** /**
@@ -335,11 +335,11 @@ public class Target {
* @return a {@link java.util.ArrayList} object. * @return a {@link java.util.ArrayList} object.
*/ */
public final ArrayList<SpellAbility> getTargetSAs() { public final ArrayList<SpellAbility> getTargetSAs() {
if (choice == null) { if (this.choice == null) {
return new ArrayList<SpellAbility>(); return new ArrayList<SpellAbility>();
} }
return choice.getTargetSAs(); return this.choice.getTargetSAs();
} }
/** /**
@@ -350,11 +350,11 @@ public class Target {
* @return a {@link java.util.ArrayList} object. * @return a {@link java.util.ArrayList} object.
*/ */
public final ArrayList<Object> getTargets() { public final ArrayList<Object> getTargets() {
if (choice == null) { if (this.choice == null) {
return new ArrayList<Object>(); return new ArrayList<Object>();
} }
return choice.getTargets(); return this.choice.getTargets();
} }
/** /**
@@ -365,10 +365,10 @@ public class Target {
* @return a int. * @return a int.
*/ */
public final int getNumTargeted() { public final int getNumTargeted() {
if (choice == null) { if (this.choice == null) {
return 0; return 0;
} }
return choice.getNumTargeted(); return this.choice.getNumTargeted();
} }
/** /**
@@ -377,7 +377,7 @@ public class Target {
* </p> * </p>
*/ */
public final void resetTargets() { public final void resetTargets() {
choice = null; this.choice = null;
} }
/** /**
@@ -413,8 +413,8 @@ public class Target {
// C = Creature P=Player/Planeswalker // C = Creature P=Player/Planeswalker
// CP = All three // CP = All three
tgtValid = true; this.tgtValid = true;
srcCard = src; this.srcCard = src;
if (parse.contains("Tgt")) { if (parse.contains("Tgt")) {
parse = parse.replace("Tgt", ""); parse = parse.replace("Tgt", "");
@@ -422,7 +422,7 @@ public class Target {
String valid; String valid;
String prompt; String prompt;
StringBuilder sb = new StringBuilder(); final StringBuilder sb = new StringBuilder();
if (parse.equals("CP")) { if (parse.equals("CP")) {
valid = "Creature,Planeswalker.YouDontCtrl,Player"; valid = "Creature,Planeswalker.YouDontCtrl,Player";
@@ -442,11 +442,11 @@ public class Target {
sb.append(src + " - "); sb.append(src + " - ");
} }
sb.append(prompt); sb.append(prompt);
vtSelection = sb.toString(); this.vtSelection = sb.toString();
ValidTgts = valid.split(","); this.validTgts = valid.split(",");
minTargets = min; this.minTargets = min;
maxTargets = max; this.maxTargets = max;
} }
/** /**
@@ -498,13 +498,13 @@ public class Target {
* a {@link java.lang.String} object. * a {@link java.lang.String} object.
*/ */
public Target(final Card src, final String select, final String[] valid, final String min, final String max) { public Target(final Card src, final String select, final String[] valid, final String min, final String max) {
srcCard = src; this.srcCard = src;
tgtValid = true; this.tgtValid = true;
vtSelection = select; this.vtSelection = select;
ValidTgts = valid; this.validTgts = valid;
minTargets = min; this.minTargets = min;
maxTargets = max; this.maxTargets = max;
} }
/** /**
@@ -515,15 +515,15 @@ public class Target {
* @return a {@link java.lang.String} object. * @return a {@link java.lang.String} object.
*/ */
public final String getTargetedString() { public final String getTargetedString() {
ArrayList<Object> tgts = getTargets(); final ArrayList<Object> tgts = this.getTargets();
StringBuilder sb = new StringBuilder(""); final StringBuilder sb = new StringBuilder("");
for (Object o : tgts) { for (final Object o : tgts) {
if (o instanceof Player) { if (o instanceof Player) {
Player p = (Player) o; final Player p = (Player) o;
sb.append(p.getName()); sb.append(p.getName());
} }
if (o instanceof Card) { if (o instanceof Card) {
Card c = (Card) o; final Card c = (Card) o;
sb.append(c); sb.append(c);
} }
sb.append(" "); sb.append(" ");
@@ -542,7 +542,7 @@ public class Target {
public final boolean canOnlyTgtOpponent() { public final boolean canOnlyTgtOpponent() {
boolean player = false; boolean player = false;
boolean opponent = false; boolean opponent = false;
for (String s : ValidTgts) { for (final String s : this.validTgts) {
if (s.equals("Opponent")) { if (s.equals("Opponent")) {
opponent = true; opponent = true;
} else if (s.equals("Player")) { } else if (s.equals("Player")) {
@@ -560,7 +560,7 @@ public class Target {
* @return a boolean. * @return a boolean.
*/ */
public final boolean canTgtPlayer() { public final boolean canTgtPlayer() {
for (String s : ValidTgts) { for (final String s : this.validTgts) {
if (s.equals("Player") || s.equals("Opponent")) { if (s.equals("Player") || s.equals("Opponent")) {
return true; return true;
} }
@@ -577,7 +577,7 @@ public class Target {
*/ */
public final boolean canTgtPermanent() { public final boolean canTgtPermanent() {
for (String s : ValidTgts) { for (final String s : this.validTgts) {
if (s.contains("Permanent")) { if (s.contains("Permanent")) {
return true; return true;
} }
@@ -591,7 +591,7 @@ public class Target {
* @return true, if successful * @return true, if successful
*/ */
public final boolean canTgtCreature() { public final boolean canTgtCreature() {
for (String s : ValidTgts) { for (final String s : this.validTgts) {
if (s.contains("Creature") && !s.contains("nonCreature")) { if (s.contains("Creature") && !s.contains("nonCreature")) {
return true; return true;
} }
@@ -607,7 +607,7 @@ public class Target {
* @return a boolean. * @return a boolean.
*/ */
public final boolean canTgtCreatureAndPlayer() { public final boolean canTgtCreatureAndPlayer() {
return canTgtPlayer() && canTgtCreature(); return this.canTgtPlayer() && this.canTgtCreature();
} }
/** /**
@@ -621,13 +621,13 @@ public class Target {
* @return a boolean. * @return a boolean.
*/ */
public final boolean hasCandidates(final boolean isTargeted) { public final boolean hasCandidates(final boolean isTargeted) {
if (canTgtPlayer()) { if (this.canTgtPlayer()) {
return true; return true;
} }
for (Card c : AllZoneUtil.getCardsIn(tgtZone)) { for (final Card c : AllZoneUtil.getCardsIn(this.tgtZone)) {
if (c.isValid(ValidTgts, srcCard.getController(), srcCard) if (c.isValid(this.validTgts, this.srcCard.getController(), this.srcCard)
&& (!isTargeted || CardFactoryUtil.canTarget(srcCard, c))) { && (!isTargeted || CardFactoryUtil.canTarget(this.srcCard, c))) {
return true; return true;
} }
} }
@@ -641,7 +641,7 @@ public class Target {
* @return true, if is unique targets * @return true, if is unique targets
*/ */
public final boolean isUniqueTargets() { public final boolean isUniqueTargets() {
return uniqueTargets; return this.uniqueTargets;
} }
/** /**

View File

@@ -24,13 +24,13 @@ public class Target_Choices {
* @return a int. * @return a int.
*/ */
public final int getNumTargeted() { public final int getNumTargeted() {
return numTargeted; return this.numTargeted;
} }
// Card or Player are legal targets. // Card or Player are legal targets.
private ArrayList<Card> targetCards = new ArrayList<Card>(); private final ArrayList<Card> targetCards = new ArrayList<Card>();
private ArrayList<Player> targetPlayers = new ArrayList<Player>(); private final ArrayList<Player> targetPlayers = new ArrayList<Player>();
private ArrayList<SpellAbility> targetSAs = new ArrayList<SpellAbility>(); private final ArrayList<SpellAbility> targetSAs = new ArrayList<SpellAbility>();
/** /**
* <p> * <p>
@@ -43,11 +43,11 @@ public class Target_Choices {
*/ */
public final boolean addTarget(final Object o) { public final boolean addTarget(final Object o) {
if (o instanceof Player) { if (o instanceof Player) {
return addTarget((Player) o); return this.addTarget((Player) o);
} else if (o instanceof Card) { } else if (o instanceof Card) {
return addTarget((Card) o); return this.addTarget((Card) o);
} else if (o instanceof SpellAbility) { } else if (o instanceof SpellAbility) {
return addTarget((SpellAbility) o); return this.addTarget((SpellAbility) o);
} }
return false; return false;
@@ -63,9 +63,9 @@ public class Target_Choices {
* @return a boolean. * @return a boolean.
*/ */
public final boolean addTarget(final Card c) { public final boolean addTarget(final Card c) {
if (!targetCards.contains(c)) { if (!this.targetCards.contains(c)) {
targetCards.add(c); this.targetCards.add(c);
numTargeted++; this.numTargeted++;
return true; return true;
} }
return false; return false;
@@ -81,9 +81,9 @@ public class Target_Choices {
* @return a boolean. * @return a boolean.
*/ */
public final boolean addTarget(final Player p) { public final boolean addTarget(final Player p) {
if (!targetPlayers.contains(p)) { if (!this.targetPlayers.contains(p)) {
targetPlayers.add(p); this.targetPlayers.add(p);
numTargeted++; this.numTargeted++;
return true; return true;
} }
return false; return false;
@@ -99,9 +99,9 @@ public class Target_Choices {
* @return a boolean. * @return a boolean.
*/ */
public final boolean addTarget(final SpellAbility sa) { public final boolean addTarget(final SpellAbility sa) {
if (!targetSAs.contains(sa)) { if (!this.targetSAs.contains(sa)) {
targetSAs.add(sa); this.targetSAs.add(sa);
numTargeted++; this.numTargeted++;
return true; return true;
} }
return false; return false;
@@ -115,7 +115,7 @@ public class Target_Choices {
* @return a {@link java.util.ArrayList} object. * @return a {@link java.util.ArrayList} object.
*/ */
public final ArrayList<Card> getTargetCards() { public final ArrayList<Card> getTargetCards() {
return targetCards; return this.targetCards;
} }
/** /**
@@ -126,7 +126,7 @@ public class Target_Choices {
* @return a {@link java.util.ArrayList} object. * @return a {@link java.util.ArrayList} object.
*/ */
public final ArrayList<Player> getTargetPlayers() { public final ArrayList<Player> getTargetPlayers() {
return targetPlayers; return this.targetPlayers;
} }
/** /**
@@ -137,7 +137,7 @@ public class Target_Choices {
* @return a {@link java.util.ArrayList} object. * @return a {@link java.util.ArrayList} object.
*/ */
public final ArrayList<SpellAbility> getTargetSAs() { public final ArrayList<SpellAbility> getTargetSAs() {
return targetSAs; return this.targetSAs;
} }
/** /**
@@ -148,10 +148,10 @@ public class Target_Choices {
* @return a {@link java.util.ArrayList} object. * @return a {@link java.util.ArrayList} object.
*/ */
public final ArrayList<Object> getTargets() { public final ArrayList<Object> getTargets() {
ArrayList<Object> tgts = new ArrayList<Object>(); final ArrayList<Object> tgts = new ArrayList<Object>();
tgts.addAll(targetPlayers); tgts.addAll(this.targetPlayers);
tgts.addAll(targetCards); tgts.addAll(this.targetCards);
tgts.addAll(targetSAs); tgts.addAll(this.targetSAs);
return tgts; return tgts;
} }
@@ -164,19 +164,19 @@ public class Target_Choices {
* @return a {@link java.lang.String} object. * @return a {@link java.lang.String} object.
*/ */
public final String getTargetedString() { public final String getTargetedString() {
ArrayList<Object> tgts = getTargets(); final ArrayList<Object> tgts = this.getTargets();
StringBuilder sb = new StringBuilder(""); final StringBuilder sb = new StringBuilder("");
for (Object o : tgts) { for (final Object o : tgts) {
if (o instanceof Player) { if (o instanceof Player) {
Player p = (Player) o; final Player p = (Player) o;
sb.append(p.getName()); sb.append(p.getName());
} }
if (o instanceof Card) { if (o instanceof Card) {
Card c = (Card) o; final Card c = (Card) o;
sb.append(c); sb.append(c);
} }
if (o instanceof SpellAbility) { if (o instanceof SpellAbility) {
SpellAbility sa = (SpellAbility) o; final SpellAbility sa = (SpellAbility) o;
sb.append(sa); sb.append(sa);
} }
sb.append(" "); sb.append(" ");

View File

@@ -39,7 +39,7 @@ public class Target_Selection {
* @return a {@link forge.card.spellability.Target} object. * @return a {@link forge.card.spellability.Target} object.
*/ */
public final Target getTgt() { 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. * @return a {@link forge.card.spellability.SpellAbility} object.
*/ */
public final SpellAbility getAbility() { public final SpellAbility getAbility() {
return ability; return this.ability;
} }
/** /**
@@ -61,7 +61,7 @@ public class Target_Selection {
* @return a {@link forge.Card} object. * @return a {@link forge.Card} object.
*/ */
public final Card getCard() { public final Card getCard() {
return card; return this.card;
} }
private SpellAbility_Requirements req = null; private SpellAbility_Requirements req = null;
@@ -76,7 +76,7 @@ public class Target_Selection {
* object. * object.
*/ */
public final void setRequirements(final SpellAbility_Requirements reqs) { public final void setRequirements(final SpellAbility_Requirements reqs) {
req = reqs; this.req = reqs;
} }
private boolean bCancel = false; private boolean bCancel = false;
@@ -90,7 +90,7 @@ public class Target_Selection {
* a boolean. * a boolean.
*/ */
public final void setCancel(final boolean done) { public final void setCancel(final boolean done) {
bCancel = done; this.bCancel = done;
} }
/** /**
@@ -101,15 +101,15 @@ public class Target_Selection {
* @return a boolean. * @return a boolean.
*/ */
public final boolean isCanceled() { public final boolean isCanceled() {
if (bCancel) { if (this.bCancel) {
return bCancel; return this.bCancel;
} }
if (subSelection == null) { if (this.subSelection == null) {
return false; return false;
} }
return subSelection.isCanceled(); return this.subSelection.isCanceled();
} }
private boolean bDoneTarget = false; private boolean bDoneTarget = false;
@@ -123,7 +123,7 @@ public class Target_Selection {
* a boolean. * a boolean.
*/ */
public final void setDoneTarget(final boolean done) { 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. * a {@link forge.card.spellability.SpellAbility} object.
*/ */
public Target_Selection(final Target tgt, final SpellAbility sa) { public Target_Selection(final Target tgt, final SpellAbility sa) {
target = tgt; this.target = tgt;
ability = sa; this.ability = sa;
card = sa.getSourceCard(); this.card = sa.getSourceCard();
} }
/** /**
@@ -150,10 +150,10 @@ public class Target_Selection {
* @return a boolean. * @return a boolean.
*/ */
public final boolean doesTarget() { public final boolean doesTarget() {
if (target == null) { if (this.target == null) {
return false; return false;
} }
return target.doesTarget(); return this.target.doesTarget();
} }
/** /**
@@ -162,8 +162,8 @@ public class Target_Selection {
* </p> * </p>
*/ */
public final void resetTargets() { public final void resetTargets() {
if (target != null) { if (this.target != null) {
target.resetTargets(); this.target.resetTargets();
} }
} }
@@ -176,28 +176,28 @@ public class Target_Selection {
*/ */
public final boolean chooseTargets() { public final boolean chooseTargets() {
// if not enough targets chosen, reset and cancel Ability // if not enough targets chosen, reset and cancel Ability
if (bCancel || (bDoneTarget && !target.isMinTargetsChosen(card, ability))) { if (this.bCancel || (this.bDoneTarget && !this.target.isMinTargetsChosen(this.card, this.ability))) {
bCancel = true; this.bCancel = true;
req.finishedTargeting(); this.req.finishedTargeting();
return false; return false;
} else if (!doesTarget() || bDoneTarget && target.isMinTargetsChosen(card, ability) } else if (!this.doesTarget() || (this.bDoneTarget && this.target.isMinTargetsChosen(this.card, this.ability))
|| target.isMaxTargetsChosen(card, ability)) { || this.target.isMaxTargetsChosen(this.card, this.ability)) {
Ability_Sub abSub = ability.getSubAbility(); final Ability_Sub abSub = this.ability.getSubAbility();
if (abSub == null) { if (abSub == null) {
// if no more SubAbilities finish targeting // if no more SubAbilities finish targeting
req.finishedTargeting(); this.req.finishedTargeting();
return true; return true;
} else { } else {
// Has Sub Ability // Has Sub Ability
subSelection = new Target_Selection(abSub.getTarget(), abSub); this.subSelection = new Target_Selection(abSub.getTarget(), abSub);
subSelection.setRequirements(req); this.subSelection.setRequirements(this.req);
subSelection.resetTargets(); this.subSelection.resetTargets();
return subSelection.chooseTargets(); return this.subSelection.chooseTargets();
} }
} }
chooseValidInput(); this.chooseValidInput();
return false; return false;
} }
@@ -210,7 +210,7 @@ public class Target_Selection {
* @return the unique targets * @return the unique targets
*/ */
public final ArrayList<Object> getUniqueTargets(final SpellAbility ability) { public final ArrayList<Object> getUniqueTargets(final SpellAbility ability) {
ArrayList<Object> targets = new ArrayList<Object>(); final ArrayList<Object> targets = new ArrayList<Object>();
SpellAbility child = ability; SpellAbility child = ability;
while (child instanceof Ability_Sub) { while (child instanceof Ability_Sub) {
child = ((Ability_Sub) child).getParent(); child = ((Ability_Sub) child).getParent();
@@ -231,43 +231,43 @@ public class Target_Selection {
* </p> * </p>
*/ */
public final void chooseValidInput() { public final void chooseValidInput() {
Target tgt = this.getTgt(); final Target tgt = this.getTgt();
List<Zone> zone = tgt.getZone(); final List<Zone> zone = tgt.getZone();
final boolean mandatory = target.getMandatory() ? target.hasCandidates(true) : false; 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 // If Zone is Stack, the choices are handled slightly differently
chooseCardFromStack(mandatory); this.chooseCardFromStack(mandatory);
return; return;
} }
CardList choices = AllZoneUtil.getCardsIn(zone).getValidCards(target.getValidTgts(), final CardList choices = AllZoneUtil.getCardsIn(zone).getValidCards(this.target.getValidTgts(),
ability.getActivatingPlayer(), ability.getSourceCard()); this.ability.getActivatingPlayer(), this.ability.getSourceCard());
ArrayList<Object> objects = new ArrayList<Object>(); ArrayList<Object> objects = new ArrayList<Object>();
if (tgt.isUniqueTargets()) { if (tgt.isUniqueTargets()) {
objects = getUniqueTargets(ability); objects = this.getUniqueTargets(this.ability);
for (Object o : objects) { for (final Object o : objects) {
if (o instanceof Card && objects.contains(o)) { if ((o instanceof Card) && objects.contains(o)) {
choices.remove((Card) o); choices.remove((Card) o);
} }
} }
} }
// Remove cards already targeted // Remove cards already targeted
ArrayList<Card> targeted = tgt.getTargetCards(); final ArrayList<Card> targeted = tgt.getTargetCards();
for (Card c : targeted) { for (final Card c : targeted) {
if (choices.contains(c)) { if (choices.contains(c)) {
choices.remove(c); choices.remove(c);
} }
} }
if (zone.contains(Constant.Zone.Battlefield)) { 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 { } 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 // CardList choices are the only cards the user can successful select
/** /**
@@ -285,22 +285,21 @@ public class Target_Selection {
* the already targeted * the already targeted
* @return a {@link forge.gui.input.Input} object. * @return a {@link forge.gui.input.Input} object.
*/ */
public final Input input_targetSpecific(final CardList choices, public final Input inputTargetSpecific(final CardList choices, final boolean targeted, final boolean mandatory,
final boolean targeted, final boolean mandatory,
final ArrayList<Object> alreadyTargeted) { final ArrayList<Object> alreadyTargeted) {
final SpellAbility sa = this.ability; final SpellAbility sa = this.ability;
final Target_Selection select = this; final Target_Selection select = this;
final Target tgt = this.target; final Target tgt = this.target;
final SpellAbility_Requirements req = this.req; final SpellAbility_Requirements req = this.req;
Input target = new Input() { final Input target = new Input() {
private static final long serialVersionUID = -1091595663541356356L; private static final long serialVersionUID = -1091595663541356356L;
@Override @Override
public void showMessage() { public void showMessage() {
StringBuilder sb = new StringBuilder(); final StringBuilder sb = new StringBuilder();
sb.append("Targeted: "); sb.append("Targeted: ");
for (Object o : alreadyTargeted) { for (final Object o : alreadyTargeted) {
sb.append(o).append(" "); sb.append(o).append(" ");
} }
sb.append(tgt.getTargetedString()); sb.append(tgt.getTargetedString());
@@ -324,14 +323,14 @@ public class Target_Selection {
@Override @Override
public void selectButtonCancel() { public void selectButtonCancel() {
select.setCancel(true); select.setCancel(true);
stop(); this.stop();
req.finishedTargeting(); req.finishedTargeting();
} }
@Override @Override
public void selectButtonOK() { public void selectButtonOK() {
select.setDoneTarget(true); select.setDoneTarget(true);
done(); this.done();
} }
@Override @Override
@@ -342,7 +341,7 @@ public class Target_Selection {
AllZone.getDisplay().showMessage("Cannot target this card (Shroud? Protection? Restrictions?)."); AllZone.getDisplay().showMessage("Cannot target this card (Shroud? Protection? Restrictions?).");
} else if (choices.contains(card)) { } else if (choices.contains(card)) {
tgt.addTarget(card); tgt.addTarget(card);
done(); this.done();
} }
} // selectCard() } // selectCard()
@@ -355,12 +354,12 @@ public class Target_Selection {
if ((tgt.canTgtPlayer() || (tgt.canOnlyTgtOpponent() && player.equals(sa.getActivatingPlayer() if ((tgt.canTgtPlayer() || (tgt.canOnlyTgtOpponent() && player.equals(sa.getActivatingPlayer()
.getOpponent()))) && player.canTarget(sa)) { .getOpponent()))) && player.canTarget(sa)) {
tgt.addTarget(player); tgt.addTarget(player);
done(); this.done();
} }
} }
void done() { void done() {
stop(); this.stop();
select.chooseTargets(); select.chooseTargets();
} }
@@ -388,16 +387,16 @@ public class Target_Selection {
final SpellAbility sa = this.ability; final SpellAbility sa = this.ability;
final String message = this.target.getVTSelection(); 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)) { if (tgt.isMinTargetsChosen(sa.getSourceCard(), sa)) {
// is there a more elegant way of doing this? // is there a more elegant way of doing this?
choicesWithDone.add(dummy); choicesWithDone.add(dummy);
} }
Object check = GuiUtils.getChoiceOptional(message, choicesWithDone.toArray()); final Object check = GuiUtils.getChoiceOptional(message, choicesWithDone.toArray());
if (check != null) { if (check != null) {
Card c = (Card) check; final Card c = (Card) check;
if (c.equals(dummy)) { if (c.equals(dummy)) {
this.setDoneTarget(true); this.setDoneTarget(true);
} else { } else {
@@ -419,16 +418,16 @@ public class Target_Selection {
* a boolean. * a boolean.
*/ */
public final void chooseCardFromStack(final boolean mandatory) { public final void chooseCardFromStack(final boolean mandatory) {
Target tgt = this.target; final Target tgt = this.target;
String message = tgt.getVTSelection(); final String message = tgt.getVTSelection();
Target_Selection select = this; final Target_Selection select = this;
// Find what's targetable, then allow human to choose // Find what's targetable, then allow human to choose
ArrayList<SpellAbility> choosables = getTargetableOnStack(this.ability, select.getTgt()); final ArrayList<SpellAbility> choosables = Target_Selection.getTargetableOnStack(this.ability, select.getTgt());
HashMap<String, SpellAbility> map = new HashMap<String, SpellAbility>(); final HashMap<String, SpellAbility> map = new HashMap<String, SpellAbility>();
for (SpellAbility sa : choosables) { for (final SpellAbility sa : choosables) {
map.put(sa.getStackDescription(), sa); map.put(sa.getStackDescription(), sa);
} }
@@ -438,7 +437,7 @@ public class Target_Selection {
if (choices.length == 0) { if (choices.length == 0) {
select.setCancel(true); select.setCancel(true);
} else { } else {
String madeChoice = GuiUtils.getChoiceOptional(message, choices); final String madeChoice = GuiUtils.getChoiceOptional(message, choices);
if (madeChoice != null) { if (madeChoice != null) {
tgt.addTarget(map.get(madeChoice)); tgt.addTarget(map.get(madeChoice));
@@ -465,14 +464,14 @@ public class Target_Selection {
* @return a {@link java.util.ArrayList} object. * @return a {@link java.util.ArrayList} object.
*/ */
public static ArrayList<SpellAbility> getTargetableOnStack(final SpellAbility sa, final Target tgt) { public static ArrayList<SpellAbility> getTargetableOnStack(final SpellAbility sa, final Target tgt) {
ArrayList<SpellAbility> choosables = new ArrayList<SpellAbility>(); final ArrayList<SpellAbility> choosables = new ArrayList<SpellAbility>();
for (int i = 0; i < AllZone.getStack().size(); i++) { for (int i = 0; i < AllZone.getStack().size(); i++) {
choosables.add(AllZone.getStack().peekAbility(i)); choosables.add(AllZone.getStack().peekAbility(i));
} }
for (int i = 0; i < choosables.size(); 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); choosables.remove(i);
} }
} }
@@ -493,7 +492,7 @@ public class Target_Selection {
* @return a boolean. * @return a boolean.
*/ */
public static boolean matchSpellAbility(final SpellAbility sa, final SpellAbility topSA, final Target tgt) { 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) { if (null == saType) {
// just take this to mean no restrictions - carry on. // 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) { if (splitTargetRestrictions != null) {
// TODO What about spells with SubAbilities with Targets? // TODO What about spells with SubAbilities with Targets?
Target matchTgt = topSA.getTarget(); final Target matchTgt = topSA.getTarget();
if (matchTgt == null) { if (matchTgt == null) {
return false; return false;
@@ -523,8 +522,8 @@ public class Target_Selection {
boolean result = false; boolean result = false;
for (Object o : matchTgt.getTargets()) { for (final Object o : matchTgt.getTargets()) {
if (matchesValid(o, splitTargetRestrictions.split(","), sa)) { if (Target_Selection.matchesValid(o, splitTargetRestrictions.split(","), sa)) {
result = true; result = true;
break; 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; return false;
} }
@@ -556,15 +555,15 @@ public class Target_Selection {
* @return a boolean. * @return a boolean.
*/ */
private static boolean matchesValid(final Object o, final String[] valids, final SpellAbility sa) { private static boolean matchesValid(final Object o, final String[] valids, final SpellAbility sa) {
Card srcCard = sa.getSourceCard(); final Card srcCard = sa.getSourceCard();
Player activatingPlayer = sa.getActivatingPlayer(); final Player activatingPlayer = sa.getActivatingPlayer();
if (o instanceof Card) { if (o instanceof Card) {
Card c = (Card) o; final Card c = (Card) o;
return c.isValid(valids, activatingPlayer, srcCard); return c.isValid(valids, activatingPlayer, srcCard);
} }
if (o instanceof Player) { if (o instanceof Player) {
for (String v : valids) { for (final String v : valids) {
if (v.equalsIgnoreCase("Player")) { if (v.equalsIgnoreCase("Player")) {
return true; return true;
} }
@@ -581,7 +580,7 @@ public class Target_Selection {
} }
if (o instanceof SpellAbility) { if (o instanceof SpellAbility) {
Card c = ((SpellAbility) o).getSourceCard(); final Card c = ((SpellAbility) o).getSourceCard();
return c.isValid(valids, activatingPlayer, srcCard); return c.isValid(valids, activatingPlayer, srcCard);
} }

View File

@@ -104,7 +104,7 @@ public class Input_PayManaCost_Ability extends Input {
public Input_PayManaCost_Ability(final String m, final String manaCost_2, public Input_PayManaCost_Ability(final String m, final String manaCost_2,
final Command paidCommand_2, final Command unpaidCommand_2, final Command paidCommand_2, final Command unpaidCommand_2,
final boolean showOKButton) { final boolean showOKButton) {
fakeAbility = new SpellAbility(SpellAbility.Ability, null) { fakeAbility = new SpellAbility(SpellAbility.getAbility(), null) {
@Override @Override
public void resolve() { public void resolve() {
} }