Fix inconsistent controller

This commit is contained in:
tool4EvEr
2023-01-26 17:19:51 +01:00
parent 58cd1c1df2
commit 15834a0d67
3 changed files with 30 additions and 33 deletions

View File

@@ -337,27 +337,30 @@ public class ComputerUtil {
return true;
}
public static final void playNoStack(final Player ai, SpellAbility sa, final Game game, final boolean effect) {
public static final boolean playNoStack(final Player ai, SpellAbility sa, final Game game, final boolean effect) {
sa.setActivatingPlayer(ai, true);
// TODO: We should really restrict what doesn't use the Stack
if (ComputerUtilCost.canPayCost(sa, ai, effect)) {
final Card source = sa.getHostCard();
if (sa.isSpell() && !source.isCopiedSpell()) {
sa.setHostCard(game.getAction().moveToStack(source, sa));
}
sa = GameActionUtil.addExtraKeywordCost(sa);
final Cost cost = sa.getPayCosts();
if (cost == null) {
ComputerUtilMana.payManaCost(ai, sa, effect);
} else {
final CostPayment pay = new CostPayment(cost, sa);
pay.payComputerCosts(new AiCostDecision(ai, sa, effect));
}
AbilityUtils.resolve(sa);
if (!ComputerUtilCost.canPayCost(sa, ai, effect)) {
return false;
}
final Card source = sa.getHostCard();
if (sa.isSpell() && !source.isCopiedSpell()) {
sa.setHostCard(game.getAction().moveToStack(source, sa));
}
sa = GameActionUtil.addExtraKeywordCost(sa);
final Cost cost = sa.getPayCosts();
if (cost == null) {
ComputerUtilMana.payManaCost(ai, sa, effect);
} else {
final CostPayment pay = new CostPayment(cost, sa);
pay.payComputerCosts(new AiCostDecision(ai, sa, effect));
}
AbilityUtils.resolve(sa);
return true;
}
public static Card getCardPreference(final Player ai, final Card activate, final String pref, final CardCollection typeList) {

View File

@@ -696,8 +696,7 @@ public class PlayerControllerAi extends PlayerController {
ability.setActivatingPlayer(c.getController(), true);
ability.setCardState(sa.getCardState());
if (ComputerUtilCost.canPayCost(ability, c.getController(), true)) {
ComputerUtil.playNoStack(c.getController(), ability, getGame(), true);
if (ComputerUtil.playNoStack(c.getController(), ability, getGame(), true)) {
// transfer this info for Balduvian Fallen
sa.setPayingMana(ability.getPayingMana());
return true;
@@ -1071,9 +1070,8 @@ public class PlayerControllerAi extends PlayerController {
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
return true;
if (ComputerUtilCost.willPayUnlessCost(sa, player, cost, alreadyPaid, allPayers)) {
return ComputerUtil.playNoStack(player, emptyAbility, getGame(), true); // AI needs something to resolve to pay that cost
}
return false;
}