Fix some payment NPE

This commit is contained in:
TRT
2022-03-18 11:55:21 +01:00
parent 11bb906932
commit 469ada0e4c
3 changed files with 6 additions and 1 deletions

View File

@@ -699,6 +699,7 @@ public class PlayerControllerAi extends PlayerController {
// TODO replace with EmptySa // TODO replace with EmptySa
final Ability ability = new AbilityStatic(c, cost, null) { @Override public void resolve() {} }; final Ability ability = new AbilityStatic(c, cost, null) { @Override public void resolve() {} };
ability.setActivatingPlayer(c.getController()); ability.setActivatingPlayer(c.getController());
ability.setCardState(sa.getCardState());
// FIXME: This is a hack to check if the AI can play the "exile from library" pay costs (Cumulative Upkeep, // FIXME: This is a hack to check if the AI can play the "exile from library" pay costs (Cumulative Upkeep,
// e.g. Thought Lash). We have to do it and bail early if the AI can't pay, because otherwise the AI will // e.g. Thought Lash). We have to do it and bail early if the AI can't pay, because otherwise the AI will
@@ -1020,6 +1021,7 @@ public class PlayerControllerAi extends PlayerController {
emptyAbility.setActivatingPlayer(player); emptyAbility.setActivatingPlayer(player);
emptyAbility.setTriggeringObjects(sa.getTriggeringObjects()); emptyAbility.setTriggeringObjects(sa.getTriggeringObjects());
emptyAbility.setSVars(sa.getSVars()); emptyAbility.setSVars(sa.getSVars());
emptyAbility.setCardState(sa.getCardState());
emptyAbility.setXManaCostPaid(sa.getRootAbility().getXManaCostPaid()); emptyAbility.setXManaCostPaid(sa.getRootAbility().getXManaCostPaid());
if (ComputerUtilCost.willPayUnlessCost(sa, player, cost, alreadyPaid, allPayers) && ComputerUtilCost.canPayCost(emptyAbility, player, true)) { if (ComputerUtilCost.willPayUnlessCost(sa, player, cost, alreadyPaid, allPayers) && ComputerUtilCost.canPayCost(emptyAbility, player, true)) {
ComputerUtil.playNoStack(player, emptyAbility, getGame(), true); // AI needs something to resolve to pay that cost ComputerUtil.playNoStack(player, emptyAbility, getGame(), true); // AI needs something to resolve to pay that cost

View File

@@ -180,8 +180,9 @@ public class PermanentAi extends SpellAbilityAi {
final SpellAbility emptyAbility = new SpellAbility.EmptySa(card, ai); final SpellAbility emptyAbility = new SpellAbility.EmptySa(card, ai);
emptyAbility.setPayCosts(new Cost(costs, true)); emptyAbility.setPayCosts(new Cost(costs, true));
emptyAbility.setTargetRestrictions(sa.getTargetRestrictions()); emptyAbility.setTargetRestrictions(sa.getTargetRestrictions());
emptyAbility.setCardState(sa.getCardState());
emptyAbility.setActivatingPlayer(ai); emptyAbility.setActivatingPlayer(ai);
if (!ComputerUtilCost.canPayCost(emptyAbility, ai, true)) { if (!ComputerUtilCost.canPayCost(emptyAbility, ai, true)) {
// AiPlayDecision.AnotherTime // AiPlayDecision.AnotherTime
return false; return false;

View File

@@ -301,6 +301,7 @@ public class CombatUtil {
// Not a great solution, but prevents a crash by passing a fake SA for Propaganda payments // Not a great solution, but prevents a crash by passing a fake SA for Propaganda payments
// If there's a better way of handling this somewhere deeper in the code, feel free to remove // If there's a better way of handling this somewhere deeper in the code, feel free to remove
final SpellAbility fakeSA = new SpellAbility.EmptySa(attacker, attacker.getController()); final SpellAbility fakeSA = new SpellAbility.EmptySa(attacker, attacker.getController());
fakeSA.setCardState(attacker.getCurrentState());
return attacker.getController().getController().payManaOptional(attacker, attackCost, fakeSA, return attacker.getController().getController().payManaOptional(attacker, attackCost, fakeSA,
"Pay additional cost to declare " + attacker + " an attacker", ManaPaymentPurpose.DeclareAttacker); "Pay additional cost to declare " + attacker + " an attacker", ManaPaymentPurpose.DeclareAttacker);
} }
@@ -345,6 +346,7 @@ public class CombatUtil {
} }
SpellAbility fakeSA = new SpellAbility.EmptySa(blocker, blocker.getController()); SpellAbility fakeSA = new SpellAbility.EmptySa(blocker, blocker.getController());
fakeSA.setCardState(blocker.getCurrentState());
return blocker.getController().getController().payManaOptional(blocker, blockCost, fakeSA, "Pay cost to declare " + blocker + " a blocker. ", ManaPaymentPurpose.DeclareBlocker); return blocker.getController().getController().payManaOptional(blocker, blockCost, fakeSA, "Pay cost to declare " + blocker + " a blocker. ", ManaPaymentPurpose.DeclareBlocker);
} }