From 1296b24960ab05d1a46979e4152dafe5007fc9bd Mon Sep 17 00:00:00 2001 From: Agetian Date: Sun, 6 May 2018 08:00:51 +0300 Subject: [PATCH] - A quick patch to make the AI compatible with MayFlashCost (may need a rewrite later when the optional costs are correctly implemented for the AI). --- .../src/main/java/forge/game/GameActionUtil.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/forge-game/src/main/java/forge/game/GameActionUtil.java b/forge-game/src/main/java/forge/game/GameActionUtil.java index d2b285ec43e..5b29188b609 100644 --- a/forge-game/src/main/java/forge/game/GameActionUtil.java +++ b/forge-game/src/main/java/forge/game/GameActionUtil.java @@ -418,6 +418,22 @@ public final class GameActionUtil { i++; } } + } else if (keyword.startsWith("MayFlashCost")) { + if (source.getGame().getPhaseHandler().isPlayerTurn(source.getController())) { + continue; // don't cast it with additional flash cost during AI's own turn, commonly a waste of mana + } + for (int i = 0; i < abilities.size(); i++) { + final SpellAbility newSA = abilities.get(i).copy(); + newSA.setBasicSpell(false); + newSA.setPayCosts(new Cost(keyword.substring(13), false).add(newSA.getPayCosts())); + newSA.setDescription(newSA.getDescription() + " (as though it had flash)"); + newSA.addOptionalCost(OptionalCost.Flash); + newSA.getRestrictions().setInstantSpeed(true); + if (newSA.canPlay()) { + abilities.add(i, newSA); + i++; + } + } } else if (keyword.startsWith("Kicker")) { String[] sCosts = TextUtil.split(keyword.substring(6), ':'); boolean generic = "Generic".equals(sCosts[sCosts.length - 1]);