- Costs should not use the terminology "Targeting" since that means something very distinct in Magic

This commit is contained in:
Sol
2013-03-12 02:19:45 +00:00
parent 6ec78bb5d6
commit 60d98a0c12
11 changed files with 36 additions and 36 deletions

View File

@@ -180,7 +180,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
if (part instanceof CostDiscard) { if (part instanceof CostDiscard) {
CostDiscard cd = (CostDiscard) part; CostDiscard cd = (CostDiscard) part;
// this is mainly for typecycling // this is mainly for typecycling
if (!cd.isTargetingThis() || !ComputerUtil.isWorseThanDraw(ai, source)) { if (!cd.payCostFromSource() || !ComputerUtil.isWorseThanDraw(ai, source)) {
return false; return false;
} }
} }

View File

@@ -87,7 +87,7 @@ public class DestroyAi extends SpellAbilityAi {
continue; continue;
} }
CostSacrifice sacCost = (CostSacrifice) part; CostSacrifice sacCost = (CostSacrifice) part;
if (sacCost.isTargetingThis() && ComputerUtilCost.canPayCost(ability, c.getController())) { if (sacCost.payCostFromSource() && ComputerUtilCost.canPayCost(ability, c.getController())) {
return false; return false;
} }
} }

View File

@@ -70,7 +70,7 @@ public class CostDiscard extends CostPartWithList {
final Integer i = this.convertAmount(); final Integer i = this.convertAmount();
if (this.isTargetingThis()) { if (this.payCostFromSource()) {
sb.append(this.getType()); sb.append(this.getType());
} else if (this.getType().equals("Hand")) { } else if (this.getType().equals("Hand")) {
sb.append("your hand"); sb.append("your hand");
@@ -109,7 +109,7 @@ public class CostDiscard extends CostPartWithList {
String type = this.getType(); String type = this.getType();
final Integer amount = this.convertAmount(); final Integer amount = this.convertAmount();
if (this.isTargetingThis()) { if (this.payCostFromSource()) {
if (!source.isInZone(ZoneType.Hand)) { if (!source.isInZone(ZoneType.Hand)) {
return false; return false;
} }
@@ -175,7 +175,7 @@ public class CostDiscard extends CostPartWithList {
final String amount = this.getAmount(); final String amount = this.getAmount();
this.resetList(); this.resetList();
if (this.isTargetingThis()) { if (this.payCostFromSource()) {
if (!handList.contains(source)) { if (!handList.contains(source)) {
return false; return false;
} }
@@ -273,7 +273,7 @@ public class CostDiscard extends CostPartWithList {
this.addToList(ai.getLastDrawnCard()); this.addToList(ai.getLastDrawnCard());
} }
else if (this.isTargetingThis()) { else if (this.payCostFromSource()) {
if (!hand.contains(source)) { if (!hand.contains(source)) {
return false; return false;
} }

View File

@@ -493,7 +493,7 @@ public class CostExile extends CostPartWithList {
final Integer i = this.convertAmount(); final Integer i = this.convertAmount();
sb.append("Exile "); sb.append("Exile ");
if (this.isTargetingThis()) { if (this.payCostFromSource()) {
sb.append(this.getType()); sb.append(this.getType());
if (!this.from.equals(ZoneType.Battlefield)) { if (!this.from.equals(ZoneType.Battlefield)) {
sb.append(" from your ").append(this.from); sb.append(" from your ").append(this.from);
@@ -508,7 +508,7 @@ public class CostExile extends CostPartWithList {
final String desc = this.getTypeDescription() == null ? this.getType() : this.getTypeDescription(); final String desc = this.getTypeDescription() == null ? this.getType() : this.getTypeDescription();
sb.append(Cost.convertAmountTypeToWords(i, this.getAmount(), desc)); sb.append(Cost.convertAmountTypeToWords(i, this.getAmount(), desc));
if (!this.isTargetingThis()) { if (!this.payCostFromSource()) {
sb.append(" you control"); sb.append(" you control");
} }
return sb.toString(); return sb.toString();
@@ -562,7 +562,7 @@ public class CostExile extends CostPartWithList {
typeList = new ArrayList<Card>(activator.getCardsIn(this.getFrom())); typeList = new ArrayList<Card>(activator.getCardsIn(this.getFrom()));
} }
} }
if (!this.isTargetingThis()) { if (!this.payCostFromSource()) {
typeList = CardLists.getValidCards(typeList, this.getType().split(";"), activator, source); typeList = CardLists.getValidCards(typeList, this.getType().split(";"), activator, source);
final Integer amount = this.convertAmount(); final Integer amount = this.convertAmount();
@@ -653,7 +653,7 @@ public class CostExile extends CostPartWithList {
} }
Input target = null; Input target = null;
if (this.isTargetingThis()) { if (this.payCostFromSource()) {
target = new InputExileThis(payment, this, ability); target = new InputExileThis(payment, this, ability);
} else if (this.from.equals(ZoneType.Battlefield) || this.from.equals(ZoneType.Hand)) { } else if (this.from.equals(ZoneType.Battlefield) || this.from.equals(ZoneType.Hand)) {
target = new InputExileType(this, payment, this.getType(), c, ability); target = new InputExileType(this, payment, this.getType(), c, ability);
@@ -692,7 +692,7 @@ public class CostExile extends CostPartWithList {
@Override @Override
public final boolean decideAIPayment(final AIPlayer ai, final SpellAbility ability, final Card source, final CostPayment payment) { public final boolean decideAIPayment(final AIPlayer ai, final SpellAbility ability, final Card source, final CostPayment payment) {
this.resetList(); this.resetList();
if (this.isTargetingThis()) { if (this.payCostFromSource()) {
this.getList().add(source); this.getList().add(source);
} else if (this.getType().equals("All")) { } else if (this.getType().equals("All")) {
this.setList(new ArrayList<Card>(ability.getActivatingPlayer().getCardsIn(this.getFrom()))); this.setList(new ArrayList<Card>(ability.getActivatingPlayer().getCardsIn(this.getFrom())));

View File

@@ -87,7 +87,7 @@ public abstract class CostPart {
* *
* @return the this * @return the this
*/ */
public final boolean isTargetingThis() { public final boolean payCostFromSource() {
return this.getType().equals("CARDNAME"); return this.getType().equals("CARDNAME");
} }

View File

@@ -98,7 +98,7 @@ public class CostPutCounter extends CostPartWithList {
sb.append(Cost.convertAmountTypeToWords(i, this.getAmount(), this.counter.getName() + " counter")); sb.append(Cost.convertAmountTypeToWords(i, this.getAmount(), this.counter.getName() + " counter"));
sb.append(" on "); sb.append(" on ");
if (this.isTargetingThis()) { if (this.payCostFromSource()) {
sb.append(this.getType()); sb.append(this.getType());
} else { } else {
final String desc = this.getTypeDescription() == null ? this.getType() : this.getTypeDescription(); final String desc = this.getTypeDescription() == null ? this.getType() : this.getTypeDescription();
@@ -129,7 +129,7 @@ public class CostPutCounter extends CostPartWithList {
*/ */
@Override @Override
public final boolean canPay(final SpellAbility ability, final Card source, final Player activator, final Cost cost, final GameState game) { public final boolean canPay(final SpellAbility ability, final Card source, final Player activator, final Cost cost, final GameState game) {
if (this.isTargetingThis()) { if (this.payCostFromSource()) {
if (source.hasKeyword("CARDNAME can't have counters placed on it.")) { if (source.hasKeyword("CARDNAME can't have counters placed on it.")) {
return false; return false;
} }
@@ -162,7 +162,7 @@ public class CostPutCounter extends CostPartWithList {
c = AbilityUtils.calculateAmount(source, this.getAmount(), ability); c = AbilityUtils.calculateAmount(source, this.getAmount(), ability);
} }
if (this.isTargetingThis()) { if (this.payCostFromSource()) {
source.addCounter(this.getCounter(), c, false); source.addCounter(this.getCounter(), c, false);
} else { } else {
// Put counter on chosen card // Put counter on chosen card
@@ -186,7 +186,7 @@ public class CostPutCounter extends CostPartWithList {
c = AbilityUtils.calculateAmount(source, this.getAmount(), ability); c = AbilityUtils.calculateAmount(source, this.getAmount(), ability);
} }
if (this.isTargetingThis()) { if (this.payCostFromSource()) {
source.addCounter(this.getCounter(), c, false); source.addCounter(this.getCounter(), c, false);
payment.setPaidManaPart(this); payment.setPaidManaPart(this);
this.addToList(source); this.addToList(source);
@@ -208,7 +208,7 @@ public class CostPutCounter extends CostPartWithList {
@Override @Override
public final boolean decideAIPayment(final AIPlayer ai, final SpellAbility ability, final Card source, final CostPayment payment) { public final boolean decideAIPayment(final AIPlayer ai, final SpellAbility ability, final Card source, final CostPayment payment) {
this.resetList(); this.resetList();
if (this.isTargetingThis()) { if (this.payCostFromSource()) {
this.addToList(source); this.addToList(source);
return true; return true;
} else { } else {

View File

@@ -131,7 +131,7 @@ public class CostRemoveCounter extends CostPartWithList {
sb.append(" from "); sb.append(" from ");
if (this.isTargetingThis()) { if (this.payCostFromSource()) {
sb.append(this.getType()); sb.append(this.getType());
} else { } else {
final String desc = this.getTypeDescription() == null ? this.getType() : this.getTypeDescription(); final String desc = this.getTypeDescription() == null ? this.getType() : this.getTypeDescription();
@@ -166,7 +166,7 @@ public class CostRemoveCounter extends CostPartWithList {
final CounterType cntrs = this.getCounter(); final CounterType cntrs = this.getCounter();
final Integer amount = this.convertAmount(); final Integer amount = this.convertAmount();
if (this.isTargetingThis()) { if (this.payCostFromSource()) {
if ((amount != null) && ((source.getCounters(cntrs) - amount) < 0)) { if ((amount != null) && ((source.getCounters(cntrs) - amount) < 0)) {
return false; return false;
} }
@@ -204,7 +204,7 @@ public class CostRemoveCounter extends CostPartWithList {
} }
} }
if (this.isTargetingThis()) { if (this.payCostFromSource()) {
source.subtractCounter(this.counter, c); source.subtractCounter(this.counter, c);
} else { } else {
for (final Card card : this.getList()) { for (final Card card : this.getList()) {
@@ -227,7 +227,7 @@ public class CostRemoveCounter extends CostPartWithList {
Integer c = this.convertAmount(); Integer c = this.convertAmount();
int maxCounters = 0; int maxCounters = 0;
if (!this.isTargetingThis()) { if (!this.payCostFromSource()) {
if (c == null) { if (c == null) {
final String sVar = ability.getSVar(amount); final String sVar = ability.getSVar(amount);
// Generalize this // Generalize this
@@ -303,7 +303,7 @@ public class CostRemoveCounter extends CostPartWithList {
} }
} }
if (!this.isTargetingThis()) { if (!this.payCostFromSource()) {
this.getList().clear(); this.getList().clear();
final List<Card> typeList = final List<Card> typeList =
CardLists.getValidCards(ai.getCardsIn(this.getZone()), this.getType().split(";"), ai, source); CardLists.getValidCards(ai.getCardsIn(this.getZone()), this.getType().split(";"), ai, source);

View File

@@ -70,7 +70,7 @@ public class CostReturn extends CostPartWithList {
final Integer i = this.convertAmount(); final Integer i = this.convertAmount();
String pronoun = "its"; String pronoun = "its";
if (this.isTargetingThis()) { if (this.payCostFromSource()) {
sb.append(this.getType()); sb.append(this.getType());
} else { } else {
final String desc = this.getTypeDescription() == null ? this.getType() : this.getTypeDescription(); final String desc = this.getTypeDescription() == null ? this.getType() : this.getTypeDescription();
@@ -98,7 +98,7 @@ public class CostReturn extends CostPartWithList {
*/ */
@Override @Override
public final boolean canPay(final SpellAbility ability, final Card source, final Player activator, final Cost cost, final GameState game) { public final boolean canPay(final SpellAbility ability, final Card source, final Player activator, final Cost cost, final GameState game) {
if (!this.isTargetingThis()) { if (!this.payCostFromSource()) {
boolean needsAnnoucement = ability.hasParam("Announce") && this.getType().contains(ability.getParam("Announce")); boolean needsAnnoucement = ability.hasParam("Announce") && this.getType().contains(ability.getParam("Announce"));
List<Card> typeList = new ArrayList<Card>(activator.getCardsIn(ZoneType.Battlefield)); List<Card> typeList = new ArrayList<Card>(activator.getCardsIn(ZoneType.Battlefield));
@@ -150,7 +150,7 @@ public class CostReturn extends CostPartWithList {
c = AbilityUtils.calculateAmount(source, amount, ability); c = AbilityUtils.calculateAmount(source, amount, ability);
} }
} }
if (this.isTargetingThis()) { if (this.payCostFromSource()) {
final Input inp = CostReturn.returnThis(ability, payment, this); final Input inp = CostReturn.returnThis(ability, payment, this);
Singletons.getModel().getMatch().getInput().setInputInterrupt(inp); Singletons.getModel().getMatch().getInput().setInputInterrupt(inp);
} else { } else {
@@ -170,7 +170,7 @@ public class CostReturn extends CostPartWithList {
@Override @Override
public final boolean decideAIPayment(final AIPlayer ai, final SpellAbility ability, final Card source, final CostPayment payment) { public final boolean decideAIPayment(final AIPlayer ai, final SpellAbility ability, final Card source, final CostPayment payment) {
this.resetList(); this.resetList();
if (this.isTargetingThis()) { if (this.payCostFromSource()) {
this.getList().add(source); this.getList().add(source);
} else { } else {
Integer c = this.convertAmount(); Integer c = this.convertAmount();

View File

@@ -72,7 +72,7 @@ public class CostReveal extends CostPartWithList {
final String type = this.getType(); final String type = this.getType();
final Integer amount = this.convertAmount(); final Integer amount = this.convertAmount();
if (this.isTargetingThis()) { if (this.payCostFromSource()) {
if (!source.isInZone(ZoneType.Hand)) { if (!source.isInZone(ZoneType.Hand)) {
return false; return false;
} }
@@ -106,7 +106,7 @@ public class CostReveal extends CostPartWithList {
List<Card> hand = new ArrayList<Card>(ai.getCardsIn(ZoneType.Hand)); List<Card> hand = new ArrayList<Card>(ai.getCardsIn(ZoneType.Hand));
this.resetList(); this.resetList();
if (this.isTargetingThis()) { if (this.payCostFromSource()) {
if (!hand.contains(source)) { if (!hand.contains(source)) {
return false; return false;
} }
@@ -156,7 +156,7 @@ public class CostReveal extends CostPartWithList {
final String amount = this.getAmount(); final String amount = this.getAmount();
this.resetList(); this.resetList();
if (this.isTargetingThis()) { if (this.payCostFromSource()) {
this.addToList(source); this.addToList(source);
payment.setPaidManaPart(this); payment.setPaidManaPart(this);
} else if (this.getType().equals("Hand")) { } else if (this.getType().equals("Hand")) {
@@ -200,7 +200,7 @@ public class CostReveal extends CostPartWithList {
final Integer i = this.convertAmount(); final Integer i = this.convertAmount();
if (this.isTargetingThis()) { if (this.payCostFromSource()) {
sb.append(this.getType()); sb.append(this.getType());
} else if (this.getType().equals("Hand")) { } else if (this.getType().equals("Hand")) {
return ("Reveal you hand"); return ("Reveal you hand");

View File

@@ -68,7 +68,7 @@ public class CostSacrifice extends CostPartWithList {
final Integer i = this.convertAmount(); final Integer i = this.convertAmount();
if (this.isTargetingThis()) { if (this.payCostFromSource()) {
sb.append(this.getType()); sb.append(this.getType());
} else { } else {
final String desc = this.getTypeDescription() == null ? this.getType() : this.getTypeDescription(); final String desc = this.getTypeDescription() == null ? this.getType() : this.getTypeDescription();
@@ -91,7 +91,7 @@ public class CostSacrifice extends CostPartWithList {
@Override @Override
public final boolean canPay(final SpellAbility ability, final Card source, final Player activator, final Cost cost, final GameState game) { public final boolean canPay(final SpellAbility ability, final Card source, final Player activator, final Cost cost, final GameState game) {
// You can always sac all // You can always sac all
if (!this.isTargetingThis()) { if (!this.payCostFromSource()) {
// If the sacrificed type is dependant on an annoucement, can't necesarily rule out the CanPlay call // If the sacrificed type is dependant on an annoucement, can't necesarily rule out the CanPlay call
boolean needsAnnoucement = ability.hasParam("Announce") && this.getType().contains(ability.getParam("Announce")); boolean needsAnnoucement = ability.hasParam("Announce") && this.getType().contains(ability.getParam("Announce"));
@@ -155,7 +155,7 @@ public class CostSacrifice extends CostPartWithList {
list = CardLists.getNotType(list, "Creature"); list = CardLists.getNotType(list, "Creature");
} }
if (this.isTargetingThis()) { if (this.payCostFromSource()) {
final Input inp = CostSacrifice.sacrificeThis(ability, payment, this); final Input inp = CostSacrifice.sacrificeThis(ability, payment, this);
Singletons.getModel().getMatch().getInput().setInputInterrupt(inp); Singletons.getModel().getMatch().getInput().setInputInterrupt(inp);
} else if (amount.equals("All")) { } else if (amount.equals("All")) {
@@ -196,7 +196,7 @@ public class CostSacrifice extends CostPartWithList {
public final boolean decideAIPayment(final AIPlayer ai, final SpellAbility ability, final Card source, final CostPayment payment) { public final boolean decideAIPayment(final AIPlayer ai, final SpellAbility ability, final Card source, final CostPayment payment) {
this.resetList(); this.resetList();
final Player activator = ability.getActivatingPlayer(); final Player activator = ability.getActivatingPlayer();
if (this.isTargetingThis()) { if (this.payCostFromSource()) {
this.getList().add(source); this.getList().add(source);
} else if (this.getAmount().equals("All")) { } else if (this.getAmount().equals("All")) {
/*List<Card> typeList = new ArrayList<Card>(activator.getCardsIn(ZoneType.Battlefield)); /*List<Card> typeList = new ArrayList<Card>(activator.getCardsIn(ZoneType.Battlefield));

View File

@@ -86,7 +86,7 @@ public class ComputerUtilCost {
final CounterType type = remCounter.getCounter(); final CounterType type = remCounter.getCounter();
final double percent = type.name().equals("P1P1") ? p1p1Percent : otherPercent; final double percent = type.name().equals("P1P1") ? p1p1Percent : otherPercent;
final int currentNum = source.getCounters(type); final int currentNum = source.getCounters(type);
if (!part.isTargetingThis()) { if (!part.payCostFromSource()) {
if (type.name().equals("P1P1")) { if (type.name().equals("P1P1")) {
return false; return false;
} }
@@ -224,7 +224,7 @@ public class ComputerUtilCost {
for (final CostPart part : cost.getCostParts()) { for (final CostPart part : cost.getCostParts()) {
if (part instanceof CostSacrifice) { if (part instanceof CostSacrifice) {
final CostSacrifice sac = (CostSacrifice) part; final CostSacrifice sac = (CostSacrifice) part;
if (sac.isTargetingThis() && source.isCreature()) { if (sac.payCostFromSource() && source.isCreature()) {
return false; return false;
} }
final String type = sac.getType(); final String type = sac.getType();