From c823a493bb2596e6585f8d47c00de3aa13297d16 Mon Sep 17 00:00:00 2001 From: Agetian Date: Mon, 19 Aug 2019 09:25:50 +0300 Subject: [PATCH] - Basic AI for payments via K'rrik's static ability. --- .../main/java/forge/ai/ComputerUtilMana.java | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java b/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java index c7da2e7fbd4..7aae37dc721 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java @@ -321,11 +321,17 @@ public class ComputerUtilMana { SpellAbility saPayment = chooseManaAbility(cost, sa, ai, toPay, saList, true); if (saPayment == null) { - if (!toPay.isPhyrexian() || !ai.canPayLife(2)) { + boolean lifeInsteadOfBlack = toPay.isBlack() && ai.hasKeyword("PayLifeInsteadOf:B"); + if ((!toPay.isPhyrexian() && !lifeInsteadOfBlack) || !ai.canPayLife(2)) { break; // cannot pay } - cost.payPhyrexian(); + if (toPay.isPhyrexian()) { + cost.payPhyrexian(); + } else if (lifeInsteadOfBlack) { + cost.decreaseShard(ManaCostShard.BLACK, 1); + } + continue; } @@ -381,6 +387,8 @@ public class ComputerUtilMana { while (!cost.isPaid()) { toPay = getNextShardToPay(cost); + boolean lifeInsteadOfBlack = toPay.isBlack() && ai.hasKeyword("PayLifeInsteadOf:B"); + Collection saList = null; if (hasConverge && (toPay == ManaCostShard.GENERIC || toPay == ManaCostShard.X)) { @@ -431,7 +439,8 @@ public class ComputerUtilMana { } if (saPayment == null) { - if (!toPay.isPhyrexian() || !ai.canPayLife(2) || (ai.getLife() <= 2 && !ai.cantLoseForZeroOrLessLife())) { + if ((!toPay.isPhyrexian() && !lifeInsteadOfBlack) || !ai.canPayLife(2) + || (ai.getLife() <= 2 && !ai.cantLoseForZeroOrLessLife())) { break; // cannot pay } @@ -446,7 +455,12 @@ public class ComputerUtilMana { } } - cost.payPhyrexian(); + if (toPay.isPhyrexian()) { + cost.payPhyrexian(); + } else if (lifeInsteadOfBlack) { + cost.decreaseShard(ManaCostShard.BLACK, 1); + } + if (!test) { ai.payLife(2, sa.getHostCard()); }