From d5bea4140d63fbf61750376fedffa52bf5c76e10 Mon Sep 17 00:00:00 2001 From: Northmoc Date: Sun, 6 Nov 2022 18:57:52 -0500 Subject: [PATCH] AbilityUtils.xCount support "Each2SpentToCast" --- .../java/forge/game/ability/AbilityUtils.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/forge-game/src/main/java/forge/game/ability/AbilityUtils.java b/forge-game/src/main/java/forge/game/ability/AbilityUtils.java index 05ab6ce2870..55177825cb4 100644 --- a/forge-game/src/main/java/forge/game/ability/AbilityUtils.java +++ b/forge-game/src/main/java/forge/game/ability/AbilityUtils.java @@ -2087,6 +2087,24 @@ public class AbilityUtils { return doXMath(castSA == null ? 0 : castSA.getPayingColors().countColors(), expr, c, ctb); } + if (sq[0].startsWith("Each2SpentToCast")) { + SpellAbility castSA = c.getCastSA(); + final List paidMana = castSA.getPayingMana(); + final String type = sq[0].split("_")[1]; + int count = 0; + int t = 0; + for (Mana m : paidMana) { + if (m.toString().equals(type)) { + t++; + if (t == 2) { + count++; + t = 0; + } + } + } + return doXMath(count, expr, c, ctb); + } + // Count$wasCastFrom.. if (sq[0].startsWith("wasCastFrom")) { boolean your = sq[0].contains("Your");