- Added Power Leak (for now, needs a special exclusion in the AI code to properly determine who the paying player is, otherwise the AI believes that it's the opponent who owns Power Leak in case it's cast by the opponent).

This commit is contained in:
Agetian
2017-08-01 16:52:26 +00:00
parent 89c369189a
commit 8a39ff469f
3 changed files with 32 additions and 1 deletions

View File

@@ -115,7 +115,22 @@ public class PlayerControllerAi extends PlayerController {
if (ability.getApi() != null) {
switch (ability.getApi()) {
case ChooseNumber:
return ability.getActivatingPlayer().isOpponentOf(player) ? 0 : ComputerUtilMana.determineLeftoverMana(ability, player);
Player payingPlayer = ability.getActivatingPlayer();
String logic = ability.getParamOrDefault("AILogic", "");
if (logic.startsWith("PowerLeakMaxMana.") && ability.getHostCard().isEnchantingCard()) {
// For cards like Power Leak, the payer will be the owner of the enchanted card
// TODO: is there any way to generalize this and avoid a special exclusion?
payingPlayer = ability.getHostCard().getEnchantingCard().getController();
}
int number = ComputerUtilMana.determineLeftoverMana(ability, player);
if (logic.startsWith("MaxMana.") || logic.startsWith("PowerLeakMaxMana.")) {
number = Math.min(number, Integer.parseInt(logic.substring(logic.indexOf(".") + 1)));
}
return payingPlayer.isOpponentOf(player) ? 0 : number;
case BidLife:
return 0;
default: