From 29c46591a649b23d652cf4b1cebb6844ab7a0a44 Mon Sep 17 00:00:00 2001 From: tool4EvEr Date: Thu, 23 Dec 2021 13:50:23 +0100 Subject: [PATCH] Clean up --- .../src/main/java/forge/ai/ComputerUtilMana.java | 15 +++++++-------- .../java/forge/game/cost/CostAdjustment.java | 14 ++++++-------- .../main/java/forge/game/cost/CostPayment.java | 16 ++-------------- 3 files changed, 15 insertions(+), 30 deletions(-) diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java b/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java index 0f0c2ad5389..a295b5fd928 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java @@ -679,8 +679,13 @@ public class ComputerUtilMana { adjustManaCostToAvoidNegEffects(cost, sa.getHostCard(), ai); List manaSpentToPay = test ? new ArrayList<>() : sa.getPayingMana(); + List paymentList = Lists.newArrayList(); + + if (payManaCostFromPool(cost, sa, ai, test, manaSpentToPay)) { + return true; // paid all from floating mana + } + boolean purePhyrexian = cost.containsOnlyPhyrexianMana(); - int testEnergyPool = ai.getCounters(CounterEnumType.ENERGY); boolean ignoreColor = false, ignoreType = false; StaticAbility mayPlay = sa.getMayPlay(); @@ -691,13 +696,6 @@ public class ComputerUtilMana { ignoreType = true; } } - - List paymentList = Lists.newArrayList(); - - if (payManaCostFromPool(cost, sa, ai, test, manaSpentToPay)) { - return true; // paid all from floating mana - } - boolean hasConverge = sa.getHostCard().hasConverge(); ListMultimap sourcesForShards = getSourcesForShards(cost, sa, ai, test, checkPlayable, manaSpentToPay, hasConverge, ignoreColor, ignoreType); @@ -706,6 +704,7 @@ public class ComputerUtilMana { return false; // no mana abilities to use for paying } + int testEnergyPool = ai.getCounters(CounterEnumType.ENERGY); final ManaPool manapool = ai.getManaPool(); ManaCostShard toPay = null; List saExcludeList = new ArrayList<>(); diff --git a/forge-game/src/main/java/forge/game/cost/CostAdjustment.java b/forge-game/src/main/java/forge/game/cost/CostAdjustment.java index 90a597fd40f..1ad7d49236e 100644 --- a/forge-game/src/main/java/forge/game/cost/CostAdjustment.java +++ b/forge-game/src/main/java/forge/game/cost/CostAdjustment.java @@ -36,16 +36,14 @@ import forge.game.zone.ZoneType; public class CostAdjustment { public static Cost adjust(final Cost cost, final SpellAbility sa) { - final Player player = sa.getActivatingPlayer(); - final Card host = sa.getHostCard(); - final Game game = player.getGame(); - if (sa.isTrigger() || cost == null) { return cost; } + final Player player = sa.getActivatingPlayer(); + final Card host = sa.getHostCard(); + final Game game = player.getGame(); Cost result = cost.copy(); - boolean isStateChangeToFaceDown = false; if (sa.isSpell()) { @@ -158,14 +156,14 @@ public class CostAdjustment { // If cardsToDelveOut is null, will immediately exile the delved cards and remember them on the host card. // Otherwise, will return them in cardsToDelveOut and the caller is responsible for doing the above. public static final void adjust(ManaCostBeingPaid cost, final SpellAbility sa, CardCollection cardsToDelveOut, boolean test) { - final Game game = sa.getActivatingPlayer().getGame(); - final Card originalCard = sa.getHostCard(); - if (sa.isTrigger()) { return; } + final Game game = sa.getActivatingPlayer().getGame(); + final Card originalCard = sa.getHostCard(); boolean isStateChangeToFaceDown = false; + if (sa.isSpell()) { if (sa.isCastFaceDown()) { // Turn face down to apply cost modifiers correctly diff --git a/forge-game/src/main/java/forge/game/cost/CostPayment.java b/forge-game/src/main/java/forge/game/cost/CostPayment.java index 41c7c712717..74e1836d044 100644 --- a/forge-game/src/main/java/forge/game/cost/CostPayment.java +++ b/forge-game/src/main/java/forge/game/cost/CostPayment.java @@ -23,11 +23,9 @@ import java.util.Map; import com.google.common.collect.Lists; import com.google.common.collect.Maps; -import forge.card.mana.ManaCost; import forge.game.Game; import forge.game.card.Card; import forge.game.mana.ManaConversionMatrix; -import forge.game.mana.ManaCostBeingPaid; import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; @@ -181,18 +179,8 @@ public class CostPayment extends ManaConversionMatrix { } Map decisions = Maps.newHashMap(); - Cost adjustedCost = CostAdjustment.adjust(cost, ability); - List parts = adjustedCost.getCostParts(); - - // For Trinisphere - if (!adjustedCost.hasManaCost()) { - ManaCostBeingPaid mc = new ManaCostBeingPaid(ManaCost.ZERO); - CostAdjustment.adjust(mc, ability, null, false); - if (mc.getConvertedManaCost() > 0) { - // add placeholder so AI will calculate it - parts.add(new CostPartMana(ManaCost.ZERO, null)); - } - } + // for Trinisphere make sure to include Zero + List parts = CostAdjustment.adjust(cost, ability).getCostPartsWithZeroMana(); // Set all of the decisions before attempting to pay anything