mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-14 09:48:02 +00:00
Merge branch 'master' into 'master'
Improved AI logic vs. Ward See merge request core-developers/forge!5695
This commit is contained in:
@@ -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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user