mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 03:38:01 +00:00
- Fixed a bug which caused the AI not to play X-dependent targeting spells like Repeal anymore.
This commit is contained in:
@@ -670,7 +670,12 @@ public class AiController {
|
||||
|
||||
// This is for playing spells regularly (no Cascade/Ripple etc.)
|
||||
private AiPlayDecision canPlayAndPayFor(final SpellAbility sa) {
|
||||
if (!ComputerUtilCost.canPayCost(sa, player)) {
|
||||
boolean XCost = sa.getHostCard() != null && sa.getHostCard().getManaCost() != null
|
||||
&& sa.getHostCard().getManaCost().countX() > 0;
|
||||
|
||||
if (!XCost && !ComputerUtilCost.canPayCost(sa, player)) {
|
||||
// for most costs, it's OK to check if they can be paid early in order to avoid running a heavy API check
|
||||
// when the AI won't even be able to play the spell in the first place (even if it could afford it)
|
||||
return AiPlayDecision.CantAfford;
|
||||
}
|
||||
|
||||
@@ -678,7 +683,20 @@ public class AiController {
|
||||
return AiPlayDecision.CantPlaySa;
|
||||
}
|
||||
|
||||
return canPlaySa(sa);
|
||||
AiPlayDecision canPlay = canPlaySa(sa); // this is the "heaviest" check, which also sets up targets, defines X, etc.
|
||||
if (canPlay != AiPlayDecision.WillPlay) {
|
||||
return canPlay;
|
||||
}
|
||||
|
||||
if (XCost && !ComputerUtilCost.canPayCost(sa, player)) {
|
||||
// for dependent costs with X, e.g. Repeal, which require a valid target to be specified before a decision can be made
|
||||
// on whether the cost can be paid
|
||||
return AiPlayDecision.CantAfford;
|
||||
}
|
||||
|
||||
// if we got here, looks like we can play the final cost and we could properly set up and target the API and
|
||||
// are willing to play the SA
|
||||
return AiPlayDecision.WillPlay;
|
||||
}
|
||||
|
||||
public AiPlayDecision canPlaySa(SpellAbility sa) {
|
||||
|
||||
Reference in New Issue
Block a user