mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 04:52:07 -08:00
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:
parent
c2e7b02e13
commit
10cf884923
2 changed files with 88 additions and 19 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue