mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
Fix AI casting suspended spells against Drannith Magistrate (#1098)
* Cleanup cards * Fix AI casting suspended spells against Drannith Magistrate Co-authored-by: tool4EvEr <tool4EvEr@192.168.0.59>
This commit is contained in:
@@ -250,6 +250,13 @@ public class ComputerUtil {
|
||||
return false;
|
||||
|
||||
final Card source = sa.getHostCard();
|
||||
|
||||
Zone fromZone = game.getZoneOf(source);
|
||||
int zonePosition = 0;
|
||||
if (fromZone != null) {
|
||||
zonePosition = fromZone.getCards().indexOf(source);
|
||||
}
|
||||
|
||||
if (sa.isSpell() && !source.isCopiedSpell()) {
|
||||
sa.setHostCard(game.getAction().moveToStack(source, sa));
|
||||
}
|
||||
@@ -257,11 +264,18 @@ public class ComputerUtil {
|
||||
sa = GameActionUtil.addExtraKeywordCost(sa);
|
||||
|
||||
final Cost cost = sa.getPayCosts();
|
||||
final CostPayment pay = new CostPayment(cost, sa);
|
||||
|
||||
// do this after card got added to stack
|
||||
if (!sa.checkRestrictions(ai)) {
|
||||
GameActionUtil.rollbackAbility(sa, fromZone, zonePosition, pay, source);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (cost == null) {
|
||||
ComputerUtilMana.payManaCost(ai, sa, false);
|
||||
game.getStack().add(sa);
|
||||
} else {
|
||||
final CostPayment pay = new CostPayment(cost, sa);
|
||||
if (pay.payComputerCosts(new AiCostDecision(ai, sa, false))) {
|
||||
game.getStack().add(sa);
|
||||
}
|
||||
@@ -292,6 +306,13 @@ public class ComputerUtil {
|
||||
newSA = GameActionUtil.addExtraKeywordCost(newSA);
|
||||
|
||||
final Card source = newSA.getHostCard();
|
||||
|
||||
Zone fromZone = game.getZoneOf(source);
|
||||
int zonePosition = 0;
|
||||
if (fromZone != null) {
|
||||
zonePosition = fromZone.getCards().indexOf(source);
|
||||
}
|
||||
|
||||
if (newSA.isSpell() && !source.isCopiedSpell()) {
|
||||
newSA.setHostCard(game.getAction().moveToStack(source, newSA));
|
||||
|
||||
@@ -303,6 +324,13 @@ public class ComputerUtil {
|
||||
}
|
||||
|
||||
final CostPayment pay = new CostPayment(newSA.getPayCosts(), newSA);
|
||||
|
||||
// do this after card got added to stack
|
||||
if (!sa.checkRestrictions(ai)) {
|
||||
GameActionUtil.rollbackAbility(sa, fromZone, zonePosition, pay, source);
|
||||
return false;
|
||||
}
|
||||
|
||||
pay.payComputerCosts(new AiCostDecision(ai, newSA, false));
|
||||
|
||||
game.getStack().add(newSA);
|
||||
|
||||
@@ -1087,7 +1087,7 @@ public class PlayerControllerAi extends PlayerController {
|
||||
if (tgtSA instanceof Spell) { // Isn't it ALWAYS a spell?
|
||||
Spell spell = (Spell) tgtSA;
|
||||
// TODO if mandatory AI is only forced to use mana when it's already in the pool
|
||||
if (tgtSA.checkRestrictions(brains.getPlayer()) && (brains.canPlayFromEffectAI(spell, !optional, noManaCost) == AiPlayDecision.WillPlay || !optional)) {
|
||||
if (brains.canPlayFromEffectAI(spell, !optional, noManaCost) == AiPlayDecision.WillPlay || !optional) {
|
||||
if (noManaCost) {
|
||||
return ComputerUtil.playSpellAbilityWithoutPayingManaCost(player, tgtSA, getGame());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user