mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 03:08:02 +00:00
replace .getZone().is with .isInZone, no null check needed
This commit is contained in:
committed by
Michael Kamensky
parent
6e2ac756c9
commit
773df25b53
@@ -1846,7 +1846,7 @@ public class AiController {
|
||||
// Special case for Bow to My Command which simulates a complex tap cost via ChooseCard
|
||||
// TODO: consider enhancing support for tapXType<Any/...> in UnlessCost to get rid of this hack
|
||||
if ("BowToMyCommand".equals(sa.getParam("AILogic"))) {
|
||||
if (!sa.getHostCard().getZone().is(ZoneType.Command)) {
|
||||
if (!sa.getHostCard().isInZone(ZoneType.Command)) {
|
||||
// Make sure that other opponents do not tap for an already abandoned scheme
|
||||
result.clear();
|
||||
break;
|
||||
|
||||
@@ -2403,7 +2403,7 @@ public class ComputerUtil {
|
||||
}
|
||||
// if source is not on the battlefield anymore, choose +1/+1
|
||||
// ones
|
||||
if (!game.getCardState(source).getZone().is(ZoneType.Battlefield)) {
|
||||
if (!game.getCardState(source).isInZone(ZoneType.Battlefield)) {
|
||||
return opponent ? "Feather" : "Quill";
|
||||
}
|
||||
// if no hand cards, try to mill opponent
|
||||
@@ -2435,7 +2435,7 @@ public class ComputerUtil {
|
||||
}
|
||||
|
||||
// if source is not on the battlefield anymore
|
||||
if (!game.getCardState(source).getZone().is(ZoneType.Battlefield)) {
|
||||
if (!game.getCardState(source).isInZone(ZoneType.Battlefield)) {
|
||||
return opponent ? "Strength" : "Numbers";
|
||||
}
|
||||
|
||||
@@ -2484,7 +2484,7 @@ public class ComputerUtil {
|
||||
}
|
||||
|
||||
// if source is not on the battlefield anymore
|
||||
if (!game.getCardState(source).getZone().is(ZoneType.Battlefield)) {
|
||||
if (!game.getCardState(source).isInZone(ZoneType.Battlefield)) {
|
||||
return opponent ? "Sprout" : "Harvest";
|
||||
}
|
||||
// TODO add Lifegain to +1/+1 counters trigger
|
||||
|
||||
@@ -1294,7 +1294,7 @@ public class ComputerUtilCard {
|
||||
// cast it during Declare Blockers, thus ruining its attacker
|
||||
if (holdCombatTricks && sa.getApi() == ApiType.Pump
|
||||
&& sa.hasParam("NumAtt") && sa.getHostCard() != null
|
||||
&& sa.getHostCard().getZone() != null && sa.getHostCard().getZone().is(ZoneType.Hand)
|
||||
&& sa.getHostCard().isInZone(ZoneType.Hand)
|
||||
&& c.getNetPower() > 0 // too obvious if attacking with a 0-power creature
|
||||
&& sa.getHostCard().isInstant() // only do it for instant speed spells in hand
|
||||
&& ComputerUtilMana.hasEnoughManaSourcesToCast(sa, ai)) {
|
||||
|
||||
@@ -729,7 +729,7 @@ public class PlayerControllerAi extends PlayerController {
|
||||
return true;
|
||||
} else {
|
||||
Card rem = (Card) source.getFirstRemembered();
|
||||
if (!rem.getZone().is(ZoneType.Battlefield)) {
|
||||
if (!rem.isInZone(ZoneType.Battlefield)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -737,7 +737,7 @@ public class PlayerControllerAi extends PlayerController {
|
||||
case "BetterTgtThanRemembered":
|
||||
if (source.getRememberedCount() > 0) {
|
||||
Card rem = (Card) source.getFirstRemembered();
|
||||
if (!rem.getZone().is(ZoneType.Battlefield)) {
|
||||
if (!rem.isInZone(ZoneType.Battlefield)) {
|
||||
return true;
|
||||
}
|
||||
for (Card c : source.getController().getCreaturesInPlay()) {
|
||||
|
||||
@@ -76,7 +76,7 @@ public class DamageDealAi extends DamageAiBase {
|
||||
// Set PayX here to maximum value.
|
||||
dmg = ComputerUtilMana.determineLeftoverMana(sa, ai);
|
||||
source.setSVar("PayX", Integer.toString(dmg));
|
||||
} else if (sa.getSVar(damage).equals("Count$CardsInYourHand") && source.getZone().is(ZoneType.Hand)) {
|
||||
} else if (sa.getSVar(damage).equals("Count$CardsInYourHand") && source.isInZone(ZoneType.Hand)) {
|
||||
dmg--; // the card will be spent casting the spell, so actual damage is 1 less
|
||||
}
|
||||
}
|
||||
@@ -113,7 +113,7 @@ public class DamageDealAi extends DamageAiBase {
|
||||
|
||||
// Set PayX here to maximum value. It will be adjusted later depending on the target.
|
||||
source.setSVar("PayX", Integer.toString(dmg));
|
||||
} else if (sa.getSVar(damage).contains("InYourHand") && source.getZone().is(ZoneType.Hand)) {
|
||||
} else if (sa.getSVar(damage).contains("InYourHand") && source.isInZone(ZoneType.Hand)) {
|
||||
dmg = CardFactoryUtil.xCount(source, sa.getSVar(damage)) - 1; // the card will be spent casting the spell, so actual damage is 1 less
|
||||
} else if (sa.getSVar(damage).equals("TargetedPlayer$CardsInHand")) {
|
||||
// cards that deal damage by the number of cards in target player's hand, e.g. Sudden Impact
|
||||
|
||||
@@ -409,7 +409,7 @@ public class DrawAi extends SpellAbilityAi {
|
||||
if (computerHandSize + numCards > computerMaxHandSize && game.getPhaseHandler().isPlayerTurn(ai)) {
|
||||
if (xPaid) {
|
||||
numCards = computerMaxHandSize - computerHandSize;
|
||||
if (sa.getHostCard().getZone().is(ZoneType.Hand)) {
|
||||
if (sa.getHostCard().isInZone(ZoneType.Hand)) {
|
||||
numCards++; // the card will be spent
|
||||
}
|
||||
source.setSVar("PayX", Integer.toString(numCards));
|
||||
|
||||
@@ -309,7 +309,7 @@ public class PumpAi extends PumpAiBase {
|
||||
}
|
||||
} else {
|
||||
defense = AbilityUtils.calculateAmount(sa.getHostCard(), numDefense, sa);
|
||||
if (numDefense.contains("X") && sa.getSVar("X").equals("Count$CardsInYourHand") && source.getZone().is(ZoneType.Hand)) {
|
||||
if (numDefense.contains("X") && sa.getSVar("X").equals("Count$CardsInYourHand") && source.isInZone(ZoneType.Hand)) {
|
||||
defense--; // the card will be spent casting the spell, so actual toughness is 1 less
|
||||
}
|
||||
}
|
||||
@@ -328,7 +328,7 @@ public class PumpAi extends PumpAiBase {
|
||||
}
|
||||
} else {
|
||||
attack = AbilityUtils.calculateAmount(sa.getHostCard(), numAttack, sa);
|
||||
if (numAttack.contains("X") && sa.getSVar("X").equals("Count$CardsInYourHand") && source.getZone().is(ZoneType.Hand)) {
|
||||
if (numAttack.contains("X") && sa.getSVar("X").equals("Count$CardsInYourHand") && source.isInZone(ZoneType.Hand)) {
|
||||
attack--; // the card will be spent casting the spell, so actual power is 1 less
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ public class SetStateAi extends SpellAbilityAi {
|
||||
if (card.isFaceDown()) {
|
||||
// hidden agenda
|
||||
if (card.getState(CardStateName.Original).hasIntrinsicKeyword("Hidden agenda")
|
||||
&& card.getZone().is(ZoneType.Command)) {
|
||||
&& card.isInZone(ZoneType.Command)) {
|
||||
String chosenName = card.getNamedCard();
|
||||
for (Card cast : ai.getGame().getStack().getSpellsCastThisTurn()) {
|
||||
if (cast.getController() == ai && cast.getName().equals(chosenName)) {
|
||||
|
||||
@@ -251,7 +251,7 @@ public class GameAction {
|
||||
}
|
||||
if(noLandLKI.isLand()) {
|
||||
// if it isn't on the Stack, it stays in that Zone
|
||||
if (!c.getZone().is(ZoneType.Stack)) {
|
||||
if (!c.isInZone(ZoneType.Stack)) {
|
||||
return c;
|
||||
}
|
||||
// if something would only be a land when entering the battlefield and not before
|
||||
|
||||
@@ -300,12 +300,12 @@ public final class GameActionUtil {
|
||||
costs.add(new OptionalCostValue(type, cost));
|
||||
}
|
||||
} else if (keyword.equals("Retrace")) {
|
||||
if (source.getZone().is(ZoneType.Graveyard)) {
|
||||
if (source.isInZone(ZoneType.Graveyard)) {
|
||||
final Cost cost = new Cost("Discard<1/Land>", false);
|
||||
costs.add(new OptionalCostValue(OptionalCost.Retrace, cost));
|
||||
}
|
||||
} else if (keyword.equals("Jump-start")) {
|
||||
if (source.getZone().is(ZoneType.Graveyard)) {
|
||||
if (source.isInZone(ZoneType.Graveyard)) {
|
||||
final Cost cost = new Cost("Discard<1/Card>", false);
|
||||
costs.add(new OptionalCostValue(OptionalCost.Jumpstart, cost));
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ public class CloneEffect extends SpellAbilityEffect {
|
||||
}
|
||||
|
||||
if (sa.hasParam("CloneZone")) {
|
||||
if (!tgtCard.getZone().is(ZoneType.smartValueOf(sa.getParam("CloneZone")))) {
|
||||
if (!tgtCard.isInZone(ZoneType.smartValueOf(sa.getParam("CloneZone")))) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -134,7 +134,7 @@ public class CloneEffect extends SpellAbilityEffect {
|
||||
tgtCard.clearImprintedCards();
|
||||
|
||||
// check if clone is now an Aura that needs to be attached
|
||||
if (tgtCard.isAura() && !tgtCard.getZone().is(ZoneType.Battlefield)) {
|
||||
if (tgtCard.isAura() && !tgtCard.isInZone(ZoneType.Battlefield)) {
|
||||
AttachEffect.attachAuraOnIndirectEnterBattlefield(tgtCard);
|
||||
}
|
||||
|
||||
|
||||
@@ -1850,7 +1850,7 @@ public class GameSimulatorTest extends SimulationTestCase {
|
||||
Card simSpark = (Card)sim.getGameCopier().find(sparkDouble);
|
||||
|
||||
assertNotNull(simSpark);
|
||||
assertTrue(simSpark.getZone().is(ZoneType.Battlefield));
|
||||
assertTrue(simSpark.isInZone(ZoneType.Battlefield));
|
||||
assertEquals(1, simSpark.getCounters(CounterType.P1P1));
|
||||
assertEquals(5, simSpark.getCounters(CounterType.LOYALTY));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user