mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 04:08:01 +00:00
checkstyle and refactor
This commit is contained in:
@@ -94,7 +94,7 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn
|
||||
* a {@link java.io.File} object.
|
||||
*/
|
||||
protected AbstractCardFactory(final File file) {
|
||||
final SpellAbility spell = new SpellAbility(SpellAbility.Spell, this.blankCard) {
|
||||
final SpellAbility spell = new SpellAbility(SpellAbility.getSpell(), this.blankCard) {
|
||||
// neither computer nor human play can play this card
|
||||
@Override
|
||||
public boolean canPlay() {
|
||||
|
||||
@@ -2638,7 +2638,7 @@ public class CardFactory_Creatures {
|
||||
abilityBuilder.append(" | SpellDescription$ Target creature can't block CARDNAME this turn.");
|
||||
final SpellAbility myAb = createAb.getAbility(abilityBuilder.toString(), card);
|
||||
|
||||
myAb.getTarget().setTargetChoices(this.chosenTarget.getTargetChoices());
|
||||
myAb.getTarget().setTargetChoices(this.getChosenTarget().getTargetChoices());
|
||||
myAb.resolve();
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ import forge.Constant.Zone;
|
||||
*/
|
||||
public abstract class Ability extends SpellAbility {
|
||||
// Slight hack for Pithing Needle
|
||||
private String sourceCardName;
|
||||
private final String sourceCardName;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -32,9 +32,9 @@ public abstract class Ability extends SpellAbility {
|
||||
* a {@link java.lang.String} object.
|
||||
*/
|
||||
public Ability(final Card sourceCard, final String manaCost) {
|
||||
super(SpellAbility.Ability, sourceCard);
|
||||
setManaCost(manaCost);
|
||||
sourceCardName = sourceCard.getName();
|
||||
super(SpellAbility.getAbility(), sourceCard);
|
||||
this.setManaCost(manaCost);
|
||||
this.sourceCardName = sourceCard.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,7 +51,7 @@ public abstract class Ability extends SpellAbility {
|
||||
*/
|
||||
public Ability(final Card sourceCard, final String manaCost, final String stackDescription) {
|
||||
this(sourceCard, manaCost);
|
||||
setStackDescription(stackDescription);
|
||||
this.setStackDescription(stackDescription);
|
||||
Log.debug("an ability is being played from" + sourceCard.getName());
|
||||
}
|
||||
|
||||
@@ -66,12 +66,13 @@ public abstract class Ability extends SpellAbility {
|
||||
pithing.addAll(AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield));
|
||||
pithing = pithing.getName("Pithing Needle");
|
||||
pithing = pithing.filter(new CardListFilter() {
|
||||
@Override
|
||||
public boolean addCard(final Card c) {
|
||||
return c.getSVar("PithingTarget").equals(sourceCardName);
|
||||
return c.getSVar("PithingTarget").equals(Ability.this.sourceCardName);
|
||||
}
|
||||
});
|
||||
|
||||
return AllZoneUtil.isCardInPlay(getSourceCard()) && !getSourceCard().isFaceDown()
|
||||
&& !getSourceCard().getName().equals("Spreading Seas") && pithing.size() == 0;
|
||||
return AllZoneUtil.isCardInPlay(this.getSourceCard()) && !this.getSourceCard().isFaceDown()
|
||||
&& !this.getSourceCard().getName().equals("Spreading Seas") && (pithing.size() == 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,11 +52,11 @@ public abstract class Ability_Activated extends SpellAbility implements java.io.
|
||||
* a {@link forge.card.spellability.Target} object.
|
||||
*/
|
||||
public Ability_Activated(final Card sourceCard, final Cost abCost, final Target tgt) {
|
||||
super(SpellAbility.Ability, sourceCard);
|
||||
setManaCost(abCost.getTotalMana());
|
||||
setPayCosts(abCost);
|
||||
if (tgt != null && tgt.doesTarget()) {
|
||||
setTarget(tgt);
|
||||
super(SpellAbility.getAbility(), sourceCard);
|
||||
this.setManaCost(abCost.getTotalMana());
|
||||
this.setPayCosts(abCost);
|
||||
if ((tgt != null) && tgt.doesTarget()) {
|
||||
this.setTarget(tgt);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,26 +67,27 @@ public abstract class Ability_Activated extends SpellAbility implements java.io.
|
||||
return false;
|
||||
}
|
||||
|
||||
final Card c = getSourceCard();
|
||||
if (c.isFaceDown() && isIntrinsic()) { // Intrinsic abilities can't be
|
||||
final Card c = this.getSourceCard();
|
||||
if (c.isFaceDown() && this.isIntrinsic()) { // Intrinsic abilities can't
|
||||
// be
|
||||
// activated by face down cards
|
||||
return false;
|
||||
}
|
||||
|
||||
Player activator = getActivatingPlayer();
|
||||
final Player activator = this.getActivatingPlayer();
|
||||
|
||||
// CantBeActivated static abilities
|
||||
CardList allp = AllZoneUtil.getCardsIn(Zone.Battlefield);
|
||||
for (Card ca : allp) {
|
||||
ArrayList<StaticAbility> staticAbilities = ca.getStaticAbilities();
|
||||
for (StaticAbility stAb : staticAbilities) {
|
||||
final CardList allp = AllZoneUtil.getCardsIn(Zone.Battlefield);
|
||||
for (final Card ca : allp) {
|
||||
final ArrayList<StaticAbility> staticAbilities = ca.getStaticAbilities();
|
||||
for (final StaticAbility stAb : staticAbilities) {
|
||||
if (stAb.applyAbility("CantBeActivated", c, activator)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (c.hasKeyword("CARDNAME's activated abilities can't be activated.") || isSuppressed()) {
|
||||
if (c.hasKeyword("CARDNAME's activated abilities can't be activated.") || this.isSuppressed()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -94,19 +95,20 @@ public abstract class Ability_Activated extends SpellAbility implements java.io.
|
||||
pithing.addAll(AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield));
|
||||
pithing = pithing.getName("Pithing Needle");
|
||||
pithing = pithing.filter(new CardListFilter() {
|
||||
@Override
|
||||
public boolean addCard(final Card crd) {
|
||||
return crd.getSVar("PithingTarget").equals(c.getName());
|
||||
}
|
||||
});
|
||||
|
||||
if (pithing.size() != 0 && !(this instanceof Ability_Mana)) {
|
||||
if ((pithing.size() != 0) && !(this instanceof Ability_Mana)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(getRestrictions().canPlay(c, this))) {
|
||||
if (!(this.getRestrictions().canPlay(c, this))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return Cost_Payment.canPayAdditionalCosts(payCosts, this);
|
||||
return Cost_Payment.canPayAdditionalCosts(this.getPayCosts(), this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,8 +100,8 @@ public abstract class Ability_Mana extends Ability_Activated implements java.io.
|
||||
public Ability_Mana(final Card sourceCard, final Cost cost, final String produced, final int num) {
|
||||
super(sourceCard, cost, null);
|
||||
|
||||
origProduced = produced;
|
||||
amount = num;
|
||||
this.origProduced = produced;
|
||||
this.amount = num;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@@ -113,7 +113,7 @@ public abstract class Ability_Mana extends Ability_Activated implements java.io.
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void resolve() {
|
||||
produceMana();
|
||||
this.produceMana();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -122,25 +122,25 @@ public abstract class Ability_Mana extends Ability_Activated implements java.io.
|
||||
* </p>
|
||||
*/
|
||||
public final void produceMana() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (amount == 0) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
if (this.amount == 0) {
|
||||
sb.append("0");
|
||||
} else {
|
||||
try {
|
||||
// if baseMana is an integer(colorless), just multiply amount
|
||||
// and baseMana
|
||||
int base = Integer.parseInt(origProduced);
|
||||
sb.append(base * amount);
|
||||
} catch (NumberFormatException e) {
|
||||
for (int i = 0; i < amount; i++) {
|
||||
final int base = Integer.parseInt(this.origProduced);
|
||||
sb.append(base * this.amount);
|
||||
} catch (final NumberFormatException e) {
|
||||
for (int i = 0; i < this.amount; i++) {
|
||||
if (i != 0) {
|
||||
sb.append(" ");
|
||||
}
|
||||
sb.append(origProduced);
|
||||
sb.append(this.origProduced);
|
||||
}
|
||||
}
|
||||
}
|
||||
produceMana(sb.toString(), this.getSourceCard().getController());
|
||||
this.produceMana(sb.toString(), this.getSourceCard().getController());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -155,7 +155,7 @@ public abstract class Ability_Mana extends Ability_Activated implements java.io.
|
||||
*/
|
||||
public final void produceMana(final String produced, final Player player) {
|
||||
final Card source = this.getSourceCard();
|
||||
ManaPool manaPool = player.getManaPool();
|
||||
final ManaPool manaPool = player.getManaPool();
|
||||
// change this, once ManaPool moves to the Player
|
||||
// this.getActivatingPlayer().ManaPool.addManaToFloating(origProduced,
|
||||
// getSourceCard());
|
||||
@@ -175,7 +175,7 @@ public abstract class Ability_Mana extends Ability_Activated implements java.io.
|
||||
}
|
||||
|
||||
// Run triggers
|
||||
HashMap<String, Object> runParams = new HashMap<String, Object>();
|
||||
final HashMap<String, Object> runParams = new HashMap<String, Object>();
|
||||
|
||||
runParams.put("Card", source);
|
||||
runParams.put("Player", player);
|
||||
@@ -193,7 +193,7 @@ public abstract class Ability_Mana extends Ability_Activated implements java.io.
|
||||
* @return a {@link java.lang.String} object.
|
||||
*/
|
||||
public final String mana() {
|
||||
return origProduced;
|
||||
return this.origProduced;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -205,7 +205,7 @@ public abstract class Ability_Mana extends Ability_Activated implements java.io.
|
||||
* a {@link java.lang.String} object.
|
||||
*/
|
||||
public final void setMana(final String s) {
|
||||
origProduced = s;
|
||||
this.origProduced = s;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -217,7 +217,7 @@ public abstract class Ability_Mana extends Ability_Activated implements java.io.
|
||||
* a boolean.
|
||||
*/
|
||||
public final void setReflectedMana(final boolean bReflect) {
|
||||
reflected = bReflect;
|
||||
this.reflected = bReflect;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -239,7 +239,7 @@ public abstract class Ability_Mana extends Ability_Activated implements java.io.
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final boolean isSacrifice() {
|
||||
return payCosts.getSacCost();
|
||||
return this.getPayCosts().getSacCost();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -250,7 +250,7 @@ public abstract class Ability_Mana extends Ability_Activated implements java.io.
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final boolean isReflectedMana() {
|
||||
return reflected;
|
||||
return this.reflected;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -263,7 +263,7 @@ public abstract class Ability_Mana extends Ability_Activated implements java.io.
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final boolean canProduce(final String s) {
|
||||
return origProduced.contains(s);
|
||||
return this.origProduced.contains(s);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -274,11 +274,11 @@ public abstract class Ability_Mana extends Ability_Activated implements java.io.
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final boolean isBasic() {
|
||||
if (origProduced.length() != 1) {
|
||||
if (this.origProduced.length() != 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (amount > 1) {
|
||||
if (this.amount > 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -293,7 +293,7 @@ public abstract class Ability_Mana extends Ability_Activated implements java.io.
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final boolean isUndoable() {
|
||||
return undoable && getPayCosts().isUndoable() && AllZoneUtil.isCardInPlay(getSourceCard());
|
||||
return this.undoable && this.getPayCosts().isUndoable() && AllZoneUtil.isCardInPlay(this.getSourceCard());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -305,7 +305,7 @@ public abstract class Ability_Mana extends Ability_Activated implements java.io.
|
||||
* a boolean.
|
||||
*/
|
||||
public final void setUndoable(final boolean bUndo) {
|
||||
undoable = bUndo;
|
||||
this.undoable = bUndo;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -317,7 +317,7 @@ public abstract class Ability_Mana extends Ability_Activated implements java.io.
|
||||
* a boolean.
|
||||
*/
|
||||
public final void setCanceled(final boolean bCancel) {
|
||||
canceled = bCancel;
|
||||
this.canceled = bCancel;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -328,7 +328,7 @@ public abstract class Ability_Mana extends Ability_Activated implements java.io.
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final boolean getCanceled() {
|
||||
return canceled;
|
||||
return this.canceled;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -337,8 +337,8 @@ public abstract class Ability_Mana extends Ability_Activated implements java.io.
|
||||
* </p>
|
||||
*/
|
||||
public final void undo() {
|
||||
if (isUndoable()) {
|
||||
getPayCosts().refundPaidCost(getSourceCard());
|
||||
if (this.isUndoable()) {
|
||||
this.getPayCosts().refundPaidCost(this.getSourceCard());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -346,13 +346,13 @@ public abstract class Ability_Mana extends Ability_Activated implements java.io.
|
||||
@Override
|
||||
public final boolean equals(final Object o) {
|
||||
// Mana abilities with same Descriptions are "equal"
|
||||
if (o == null || !(o instanceof Ability_Mana)) {
|
||||
if ((o == null) || !(o instanceof Ability_Mana)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Ability_Mana abm = (Ability_Mana) o;
|
||||
final Ability_Mana abm = (Ability_Mana) o;
|
||||
|
||||
if (abm.getType() != getType()) {
|
||||
if (abm.getType() != this.getType()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ public abstract class Ability_Sub extends SpellAbility implements java.io.Serial
|
||||
* a {@link forge.card.spellability.Target} object.
|
||||
*/
|
||||
public Ability_Sub(final Card sourceCard, final Target tgt) {
|
||||
super(SpellAbility.Ability, sourceCard);
|
||||
super(SpellAbility.getAbility(), sourceCard);
|
||||
this.setTarget(tgt);
|
||||
}
|
||||
|
||||
|
||||
@@ -34,20 +34,21 @@ public class Ability_Triggered extends Ability implements Command {
|
||||
* @return the trigger
|
||||
*/
|
||||
public final ZCTrigger getTrigger() {
|
||||
return trigger;
|
||||
return this.trigger;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the trigger.
|
||||
*
|
||||
* @param trigger the new trigger
|
||||
* @param trigger
|
||||
* the new trigger
|
||||
*/
|
||||
public final void setTrigger(final ZCTrigger trigger) {
|
||||
this.trigger = trigger;
|
||||
}
|
||||
|
||||
/** The todo. */
|
||||
private Command todo;
|
||||
private final Command todo;
|
||||
|
||||
/**
|
||||
* <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) {
|
||||
super(sourceCard, "0");
|
||||
setTrigger(true);
|
||||
todo = sourceCommand;
|
||||
trigger = situation;
|
||||
if (todo instanceof Ability_Triggered) {
|
||||
setStackDescription(((SpellAbility) todo).getStackDescription());
|
||||
restrictions = ((Ability_Triggered) todo).restrictions;
|
||||
this.setTrigger(true);
|
||||
this.todo = sourceCommand;
|
||||
this.trigger = situation;
|
||||
if (this.todo instanceof Ability_Triggered) {
|
||||
this.setStackDescription(((SpellAbility) this.todo).getStackDescription());
|
||||
this.restrictions = ((Ability_Triggered) this.todo).restrictions;
|
||||
} else {
|
||||
setStackDescription("Triggered ability: " + sourceCard + " " + situation);
|
||||
restrictions = new String[] {"named " + sourceCard.getName()};
|
||||
this.setStackDescription("Triggered ability: " + sourceCard + " " + situation);
|
||||
this.restrictions = new String[] { "named " + sourceCard.getName() };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,7 +91,7 @@ public class Ability_Triggered extends Ability implements Command {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final void resolve() {
|
||||
todo.execute();
|
||||
this.todo.execute();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -98,8 +99,9 @@ public class Ability_Triggered extends Ability implements Command {
|
||||
* execute.
|
||||
* </p>
|
||||
*/
|
||||
@Override
|
||||
public final void execute() {
|
||||
resolve();
|
||||
this.resolve();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -112,7 +114,7 @@ public class Ability_Triggered extends Ability implements Command {
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final boolean triggerFor(final Card c) {
|
||||
return !(new CardList(c)).getValidCards(restrictions, c.getController(), c).isEmpty();
|
||||
return !(new CardList(c)).getValidCards(this.restrictions, c.getController(), c).isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -127,19 +129,20 @@ public class Ability_Triggered extends Ability implements Command {
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final boolean triggerOnZoneChange(final String sourceZone, final String destinationZone) {
|
||||
return trigger.triggerOn(sourceZone, destinationZone);
|
||||
return this.trigger.triggerOn(sourceZone, destinationZone);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final boolean equals(final Object o) // TODO triggers affecting other cards
|
||||
{
|
||||
public final boolean equals(final Object o) {
|
||||
// TODO triggers affecting other
|
||||
// cards
|
||||
if (!(o instanceof Ability_Triggered)) {
|
||||
return false;
|
||||
}
|
||||
Ability_Triggered tmp = (Ability_Triggered) o;
|
||||
return tmp.getSourceCard().equals(getSourceCard()) && tmp.trigger.equals(trigger) && tmp.todo.equals(todo)
|
||||
&& Arrays.equals(tmp.restrictions, restrictions);
|
||||
final Ability_Triggered tmp = (Ability_Triggered) o;
|
||||
return tmp.getSourceCard().equals(this.getSourceCard()) && tmp.trigger.equals(this.trigger)
|
||||
&& tmp.todo.equals(this.todo) && Arrays.equals(tmp.restrictions, this.restrictions);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -150,6 +153,7 @@ public class Ability_Triggered extends Ability implements Command {
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final boolean isBasic() {
|
||||
return restrictions.length == 1 && restrictions[0].equals("named " + getSourceCard().getName());
|
||||
return (this.restrictions.length == 1)
|
||||
&& this.restrictions[0].equals("named " + this.getSourceCard().getName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,11 +37,11 @@ public abstract class Spell extends SpellAbility implements java.io.Serializable
|
||||
* a {@link forge.Card} object.
|
||||
*/
|
||||
public Spell(final Card sourceCard) {
|
||||
super(SpellAbility.Spell, sourceCard);
|
||||
super(SpellAbility.getSpell(), sourceCard);
|
||||
|
||||
setManaCost(sourceCard.getManaCost());
|
||||
setStackDescription(sourceCard.getSpellText());
|
||||
getRestrictions().setZone(Constant.Zone.Hand);
|
||||
this.setManaCost(sourceCard.getManaCost());
|
||||
this.setStackDescription(sourceCard.getSpellText());
|
||||
this.getRestrictions().setZone(Constant.Zone.Hand);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -57,14 +57,14 @@ public abstract class Spell extends SpellAbility implements java.io.Serializable
|
||||
* a {@link forge.card.spellability.Target} object.
|
||||
*/
|
||||
public Spell(final Card sourceCard, final Cost abCost, final Target abTgt) {
|
||||
super(SpellAbility.Spell, sourceCard);
|
||||
super(SpellAbility.getSpell(), sourceCard);
|
||||
|
||||
setManaCost(sourceCard.getManaCost());
|
||||
this.setManaCost(sourceCard.getManaCost());
|
||||
|
||||
setPayCosts(abCost);
|
||||
setTarget(abTgt);
|
||||
setStackDescription(sourceCard.getSpellText());
|
||||
getRestrictions().setZone(Constant.Zone.Hand);
|
||||
this.setPayCosts(abCost);
|
||||
this.setTarget(abTgt);
|
||||
this.setStackDescription(sourceCard.getSpellText());
|
||||
this.getRestrictions().setZone(Constant.Zone.Hand);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@@ -74,16 +74,16 @@ public abstract class Spell extends SpellAbility implements java.io.Serializable
|
||||
return false;
|
||||
}
|
||||
|
||||
Card card = getSourceCard();
|
||||
final Card card = this.getSourceCard();
|
||||
|
||||
Player activator = getActivatingPlayer();
|
||||
final Player activator = this.getActivatingPlayer();
|
||||
|
||||
// CantBeCast static abilities
|
||||
CardList allp = AllZoneUtil.getCardsIn(Zone.Battlefield);
|
||||
final CardList allp = AllZoneUtil.getCardsIn(Zone.Battlefield);
|
||||
allp.add(card);
|
||||
for (Card ca : allp) {
|
||||
ArrayList<StaticAbility> staticAbilities = ca.getStaticAbilities();
|
||||
for (StaticAbility stAb : staticAbilities) {
|
||||
for (final Card ca : allp) {
|
||||
final ArrayList<StaticAbility> staticAbilities = ca.getStaticAbilities();
|
||||
for (final StaticAbility stAb : staticAbilities) {
|
||||
if (stAb.applyAbility("CantBeCast", card, activator)) {
|
||||
return false;
|
||||
}
|
||||
@@ -94,8 +94,8 @@ public abstract class Spell extends SpellAbility implements java.io.Serializable
|
||||
return false;
|
||||
}
|
||||
|
||||
if (payCosts != null) {
|
||||
if (!Cost_Payment.canPayAdditionalCosts(payCosts, this)) {
|
||||
if (this.getPayCosts() != null) {
|
||||
if (!Cost_Payment.canPayAdditionalCosts(this.getPayCosts(), this)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -110,9 +110,9 @@ public abstract class Spell extends SpellAbility implements java.io.Serializable
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public boolean canPlayAI() {
|
||||
Card card = getSourceCard();
|
||||
final Card card = this.getSourceCard();
|
||||
if (card.getSVar("NeedsToPlay").length() > 0) {
|
||||
String needsToPlay = card.getSVar("NeedsToPlay");
|
||||
final String needsToPlay = card.getSVar("NeedsToPlay");
|
||||
CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield);
|
||||
|
||||
list = list.getValidCards(needsToPlay.split(","), card.getController(), card);
|
||||
@@ -135,7 +135,7 @@ public abstract class Spell extends SpellAbility implements java.io.Serializable
|
||||
public final Object clone() {
|
||||
try {
|
||||
return super.clone();
|
||||
} catch (Exception ex) {
|
||||
} catch (final Exception ex) {
|
||||
ErrorViewer.showError(ex);
|
||||
throw new RuntimeException("Spell : clone() error, " + ex);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -13,7 +13,7 @@ import forge.ComputerUtil;
|
||||
* @version $Id$
|
||||
*/
|
||||
public class SpellAbilityList {
|
||||
private ArrayList<SpellAbility> list = new ArrayList<SpellAbility>();
|
||||
private final ArrayList<SpellAbility> list = new ArrayList<SpellAbility>();
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -32,7 +32,7 @@ public class SpellAbilityList {
|
||||
* a {@link forge.card.spellability.SpellAbility} object.
|
||||
*/
|
||||
public SpellAbilityList(final SpellAbility s) {
|
||||
add(s);
|
||||
this.add(s);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -45,8 +45,8 @@ public class SpellAbilityList {
|
||||
* objects.
|
||||
*/
|
||||
public SpellAbilityList(final SpellAbility[] s) {
|
||||
for (int i = 0; i < s.length; i++) {
|
||||
add(s[i]);
|
||||
for (final SpellAbility element : s) {
|
||||
this.add(element);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ public class SpellAbilityList {
|
||||
* a int.
|
||||
*/
|
||||
public final void remove(final int n) {
|
||||
list.remove(n);
|
||||
this.list.remove(n);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -71,7 +71,7 @@ public class SpellAbilityList {
|
||||
* a {@link forge.card.spellability.SpellAbility} object.
|
||||
*/
|
||||
public final void add(final SpellAbility s) {
|
||||
list.add(s);
|
||||
this.list.add(s);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -82,7 +82,7 @@ public class SpellAbilityList {
|
||||
* @return a int.
|
||||
*/
|
||||
public final int size() {
|
||||
return list.size();
|
||||
return this.list.size();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -95,7 +95,7 @@ public class SpellAbilityList {
|
||||
* @return a {@link forge.card.spellability.SpellAbility} object.
|
||||
*/
|
||||
public final SpellAbility get(final int n) {
|
||||
return list.get(n);
|
||||
return this.list.get(n);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -108,7 +108,7 @@ public class SpellAbilityList {
|
||||
*/
|
||||
public final void addAll(final SpellAbilityList s) {
|
||||
for (int i = 0; i < s.size(); i++) {
|
||||
add(s.get(i));
|
||||
this.add(s.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,24 +119,24 @@ public class SpellAbilityList {
|
||||
* </p>
|
||||
*/
|
||||
public final void execute() {
|
||||
for (int i = 0; i < size(); i++) {
|
||||
if (!ComputerUtil.canPayCost(get(i))) {
|
||||
for (int i = 0; i < this.size(); i++) {
|
||||
if (!ComputerUtil.canPayCost(this.get(i))) {
|
||||
throw new RuntimeException("SpellAbilityList : execute() error, cannot pay for the spell "
|
||||
+ get(i).getSourceCard() + " - " + get(i).getStackDescription());
|
||||
+ this.get(i).getSourceCard() + " - " + this.get(i).getStackDescription());
|
||||
}
|
||||
|
||||
ComputerUtil.playNoStack(get(i));
|
||||
ComputerUtil.playNoStack(this.get(i));
|
||||
}
|
||||
} // execute()
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < size(); i++) {
|
||||
sb.append(get(i).getSourceCard().toString());
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < this.size(); i++) {
|
||||
sb.append(this.get(i).getSourceCard().toString());
|
||||
sb.append(" - ");
|
||||
sb.append(get(i).getStackDescription());
|
||||
sb.append(this.get(i).getStackDescription());
|
||||
sb.append("\r\n");
|
||||
}
|
||||
return sb.toString();
|
||||
@@ -148,6 +148,6 @@ public class SpellAbilityList {
|
||||
if (o == null) {
|
||||
return false;
|
||||
}
|
||||
return toString().equals(o.toString());
|
||||
return this.toString().equals(o.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,32 +47,32 @@ public class SpellAbility_Condition extends SpellAbility_Variables {
|
||||
*/
|
||||
public final void setConditions(final HashMap<String, String> params) {
|
||||
if (params.containsKey("Condition")) {
|
||||
String value = params.get("Condition");
|
||||
final String value = params.get("Condition");
|
||||
if (value.equals("Threshold")) {
|
||||
setThreshold(true);
|
||||
this.setThreshold(true);
|
||||
}
|
||||
if (value.equals("Metalcraft")) {
|
||||
setMetalcraft(true);
|
||||
this.setMetalcraft(true);
|
||||
}
|
||||
if (value.equals("Hellbent")) {
|
||||
setHellbent(true);
|
||||
this.setHellbent(true);
|
||||
}
|
||||
}
|
||||
|
||||
if (params.containsKey("ConditionZone")) {
|
||||
setZone(Zone.smartValueOf(params.get("ContitionZone")));
|
||||
this.setZone(Zone.smartValueOf(params.get("ContitionZone")));
|
||||
}
|
||||
|
||||
if (params.containsKey("ConditionSorcerySpeed")) {
|
||||
setSorcerySpeed(true);
|
||||
this.setSorcerySpeed(true);
|
||||
}
|
||||
|
||||
if (params.containsKey("ConditionPlayerTurn")) {
|
||||
setPlayerTurn(true);
|
||||
this.setPlayerTurn(true);
|
||||
}
|
||||
|
||||
if (params.containsKey("ConditionOpponentTurn")) {
|
||||
setOpponentTurn(true);
|
||||
this.setOpponentTurn(true);
|
||||
}
|
||||
|
||||
if (params.containsKey("ConditionPhases")) {
|
||||
@@ -84,59 +84,59 @@ public class SpellAbility_Condition extends SpellAbility_Variables {
|
||||
// Draw-> (After Upkeep)
|
||||
// Upkeep->Combat_Begin (Before Declare Attackers)
|
||||
|
||||
String[] split = phases.split("->", 2);
|
||||
final String[] split = phases.split("->", 2);
|
||||
phases = AllZone.getPhase().buildActivateString(split[0], split[1]);
|
||||
}
|
||||
|
||||
setPhases(phases);
|
||||
this.setPhases(phases);
|
||||
}
|
||||
|
||||
if (params.containsKey("ConditionAllM12Empires")) {
|
||||
setAllM12Empires(true);
|
||||
this.setAllM12Empires(true);
|
||||
}
|
||||
if (params.containsKey("ConditionNotAllM12Empires")) {
|
||||
setNotAllM12Empires(true);
|
||||
this.setNotAllM12Empires(true);
|
||||
}
|
||||
|
||||
if (params.containsKey("ConditionCardsInHand")) {
|
||||
setActivateCardsInHand(Integer.parseInt(params.get("ConditionCardsInHand")));
|
||||
this.setActivateCardsInHand(Integer.parseInt(params.get("ConditionCardsInHand")));
|
||||
}
|
||||
|
||||
// Condition version of IsPresent stuff
|
||||
if (params.containsKey("ConditionPresent")) {
|
||||
setIsPresent(params.get("ConditionPresent"));
|
||||
this.setIsPresent(params.get("ConditionPresent"));
|
||||
if (params.containsKey("ConditionCompare")) {
|
||||
setPresentCompare(params.get("ConditionCompare"));
|
||||
this.setPresentCompare(params.get("ConditionCompare"));
|
||||
}
|
||||
}
|
||||
|
||||
if (params.containsKey("ConditionDefined")) {
|
||||
setPresentDefined(params.get("ConditionDefined"));
|
||||
this.setPresentDefined(params.get("ConditionDefined"));
|
||||
}
|
||||
|
||||
if (params.containsKey("ConditionNotPresent")) {
|
||||
setIsPresent(params.get("ConditionNotPresent"));
|
||||
setPresentCompare("EQ0");
|
||||
this.setIsPresent(params.get("ConditionNotPresent"));
|
||||
this.setPresentCompare("EQ0");
|
||||
}
|
||||
|
||||
// basically PresentCompare for life totals:
|
||||
if (params.containsKey("ConditionLifeTotal")) {
|
||||
setLifeTotal(params.get("ConditionLifeTotal"));
|
||||
this.setLifeTotal(params.get("ConditionLifeTotal"));
|
||||
if (params.containsKey("ConditionLifeAmount")) {
|
||||
setLifeAmount(params.get("ConditionLifeAmount"));
|
||||
this.setLifeAmount(params.get("ConditionLifeAmount"));
|
||||
}
|
||||
}
|
||||
|
||||
if (params.containsKey("ConditionManaSpent")) {
|
||||
setManaSpent(params.get("ConditionManaSpent"));
|
||||
this.setManaSpent(params.get("ConditionManaSpent"));
|
||||
}
|
||||
|
||||
if (params.containsKey("ConditionCheckSVar")) {
|
||||
setSvarToCheck(params.get("ConditionCheckSVar"));
|
||||
this.setSvarToCheck(params.get("ConditionCheckSVar"));
|
||||
}
|
||||
if (params.containsKey("ConditionSVarCompare")) {
|
||||
setSvarOperator(params.get("ConditionSVarCompare").substring(0, 2));
|
||||
setSvarOperand(params.get("ConditionSVarCompare").substring(2));
|
||||
this.setSvarOperator(params.get("ConditionSVarCompare").substring(0, 2));
|
||||
this.setSvarOperand(params.get("ConditionSVarCompare").substring(2));
|
||||
}
|
||||
|
||||
} // setConditions
|
||||
@@ -159,42 +159,42 @@ public class SpellAbility_Condition extends SpellAbility_Variables {
|
||||
+ " Did not have activator set in SpellAbility_Condition.checkConditions()");
|
||||
}
|
||||
|
||||
if (isHellbent()) {
|
||||
if (this.isHellbent()) {
|
||||
if (!activator.hasHellbent()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (isThreshold()) {
|
||||
if (this.isThreshold()) {
|
||||
if (!activator.hasThreshold()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (isMetalcraft()) {
|
||||
if (this.isMetalcraft()) {
|
||||
if (!activator.hasMetalcraft()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (isSorcerySpeed() && !Phase.canCastSorcery(activator)) {
|
||||
if (this.isSorcerySpeed() && !Phase.canCastSorcery(activator)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isPlayerTurn() && !AllZone.getPhase().isPlayerTurn(activator)) {
|
||||
if (this.isPlayerTurn() && !AllZone.getPhase().isPlayerTurn(activator)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isOpponentTurn() && AllZone.getPhase().isPlayerTurn(activator)) {
|
||||
if (this.isOpponentTurn() && AllZone.getPhase().isPlayerTurn(activator)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (getActivationLimit() != -1 && getNumberTurnActivations() >= getActivationLimit()) {
|
||||
if ((this.getActivationLimit() != -1) && (this.getNumberTurnActivations() >= this.getActivationLimit())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (getPhases().size() > 0) {
|
||||
if (this.getPhases().size() > 0) {
|
||||
boolean isPhase = false;
|
||||
String currPhase = AllZone.getPhase().getPhase();
|
||||
for (String s : getPhases()) {
|
||||
final String currPhase = AllZone.getPhase().getPhase();
|
||||
for (final String s : this.getPhases()) {
|
||||
if (s.equals(currPhase)) {
|
||||
isPhase = true;
|
||||
break;
|
||||
@@ -206,8 +206,8 @@ public class SpellAbility_Condition extends SpellAbility_Variables {
|
||||
}
|
||||
}
|
||||
|
||||
if (isAllM12Empires()) {
|
||||
Player p = sa.getSourceCard().getController();
|
||||
if (this.isAllM12Empires()) {
|
||||
final Player p = sa.getSourceCard().getController();
|
||||
boolean has = AllZoneUtil.isCardInPlay("Crown of Empires", p);
|
||||
has &= AllZoneUtil.isCardInPlay("Scepter of Empires", p);
|
||||
has &= AllZoneUtil.isCardInPlay("Throne of Empires", p);
|
||||
@@ -215,8 +215,8 @@ public class SpellAbility_Condition extends SpellAbility_Variables {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (isNotAllM12Empires()) {
|
||||
Player p = sa.getSourceCard().getController();
|
||||
if (this.isNotAllM12Empires()) {
|
||||
final Player p = sa.getSourceCard().getController();
|
||||
boolean has = AllZoneUtil.isCardInPlay("Crown of Empires", p);
|
||||
has &= AllZoneUtil.isCardInPlay("Scepter of Empires", p);
|
||||
has &= AllZoneUtil.isCardInPlay("Throne of Empires", p);
|
||||
@@ -225,72 +225,73 @@ public class SpellAbility_Condition extends SpellAbility_Variables {
|
||||
}
|
||||
}
|
||||
|
||||
if (getCardsInHand() != -1) {
|
||||
if (this.getCardsInHand() != -1) {
|
||||
// Can handle Library of Alexandria, or Hellbent
|
||||
if (activator.getCardsIn(Zone.Hand).size() != getCardsInHand()) {
|
||||
if (activator.getCardsIn(Zone.Hand).size() != this.getCardsInHand()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (getIsPresent() != null) {
|
||||
if (this.getIsPresent() != null) {
|
||||
CardList list = new CardList();
|
||||
if (getPresentDefined() != null) {
|
||||
list.addAll(AbilityFactory.getDefinedCards(sa.getSourceCard(), getPresentDefined(), sa).toArray());
|
||||
if (this.getPresentDefined() != null) {
|
||||
list.addAll(AbilityFactory.getDefinedCards(sa.getSourceCard(), this.getPresentDefined(), sa).toArray());
|
||||
} else {
|
||||
list = AllZoneUtil.getCardsIn(Zone.Battlefield);
|
||||
}
|
||||
|
||||
list = list.getValidCards(getIsPresent().split(","), sa.getActivatingPlayer(), sa.getSourceCard());
|
||||
list = list.getValidCards(this.getIsPresent().split(","), sa.getActivatingPlayer(), sa.getSourceCard());
|
||||
|
||||
int right;
|
||||
String rightString = getPresentCompare().substring(2);
|
||||
final String rightString = this.getPresentCompare().substring(2);
|
||||
try { // If this is an Integer, just parse it
|
||||
right = Integer.parseInt(rightString);
|
||||
} catch (NumberFormatException e) { // Otherwise, grab it from the
|
||||
} catch (final NumberFormatException e) { // Otherwise, grab it from
|
||||
// the
|
||||
// SVar
|
||||
right = CardFactoryUtil.xCount(sa.getSourceCard(), sa.getSourceCard().getSVar(rightString));
|
||||
}
|
||||
|
||||
int left = list.size();
|
||||
final int left = list.size();
|
||||
|
||||
if (!AllZoneUtil.compare(left, getPresentCompare(), right)) {
|
||||
if (!AllZoneUtil.compare(left, this.getPresentCompare(), right)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (getLifeTotal() != null) {
|
||||
if (this.getLifeTotal() != null) {
|
||||
int life = 1;
|
||||
if (getLifeTotal().equals("You")) {
|
||||
if (this.getLifeTotal().equals("You")) {
|
||||
life = activator.getLife();
|
||||
}
|
||||
if (getLifeTotal().equals("Opponent")) {
|
||||
if (this.getLifeTotal().equals("Opponent")) {
|
||||
life = activator.getOpponent().getLife();
|
||||
}
|
||||
|
||||
int right = 1;
|
||||
String rightString = getLifeAmount().substring(2);
|
||||
final String rightString = this.getLifeAmount().substring(2);
|
||||
if (rightString.equals("X")) {
|
||||
right = CardFactoryUtil.xCount(sa.getSourceCard(), sa.getSourceCard().getSVar("X"));
|
||||
} else {
|
||||
right = Integer.parseInt(getLifeAmount().substring(2));
|
||||
right = Integer.parseInt(this.getLifeAmount().substring(2));
|
||||
}
|
||||
|
||||
if (!AllZoneUtil.compare(life, getLifeAmount(), right)) {
|
||||
if (!AllZoneUtil.compare(life, this.getLifeAmount(), right)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (null != getManaSpent()) {
|
||||
if (!sa.getSourceCard().getColorsPaid().contains(getManaSpent())) {
|
||||
if (null != this.getManaSpent()) {
|
||||
if (!sa.getSourceCard().getColorsPaid().contains(this.getManaSpent())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (getsVarToCheck() != null) {
|
||||
int svarValue = AbilityFactory.calculateAmount(sa.getSourceCard(), getsVarToCheck(), sa);
|
||||
int operandValue = AbilityFactory.calculateAmount(sa.getSourceCard(), getsVarOperand(), sa);
|
||||
if (this.getsVarToCheck() != null) {
|
||||
final int svarValue = AbilityFactory.calculateAmount(sa.getSourceCard(), this.getsVarToCheck(), sa);
|
||||
final int operandValue = AbilityFactory.calculateAmount(sa.getSourceCard(), this.getsVarOperand(), sa);
|
||||
|
||||
if (!AllZoneUtil.compare(svarValue, getsVarOperator(), operandValue)) {
|
||||
if (!AllZoneUtil.compare(svarValue, this.getsVarOperator(), operandValue)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ public class SpellAbility_Requirements {
|
||||
* a boolean.
|
||||
*/
|
||||
public final void setSkipStack(final boolean bSkip) {
|
||||
skipStack = bSkip;
|
||||
this.skipStack = bSkip;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -44,7 +44,7 @@ public class SpellAbility_Requirements {
|
||||
* a boolean.
|
||||
*/
|
||||
public final void setFree(final boolean bFree) {
|
||||
isFree = bFree;
|
||||
this.isFree = bFree;
|
||||
}
|
||||
|
||||
private PlayerZone fromZone = null;
|
||||
@@ -63,9 +63,9 @@ public class SpellAbility_Requirements {
|
||||
* a {@link forge.card.cost.Cost_Payment} object.
|
||||
*/
|
||||
public SpellAbility_Requirements(final SpellAbility sa, final Target_Selection ts, final Cost_Payment cp) {
|
||||
ability = sa;
|
||||
select = ts;
|
||||
payment = cp;
|
||||
this.ability = sa;
|
||||
this.select = ts;
|
||||
this.payment = cp;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -74,7 +74,7 @@ public class SpellAbility_Requirements {
|
||||
* </p>
|
||||
*/
|
||||
public final void fillRequirements() {
|
||||
fillRequirements(false);
|
||||
this.fillRequirements(false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -86,13 +86,13 @@ public class SpellAbility_Requirements {
|
||||
* a boolean.
|
||||
*/
|
||||
public final void fillRequirements(final boolean skipTargeting) {
|
||||
if (ability instanceof Spell && !bCasting) {
|
||||
if ((this.ability instanceof Spell) && !this.bCasting) {
|
||||
// remove from hand
|
||||
bCasting = true;
|
||||
if (!ability.getSourceCard().isCopiedSpell()) {
|
||||
Card c = ability.getSourceCard();
|
||||
this.bCasting = true;
|
||||
if (!this.ability.getSourceCard().isCopiedSpell()) {
|
||||
final Card c = this.ability.getSourceCard();
|
||||
|
||||
fromZone = AllZone.getZoneOf(c);
|
||||
this.fromZone = AllZone.getZoneOf(c);
|
||||
AllZone.getGameAction().moveToStack(c);
|
||||
}
|
||||
}
|
||||
@@ -104,12 +104,12 @@ public class SpellAbility_Requirements {
|
||||
// Skip to paying if parent ability doesn't target and has no
|
||||
// subAbilities.
|
||||
// (or trigger case where its already targeted)
|
||||
if (!skipTargeting && (select.doesTarget() || ability.getSubAbility() != null)) {
|
||||
select.setRequirements(this);
|
||||
select.resetTargets();
|
||||
select.chooseTargets();
|
||||
if (!skipTargeting && (this.select.doesTarget() || (this.ability.getSubAbility() != null))) {
|
||||
this.select.setRequirements(this);
|
||||
this.select.resetTargets();
|
||||
this.select.chooseTargets();
|
||||
} else {
|
||||
needPayment();
|
||||
this.needPayment();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,19 +119,19 @@ public class SpellAbility_Requirements {
|
||||
* </p>
|
||||
*/
|
||||
public final void finishedTargeting() {
|
||||
if (select.isCanceled()) {
|
||||
if (this.select.isCanceled()) {
|
||||
// cancel ability during target choosing
|
||||
Card c = ability.getSourceCard();
|
||||
if (bCasting && !c.isCopiedSpell()) { // and not a copy
|
||||
final Card c = this.ability.getSourceCard();
|
||||
if (this.bCasting && !c.isCopiedSpell()) { // and not a copy
|
||||
// add back to where it came from
|
||||
AllZone.getGameAction().moveTo(fromZone, c);
|
||||
AllZone.getGameAction().moveTo(this.fromZone, c);
|
||||
}
|
||||
|
||||
select.resetTargets();
|
||||
this.select.resetTargets();
|
||||
AllZone.getStack().clearFrozen();
|
||||
return;
|
||||
} else {
|
||||
needPayment();
|
||||
this.needPayment();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,10 +141,10 @@ public class SpellAbility_Requirements {
|
||||
* </p>
|
||||
*/
|
||||
public final void needPayment() {
|
||||
if (!isFree) {
|
||||
startPaying();
|
||||
if (!this.isFree) {
|
||||
this.startPaying();
|
||||
} else {
|
||||
finishPaying();
|
||||
this.finishPaying();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,8 +154,8 @@ public class SpellAbility_Requirements {
|
||||
* </p>
|
||||
*/
|
||||
public final void startPaying() {
|
||||
payment.setRequirements(this);
|
||||
payment.payCost();
|
||||
this.payment.setRequirements(this);
|
||||
this.payment.payCost();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -164,28 +164,28 @@ public class SpellAbility_Requirements {
|
||||
* </p>
|
||||
*/
|
||||
public final void finishPaying() {
|
||||
if (isFree || payment.isAllPaid()) {
|
||||
if (skipStack) {
|
||||
AbilityFactory.resolve(ability, false);
|
||||
if (this.isFree || this.payment.isAllPaid()) {
|
||||
if (this.skipStack) {
|
||||
AbilityFactory.resolve(this.ability, false);
|
||||
} else {
|
||||
addAbilityToStack();
|
||||
this.addAbilityToStack();
|
||||
}
|
||||
|
||||
select.resetTargets();
|
||||
this.select.resetTargets();
|
||||
AllZone.getGameAction().checkStateEffects();
|
||||
} else if (payment.isCanceled()) {
|
||||
Card c = ability.getSourceCard();
|
||||
if (bCasting && !c.isCopiedSpell()) { // and not a copy
|
||||
} else if (this.payment.isCanceled()) {
|
||||
final Card c = this.ability.getSourceCard();
|
||||
if (this.bCasting && !c.isCopiedSpell()) { // and not a copy
|
||||
// add back to Previous Zone
|
||||
AllZone.getGameAction().moveTo(fromZone, c);
|
||||
AllZone.getGameAction().moveTo(this.fromZone, c);
|
||||
}
|
||||
|
||||
if (select != null) {
|
||||
select.resetTargets();
|
||||
if (this.select != null) {
|
||||
this.select.resetTargets();
|
||||
}
|
||||
|
||||
ability.resetOnceResolved();
|
||||
payment.cancelPayment();
|
||||
this.ability.resetOnceResolved();
|
||||
this.payment.cancelPayment();
|
||||
AllZone.getStack().clearFrozen();
|
||||
}
|
||||
}
|
||||
@@ -197,23 +197,23 @@ public class SpellAbility_Requirements {
|
||||
*/
|
||||
public final void addAbilityToStack() {
|
||||
// For older abilities that don't setStackDescription set it here
|
||||
if (ability.getStackDescription().equals("")) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(ability.getSourceCard().getName());
|
||||
if (ability.getTarget() != null) {
|
||||
ArrayList<Object> targets = ability.getTarget().getTargets();
|
||||
if (this.ability.getStackDescription().equals("")) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append(this.ability.getSourceCard().getName());
|
||||
if (this.ability.getTarget() != null) {
|
||||
final ArrayList<Object> targets = this.ability.getTarget().getTargets();
|
||||
if (targets.size() > 0) {
|
||||
sb.append(" - Targeting ");
|
||||
for (Object o : targets) {
|
||||
for (final Object o : targets) {
|
||||
sb.append(o.toString()).append(" ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ability.setStackDescription(sb.toString());
|
||||
this.ability.setStackDescription(sb.toString());
|
||||
}
|
||||
|
||||
AllZone.getHumanPlayer().getManaPool().clearPay(ability, false);
|
||||
AllZone.getStack().addAndUnfreeze(ability);
|
||||
AllZone.getHumanPlayer().getManaPool().clearPay(this.ability, false);
|
||||
AllZone.getStack().addAndUnfreeze(this.ability);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,56 +51,56 @@ public class SpellAbility_Restriction extends SpellAbility_Variables {
|
||||
*/
|
||||
public final void setRestrictions(final HashMap<String, String> params) {
|
||||
if (params.containsKey("Activation")) {
|
||||
String value = params.get("Activation");
|
||||
final String value = params.get("Activation");
|
||||
if (value.equals("Threshold")) {
|
||||
setThreshold(true);
|
||||
this.setThreshold(true);
|
||||
}
|
||||
if (value.equals("Metalcraft")) {
|
||||
setMetalcraft(true);
|
||||
this.setMetalcraft(true);
|
||||
}
|
||||
if (value.equals("Hellbent")) {
|
||||
setHellbent(true);
|
||||
this.setHellbent(true);
|
||||
}
|
||||
if (value.startsWith("Prowl")) {
|
||||
ArrayList<String> prowlTypes = new ArrayList<String>();
|
||||
final ArrayList<String> prowlTypes = new ArrayList<String>();
|
||||
prowlTypes.add("Rogue");
|
||||
if (value.split("Prowl").length > 1) {
|
||||
prowlTypes.add(value.split("Prowl")[1]);
|
||||
}
|
||||
setProwl(prowlTypes);
|
||||
this.setProwl(prowlTypes);
|
||||
}
|
||||
}
|
||||
|
||||
if (params.containsKey("ActivationZone")) {
|
||||
setZone(Zone.smartValueOf(params.get("ActivationZone")));
|
||||
this.setZone(Zone.smartValueOf(params.get("ActivationZone")));
|
||||
}
|
||||
|
||||
if (params.containsKey("Flashback")) {
|
||||
setZone(Zone.Graveyard);
|
||||
this.setZone(Zone.Graveyard);
|
||||
}
|
||||
|
||||
if (params.containsKey("SorcerySpeed")) {
|
||||
setSorcerySpeed(true);
|
||||
this.setSorcerySpeed(true);
|
||||
}
|
||||
|
||||
if (params.containsKey("PlayerTurn")) {
|
||||
setPlayerTurn(true);
|
||||
this.setPlayerTurn(true);
|
||||
}
|
||||
|
||||
if (params.containsKey("OpponentTurn")) {
|
||||
setOpponentTurn(true);
|
||||
this.setOpponentTurn(true);
|
||||
}
|
||||
|
||||
if (params.containsKey("AnyPlayer")) {
|
||||
setAnyPlayer(true);
|
||||
this.setAnyPlayer(true);
|
||||
}
|
||||
|
||||
if (params.containsKey("ActivationLimit")) {
|
||||
setActivationLimit(Integer.parseInt(params.get("ActivationLimit")));
|
||||
this.setActivationLimit(Integer.parseInt(params.get("ActivationLimit")));
|
||||
}
|
||||
|
||||
if (params.containsKey("ActivationNumberSacrifice")) {
|
||||
setActivationNumberSacrifice(Integer.parseInt(params.get("ActivationNumberSacrifice")));
|
||||
this.setActivationNumberSacrifice(Integer.parseInt(params.get("ActivationNumberSacrifice")));
|
||||
}
|
||||
|
||||
if (params.containsKey("ActivationPhases")) {
|
||||
@@ -112,50 +112,50 @@ public class SpellAbility_Restriction extends SpellAbility_Variables {
|
||||
// Draw-> (After Upkeep)
|
||||
// Upkeep->Combat_Begin (Before Declare Attackers)
|
||||
|
||||
String[] split = phases.split("->", 2);
|
||||
final String[] split = phases.split("->", 2);
|
||||
phases = AllZone.getPhase().buildActivateString(split[0], split[1]);
|
||||
}
|
||||
|
||||
setPhases(phases);
|
||||
this.setPhases(phases);
|
||||
}
|
||||
|
||||
if (params.containsKey("ActivationCardsInHand")) {
|
||||
setActivateCardsInHand(Integer.parseInt(params.get("ActivationCardsInHand")));
|
||||
this.setActivateCardsInHand(Integer.parseInt(params.get("ActivationCardsInHand")));
|
||||
}
|
||||
|
||||
if (params.containsKey("Planeswalker")) {
|
||||
setPlaneswalker(true);
|
||||
this.setPlaneswalker(true);
|
||||
}
|
||||
|
||||
if (params.containsKey("IsPresent")) {
|
||||
setIsPresent(params.get("IsPresent"));
|
||||
this.setIsPresent(params.get("IsPresent"));
|
||||
if (params.containsKey("PresentCompare")) {
|
||||
setPresentCompare(params.get("PresentCompare"));
|
||||
this.setPresentCompare(params.get("PresentCompare"));
|
||||
}
|
||||
if (params.containsKey("PresentZone")) {
|
||||
setPresentZone(Zone.smartValueOf(params.get("PresentZone")));
|
||||
this.setPresentZone(Zone.smartValueOf(params.get("PresentZone")));
|
||||
}
|
||||
}
|
||||
|
||||
if (params.containsKey("IsNotPresent")) {
|
||||
setIsPresent(params.get("IsNotPresent"));
|
||||
setPresentCompare("EQ0");
|
||||
this.setIsPresent(params.get("IsNotPresent"));
|
||||
this.setPresentCompare("EQ0");
|
||||
}
|
||||
|
||||
// basically PresentCompare for life totals:
|
||||
if (params.containsKey("ActivationLifeTotal")) {
|
||||
setLifeTotal(params.get("ActivationLifeTotal"));
|
||||
this.setLifeTotal(params.get("ActivationLifeTotal"));
|
||||
if (params.containsKey("ActivationLifeAmount")) {
|
||||
setLifeAmount(params.get("ActivationLifeAmount"));
|
||||
this.setLifeAmount(params.get("ActivationLifeAmount"));
|
||||
}
|
||||
}
|
||||
|
||||
if (params.containsKey("CheckSVar")) {
|
||||
setSvarToCheck(params.get("CheckSVar"));
|
||||
this.setSvarToCheck(params.get("CheckSVar"));
|
||||
}
|
||||
if (params.containsKey("SVarCompare")) {
|
||||
setSvarOperator(params.get("SVarCompare").substring(0, 2));
|
||||
setSvarOperand(params.get("SVarCompare").substring(2));
|
||||
this.setSvarOperator(params.get("SVarCompare").substring(0, 2));
|
||||
this.setSvarOperand(params.get("SVarCompare").substring(2));
|
||||
}
|
||||
} // end setRestrictions()
|
||||
|
||||
@@ -175,14 +175,14 @@ public class SpellAbility_Restriction extends SpellAbility_Variables {
|
||||
return false;
|
||||
}
|
||||
|
||||
PlayerZone cardZone = AllZone.getZoneOf(c);
|
||||
if (!cardZone.is(getZone())) {
|
||||
final PlayerZone cardZone = AllZone.getZoneOf(c);
|
||||
if (!cardZone.is(this.getZone())) {
|
||||
// If Card is not in the default activating zone, do some additional
|
||||
// checks
|
||||
// Not a Spell, or on Battlefield, return false
|
||||
if (!sa.isSpell() || cardZone.is(Zone.Battlefield)) {
|
||||
return false;
|
||||
} else if (!c.hasStartOfKeyword("May be played") || !getZone().equals(Zone.Hand)) {
|
||||
} else if (!c.hasStartOfKeyword("May be played") || !this.getZone().equals(Zone.Hand)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -193,30 +193,30 @@ public class SpellAbility_Restriction extends SpellAbility_Variables {
|
||||
System.out.println(c.getName() + " Did not have activator set in SpellAbility_Restriction.canPlay()");
|
||||
}
|
||||
|
||||
if (isSorcerySpeed() && !Phase.canCastSorcery(activator)) {
|
||||
if (this.isSorcerySpeed() && !Phase.canCastSorcery(activator)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isPlayerTurn() && !AllZone.getPhase().isPlayerTurn(activator)) {
|
||||
if (this.isPlayerTurn() && !AllZone.getPhase().isPlayerTurn(activator)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isOpponentTurn() && AllZone.getPhase().isPlayerTurn(activator)) {
|
||||
if (this.isOpponentTurn() && AllZone.getPhase().isPlayerTurn(activator)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isAnyPlayer() && !activator.equals(c.getController())) {
|
||||
if (!this.isAnyPlayer() && !activator.equals(c.getController())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (getActivationLimit() != -1 && getNumberTurnActivations() >= getActivationLimit()) {
|
||||
if ((this.getActivationLimit() != -1) && (this.getNumberTurnActivations() >= this.getActivationLimit())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (getPhases().size() > 0) {
|
||||
if (this.getPhases().size() > 0) {
|
||||
boolean isPhase = false;
|
||||
String currPhase = AllZone.getPhase().getPhase();
|
||||
for (String s : getPhases()) {
|
||||
final String currPhase = AllZone.getPhase().getPhase();
|
||||
for (final String s : this.getPhases()) {
|
||||
if (s.equals(currPhase)) {
|
||||
isPhase = true;
|
||||
break;
|
||||
@@ -228,31 +228,31 @@ public class SpellAbility_Restriction extends SpellAbility_Variables {
|
||||
}
|
||||
}
|
||||
|
||||
if (getCardsInHand() != -1) {
|
||||
if (activator.getCardsIn(Zone.Hand).size() != getCardsInHand()) {
|
||||
if (this.getCardsInHand() != -1) {
|
||||
if (activator.getCardsIn(Zone.Hand).size() != this.getCardsInHand()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (isHellbent()) {
|
||||
if (this.isHellbent()) {
|
||||
if (!activator.hasHellbent()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (isThreshold()) {
|
||||
if (this.isThreshold()) {
|
||||
if (!activator.hasThreshold()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (isMetalcraft()) {
|
||||
if (this.isMetalcraft()) {
|
||||
if (!activator.hasMetalcraft()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (getProwl() != null) {
|
||||
if (this.getProwl() != null) {
|
||||
// only true if the activating player has damaged the opponent with
|
||||
// one of the specified types
|
||||
boolean prowlFlag = false;
|
||||
for (String type : getProwl()) {
|
||||
for (final String type : this.getProwl()) {
|
||||
if (activator.hasProwl(type)) {
|
||||
prowlFlag = true;
|
||||
}
|
||||
@@ -261,68 +261,68 @@ public class SpellAbility_Restriction extends SpellAbility_Variables {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (getIsPresent() != null) {
|
||||
CardList list = AllZoneUtil.getCardsIn(getPresentZone());
|
||||
if (this.getIsPresent() != null) {
|
||||
CardList list = AllZoneUtil.getCardsIn(this.getPresentZone());
|
||||
|
||||
list = list.getValidCards(getIsPresent().split(","), activator, c);
|
||||
list = list.getValidCards(this.getIsPresent().split(","), activator, c);
|
||||
|
||||
int right = 1;
|
||||
String rightString = getPresentCompare().substring(2);
|
||||
final String rightString = this.getPresentCompare().substring(2);
|
||||
if (rightString.equals("X")) {
|
||||
right = CardFactoryUtil.xCount(c, c.getSVar("X"));
|
||||
} else {
|
||||
right = Integer.parseInt(getPresentCompare().substring(2));
|
||||
right = Integer.parseInt(this.getPresentCompare().substring(2));
|
||||
}
|
||||
int left = list.size();
|
||||
final int left = list.size();
|
||||
|
||||
if (!AllZoneUtil.compare(left, getPresentCompare(), right)) {
|
||||
if (!AllZoneUtil.compare(left, this.getPresentCompare(), right)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (getLifeTotal() != null) {
|
||||
if (this.getLifeTotal() != null) {
|
||||
int life = 1;
|
||||
if (getLifeTotal().equals("You")) {
|
||||
if (this.getLifeTotal().equals("You")) {
|
||||
life = activator.getLife();
|
||||
}
|
||||
if (getLifeTotal().equals("Opponent")) {
|
||||
if (this.getLifeTotal().equals("Opponent")) {
|
||||
life = activator.getOpponent().getLife();
|
||||
}
|
||||
|
||||
int right = 1;
|
||||
String rightString = getLifeAmount().substring(2);
|
||||
final String rightString = this.getLifeAmount().substring(2);
|
||||
if (rightString.equals("X")) {
|
||||
right = CardFactoryUtil.xCount(sa.getSourceCard(), sa.getSourceCard().getSVar("X"));
|
||||
} else {
|
||||
right = Integer.parseInt(getLifeAmount().substring(2));
|
||||
right = Integer.parseInt(this.getLifeAmount().substring(2));
|
||||
}
|
||||
|
||||
if (!AllZoneUtil.compare(life, getLifeAmount(), right)) {
|
||||
if (!AllZoneUtil.compare(life, this.getLifeAmount(), right)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (isPwAbility()) {
|
||||
if (this.isPwAbility()) {
|
||||
// Planeswalker abilities can only be activated as Sorceries
|
||||
if (!Phase.canCastSorcery(activator)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (SpellAbility pwAbs : c.getAllSpellAbilities()) {
|
||||
for (final SpellAbility pwAbs : c.getAllSpellAbilities()) {
|
||||
// check all abilities on card that have their planeswalker
|
||||
// restriction set to confirm they haven't been activated
|
||||
SpellAbility_Restriction restrict = pwAbs.getRestrictions();
|
||||
if (restrict.getPlaneswalker() && restrict.getNumberTurnActivations() > 0) {
|
||||
final SpellAbility_Restriction restrict = pwAbs.getRestrictions();
|
||||
if (restrict.getPlaneswalker() && (restrict.getNumberTurnActivations() > 0)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (getsVarToCheck() != null) {
|
||||
int svarValue = AbilityFactory.calculateAmount(c, getsVarToCheck(), sa);
|
||||
int operandValue = AbilityFactory.calculateAmount(c, getsVarOperand(), sa);
|
||||
if (this.getsVarToCheck() != null) {
|
||||
final int svarValue = AbilityFactory.calculateAmount(c, this.getsVarToCheck(), sa);
|
||||
final int operandValue = AbilityFactory.calculateAmount(c, this.getsVarOperand(), sa);
|
||||
|
||||
if (!AllZoneUtil.compare(svarValue, getsVarOperator(), operandValue)) {
|
||||
if (!AllZoneUtil.compare(svarValue, this.getsVarOperator(), operandValue)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -36,9 +36,6 @@ public class SpellAbility_StackInstance {
|
||||
/** The activating player. */
|
||||
private Player activatingPlayer = null;
|
||||
|
||||
/** The activated from. */
|
||||
private String activatedFrom = null;
|
||||
|
||||
/** The stack description. */
|
||||
private String stackDescription = null;
|
||||
|
||||
@@ -60,7 +57,7 @@ public class SpellAbility_StackInstance {
|
||||
// Triggers
|
||||
private HashMap<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>
|
||||
@@ -72,41 +69,41 @@ public class SpellAbility_StackInstance {
|
||||
*/
|
||||
public SpellAbility_StackInstance(final SpellAbility sa) {
|
||||
// Base SA info
|
||||
ability = sa;
|
||||
stackDescription = ability.getStackDescription();
|
||||
activatingPlayer = sa.getActivatingPlayer();
|
||||
this.ability = sa;
|
||||
this.stackDescription = this.ability.getStackDescription();
|
||||
this.activatingPlayer = sa.getActivatingPlayer();
|
||||
|
||||
// Payment info
|
||||
paidHash = ability.getPaidHash();
|
||||
ability.resetPaidHash();
|
||||
this.paidHash = this.ability.getPaidHash();
|
||||
this.ability.resetPaidHash();
|
||||
|
||||
// TODO getXManaCostPaid should be on the SA, not the Card
|
||||
xManaPaid = sa.getSourceCard().getXManaCostPaid();
|
||||
this.xManaPaid = sa.getSourceCard().getXManaCostPaid();
|
||||
|
||||
// Triggering info
|
||||
triggeringObjects = sa.getTriggeringObjects();
|
||||
this.triggeringObjects = sa.getTriggeringObjects();
|
||||
|
||||
Ability_Sub subAb = ability.getSubAbility();
|
||||
final Ability_Sub subAb = this.ability.getSubAbility();
|
||||
if (subAb != null) {
|
||||
subInstace = new SpellAbility_StackInstance(subAb);
|
||||
this.subInstace = new SpellAbility_StackInstance(subAb);
|
||||
}
|
||||
|
||||
// Targeting info -- 29/06/11 Moved to after taking care of SubAbilities
|
||||
// because otherwise AF_DealDamage SubAbilities that use Defined$
|
||||
// Targeted breaks (since it's parents target is reset)
|
||||
Target target = sa.getTarget();
|
||||
final Target target = sa.getTarget();
|
||||
if (target != null) {
|
||||
tc = target.getTargetChoices();
|
||||
ability.getTarget().resetTargets();
|
||||
this.tc = target.getTargetChoices();
|
||||
this.ability.getTarget().resetTargets();
|
||||
}
|
||||
|
||||
Card source = ability.getSourceCard();
|
||||
final Card source = this.ability.getSourceCard();
|
||||
|
||||
// Store SVars and Clear
|
||||
for (String store : Card.getStorableSVars()) {
|
||||
String value = source.getSVar(store);
|
||||
for (final String store : Card.getStorableSVars()) {
|
||||
final String value = source.getSVar(store);
|
||||
if (value.length() > 0) {
|
||||
storedSVars.put(store, value);
|
||||
this.storedSVars.put(store, value);
|
||||
source.setSVar(store, "");
|
||||
}
|
||||
}
|
||||
@@ -120,34 +117,34 @@ public class SpellAbility_StackInstance {
|
||||
* @return a {@link forge.card.spellability.SpellAbility} object.
|
||||
*/
|
||||
public final SpellAbility getSpellAbility() {
|
||||
if (ability.getTarget() != null) {
|
||||
ability.getTarget().resetTargets();
|
||||
ability.getTarget().setTargetChoices(tc);
|
||||
if (this.ability.getTarget() != null) {
|
||||
this.ability.getTarget().resetTargets();
|
||||
this.ability.getTarget().setTargetChoices(this.tc);
|
||||
}
|
||||
ability.setActivatingPlayer(activatingPlayer);
|
||||
this.ability.setActivatingPlayer(this.activatingPlayer);
|
||||
|
||||
// Saved sub-SA needs to be reset on the way out
|
||||
if (this.subInstace != null) {
|
||||
ability.setSubAbility((Ability_Sub) this.subInstace.getSpellAbility());
|
||||
this.ability.setSubAbility((Ability_Sub) this.subInstace.getSpellAbility());
|
||||
}
|
||||
|
||||
// Set Cost specific things here
|
||||
ability.setPaidHash(paidHash);
|
||||
ability.getSourceCard().setXManaCostPaid(xManaPaid);
|
||||
this.ability.setPaidHash(this.paidHash);
|
||||
this.ability.getSourceCard().setXManaCostPaid(this.xManaPaid);
|
||||
|
||||
// Triggered
|
||||
ability.setAllTriggeringObjects(triggeringObjects);
|
||||
this.ability.setAllTriggeringObjects(this.triggeringObjects);
|
||||
|
||||
// Add SVars back in
|
||||
Card source = ability.getSourceCard();
|
||||
for (String store : storedSVars.keySet()) {
|
||||
String value = storedSVars.get(store);
|
||||
final Card source = this.ability.getSourceCard();
|
||||
for (final String store : this.storedSVars.keySet()) {
|
||||
final String value = this.storedSVars.get(store);
|
||||
if (value.length() > 0) {
|
||||
source.setSVar(store, value);
|
||||
}
|
||||
}
|
||||
|
||||
return ability;
|
||||
return this.ability;
|
||||
}
|
||||
|
||||
// A bit of SA shared abilities to restrict conflicts
|
||||
@@ -159,7 +156,7 @@ public class SpellAbility_StackInstance {
|
||||
* @return a {@link java.lang.String} object.
|
||||
*/
|
||||
public final String getStackDescription() {
|
||||
return stackDescription;
|
||||
return this.stackDescription;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -170,7 +167,7 @@ public class SpellAbility_StackInstance {
|
||||
* @return a {@link forge.Card} object.
|
||||
*/
|
||||
public final Card getSourceCard() {
|
||||
return ability.getSourceCard();
|
||||
return this.ability.getSourceCard();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -181,7 +178,7 @@ public class SpellAbility_StackInstance {
|
||||
* @return a {@link forge.Player} object.
|
||||
*/
|
||||
public final Player getActivatingPlayer() {
|
||||
return activatingPlayer;
|
||||
return this.activatingPlayer;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -192,7 +189,7 @@ public class SpellAbility_StackInstance {
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final boolean isSpell() {
|
||||
return ability.isSpell();
|
||||
return this.ability.isSpell();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -203,7 +200,7 @@ public class SpellAbility_StackInstance {
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final boolean isAbility() {
|
||||
return ability.isAbility();
|
||||
return this.ability.isAbility();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -214,7 +211,7 @@ public class SpellAbility_StackInstance {
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final boolean isTrigger() {
|
||||
return ability.isTrigger();
|
||||
return this.ability.isTrigger();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -227,7 +224,7 @@ public class SpellAbility_StackInstance {
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final boolean isStateTrigger(final int id) {
|
||||
return ability.getSourceTrigger() == id;
|
||||
return this.ability.getSourceTrigger() == id;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -236,6 +233,6 @@ public class SpellAbility_StackInstance {
|
||||
* @return true, if is optional trigger
|
||||
*/
|
||||
public final boolean isOptionalTrigger() {
|
||||
return ability.isOptionalTrigger();
|
||||
return this.ability.isOptionalTrigger();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -719,7 +719,8 @@ public class SpellAbility_Variables {
|
||||
/**
|
||||
* Sets the s var operand.
|
||||
*
|
||||
* @param sVarOperand the sVarOperand to set
|
||||
* @param sVarOperand
|
||||
* the sVarOperand to set
|
||||
*/
|
||||
public final void setsVarOperand(final String sVarOperand) {
|
||||
this.sVarOperand = sVarOperand; // TODO Add 0 to parameter's name.
|
||||
@@ -737,7 +738,8 @@ public class SpellAbility_Variables {
|
||||
/**
|
||||
* Sets the s var to check.
|
||||
*
|
||||
* @param sVarToCheck the sVarToCheck to set
|
||||
* @param sVarToCheck
|
||||
* the sVarToCheck to set
|
||||
*/
|
||||
public final void setsVarToCheck(final String sVarToCheck) {
|
||||
this.sVarToCheck = sVarToCheck;
|
||||
@@ -755,7 +757,8 @@ public class SpellAbility_Variables {
|
||||
/**
|
||||
* Sets the s var operator.
|
||||
*
|
||||
* @param sVarOperator the sVarOperator to set
|
||||
* @param sVarOperator
|
||||
* the sVarOperator to set
|
||||
*/
|
||||
public final void setsVarOperator(final String sVarOperator) {
|
||||
this.sVarOperator = sVarOperator; // TODO: Add 0 to parameter's name.
|
||||
@@ -782,7 +785,8 @@ public class SpellAbility_Variables {
|
||||
/**
|
||||
* Sets the cards in hand.
|
||||
*
|
||||
* @param cardsInHand the cardsInHand to set
|
||||
* @param cardsInHand
|
||||
* the cardsInHand to set
|
||||
*/
|
||||
public final void setCardsInHand(final int cardsInHand) {
|
||||
this.cardsInHand = cardsInHand; // TODO: Add 0 to parameter's name.
|
||||
@@ -803,7 +807,7 @@ public class SpellAbility_Variables {
|
||||
* @return the anyPlayer
|
||||
*/
|
||||
public final boolean isAnyPlayer() {
|
||||
return anyPlayer;
|
||||
return this.anyPlayer;
|
||||
}
|
||||
|
||||
} // end class SpellAbility_Variables
|
||||
|
||||
@@ -41,94 +41,99 @@ public class Spell_Permanent extends Spell {
|
||||
|
||||
@Override
|
||||
public void showMessage() {
|
||||
CardList choice = (CardList) championGetCreature.execute();
|
||||
final CardList choice = (CardList) Spell_Permanent.this.championGetCreature.execute();
|
||||
|
||||
stopSetNext(CardFactoryUtil.inputTargetChampionSac(getSourceCard(), championAbilityComes, choice,
|
||||
"Select another " + championValidDesc + " you control to exile", false, false));
|
||||
this.stopSetNext(CardFactoryUtil.inputTargetChampionSac(Spell_Permanent.this.getSourceCard(),
|
||||
Spell_Permanent.this.championAbilityComes, choice, "Select another "
|
||||
+ Spell_Permanent.this.championValidDesc + " you control to exile", false, false));
|
||||
ButtonUtil.disableAll(); // target this card means: sacrifice this
|
||||
// card
|
||||
}
|
||||
};
|
||||
|
||||
private final CommandReturn championGetCreature = new CommandReturn() {
|
||||
@Override
|
||||
public Object execute() {
|
||||
CardList cards = getSourceCard().getController().getCardsIn(Zone.Battlefield);
|
||||
return cards.getValidCards(championValid, getSourceCard().getController(), getSourceCard());
|
||||
final CardList cards = Spell_Permanent.this.getSourceCard().getController().getCardsIn(Zone.Battlefield);
|
||||
return cards.getValidCards(Spell_Permanent.this.championValid, Spell_Permanent.this.getSourceCard()
|
||||
.getController(), Spell_Permanent.this.getSourceCard());
|
||||
}
|
||||
}; // CommandReturn
|
||||
|
||||
/** The champion ability comes. */
|
||||
private final SpellAbility championAbilityComes = new Ability(getSourceCard(), "0") {
|
||||
private final SpellAbility championAbilityComes = new Ability(this.getSourceCard(), "0") {
|
||||
@Override
|
||||
public void resolve() {
|
||||
|
||||
Card source = getSourceCard();
|
||||
Player controller = source.getController();
|
||||
final Card source = this.getSourceCard();
|
||||
final Player controller = source.getController();
|
||||
|
||||
CardList creature = (CardList) championGetCreature.execute();
|
||||
final CardList creature = (CardList) Spell_Permanent.this.championGetCreature.execute();
|
||||
if (creature.size() == 0) {
|
||||
AllZone.getGameAction().sacrifice(source);
|
||||
return;
|
||||
} else if (controller.isHuman()) {
|
||||
AllZone.getInputControl().setInput(championInputComes);
|
||||
AllZone.getInputControl().setInput(Spell_Permanent.this.championInputComes);
|
||||
} else { // Computer
|
||||
CardList computer = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield);
|
||||
computer = computer.getValidCards(championValid, controller, source);
|
||||
computer = computer.getValidCards(Spell_Permanent.this.championValid, controller, source);
|
||||
computer.remove(source);
|
||||
|
||||
computer.shuffle();
|
||||
if (computer.size() != 0) {
|
||||
Card c = computer.get(0);
|
||||
final Card c = computer.get(0);
|
||||
source.setChampionedCard(c);
|
||||
if (AllZoneUtil.isCardInPlay(c)) {
|
||||
AllZone.getGameAction().exile(c);
|
||||
}
|
||||
|
||||
// Run triggers
|
||||
HashMap<String, Object> runParams = new HashMap<String, Object>();
|
||||
final HashMap<String, Object> runParams = new HashMap<String, Object>();
|
||||
runParams.put("Card", source);
|
||||
runParams.put("Championed", source.getChampionedCard());
|
||||
AllZone.getTriggerHandler().runTrigger("Championed", runParams);
|
||||
} else {
|
||||
AllZone.getGameAction().sacrifice(getSourceCard());
|
||||
AllZone.getGameAction().sacrifice(this.getSourceCard());
|
||||
}
|
||||
} // computer
|
||||
} // resolve()
|
||||
};
|
||||
|
||||
/** The champion command comes. */
|
||||
private Command championCommandComes = new Command() {
|
||||
private final Command championCommandComes = new Command() {
|
||||
|
||||
private static final long serialVersionUID = -3580408066322945328L;
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(getSourceCard()).append(
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append(Spell_Permanent.this.getSourceCard()).append(
|
||||
" - When CARDNAME enters the battlefield, sacrifice it unless you exile a creature you control.");
|
||||
championAbilityComes.setStackDescription(sb.toString());
|
||||
AllZone.getStack().addSimultaneousStackEntry(championAbilityComes);
|
||||
Spell_Permanent.this.championAbilityComes.setStackDescription(sb.toString());
|
||||
AllZone.getStack().addSimultaneousStackEntry(Spell_Permanent.this.championAbilityComes);
|
||||
} // execute()
|
||||
}; // championCommandComes
|
||||
|
||||
/** The champion command leaves play. */
|
||||
private Command championCommandLeavesPlay = new Command() {
|
||||
private final Command championCommandLeavesPlay = new Command() {
|
||||
|
||||
private static final long serialVersionUID = -5903638227914705191L;
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
|
||||
SpellAbility ability = new Ability(getSourceCard(), "0") {
|
||||
final SpellAbility ability = new Ability(Spell_Permanent.this.getSourceCard(), "0") {
|
||||
@Override
|
||||
public void resolve() {
|
||||
Card c = getSourceCard().getChampionedCard();
|
||||
if (c != null && !c.isToken() && AllZoneUtil.isCardExiled(c)) {
|
||||
final Card c = this.getSourceCard().getChampionedCard();
|
||||
if ((c != null) && !c.isToken() && AllZoneUtil.isCardExiled(c)) {
|
||||
AllZone.getGameAction().moveToPlay(c);
|
||||
}
|
||||
} // resolve()
|
||||
}; // SpellAbility
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(getSourceCard()).append(
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append(Spell_Permanent.this.getSourceCard()).append(
|
||||
" - When CARDNAME leaves the battlefield, exiled card returns to the battlefield.");
|
||||
ability.setStackDescription(sb.toString());
|
||||
|
||||
@@ -184,36 +189,36 @@ public class Spell_Permanent extends Spell {
|
||||
super(sourceCard, cost, tgt);
|
||||
|
||||
if (CardFactoryUtil.hasKeyword(sourceCard, "Champion") != -1) {
|
||||
int n = CardFactoryUtil.hasKeyword(sourceCard, "Champion");
|
||||
final int n = CardFactoryUtil.hasKeyword(sourceCard, "Champion");
|
||||
|
||||
String toParse = sourceCard.getKeyword().get(n).toString();
|
||||
String[] parsed = toParse.split(":");
|
||||
willChampion = true;
|
||||
championValid = parsed[1];
|
||||
final String toParse = sourceCard.getKeyword().get(n).toString();
|
||||
final String[] parsed = toParse.split(":");
|
||||
this.willChampion = true;
|
||||
this.championValid = parsed[1];
|
||||
if (parsed.length > 2) {
|
||||
championValidDesc = parsed[2];
|
||||
this.championValidDesc = parsed[2];
|
||||
} else {
|
||||
championValidDesc = championValid;
|
||||
this.championValidDesc = this.championValid;
|
||||
}
|
||||
}
|
||||
|
||||
if (sourceCard.isCreature()) {
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append(sourceCard.getName()).append(" - Creature ").append(sourceCard.getNetAttack());
|
||||
sb.append(" / ").append(sourceCard.getNetDefense());
|
||||
setStackDescription(sb.toString());
|
||||
this.setStackDescription(sb.toString());
|
||||
} else {
|
||||
setStackDescription(sourceCard.getName());
|
||||
this.setStackDescription(sourceCard.getName());
|
||||
}
|
||||
|
||||
if (setDesc) {
|
||||
setDescription(getStackDescription());
|
||||
this.setDescription(this.getStackDescription());
|
||||
}
|
||||
|
||||
if (willChampion) {
|
||||
sourceCard.addComesIntoPlayCommand(championCommandComes);
|
||||
sourceCard.addLeavesPlayCommand(championCommandLeavesPlay);
|
||||
if (this.willChampion) {
|
||||
sourceCard.addComesIntoPlayCommand(this.championCommandComes);
|
||||
sourceCard.addLeavesPlayCommand(this.championCommandLeavesPlay);
|
||||
}
|
||||
|
||||
} // Spell_Permanent()
|
||||
@@ -221,12 +226,12 @@ public class Spell_Permanent extends Spell {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public boolean canPlay() {
|
||||
Card source = getSourceCard();
|
||||
final Card source = this.getSourceCard();
|
||||
|
||||
Player turn = AllZone.getPhase().getPlayerTurn();
|
||||
final Player turn = AllZone.getPhase().getPlayerTurn();
|
||||
|
||||
if (source.getName().equals("Serra Avenger")) {
|
||||
if (turn.equals(source.getController()) && turn.getTurn() <= 3) {
|
||||
if (turn.equals(source.getController()) && (turn.getTurn() <= 3)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -239,11 +244,11 @@ public class Spell_Permanent extends Spell {
|
||||
@Override
|
||||
public boolean canPlayAI() {
|
||||
|
||||
Card card = getSourceCard();
|
||||
final Card card = this.getSourceCard();
|
||||
|
||||
// check on legendary
|
||||
if (card.isType("Legendary")) {
|
||||
CardList list = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield);
|
||||
final CardList list = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield);
|
||||
if (list.containsName(card.getName())) {
|
||||
return false;
|
||||
}
|
||||
@@ -253,8 +258,8 @@ public class Spell_Permanent extends Spell {
|
||||
list = list.getType("Planeswalker");
|
||||
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
String subtype = card.getType().get(card.getType().size() - 1);
|
||||
CardList cl = list.getType(subtype);
|
||||
final String subtype = card.getType().get(card.getType().size() - 1);
|
||||
final CardList cl = list.getType(subtype);
|
||||
|
||||
if (cl.size() > 0) {
|
||||
return false;
|
||||
@@ -269,24 +274,24 @@ public class Spell_Permanent extends Spell {
|
||||
}
|
||||
}
|
||||
|
||||
if (card.isCreature() && card.getNetDefense() <= 0 && !card.hasStartOfKeyword("etbCounter")
|
||||
if (card.isCreature() && (card.getNetDefense() <= 0) && !card.hasStartOfKeyword("etbCounter")
|
||||
&& !card.getText().contains("Modular")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (willChampion) {
|
||||
Object o = championGetCreature.execute();
|
||||
if (this.willChampion) {
|
||||
final Object o = this.championGetCreature.execute();
|
||||
if (o == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
CardList cl = (CardList) championGetCreature.execute();
|
||||
if ((o == null) || !(cl.size() > 0) || !AllZone.getZoneOf(getSourceCard()).is(Constant.Zone.Hand)) {
|
||||
final CardList cl = (CardList) this.championGetCreature.execute();
|
||||
if ((o == null) || !(cl.size() > 0) || !AllZone.getZoneOf(this.getSourceCard()).is(Constant.Zone.Hand)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!checkETBEffects(card, this, null)) {
|
||||
if (!Spell_Permanent.checkETBEffects(card, this, null)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -308,11 +313,11 @@ public class Spell_Permanent extends Spell {
|
||||
*/
|
||||
public static boolean checkETBEffects(final Card card, final SpellAbility sa, final String api) {
|
||||
// Trigger play improvements
|
||||
ArrayList<Trigger> triggers = card.getTriggers();
|
||||
for (Trigger tr : triggers) {
|
||||
final ArrayList<Trigger> triggers = card.getTriggers();
|
||||
for (final Trigger tr : triggers) {
|
||||
// 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")) {
|
||||
continue;
|
||||
}
|
||||
@@ -335,14 +340,14 @@ public class Spell_Permanent extends Spell {
|
||||
}
|
||||
|
||||
// Maybe better considerations
|
||||
AbilityFactory af = new AbilityFactory();
|
||||
String execute = params.get("Execute");
|
||||
final AbilityFactory af = new AbilityFactory();
|
||||
final String execute = params.get("Execute");
|
||||
if (execute == null) {
|
||||
continue;
|
||||
}
|
||||
SpellAbility exSA = af.getAbility(card.getSVar(execute), card);
|
||||
final SpellAbility exSA = af.getAbility(card.getSVar(execute), card);
|
||||
|
||||
if (api != null && !af.getAPI().equals(api)) {
|
||||
if ((api != null) && !af.getAPI().equals(api)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -355,7 +360,7 @@ public class Spell_Permanent extends Spell {
|
||||
// Run non-mandatory trigger.
|
||||
// These checks only work if the Executing SpellAbility is an
|
||||
// Ability_Sub.
|
||||
if (exSA instanceof Ability_Sub && !exSA.doTrigger(false)) {
|
||||
if ((exSA instanceof Ability_Sub) && !exSA.doTrigger(false)) {
|
||||
// AI would not run this trigger if given the chance
|
||||
|
||||
// if trigger is mandatory, return false
|
||||
@@ -373,7 +378,7 @@ public class Spell_Permanent extends Spell {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void resolve() {
|
||||
Card c = getSourceCard();
|
||||
final Card c = this.getSourceCard();
|
||||
AllZone.getGameAction().moveToPlay(c);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public class Target {
|
||||
* @return a {@link forge.card.spellability.Target_Choices} object.
|
||||
*/
|
||||
public final Target_Choices getTargetChoices() {
|
||||
return choice;
|
||||
return this.choice;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -48,7 +48,7 @@ public class Target {
|
||||
* a {@link forge.card.spellability.Target_Choices} object.
|
||||
*/
|
||||
public final void setTargetChoices(final Target_Choices tc) {
|
||||
choice = tc;
|
||||
this.choice = tc;
|
||||
}
|
||||
|
||||
private boolean bMandatory = false;
|
||||
@@ -61,7 +61,7 @@ public class Target {
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final boolean getMandatory() {
|
||||
return bMandatory;
|
||||
return this.bMandatory;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,11 +73,11 @@ public class Target {
|
||||
* a boolean.
|
||||
*/
|
||||
public final void setMandatory(final boolean m) {
|
||||
bMandatory = m;
|
||||
this.bMandatory = m;
|
||||
}
|
||||
|
||||
private boolean tgtValid = false;
|
||||
private String[] ValidTgts;
|
||||
private String[] validTgts;
|
||||
private String vtSelection = "";
|
||||
|
||||
/**
|
||||
@@ -88,7 +88,7 @@ public class Target {
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final boolean doesTarget() {
|
||||
return tgtValid;
|
||||
return this.tgtValid;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -99,7 +99,7 @@ public class Target {
|
||||
* @return an array of {@link java.lang.String} objects.
|
||||
*/
|
||||
public final String[] getValidTgts() {
|
||||
return ValidTgts;
|
||||
return this.validTgts;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -110,7 +110,7 @@ public class Target {
|
||||
* @return a {@link java.lang.String} object.
|
||||
*/
|
||||
public final String getVTSelection() {
|
||||
return vtSelection;
|
||||
return this.vtSelection;
|
||||
}
|
||||
|
||||
private String minTargets;
|
||||
@@ -128,7 +128,7 @@ public class Target {
|
||||
* @return a int.
|
||||
*/
|
||||
public final int getMinTargets(final Card c, final SpellAbility sa) {
|
||||
return AbilityFactory.calculateAmount(c, minTargets, sa);
|
||||
return AbilityFactory.calculateAmount(c, this.minTargets, sa);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -143,7 +143,7 @@ public class Target {
|
||||
* @return a int.
|
||||
*/
|
||||
public final int getMaxTargets(final Card c, final SpellAbility sa) {
|
||||
return AbilityFactory.calculateAmount(c, maxTargets, sa);
|
||||
return AbilityFactory.calculateAmount(c, this.maxTargets, sa);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -158,7 +158,7 @@ public class Target {
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final boolean isMaxTargetsChosen(final Card c, final SpellAbility sa) {
|
||||
return choice != null && getMaxTargets(c, sa) == choice.getNumTargeted();
|
||||
return (this.choice != null) && (this.getMaxTargets(c, sa) == this.choice.getNumTargeted());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -173,10 +173,10 @@ public class Target {
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final boolean isMinTargetsChosen(final Card c, final SpellAbility sa) {
|
||||
if (getMinTargets(c, sa) == 0) {
|
||||
if (this.getMinTargets(c, sa) == 0) {
|
||||
return true;
|
||||
}
|
||||
return choice != null && getMinTargets(c, sa) <= choice.getNumTargeted();
|
||||
return (this.choice != null) && (this.getMinTargets(c, sa) <= this.choice.getNumTargeted());
|
||||
}
|
||||
|
||||
private List<Constant.Zone> tgtZone = Arrays.asList(Constant.Zone.Battlefield);
|
||||
@@ -190,7 +190,7 @@ public class Target {
|
||||
* a {@link java.lang.String} object.
|
||||
*/
|
||||
public final void setZone(final Constant.Zone tZone) {
|
||||
tgtZone = Arrays.asList(tZone);
|
||||
this.tgtZone = Arrays.asList(tZone);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -200,7 +200,7 @@ public class Target {
|
||||
* the new zone
|
||||
*/
|
||||
public final void setZone(final List<Constant.Zone> tZone) {
|
||||
tgtZone = tZone;
|
||||
this.tgtZone = tZone;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -211,7 +211,7 @@ public class Target {
|
||||
* @return a {@link java.lang.String} object.
|
||||
*/
|
||||
public final List<Constant.Zone> getZone() {
|
||||
return tgtZone;
|
||||
return this.tgtZone;
|
||||
}
|
||||
|
||||
// Used for Counters. Currently, Spell,Activated,Triggered can be
|
||||
@@ -227,7 +227,7 @@ public class Target {
|
||||
* a {@link java.lang.String} object.
|
||||
*/
|
||||
public final void setTargetSpellAbilityType(final String tgtSAType) {
|
||||
targetSpellAbilityType = tgtSAType;
|
||||
this.targetSpellAbilityType = tgtSAType;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -238,7 +238,7 @@ public class Target {
|
||||
* @return a {@link java.lang.String} object.
|
||||
*/
|
||||
public final String getTargetSpellAbilityType() {
|
||||
return targetSpellAbilityType;
|
||||
return this.targetSpellAbilityType;
|
||||
}
|
||||
|
||||
// Used for Counters. The target SA of this SA must be targeting a Valid X
|
||||
@@ -253,7 +253,7 @@ public class Target {
|
||||
* a {@link java.lang.String} object.
|
||||
*/
|
||||
public final void setSAValidTargeting(final String saValidTgting) {
|
||||
saValidTargeting = saValidTgting;
|
||||
this.saValidTargeting = saValidTgting;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -264,7 +264,7 @@ public class Target {
|
||||
* @return a {@link java.lang.String} object.
|
||||
*/
|
||||
public final String getSAValidTargeting() {
|
||||
return saValidTargeting;
|
||||
return this.saValidTargeting;
|
||||
}
|
||||
|
||||
// Leaving old structure behind for compatibility.
|
||||
@@ -278,20 +278,20 @@ public class Target {
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final boolean addTarget(final Object o) {
|
||||
if (choice == null) {
|
||||
choice = new Target_Choices();
|
||||
if (this.choice == null) {
|
||||
this.choice = new Target_Choices();
|
||||
}
|
||||
|
||||
if (o instanceof Card) {
|
||||
return choice.addTarget((Card) o);
|
||||
return this.choice.addTarget((Card) o);
|
||||
}
|
||||
|
||||
if (o instanceof Player) {
|
||||
return choice.addTarget((Player) o);
|
||||
return this.choice.addTarget((Player) o);
|
||||
}
|
||||
|
||||
if (o instanceof SpellAbility) {
|
||||
return choice.addTarget((SpellAbility) o);
|
||||
return this.choice.addTarget((SpellAbility) o);
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -305,11 +305,11 @@ public class Target {
|
||||
* @return a {@link java.util.ArrayList} object.
|
||||
*/
|
||||
public final ArrayList<Card> getTargetCards() {
|
||||
if (choice == null) {
|
||||
if (this.choice == null) {
|
||||
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.
|
||||
*/
|
||||
public final ArrayList<Player> getTargetPlayers() {
|
||||
if (choice == null) {
|
||||
if (this.choice == null) {
|
||||
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.
|
||||
*/
|
||||
public final ArrayList<SpellAbility> getTargetSAs() {
|
||||
if (choice == null) {
|
||||
if (this.choice == null) {
|
||||
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.
|
||||
*/
|
||||
public final ArrayList<Object> getTargets() {
|
||||
if (choice == null) {
|
||||
if (this.choice == null) {
|
||||
return new ArrayList<Object>();
|
||||
}
|
||||
|
||||
return choice.getTargets();
|
||||
return this.choice.getTargets();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -365,10 +365,10 @@ public class Target {
|
||||
* @return a int.
|
||||
*/
|
||||
public final int getNumTargeted() {
|
||||
if (choice == null) {
|
||||
if (this.choice == null) {
|
||||
return 0;
|
||||
}
|
||||
return choice.getNumTargeted();
|
||||
return this.choice.getNumTargeted();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -377,7 +377,7 @@ public class Target {
|
||||
* </p>
|
||||
*/
|
||||
public final void resetTargets() {
|
||||
choice = null;
|
||||
this.choice = null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -413,8 +413,8 @@ public class Target {
|
||||
// C = Creature P=Player/Planeswalker
|
||||
// CP = All three
|
||||
|
||||
tgtValid = true;
|
||||
srcCard = src;
|
||||
this.tgtValid = true;
|
||||
this.srcCard = src;
|
||||
|
||||
if (parse.contains("Tgt")) {
|
||||
parse = parse.replace("Tgt", "");
|
||||
@@ -422,7 +422,7 @@ public class Target {
|
||||
|
||||
String valid;
|
||||
String prompt;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
|
||||
if (parse.equals("CP")) {
|
||||
valid = "Creature,Planeswalker.YouDontCtrl,Player";
|
||||
@@ -442,11 +442,11 @@ public class Target {
|
||||
sb.append(src + " - ");
|
||||
}
|
||||
sb.append(prompt);
|
||||
vtSelection = sb.toString();
|
||||
ValidTgts = valid.split(",");
|
||||
this.vtSelection = sb.toString();
|
||||
this.validTgts = valid.split(",");
|
||||
|
||||
minTargets = min;
|
||||
maxTargets = max;
|
||||
this.minTargets = min;
|
||||
this.maxTargets = max;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -498,13 +498,13 @@ public class Target {
|
||||
* a {@link java.lang.String} object.
|
||||
*/
|
||||
public Target(final Card src, final String select, final String[] valid, final String min, final String max) {
|
||||
srcCard = src;
|
||||
tgtValid = true;
|
||||
vtSelection = select;
|
||||
ValidTgts = valid;
|
||||
this.srcCard = src;
|
||||
this.tgtValid = true;
|
||||
this.vtSelection = select;
|
||||
this.validTgts = valid;
|
||||
|
||||
minTargets = min;
|
||||
maxTargets = max;
|
||||
this.minTargets = min;
|
||||
this.maxTargets = max;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -515,15 +515,15 @@ public class Target {
|
||||
* @return a {@link java.lang.String} object.
|
||||
*/
|
||||
public final String getTargetedString() {
|
||||
ArrayList<Object> tgts = getTargets();
|
||||
StringBuilder sb = new StringBuilder("");
|
||||
for (Object o : tgts) {
|
||||
final ArrayList<Object> tgts = this.getTargets();
|
||||
final StringBuilder sb = new StringBuilder("");
|
||||
for (final Object o : tgts) {
|
||||
if (o instanceof Player) {
|
||||
Player p = (Player) o;
|
||||
final Player p = (Player) o;
|
||||
sb.append(p.getName());
|
||||
}
|
||||
if (o instanceof Card) {
|
||||
Card c = (Card) o;
|
||||
final Card c = (Card) o;
|
||||
sb.append(c);
|
||||
}
|
||||
sb.append(" ");
|
||||
@@ -542,7 +542,7 @@ public class Target {
|
||||
public final boolean canOnlyTgtOpponent() {
|
||||
boolean player = false;
|
||||
boolean opponent = false;
|
||||
for (String s : ValidTgts) {
|
||||
for (final String s : this.validTgts) {
|
||||
if (s.equals("Opponent")) {
|
||||
opponent = true;
|
||||
} else if (s.equals("Player")) {
|
||||
@@ -560,7 +560,7 @@ public class Target {
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final boolean canTgtPlayer() {
|
||||
for (String s : ValidTgts) {
|
||||
for (final String s : this.validTgts) {
|
||||
if (s.equals("Player") || s.equals("Opponent")) {
|
||||
return true;
|
||||
}
|
||||
@@ -577,7 +577,7 @@ public class Target {
|
||||
*/
|
||||
|
||||
public final boolean canTgtPermanent() {
|
||||
for (String s : ValidTgts) {
|
||||
for (final String s : this.validTgts) {
|
||||
if (s.contains("Permanent")) {
|
||||
return true;
|
||||
}
|
||||
@@ -591,7 +591,7 @@ public class Target {
|
||||
* @return true, if successful
|
||||
*/
|
||||
public final boolean canTgtCreature() {
|
||||
for (String s : ValidTgts) {
|
||||
for (final String s : this.validTgts) {
|
||||
if (s.contains("Creature") && !s.contains("nonCreature")) {
|
||||
return true;
|
||||
}
|
||||
@@ -607,7 +607,7 @@ public class Target {
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final boolean canTgtCreatureAndPlayer() {
|
||||
return canTgtPlayer() && canTgtCreature();
|
||||
return this.canTgtPlayer() && this.canTgtCreature();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -621,13 +621,13 @@ public class Target {
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final boolean hasCandidates(final boolean isTargeted) {
|
||||
if (canTgtPlayer()) {
|
||||
if (this.canTgtPlayer()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (Card c : AllZoneUtil.getCardsIn(tgtZone)) {
|
||||
if (c.isValid(ValidTgts, srcCard.getController(), srcCard)
|
||||
&& (!isTargeted || CardFactoryUtil.canTarget(srcCard, c))) {
|
||||
for (final Card c : AllZoneUtil.getCardsIn(this.tgtZone)) {
|
||||
if (c.isValid(this.validTgts, this.srcCard.getController(), this.srcCard)
|
||||
&& (!isTargeted || CardFactoryUtil.canTarget(this.srcCard, c))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -641,7 +641,7 @@ public class Target {
|
||||
* @return true, if is unique targets
|
||||
*/
|
||||
public final boolean isUniqueTargets() {
|
||||
return uniqueTargets;
|
||||
return this.uniqueTargets;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,13 +24,13 @@ public class Target_Choices {
|
||||
* @return a int.
|
||||
*/
|
||||
public final int getNumTargeted() {
|
||||
return numTargeted;
|
||||
return this.numTargeted;
|
||||
}
|
||||
|
||||
// Card or Player are legal targets.
|
||||
private ArrayList<Card> targetCards = new ArrayList<Card>();
|
||||
private ArrayList<Player> targetPlayers = new ArrayList<Player>();
|
||||
private ArrayList<SpellAbility> targetSAs = new ArrayList<SpellAbility>();
|
||||
private final ArrayList<Card> targetCards = new ArrayList<Card>();
|
||||
private final ArrayList<Player> targetPlayers = new ArrayList<Player>();
|
||||
private final ArrayList<SpellAbility> targetSAs = new ArrayList<SpellAbility>();
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -43,11 +43,11 @@ public class Target_Choices {
|
||||
*/
|
||||
public final boolean addTarget(final Object o) {
|
||||
if (o instanceof Player) {
|
||||
return addTarget((Player) o);
|
||||
return this.addTarget((Player) o);
|
||||
} else if (o instanceof Card) {
|
||||
return addTarget((Card) o);
|
||||
return this.addTarget((Card) o);
|
||||
} else if (o instanceof SpellAbility) {
|
||||
return addTarget((SpellAbility) o);
|
||||
return this.addTarget((SpellAbility) o);
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -63,9 +63,9 @@ public class Target_Choices {
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final boolean addTarget(final Card c) {
|
||||
if (!targetCards.contains(c)) {
|
||||
targetCards.add(c);
|
||||
numTargeted++;
|
||||
if (!this.targetCards.contains(c)) {
|
||||
this.targetCards.add(c);
|
||||
this.numTargeted++;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -81,9 +81,9 @@ public class Target_Choices {
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final boolean addTarget(final Player p) {
|
||||
if (!targetPlayers.contains(p)) {
|
||||
targetPlayers.add(p);
|
||||
numTargeted++;
|
||||
if (!this.targetPlayers.contains(p)) {
|
||||
this.targetPlayers.add(p);
|
||||
this.numTargeted++;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -99,9 +99,9 @@ public class Target_Choices {
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final boolean addTarget(final SpellAbility sa) {
|
||||
if (!targetSAs.contains(sa)) {
|
||||
targetSAs.add(sa);
|
||||
numTargeted++;
|
||||
if (!this.targetSAs.contains(sa)) {
|
||||
this.targetSAs.add(sa);
|
||||
this.numTargeted++;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -115,7 +115,7 @@ public class Target_Choices {
|
||||
* @return a {@link java.util.ArrayList} object.
|
||||
*/
|
||||
public final ArrayList<Card> getTargetCards() {
|
||||
return targetCards;
|
||||
return this.targetCards;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -126,7 +126,7 @@ public class Target_Choices {
|
||||
* @return a {@link java.util.ArrayList} object.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
public final ArrayList<Object> getTargets() {
|
||||
ArrayList<Object> tgts = new ArrayList<Object>();
|
||||
tgts.addAll(targetPlayers);
|
||||
tgts.addAll(targetCards);
|
||||
tgts.addAll(targetSAs);
|
||||
final ArrayList<Object> tgts = new ArrayList<Object>();
|
||||
tgts.addAll(this.targetPlayers);
|
||||
tgts.addAll(this.targetCards);
|
||||
tgts.addAll(this.targetSAs);
|
||||
|
||||
return tgts;
|
||||
}
|
||||
@@ -164,19 +164,19 @@ public class Target_Choices {
|
||||
* @return a {@link java.lang.String} object.
|
||||
*/
|
||||
public final String getTargetedString() {
|
||||
ArrayList<Object> tgts = getTargets();
|
||||
StringBuilder sb = new StringBuilder("");
|
||||
for (Object o : tgts) {
|
||||
final ArrayList<Object> tgts = this.getTargets();
|
||||
final StringBuilder sb = new StringBuilder("");
|
||||
for (final Object o : tgts) {
|
||||
if (o instanceof Player) {
|
||||
Player p = (Player) o;
|
||||
final Player p = (Player) o;
|
||||
sb.append(p.getName());
|
||||
}
|
||||
if (o instanceof Card) {
|
||||
Card c = (Card) o;
|
||||
final Card c = (Card) o;
|
||||
sb.append(c);
|
||||
}
|
||||
if (o instanceof SpellAbility) {
|
||||
SpellAbility sa = (SpellAbility) o;
|
||||
final SpellAbility sa = (SpellAbility) o;
|
||||
sb.append(sa);
|
||||
}
|
||||
sb.append(" ");
|
||||
|
||||
@@ -39,7 +39,7 @@ public class Target_Selection {
|
||||
* @return a {@link forge.card.spellability.Target} object.
|
||||
*/
|
||||
public final Target getTgt() {
|
||||
return target;
|
||||
return this.target;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -50,7 +50,7 @@ public class Target_Selection {
|
||||
* @return a {@link forge.card.spellability.SpellAbility} object.
|
||||
*/
|
||||
public final SpellAbility getAbility() {
|
||||
return ability;
|
||||
return this.ability;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,7 +61,7 @@ public class Target_Selection {
|
||||
* @return a {@link forge.Card} object.
|
||||
*/
|
||||
public final Card getCard() {
|
||||
return card;
|
||||
return this.card;
|
||||
}
|
||||
|
||||
private SpellAbility_Requirements req = null;
|
||||
@@ -76,7 +76,7 @@ public class Target_Selection {
|
||||
* object.
|
||||
*/
|
||||
public final void setRequirements(final SpellAbility_Requirements reqs) {
|
||||
req = reqs;
|
||||
this.req = reqs;
|
||||
}
|
||||
|
||||
private boolean bCancel = false;
|
||||
@@ -90,7 +90,7 @@ public class Target_Selection {
|
||||
* a boolean.
|
||||
*/
|
||||
public final void setCancel(final boolean done) {
|
||||
bCancel = done;
|
||||
this.bCancel = done;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -101,15 +101,15 @@ public class Target_Selection {
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final boolean isCanceled() {
|
||||
if (bCancel) {
|
||||
return bCancel;
|
||||
if (this.bCancel) {
|
||||
return this.bCancel;
|
||||
}
|
||||
|
||||
if (subSelection == null) {
|
||||
if (this.subSelection == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return subSelection.isCanceled();
|
||||
return this.subSelection.isCanceled();
|
||||
}
|
||||
|
||||
private boolean bDoneTarget = false;
|
||||
@@ -123,7 +123,7 @@ public class Target_Selection {
|
||||
* a boolean.
|
||||
*/
|
||||
public final void setDoneTarget(final boolean done) {
|
||||
bDoneTarget = done;
|
||||
this.bDoneTarget = done;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -137,9 +137,9 @@ public class Target_Selection {
|
||||
* a {@link forge.card.spellability.SpellAbility} object.
|
||||
*/
|
||||
public Target_Selection(final Target tgt, final SpellAbility sa) {
|
||||
target = tgt;
|
||||
ability = sa;
|
||||
card = sa.getSourceCard();
|
||||
this.target = tgt;
|
||||
this.ability = sa;
|
||||
this.card = sa.getSourceCard();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -150,10 +150,10 @@ public class Target_Selection {
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final boolean doesTarget() {
|
||||
if (target == null) {
|
||||
if (this.target == null) {
|
||||
return false;
|
||||
}
|
||||
return target.doesTarget();
|
||||
return this.target.doesTarget();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -162,8 +162,8 @@ public class Target_Selection {
|
||||
* </p>
|
||||
*/
|
||||
public final void resetTargets() {
|
||||
if (target != null) {
|
||||
target.resetTargets();
|
||||
if (this.target != null) {
|
||||
this.target.resetTargets();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,28 +176,28 @@ public class Target_Selection {
|
||||
*/
|
||||
public final boolean chooseTargets() {
|
||||
// if not enough targets chosen, reset and cancel Ability
|
||||
if (bCancel || (bDoneTarget && !target.isMinTargetsChosen(card, ability))) {
|
||||
bCancel = true;
|
||||
req.finishedTargeting();
|
||||
if (this.bCancel || (this.bDoneTarget && !this.target.isMinTargetsChosen(this.card, this.ability))) {
|
||||
this.bCancel = true;
|
||||
this.req.finishedTargeting();
|
||||
return false;
|
||||
} else if (!doesTarget() || bDoneTarget && target.isMinTargetsChosen(card, ability)
|
||||
|| target.isMaxTargetsChosen(card, ability)) {
|
||||
Ability_Sub abSub = ability.getSubAbility();
|
||||
} else if (!this.doesTarget() || (this.bDoneTarget && this.target.isMinTargetsChosen(this.card, this.ability))
|
||||
|| this.target.isMaxTargetsChosen(this.card, this.ability)) {
|
||||
final Ability_Sub abSub = this.ability.getSubAbility();
|
||||
|
||||
if (abSub == null) {
|
||||
// if no more SubAbilities finish targeting
|
||||
req.finishedTargeting();
|
||||
this.req.finishedTargeting();
|
||||
return true;
|
||||
} else {
|
||||
// Has Sub Ability
|
||||
subSelection = new Target_Selection(abSub.getTarget(), abSub);
|
||||
subSelection.setRequirements(req);
|
||||
subSelection.resetTargets();
|
||||
return subSelection.chooseTargets();
|
||||
this.subSelection = new Target_Selection(abSub.getTarget(), abSub);
|
||||
this.subSelection.setRequirements(this.req);
|
||||
this.subSelection.resetTargets();
|
||||
return this.subSelection.chooseTargets();
|
||||
}
|
||||
}
|
||||
|
||||
chooseValidInput();
|
||||
this.chooseValidInput();
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -210,7 +210,7 @@ public class Target_Selection {
|
||||
* @return the unique targets
|
||||
*/
|
||||
public final ArrayList<Object> getUniqueTargets(final SpellAbility ability) {
|
||||
ArrayList<Object> targets = new ArrayList<Object>();
|
||||
final ArrayList<Object> targets = new ArrayList<Object>();
|
||||
SpellAbility child = ability;
|
||||
while (child instanceof Ability_Sub) {
|
||||
child = ((Ability_Sub) child).getParent();
|
||||
@@ -231,41 +231,41 @@ public class Target_Selection {
|
||||
* </p>
|
||||
*/
|
||||
public final void chooseValidInput() {
|
||||
Target tgt = this.getTgt();
|
||||
List<Zone> zone = tgt.getZone();
|
||||
final boolean mandatory = target.getMandatory() ? target.hasCandidates(true) : false;
|
||||
final Target tgt = this.getTgt();
|
||||
final List<Zone> zone = tgt.getZone();
|
||||
final boolean mandatory = this.target.getMandatory() ? this.target.hasCandidates(true) : false;
|
||||
|
||||
if (zone.contains(Constant.Zone.Stack) && zone.size() == 1) {
|
||||
if (zone.contains(Constant.Zone.Stack) && (zone.size() == 1)) {
|
||||
// If Zone is Stack, the choices are handled slightly differently
|
||||
chooseCardFromStack(mandatory);
|
||||
this.chooseCardFromStack(mandatory);
|
||||
return;
|
||||
}
|
||||
|
||||
CardList choices = AllZoneUtil.getCardsIn(zone).getValidCards(target.getValidTgts(),
|
||||
ability.getActivatingPlayer(), ability.getSourceCard());
|
||||
final CardList choices = AllZoneUtil.getCardsIn(zone).getValidCards(this.target.getValidTgts(),
|
||||
this.ability.getActivatingPlayer(), this.ability.getSourceCard());
|
||||
|
||||
ArrayList<Object> objects = new ArrayList<Object>();
|
||||
if (tgt.isUniqueTargets()) {
|
||||
objects = getUniqueTargets(ability);
|
||||
for (Object o : objects) {
|
||||
if (o instanceof Card && objects.contains(o)) {
|
||||
objects = this.getUniqueTargets(this.ability);
|
||||
for (final Object o : objects) {
|
||||
if ((o instanceof Card) && objects.contains(o)) {
|
||||
choices.remove((Card) o);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Remove cards already targeted
|
||||
ArrayList<Card> targeted = tgt.getTargetCards();
|
||||
for (Card c : targeted) {
|
||||
final ArrayList<Card> targeted = tgt.getTargetCards();
|
||||
for (final Card c : targeted) {
|
||||
if (choices.contains(c)) {
|
||||
choices.remove(c);
|
||||
}
|
||||
}
|
||||
|
||||
if (zone.contains(Constant.Zone.Battlefield)) {
|
||||
AllZone.getInputControl().setInput(input_targetSpecific(choices, true, mandatory, objects));
|
||||
AllZone.getInputControl().setInput(this.inputTargetSpecific(choices, true, mandatory, objects));
|
||||
} else {
|
||||
chooseCardFromList(choices, true, mandatory);
|
||||
this.chooseCardFromList(choices, true, mandatory);
|
||||
}
|
||||
} // input_targetValid
|
||||
|
||||
@@ -285,22 +285,21 @@ public class Target_Selection {
|
||||
* the already targeted
|
||||
* @return a {@link forge.gui.input.Input} object.
|
||||
*/
|
||||
public final Input input_targetSpecific(final CardList choices,
|
||||
final boolean targeted, final boolean mandatory,
|
||||
public final Input inputTargetSpecific(final CardList choices, final boolean targeted, final boolean mandatory,
|
||||
final ArrayList<Object> alreadyTargeted) {
|
||||
final SpellAbility sa = this.ability;
|
||||
final Target_Selection select = this;
|
||||
final Target tgt = this.target;
|
||||
final SpellAbility_Requirements req = this.req;
|
||||
|
||||
Input target = new Input() {
|
||||
final Input target = new Input() {
|
||||
private static final long serialVersionUID = -1091595663541356356L;
|
||||
|
||||
@Override
|
||||
public void showMessage() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append("Targeted: ");
|
||||
for (Object o : alreadyTargeted) {
|
||||
for (final Object o : alreadyTargeted) {
|
||||
sb.append(o).append(" ");
|
||||
}
|
||||
sb.append(tgt.getTargetedString());
|
||||
@@ -324,14 +323,14 @@ public class Target_Selection {
|
||||
@Override
|
||||
public void selectButtonCancel() {
|
||||
select.setCancel(true);
|
||||
stop();
|
||||
this.stop();
|
||||
req.finishedTargeting();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectButtonOK() {
|
||||
select.setDoneTarget(true);
|
||||
done();
|
||||
this.done();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -342,7 +341,7 @@ public class Target_Selection {
|
||||
AllZone.getDisplay().showMessage("Cannot target this card (Shroud? Protection? Restrictions?).");
|
||||
} else if (choices.contains(card)) {
|
||||
tgt.addTarget(card);
|
||||
done();
|
||||
this.done();
|
||||
}
|
||||
} // selectCard()
|
||||
|
||||
@@ -355,12 +354,12 @@ public class Target_Selection {
|
||||
if ((tgt.canTgtPlayer() || (tgt.canOnlyTgtOpponent() && player.equals(sa.getActivatingPlayer()
|
||||
.getOpponent()))) && player.canTarget(sa)) {
|
||||
tgt.addTarget(player);
|
||||
done();
|
||||
this.done();
|
||||
}
|
||||
}
|
||||
|
||||
void done() {
|
||||
stop();
|
||||
this.stop();
|
||||
|
||||
select.chooseTargets();
|
||||
}
|
||||
@@ -388,16 +387,16 @@ public class Target_Selection {
|
||||
final SpellAbility sa = this.ability;
|
||||
final String message = this.target.getVTSelection();
|
||||
|
||||
Target tgt = this.getTgt();
|
||||
final Target tgt = this.getTgt();
|
||||
|
||||
CardList choicesWithDone = choices;
|
||||
final CardList choicesWithDone = choices;
|
||||
if (tgt.isMinTargetsChosen(sa.getSourceCard(), sa)) {
|
||||
// is there a more elegant way of doing this?
|
||||
choicesWithDone.add(dummy);
|
||||
}
|
||||
Object check = GuiUtils.getChoiceOptional(message, choicesWithDone.toArray());
|
||||
final Object check = GuiUtils.getChoiceOptional(message, choicesWithDone.toArray());
|
||||
if (check != null) {
|
||||
Card c = (Card) check;
|
||||
final Card c = (Card) check;
|
||||
if (c.equals(dummy)) {
|
||||
this.setDoneTarget(true);
|
||||
} else {
|
||||
@@ -419,16 +418,16 @@ public class Target_Selection {
|
||||
* a boolean.
|
||||
*/
|
||||
public final void chooseCardFromStack(final boolean mandatory) {
|
||||
Target tgt = this.target;
|
||||
String message = tgt.getVTSelection();
|
||||
Target_Selection select = this;
|
||||
final Target tgt = this.target;
|
||||
final String message = tgt.getVTSelection();
|
||||
final Target_Selection select = this;
|
||||
|
||||
// Find what's targetable, then allow human to choose
|
||||
ArrayList<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);
|
||||
}
|
||||
|
||||
@@ -438,7 +437,7 @@ public class Target_Selection {
|
||||
if (choices.length == 0) {
|
||||
select.setCancel(true);
|
||||
} else {
|
||||
String madeChoice = GuiUtils.getChoiceOptional(message, choices);
|
||||
final String madeChoice = GuiUtils.getChoiceOptional(message, choices);
|
||||
|
||||
if (madeChoice != null) {
|
||||
tgt.addTarget(map.get(madeChoice));
|
||||
@@ -465,14 +464,14 @@ public class Target_Selection {
|
||||
* @return a {@link java.util.ArrayList} object.
|
||||
*/
|
||||
public static ArrayList<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++) {
|
||||
choosables.add(AllZone.getStack().peekAbility(i));
|
||||
}
|
||||
|
||||
for (int i = 0; i < choosables.size(); i++) {
|
||||
if (!matchSpellAbility(sa, choosables.get(i), tgt)) {
|
||||
if (!Target_Selection.matchSpellAbility(sa, choosables.get(i), tgt)) {
|
||||
choosables.remove(i);
|
||||
}
|
||||
}
|
||||
@@ -493,7 +492,7 @@ public class Target_Selection {
|
||||
* @return a boolean.
|
||||
*/
|
||||
public static boolean matchSpellAbility(final SpellAbility sa, final SpellAbility topSA, final Target tgt) {
|
||||
String saType = tgt.getTargetSpellAbilityType();
|
||||
final String saType = tgt.getTargetSpellAbilityType();
|
||||
|
||||
if (null == saType) {
|
||||
// just take this to mean no restrictions - carry on.
|
||||
@@ -511,11 +510,11 @@ public class Target_Selection {
|
||||
}
|
||||
}
|
||||
|
||||
String splitTargetRestrictions = tgt.getSAValidTargeting();
|
||||
final String splitTargetRestrictions = tgt.getSAValidTargeting();
|
||||
if (splitTargetRestrictions != null) {
|
||||
// TODO What about spells with SubAbilities with Targets?
|
||||
|
||||
Target matchTgt = topSA.getTarget();
|
||||
final Target matchTgt = topSA.getTarget();
|
||||
|
||||
if (matchTgt == null) {
|
||||
return false;
|
||||
@@ -523,8 +522,8 @@ public class Target_Selection {
|
||||
|
||||
boolean result = false;
|
||||
|
||||
for (Object o : matchTgt.getTargets()) {
|
||||
if (matchesValid(o, splitTargetRestrictions.split(","), sa)) {
|
||||
for (final Object o : matchTgt.getTargets()) {
|
||||
if (Target_Selection.matchesValid(o, splitTargetRestrictions.split(","), sa)) {
|
||||
result = true;
|
||||
break;
|
||||
}
|
||||
@@ -535,7 +534,7 @@ public class Target_Selection {
|
||||
}
|
||||
}
|
||||
|
||||
if (!matchesValid(topSA, tgt.getValidTgts(), sa)) {
|
||||
if (!Target_Selection.matchesValid(topSA, tgt.getValidTgts(), sa)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -556,15 +555,15 @@ public class Target_Selection {
|
||||
* @return a boolean.
|
||||
*/
|
||||
private static boolean matchesValid(final Object o, final String[] valids, final SpellAbility sa) {
|
||||
Card srcCard = sa.getSourceCard();
|
||||
Player activatingPlayer = sa.getActivatingPlayer();
|
||||
final Card srcCard = sa.getSourceCard();
|
||||
final Player activatingPlayer = sa.getActivatingPlayer();
|
||||
if (o instanceof Card) {
|
||||
Card c = (Card) o;
|
||||
final Card c = (Card) o;
|
||||
return c.isValid(valids, activatingPlayer, srcCard);
|
||||
}
|
||||
|
||||
if (o instanceof Player) {
|
||||
for (String v : valids) {
|
||||
for (final String v : valids) {
|
||||
if (v.equalsIgnoreCase("Player")) {
|
||||
return true;
|
||||
}
|
||||
@@ -581,7 +580,7 @@ public class Target_Selection {
|
||||
}
|
||||
|
||||
if (o instanceof SpellAbility) {
|
||||
Card c = ((SpellAbility) o).getSourceCard();
|
||||
final Card c = ((SpellAbility) o).getSourceCard();
|
||||
return c.isValid(valids, activatingPlayer, srcCard);
|
||||
}
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ public class Input_PayManaCost_Ability extends Input {
|
||||
public Input_PayManaCost_Ability(final String m, final String manaCost_2,
|
||||
final Command paidCommand_2, final Command unpaidCommand_2,
|
||||
final boolean showOKButton) {
|
||||
fakeAbility = new SpellAbility(SpellAbility.Ability, null) {
|
||||
fakeAbility = new SpellAbility(SpellAbility.getAbility(), null) {
|
||||
@Override
|
||||
public void resolve() {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user