PlayAi: Fix NPE with Invoke Calamity

This commit is contained in:
tool4EvEr
2022-04-13 10:21:48 +02:00
parent 80c51f4ef5
commit 4e63a9431d
12 changed files with 17 additions and 33 deletions

View File

@@ -195,8 +195,7 @@ public class PlayAi extends SpellAbilityAi {
final Card source = sa.getHostCard(); final Card source = sa.getHostCard();
if (tgt != null) { if (tgt != null) {
ZoneType zone = tgt.getZone().get(0); cards = CardLists.getValidCards(ai.getGame().getCardsIn(tgt.getZone()), tgt.getValidTgts(), ai, source, sa);
cards = CardLists.getValidCards(ai.getGame().getCardsIn(zone), tgt.getValidTgts(), ai, source, sa);
} else if (!sa.hasParam("Valid")) { } else if (!sa.hasParam("Valid")) {
cards = AbilityUtils.getDefinedCards(source, sa.getParam("Defined"), sa); cards = AbilityUtils.getDefinedCards(source, sa.getParam("Defined"), sa);
} }
@@ -214,9 +213,11 @@ public class PlayAi extends SpellAbilityAi {
// Ensure that if a ValidZone is specified, there's at least something to choose from in that zone. // Ensure that if a ValidZone is specified, there's at least something to choose from in that zone.
if (sa.hasParam("ValidZone")) { if (sa.hasParam("ValidZone")) {
cards = new CardCollection(AbilityUtils.filterListByType(ai.getGame().getCardsIn(ZoneType.valueOf(sa.getParam("ValidZone"))), cards = new CardCollection(AbilityUtils.filterListByType(ai.getGame().getCardsIn(ZoneType.listValueOf(sa.getParam("ValidZone"))),
sa.getParam("Valid"), sa)); sa.getParam("Valid"), sa));
} }
// exclude own card
cards.remove(source);
return cards; return cards;
} }

View File

