Tweak logic so it checks the right face for cost

This commit is contained in:
tool4EvEr
2023-04-02 10:31:53 +02:00
parent 788c655802
commit 7def3a9e6b

View File

@@ -738,7 +738,6 @@ public class AiController {
return false;
}
// This is for playing spells regularly (no Cascade/Ripple etc.)
private AiPlayDecision canPlayAndPayFor(final SpellAbility sa) {
if (!sa.canPlay()) {
return AiPlayDecision.CantPlaySa;
@@ -746,6 +745,25 @@ public class AiController {
final Card host = sa.getHostCard();
// state needs to be switched here so API checks evaluate the right face
CardStateName currentState = sa.getCardState() != null && host.getCurrentStateName() != sa.getCardStateName() && !host.isInPlay() ? host.getCurrentStateName() : null;
if (currentState != null) {
host.setState(sa.getCardStateName(), false);
}
AiPlayDecision decision = canPlayAndPayForFace(sa);
if (currentState != null) {
host.setState(currentState, false);
}
return decision;
}
// This is for playing spells regularly (no Cascade/Ripple etc.)
private AiPlayDecision canPlayAndPayForFace(final SpellAbility sa) {
final Card host = sa.getHostCard();
// Check a predefined condition
if (sa.hasParam("AICheckSVar")) {
final String svarToCheck = sa.getParam("AICheckSVar");
@@ -783,18 +801,8 @@ public class AiController {
}
}
// state needs to be switched here so API checks evaluate the right face
CardStateName currentState = sa.getCardState() != null && host.getCurrentStateName() != sa.getCardStateName() && !host.isInPlay() ? host.getCurrentStateName() : null;
if (currentState != null) {
host.setState(sa.getCardStateName(), false);
}
AiPlayDecision canPlay = canPlaySa(sa); // this is the "heaviest" check, which also sets up targets, defines X, etc.
if (currentState != null) {
host.setState(currentState, false);
}
if (canPlay != AiPlayDecision.WillPlay) {
return canPlay;
}