mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 04:38:00 +00:00
Tweak logic so it checks the right face for cost
This commit is contained in:
@@ -738,7 +738,6 @@ public class AiController {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is for playing spells regularly (no Cascade/Ripple etc.)
|
|
||||||
private AiPlayDecision canPlayAndPayFor(final SpellAbility sa) {
|
private AiPlayDecision canPlayAndPayFor(final SpellAbility sa) {
|
||||||
if (!sa.canPlay()) {
|
if (!sa.canPlay()) {
|
||||||
return AiPlayDecision.CantPlaySa;
|
return AiPlayDecision.CantPlaySa;
|
||||||
@@ -746,6 +745,25 @@ public class AiController {
|
|||||||
|
|
||||||
final Card host = sa.getHostCard();
|
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
|
// Check a predefined condition
|
||||||
if (sa.hasParam("AICheckSVar")) {
|
if (sa.hasParam("AICheckSVar")) {
|
||||||
final String svarToCheck = sa.getParam("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.
|
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) {
|
if (canPlay != AiPlayDecision.WillPlay) {
|
||||||
return canPlay;
|
return canPlay;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user