@@ -2047,7 +2047,7 @@ public class AbilityUtils {
return doXMath(c.getNetToughness(), expr, c, ctb); return doXMath(c.getNetToughness(), expr, c, ctb);
} }
if (sq[0].contains("CardSumPT")) { if (sq[0].contains("CardSumPT")) {
return doXMath((c.getNetPower() + c.getNetToughness()), expr, c, ctb); return doXMath(c.getNetPower() + c.getNetToughness(), expr, c, ctb);
} }
if (sq[0].contains("CardNumTypes")) { if (sq[0].contains("CardNumTypes")) {
Card ce; Card ce;
@@ -2814,14 +2814,7 @@ public class AbilityUtils {
if (sq[0].startsWith("HighestCMC_")) { if (sq[0].startsWith("HighestCMC_")) {
final String restriction = l[0].substring(11); final String restriction = l[0].substring(11);
CardCollection list = CardLists.getValidCards(game.getCardsInGame(), restriction, player, c, ctb); CardCollection list = CardLists.getValidCards(game.getCardsInGame(), restriction, player, c, ctb);
int highest = 0; return Aggregates.max(list, CardPredicates.Accessors.fnGetCmc);
for (final Card crd : list) {
// dont check for Split card anymore
if (crd.getCMC() > highest) {
highest = crd.getCMC();
}
}
return highest;
} }
if (sq[0].startsWith("MostCardName")) { if (sq[0].startsWith("MostCardName")) {
@@ -2918,12 +2911,6 @@ public class AbilityUtils {
// Complex counting methods // Complex counting methods
CardCollectionView someCards = getCardListForXCount(c, player, sq, ctb); CardCollectionView someCards = getCardListForXCount(c, player, sq, ctb);
// 1/10 - Count$MaxCMCYouCtrl
if (sq[0].startsWith("MaxCMC")) {
int mmc = Aggregates.max(someCards, CardPredicates.Accessors.fnGetCmc);
return doXMath(mmc, expr, c, ctb);
}
return doXMath(someCards.size(), expr, c, ctb); return doXMath(someCards.size(), expr, c, ctb);
} }
@@ -3861,6 +3848,7 @@ public class AbilityUtils {
CardCollection list = null; CardCollection list = null;
if (sa instanceof SpellAbility) { if (sa instanceof SpellAbility) {
SpellAbility root = ((SpellAbility)sa).getRootAbility(); SpellAbility root = ((SpellAbility)sa).getRootAbility();
// TODO do we really need these checks?
if (defined.startsWith("SacrificedCards")) { if (defined.startsWith("SacrificedCards")) {
list = root.getPaidList("SacrificedCards"); list = root.getPaidList("SacrificedCards");
} else if (defined.startsWith("Sacrificed")) { } else if (defined.startsWith("Sacrificed")) {

View File

@@ -5575,7 +5575,6 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
} }
public final boolean isTributed() { return tributed; } public final boolean isTributed() { return tributed; }
public final void setTributed(final boolean b) { public final void setTributed(final boolean b) {
tributed = b; tributed = b;
} }
@@ -5670,7 +5669,6 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
public boolean isForetoldByEffect() { public boolean isForetoldByEffect() {
return foretoldByEffect; return foretoldByEffect;
} }
public void setForetoldByEffect(final boolean val) { public void setForetoldByEffect(final boolean val) {
this.foretoldByEffect = val; this.foretoldByEffect = val;
} }
@@ -5678,7 +5676,6 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
public boolean isForetoldThisTurn() { public boolean isForetoldThisTurn() {
return foretoldThisTurn; return foretoldThisTurn;
} }
public final void setForetoldThisTurn(final boolean foretoldThisTurn) { public final void setForetoldThisTurn(final boolean foretoldThisTurn) {
this.foretoldThisTurn = foretoldThisTurn; this.foretoldThisTurn = foretoldThisTurn;
} }
@@ -5690,11 +5687,9 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
public int getTimesCrewedThisTurn() { public int getTimesCrewedThisTurn() {
return timesCrewedThisTurn; return timesCrewedThisTurn;
} }
public final void setTimesCrewedThisTurn(final int t) { public final void setTimesCrewedThisTurn(final int t) {
this.timesCrewedThisTurn = t; this.timesCrewedThisTurn = t;
} }
public void resetTimesCrewedThisTurn() { public void resetTimesCrewedThisTurn() {
timesCrewedThisTurn = 0; timesCrewedThisTurn = 0;
} }
@@ -6208,7 +6203,7 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
int xPaid = 0; int xPaid = 0;
// 2012-07-22 - If a card is on the stack, count the xManaCost in with it's CMC // If a card is on the stack, count the xManaCost in with it's CMC
if (isInZone(ZoneType.Stack) && getManaCost() != null) { if (isInZone(ZoneType.Stack) && getManaCost() != null) {
xPaid = getXManaCostPaid() * getManaCost().countX(); xPaid = getXManaCostPaid() * getManaCost().countX();
} }

View File

@@ -2,5 +2,5 @@ Name:Accelerated Mutation
ManaCost:3 G G ManaCost:3 G G
Types:Instant Types:Instant
A:SP$ Pump | Cost$ 3 G G | ValidTgts$ Creature | TgtPrompt$ Select target creature | NumAtt$ X | NumDef$ X | SpellDescription$ Target creature gets +X/+X until end of turn, where X is the highest mana value among permanents you control. A:SP$ Pump | Cost$ 3 G G | ValidTgts$ Creature | TgtPrompt$ Select target creature | NumAtt$ X | NumDef$ X | SpellDescription$ Target creature gets +X/+X until end of turn, where X is the highest mana value among permanents you control.
SVar:X:Count$MaxCMCYouCtrl SVar:X:Count$HighestCMC_Permanent.YouCtrl+inZoneBattlefield
Oracle:Target creature gets +X/+X until end of turn, where X is the highest mana value among permanents you control. Oracle:Target creature gets +X/+X until end of turn, where X is the highest mana value among permanents you control.

View File

@@ -3,5 +3,5 @@ ManaCost:2 G
Types:Instant Types:Instant
A:SP$ Pump | ValidTgts$ Creature | TgtPrompt$ Select target creature | NumAtt$ X | NumDef$ X | SubAbility$ DBUntap | SpellDescription$ Target creature gets +X/+X until end of turn, where X is the greatest mana value among permanents you control. A:SP$ Pump | ValidTgts$ Creature | TgtPrompt$ Select target creature | NumAtt$ X | NumDef$ X | SubAbility$ DBUntap | SpellDescription$ Target creature gets +X/+X until end of turn, where X is the greatest mana value among permanents you control.
SVar:DBUntap:DB$ Untap | Defined$ Targeted | SpellDescription$ Untap it. SVar:DBUntap:DB$ Untap | Defined$ Targeted | SpellDescription$ Untap it.
SVar:X:Count$MaxCMCYouCtrl SVar:X:Count$HighestCMC_Permanent.YouCtrl+inZoneBattlefield
Oracle:Target creature gets +X/+X until end of turn, where X is the greatest mana value among permanents you control. Untap it. Oracle:Target creature gets +X/+X until end of turn, where X is the greatest mana value among permanents you control. Untap it.

View File

@@ -2,6 +2,6 @@ Name:Cabal Conditioning
ManaCost:6 B ManaCost:6 B
Types:Sorcery Types:Sorcery
A:SP$ Discard | Cost$ 6 B | ValidTgts$ Player | TgtPrompt$ Select target player | TargetMin$ 0 | TargetMax$ MaxTgt | NumCards$ X | Mode$ TgtChoose | SpellDescription$ Any number of target players each discard a number of cards equal to the highest mana value among permanents you control. A:SP$ Discard | Cost$ 6 B | ValidTgts$ Player | TgtPrompt$ Select target player | TargetMin$ 0 | TargetMax$ MaxTgt | NumCards$ X | Mode$ TgtChoose | SpellDescription$ Any number of target players each discard a number of cards equal to the highest mana value among permanents you control.
SVar:X:Count$MaxCMCYouCtrl SVar:X:Count$HighestCMC_Permanent.YouCtrl+inZoneBattlefield
SVar:MaxTgt:PlayerCountPlayers$Amount SVar:MaxTgt:PlayerCountPlayers$Amount
Oracle:Any number of target players each discard a number of cards equal to the highest mana value among permanents you control. Oracle:Any number of target players each discard a number of cards equal to the highest mana value among permanents you control.

View File

@@ -3,6 +3,6 @@ ManaCost:1 U
Types:Instant Types:Instant
A:SP$ Counter | Cost$ 1 U | TargetType$ Spell | ValidTgts$ Card | ConditionCheckSVar$ X | ConditionSVarCompare$ LEY | SpellDescription$ Counter target spell if its mana value is less than or equal to the highest mana value among permanents you control. A:SP$ Counter | Cost$ 1 U | TargetType$ Spell | ValidTgts$ Card | ConditionCheckSVar$ X | ConditionSVarCompare$ LEY | SpellDescription$ Counter target spell if its mana value is less than or equal to the highest mana value among permanents you control.
SVar:X:Targeted$CardManaCost SVar:X:Targeted$CardManaCost
SVar:Y:Count$MaxCMCYouCtrl SVar:Y:Count$HighestCMC_Permanent.YouCtrl+inZoneBattlefield
AI:RemoveDeck:All AI:RemoveDeck:All
Oracle:Counter target spell if its mana value is less than or equal to the highest mana value among permanents you control. Oracle:Counter target spell if its mana value is less than or equal to the highest mana value among permanents you control.

View File

@@ -1,7 +1,7 @@
Name:Invoke Calamity Name:Invoke Calamity
ManaCost:1 R R R R ManaCost:1 R R R R
Types:Instant Types:Instant
A:SP$ Play | Valid$ Instant.YouOwn,Sorcery.YouOwn | WithTotalCMC$ 6 | ValidZone$ Graveyard,Hand | Amount$ 2 | WithoutManaCost$ True | Optional$ True | ReplaceGraveyard$ Exile | SubAbility$ DBExile | StackDescription$ SpellDescription | SpellDescription$ You may cast up to two instant and/or sorcery spells with total mana value 6 or less from your graveyard and/or hand without paying their mana costs. If those spells would be put into your graveyard, exile them instead. A:SP$ Play | Valid$ Card.YouOwn | ValidSA$ Instant,Sorcery | WithTotalCMC$ 6 | ValidZone$ Graveyard,Hand | Amount$ 2 | WithoutManaCost$ True | Optional$ True | ReplaceGraveyard$ Exile | SubAbility$ DBExile | StackDescription$ SpellDescription | SpellDescription$ You may cast up to two instant and/or sorcery spells with total mana value 6 or less from your graveyard and/or hand without paying their mana costs. If those spells would be put into your graveyard, exile them instead.
SVar:DBExile:DB$ ChangeZone | Origin$ Stack | Destination$ Exile | SpellDescription$ Exile CARDNAME. SVar:DBExile:DB$ ChangeZone | Origin$ Stack | Destination$ Exile | SpellDescription$ Exile CARDNAME.
DeckNeeds:Type$Instant|Sorcery DeckNeeds:Type$Instant|Sorcery
DeckHas:Ability$Graveyard DeckHas:Ability$Graveyard

View File

@@ -2,6 +2,6 @@ Name:Reward the Faithful
ManaCost:W ManaCost:W
Types:Instant Types:Instant
A:SP$ GainLife | Cost$ W | ValidTgts$ Player | TgtPrompt$ Select target player | TargetMin$ 0 | TargetMax$ MaxTgt | LifeAmount$ X | SpellDescription$ Any number of target players each gain life equal to the highest mana value among permanents you control. A:SP$ GainLife | Cost$ W | ValidTgts$ Player | TgtPrompt$ Select target player | TargetMin$ 0 | TargetMax$ MaxTgt | LifeAmount$ X | SpellDescription$ Any number of target players each gain life equal to the highest mana value among permanents you control.
SVar:X:Count$MaxCMCYouCtrl SVar:X:Count$HighestCMC_Permanent.YouCtrl+inZoneBattlefield
SVar:MaxTgt:PlayerCountPlayers$Amount SVar:MaxTgt:PlayerCountPlayers$Amount
Oracle:Any number of target players each gain life equal to the highest mana value among permanents you control. Oracle:Any number of target players each gain life equal to the highest mana value among permanents you control.

View File

@@ -2,6 +2,6 @@ Name:Rush of Knowledge
ManaCost:4 U ManaCost:4 U
Types:Sorcery Types:Sorcery
A:SP$ Draw | Cost$ 4 U | Defined$ You | NumCards$ X | SpellDescription$ Draw cards equal to the highest mana value among permanents you control. A:SP$ Draw | Cost$ 4 U | Defined$ You | NumCards$ X | SpellDescription$ Draw cards equal to the highest mana value among permanents you control.
SVar:X:Count$MaxCMCYouCtrl SVar:X:Count$HighestCMC_Permanent.YouCtrl+inZoneBattlefield
AI:RemoveDeck:Random AI:RemoveDeck:Random
Oracle:Draw cards equal to the highest mana value among permanents you control. Oracle:Draw cards equal to the highest mana value among permanents you control.

View File

@@ -2,5 +2,5 @@ Name:Torrent of Fire
ManaCost:3 R R ManaCost:3 R R
Types:Sorcery Types:Sorcery
A:SP$ DealDamage | Cost$ 3 R R | ValidTgts$ Creature,Player,Planeswalker | TgtPrompt$ Select any target | NumDmg$ X | SpellDescription$ CARDNAME deals damage to any target equal to the highest mana value among permanents you control. A:SP$ DealDamage | Cost$ 3 R R | ValidTgts$ Creature,Player,Planeswalker | TgtPrompt$ Select any target | NumDmg$ X | SpellDescription$ CARDNAME deals damage to any target equal to the highest mana value among permanents you control.
SVar:X:Count$MaxCMCYouCtrl SVar:X:Count$HighestCMC_Permanent.YouCtrl+inZoneBattlefield
Oracle:Torrent of Fire deals damage to any target equal to the highest mana value among permanents you control. Oracle:Torrent of Fire deals damage to any target equal to the highest mana value among permanents you control.

View File

@@ -2,6 +2,6 @@ Name:Ugin's Insight
ManaCost:3 U U ManaCost:3 U U
Types:Sorcery Types:Sorcery
A:SP$ Scry | Cost$ 3 U U | ScryNum$ X | SubAbility$ DBDraw | SpellDescription$ Scry X, where X is the highest mana value among permanents you control, then draw three cards. A:SP$ Scry | Cost$ 3 U U | ScryNum$ X | SubAbility$ DBDraw | SpellDescription$ Scry X, where X is the highest mana value among permanents you control, then draw three cards.
SVar:X:Count$MaxCMCYouCtrl SVar:X:Count$HighestCMC_Permanent.YouCtrl+inZoneBattlefield
SVar:DBDraw:DB$ Draw | NumCards$ 3 SVar:DBDraw:DB$ Draw | NumCards$ 3
Oracle:Scry X, where X is the highest mana value among permanents you control, then draw three cards. Oracle:Scry X, where X is the highest mana value among permanents you control, then draw three cards.