diff --git a/src/main/java/forge/card/ability/ai/ChangeZoneAi.java b/src/main/java/forge/card/ability/ai/ChangeZoneAi.java index 7ae758ddf9c..b9d572d06bf 100644 --- a/src/main/java/forge/card/ability/ai/ChangeZoneAi.java +++ b/src/main/java/forge/card/ability/ai/ChangeZoneAi.java @@ -180,7 +180,7 @@ public class ChangeZoneAi extends SpellAbilityAi { if (part instanceof CostDiscard) { CostDiscard cd = (CostDiscard) part; // this is mainly for typecycling - if (!cd.isTargetingThis() || !ComputerUtil.isWorseThanDraw(ai, source)) { + if (!cd.payCostFromSource() || !ComputerUtil.isWorseThanDraw(ai, source)) { return false; } } diff --git a/src/main/java/forge/card/ability/ai/DestroyAi.java b/src/main/java/forge/card/ability/ai/DestroyAi.java index c02550c868a..11b6058be3a 100644 --- a/src/main/java/forge/card/ability/ai/DestroyAi.java +++ b/src/main/java/forge/card/ability/ai/DestroyAi.java @@ -87,7 +87,7 @@ public class DestroyAi extends SpellAbilityAi { continue; } CostSacrifice sacCost = (CostSacrifice) part; - if (sacCost.isTargetingThis() && ComputerUtilCost.canPayCost(ability, c.getController())) { + if (sacCost.payCostFromSource() && ComputerUtilCost.canPayCost(ability, c.getController())) { return false; } } diff --git a/src/main/java/forge/card/cost/CostDiscard.java b/src/main/java/forge/card/cost/CostDiscard.java index a07e283391e..e51fb9f0c9d 100644 --- a/src/main/java/forge/card/cost/CostDiscard.java +++ b/src/main/java/forge/card/cost/CostDiscard.java @@ -70,7 +70,7 @@ public class CostDiscard extends CostPartWithList { final Integer i = this.convertAmount(); - if (this.isTargetingThis()) { + if (this.payCostFromSource()) { sb.append(this.getType()); } else if (this.getType().equals("Hand")) { sb.append("your hand"); @@ -109,7 +109,7 @@ public class CostDiscard extends CostPartWithList { String type = this.getType(); final Integer amount = this.convertAmount(); - if (this.isTargetingThis()) { + if (this.payCostFromSource()) { if (!source.isInZone(ZoneType.Hand)) { return false; } @@ -175,7 +175,7 @@ public class CostDiscard extends CostPartWithList { final String amount = this.getAmount(); this.resetList(); - if (this.isTargetingThis()) { + if (this.payCostFromSource()) { if (!handList.contains(source)) { return false; } @@ -273,7 +273,7 @@ public class CostDiscard extends CostPartWithList { this.addToList(ai.getLastDrawnCard()); } - else if (this.isTargetingThis()) { + else if (this.payCostFromSource()) { if (!hand.contains(source)) { return false; } diff --git a/src/main/java/forge/card/cost/CostExile.java b/src/main/java/forge/card/cost/CostExile.java index db2ec4875d9..f215fbcb336 100644 --- a/src/main/java/forge/card/cost/CostExile.java +++ b/src/main/java/forge/card/cost/CostExile.java @@ -493,7 +493,7 @@ public class CostExile extends CostPartWithList { final Integer i = this.convertAmount(); sb.append("Exile "); - if (this.isTargetingThis()) { + if (this.payCostFromSource()) { sb.append(this.getType()); if (!this.from.equals(ZoneType.Battlefield)) { 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(); sb.append(Cost.convertAmountTypeToWords(i, this.getAmount(), desc)); - if (!this.isTargetingThis()) { + if (!this.payCostFromSource()) { sb.append(" you control"); } return sb.toString(); @@ -562,7 +562,7 @@ public class CostExile extends CostPartWithList { typeList = new ArrayList(activator.getCardsIn(this.getFrom())); } } - if (!this.isTargetingThis()) { + if (!this.payCostFromSource()) { typeList = CardLists.getValidCards(typeList, this.getType().split(";"), activator, source); final Integer amount = this.convertAmount(); @@ -653,7 +653,7 @@ public class CostExile extends CostPartWithList { } Input target = null; - if (this.isTargetingThis()) { + if (this.payCostFromSource()) { target = new InputExileThis(payment, this, ability); } else if (this.from.equals(ZoneType.Battlefield) || this.from.equals(ZoneType.Hand)) { target = new InputExileType(this, payment, this.getType(), c, ability); @@ -692,7 +692,7 @@ public class CostExile extends CostPartWithList { @Override public final boolean decideAIPayment(final AIPlayer ai, final SpellAbility ability, final Card source, final CostPayment payment) { this.resetList(); - if (this.isTargetingThis()) { + if (this.payCostFromSource()) { this.getList().add(source); } else if (this.getType().equals("All")) { this.setList(new ArrayList(ability.getActivatingPlayer().getCardsIn(this.getFrom()))); diff --git a/src/main/java/forge/card/cost/CostPart.java b/src/main/java/forge/card/cost/CostPart.java index 64cbf34dec0..675d151f993 100644 --- a/src/main/java/forge/card/cost/CostPart.java +++ b/src/main/java/forge/card/cost/CostPart.java @@ -87,7 +87,7 @@ public abstract class CostPart { * * @return the this */ - public final boolean isTargetingThis() { + public final boolean payCostFromSource() { return this.getType().equals("CARDNAME"); } diff --git a/src/main/java/forge/card/cost/CostPutCounter.java b/src/main/java/forge/card/cost/CostPutCounter.java index 84a6ae0fa21..606da7070c9 100644 --- a/src/main/java/forge/card/cost/CostPutCounter.java +++ b/src/main/java/forge/card/cost/CostPutCounter.java @@ -98,7 +98,7 @@ public class CostPutCounter extends CostPartWithList { sb.append(Cost.convertAmountTypeToWords(i, this.getAmount(), this.counter.getName() + " counter")); sb.append(" on "); - if (this.isTargetingThis()) { + if (this.payCostFromSource()) { sb.append(this.getType()); } else { final String desc = this.getTypeDescription() == null ? this.getType() : this.getTypeDescription(); @@ -129,7 +129,7 @@ public class CostPutCounter extends CostPartWithList { */ @Override 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.")) { return false; } @@ -162,7 +162,7 @@ public class CostPutCounter extends CostPartWithList { c = AbilityUtils.calculateAmount(source, this.getAmount(), ability); } - if (this.isTargetingThis()) { + if (this.payCostFromSource()) { source.addCounter(this.getCounter(), c, false); } else { // Put counter on chosen card @@ -186,7 +186,7 @@ public class CostPutCounter extends CostPartWithList { c = AbilityUtils.calculateAmount(source, this.getAmount(), ability); } - if (this.isTargetingThis()) { + if (this.payCostFromSource()) { source.addCounter(this.getCounter(), c, false); payment.setPaidManaPart(this); this.addToList(source); @@ -208,7 +208,7 @@ public class CostPutCounter extends CostPartWithList { @Override public final boolean decideAIPayment(final AIPlayer ai, final SpellAbility ability, final Card source, final CostPayment payment) { this.resetList(); - if (this.isTargetingThis()) { + if (this.payCostFromSource()) { this.addToList(source); return true; } else { diff --git a/src/main/java/forge/card/cost/CostRemoveCounter.java b/src/main/java/forge/card/cost/CostRemoveCounter.java index e8f8dd4b8ff..3c1c0a038e2 100644 --- a/src/main/java/forge/card/cost/CostRemoveCounter.java +++ b/src/main/java/forge/card/cost/CostRemoveCounter.java @@ -131,7 +131,7 @@ public class CostRemoveCounter extends CostPartWithList { sb.append(" from "); - if (this.isTargetingThis()) { + if (this.payCostFromSource()) { sb.append(this.getType()); } else { 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 Integer amount = this.convertAmount(); - if (this.isTargetingThis()) { + if (this.payCostFromSource()) { if ((amount != null) && ((source.getCounters(cntrs) - amount) < 0)) { return false; } @@ -204,7 +204,7 @@ public class CostRemoveCounter extends CostPartWithList { } } - if (this.isTargetingThis()) { + if (this.payCostFromSource()) { source.subtractCounter(this.counter, c); } else { for (final Card card : this.getList()) { @@ -227,7 +227,7 @@ public class CostRemoveCounter extends CostPartWithList { Integer c = this.convertAmount(); int maxCounters = 0; - if (!this.isTargetingThis()) { + if (!this.payCostFromSource()) { if (c == null) { final String sVar = ability.getSVar(amount); // Generalize this @@ -303,7 +303,7 @@ public class CostRemoveCounter extends CostPartWithList { } } - if (!this.isTargetingThis()) { + if (!this.payCostFromSource()) { this.getList().clear(); final List typeList = CardLists.getValidCards(ai.getCardsIn(this.getZone()), this.getType().split(";"), ai, source); diff --git a/src/main/java/forge/card/cost/CostReturn.java b/src/main/java/forge/card/cost/CostReturn.java index 18baa33084e..c020c5d30c2 100644 --- a/src/main/java/forge/card/cost/CostReturn.java +++ b/src/main/java/forge/card/cost/CostReturn.java @@ -70,7 +70,7 @@ public class CostReturn extends CostPartWithList { final Integer i = this.convertAmount(); String pronoun = "its"; - if (this.isTargetingThis()) { + if (this.payCostFromSource()) { sb.append(this.getType()); } else { final String desc = this.getTypeDescription() == null ? this.getType() : this.getTypeDescription(); @@ -98,7 +98,7 @@ public class CostReturn extends CostPartWithList { */ @Override 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")); List typeList = new ArrayList(activator.getCardsIn(ZoneType.Battlefield)); @@ -150,7 +150,7 @@ public class CostReturn extends CostPartWithList { c = AbilityUtils.calculateAmount(source, amount, ability); } } - if (this.isTargetingThis()) { + if (this.payCostFromSource()) { final Input inp = CostReturn.returnThis(ability, payment, this); Singletons.getModel().getMatch().getInput().setInputInterrupt(inp); } else { @@ -170,7 +170,7 @@ public class CostReturn extends CostPartWithList { @Override public final boolean decideAIPayment(final AIPlayer ai, final SpellAbility ability, final Card source, final CostPayment payment) { this.resetList(); - if (this.isTargetingThis()) { + if (this.payCostFromSource()) { this.getList().add(source); } else { Integer c = this.convertAmount(); diff --git a/src/main/java/forge/card/cost/CostReveal.java b/src/main/java/forge/card/cost/CostReveal.java index 0714f8356a0..80fab3eb8ee 100644 --- a/src/main/java/forge/card/cost/CostReveal.java +++ b/src/main/java/forge/card/cost/CostReveal.java @@ -72,7 +72,7 @@ public class CostReveal extends CostPartWithList { final String type = this.getType(); final Integer amount = this.convertAmount(); - if (this.isTargetingThis()) { + if (this.payCostFromSource()) { if (!source.isInZone(ZoneType.Hand)) { return false; } @@ -106,7 +106,7 @@ public class CostReveal extends CostPartWithList { List hand = new ArrayList(ai.getCardsIn(ZoneType.Hand)); this.resetList(); - if (this.isTargetingThis()) { + if (this.payCostFromSource()) { if (!hand.contains(source)) { return false; } @@ -156,7 +156,7 @@ public class CostReveal extends CostPartWithList { final String amount = this.getAmount(); this.resetList(); - if (this.isTargetingThis()) { + if (this.payCostFromSource()) { this.addToList(source); payment.setPaidManaPart(this); } else if (this.getType().equals("Hand")) { @@ -200,7 +200,7 @@ public class CostReveal extends CostPartWithList { final Integer i = this.convertAmount(); - if (this.isTargetingThis()) { + if (this.payCostFromSource()) { sb.append(this.getType()); } else if (this.getType().equals("Hand")) { return ("Reveal you hand"); diff --git a/src/main/java/forge/card/cost/CostSacrifice.java b/src/main/java/forge/card/cost/CostSacrifice.java index 1cf0433ba17..36d8a281860 100644 --- a/src/main/java/forge/card/cost/CostSacrifice.java +++ b/src/main/java/forge/card/cost/CostSacrifice.java @@ -68,7 +68,7 @@ public class CostSacrifice extends CostPartWithList { final Integer i = this.convertAmount(); - if (this.isTargetingThis()) { + if (this.payCostFromSource()) { sb.append(this.getType()); } else { final String desc = this.getTypeDescription() == null ? this.getType() : this.getTypeDescription(); @@ -91,7 +91,7 @@ public class CostSacrifice extends CostPartWithList { @Override public final boolean canPay(final SpellAbility ability, final Card source, final Player activator, final Cost cost, final GameState game) { // 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 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"); } - if (this.isTargetingThis()) { + if (this.payCostFromSource()) { final Input inp = CostSacrifice.sacrificeThis(ability, payment, this); Singletons.getModel().getMatch().getInput().setInputInterrupt(inp); } 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) { this.resetList(); final Player activator = ability.getActivatingPlayer(); - if (this.isTargetingThis()) { + if (this.payCostFromSource()) { this.getList().add(source); } else if (this.getAmount().equals("All")) { /*List typeList = new ArrayList(activator.getCardsIn(ZoneType.Battlefield)); diff --git a/src/main/java/forge/game/ai/ComputerUtilCost.java b/src/main/java/forge/game/ai/ComputerUtilCost.java index d3871332f0b..5e0b6d9cf00 100644 --- a/src/main/java/forge/game/ai/ComputerUtilCost.java +++ b/src/main/java/forge/game/ai/ComputerUtilCost.java @@ -86,7 +86,7 @@ public class ComputerUtilCost { final CounterType type = remCounter.getCounter(); final double percent = type.name().equals("P1P1") ? p1p1Percent : otherPercent; final int currentNum = source.getCounters(type); - if (!part.isTargetingThis()) { + if (!part.payCostFromSource()) { if (type.name().equals("P1P1")) { return false; } @@ -224,7 +224,7 @@ public class ComputerUtilCost { for (final CostPart part : cost.getCostParts()) { if (part instanceof CostSacrifice) { final CostSacrifice sac = (CostSacrifice) part; - if (sac.isTargetingThis() && source.isCreature()) { + if (sac.payCostFromSource() && source.isCreature()) { return false; } final String type = sac.getType();