mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
Fix some payment NPE
This commit is contained in:
@@ -699,6 +699,7 @@ public class PlayerControllerAi extends PlayerController {
|
||||
// TODO replace with EmptySa
|
||||
final Ability ability = new AbilityStatic(c, cost, null) { @Override public void resolve() {} };
|
||||
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,
|
||||
// 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.setTriggeringObjects(sa.getTriggeringObjects());
|
||||
emptyAbility.setSVars(sa.getSVars());
|
||||
emptyAbility.setCardState(sa.getCardState());
|
||||
emptyAbility.setXManaCostPaid(sa.getRootAbility().getXManaCostPaid());
|
||||
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
|
||||
|
||||
@@ -180,8 +180,9 @@ public class PermanentAi extends SpellAbilityAi {
|
||||
final SpellAbility emptyAbility = new SpellAbility.EmptySa(card, ai);
|
||||
emptyAbility.setPayCosts(new Cost(costs, true));
|
||||
emptyAbility.setTargetRestrictions(sa.getTargetRestrictions());
|
||||
|
||||
emptyAbility.setCardState(sa.getCardState());
|
||||
emptyAbility.setActivatingPlayer(ai);
|
||||
|
||||
if (!ComputerUtilCost.canPayCost(emptyAbility, ai, true)) {
|
||||
// AiPlayDecision.AnotherTime
|
||||
return false;
|
||||
|
||||
@@ -301,6 +301,7 @@ public class CombatUtil {
|
||||
// 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
|
||||
final SpellAbility fakeSA = new SpellAbility.EmptySa(attacker, attacker.getController());
|
||||
fakeSA.setCardState(attacker.getCurrentState());
|
||||
return attacker.getController().getController().payManaOptional(attacker, attackCost, fakeSA,
|
||||
"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());
|
||||
fakeSA.setCardState(blocker.getCurrentState());
|
||||
return blocker.getController().getController().payManaOptional(blocker, blockCost, fakeSA, "Pay cost to declare " + blocker + " a blocker. ", ManaPaymentPurpose.DeclareBlocker);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user