Merge branch 'master' into 'master'

Improved AI logic vs. Ward

See merge request core-developers/forge!5695
This commit is contained in:
Michael Kamensky
2021-10-31 04:38:44 +00:00
2 changed files with 23 additions and 0 deletions

View File

@@ -730,7 +730,21 @@ public class AiController {
if (sa.getCardState() != null && !sa.getHostCard().isInPlay() && sa.getCardState().getStateName() == CardStateName.Modal) { if (sa.getCardState() != null && !sa.getHostCard().isInPlay() && sa.getCardState().getStateName() == CardStateName.Modal) {
sa.getHostCard().setState(CardStateName.Modal, false); sa.getHostCard().setState(CardStateName.Modal, 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.
// Account for possible Ward after the spell is fully targeted
if (sa.usesTargeting()) {
for (Card tgt : sa.getTargets().getTargetCards()) {
if (tgt.hasKeyword(Keyword.WARD)) {
int amount = tgt.getKeywordMagnitude(Keyword.WARD);
if (amount > 0 && !ComputerUtilCost.canPayCost(sa, player)) {
return AiPlayDecision.CantAfford;
}
}
}
}
if (sa.getCardState() != null && !sa.getHostCard().isInPlay() && sa.getCardState().getStateName() == CardStateName.Modal) { if (sa.getCardState() != null && !sa.getHostCard().isInPlay() && sa.getCardState().getStateName() == CardStateName.Modal) {
sa.getHostCard().setState(CardStateName.Original, false); sa.getHostCard().setState(CardStateName.Original, false);
} }

View File

@@ -589,6 +589,15 @@ public class ComputerUtilCost {
} }
} }
// Ward - will be accounted for when rechecking a targeted ability
if (sa.usesTargeting()) {
for (Card tgt : sa.getTargets().getTargetCards()) {
if (tgt.hasKeyword(Keyword.WARD)) {
extraManaNeeded += tgt.getKeywordMagnitude(Keyword.WARD);
}
}
}
// TODO: Alternate costs which involve both paying mana and tapping a card, e.g. Zahid, Djinn of the Lamp // TODO: Alternate costs which involve both paying mana and tapping a card, e.g. Zahid, Djinn of the Lamp
// Current AI decides on each part separately, thus making it possible for the AI to cheat by // Current AI decides on each part separately, thus making it possible for the AI to cheat by
// tapping a mana source for mana and for the tap cost at the same time. Until this is improved, AI // tapping a mana source for mana and for the tap cost at the same time. Until this is improved, AI