AI and test framework improved:

* Now AI can see and use special mana payments like convoke, delve, improvise pays;
* Now devs can test special mana payments (disable auto-payment and use choices for mana pool and special pays);
* Fixed broken TargetDiscard in tests;
* Fixed broken same named targets in tests;
This commit is contained in:
Oleg Agafonov 2020-06-19 13:16:26 +04:00
parent c2e7b02e13
commit 10cf884923
2 changed files with 88 additions and 19 deletions

View file

@ -1533,10 +1533,34 @@ public class ComputerPlayer extends PlayerImpl implements Player {
}
}
}
// pay phyrexian life costs
if (cost instanceof PhyrexianManaCost) {
return cost.pay(null, game, null, playerId, false, null) || permittingObject != null;
}
// pay special mana like convoke cost (tap for pay)
// GUI: user see "special" button while pay spell's cost
// TODO: AI can't prioritize special mana types to pay, e.g. it will use first available
SpecialAction specialAction = game.getState().getSpecialActions().getControlledBy(this.getId(), true)
.values().stream().findFirst().orElse(null);
ManaOptions specialMana = specialAction == null ? null : specialAction.getManaOptions(ability, game, unpaid);
if (specialMana != null) {
for (Mana netMana : specialMana) {
if (cost.testPay(netMana) || permittingObject != null) {
if (netMana instanceof ConditionalMana && !((ConditionalMana) netMana).apply(ability, game, getId(), cost)) {
continue;
}
specialAction.setUnpaidMana(unpaid);
if (activateAbility(specialAction, game)) {
return true;
}
// only one time try to pay
break;
}
}
}
return false;
}