diff --git a/forge-ai/src/main/java/forge/ai/simulation/GameStateEvaluator.java b/forge-ai/src/main/java/forge/ai/simulation/GameStateEvaluator.java index e95f45365ca..6f8bd03b07c 100644 --- a/forge-ai/src/main/java/forge/ai/simulation/GameStateEvaluator.java +++ b/forge-ai/src/main/java/forge/ai/simulation/GameStateEvaluator.java @@ -6,9 +6,14 @@ import forge.game.card.Card; import forge.game.card.CounterEnumType; import forge.game.phase.PhaseType; import forge.game.player.Player; +import forge.game.spellability.AbilityManaPart; import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + import static java.lang.Math.max; public class GameStateEvaluator { @@ -160,11 +165,15 @@ public class GameStateEvaluator { // for each mana color a land generates for free, increase the value by one // for each mana a land can produce, add one hundred. int max_produced = 0; - int possible_colors = 0; + Set colors_produced = new HashSet<>(); for (SpellAbility m: c.getManaAbilities()) { - max_produced = max(max_produced, m.amountOfManaGenerated(false)); + max_produced = max(max_produced, m.amountOfManaGenerated(true)); + for (AbilityManaPart mp : m.getAllManaParts()) { + colors_produced.addAll(Arrays.asList(mp.mana(m).split(" "))); + } } value = 100 * max_produced; + value += colors_produced.size(); return value; } else if (c.isEnchantingCard()) { // TODO: Should provide value in whatever it's enchanting? diff --git a/forge-gui-desktop/src/test/java/forge/ai/simulation/SpellAbilityPickerSimulationTest.java b/forge-gui-desktop/src/test/java/forge/ai/simulation/SpellAbilityPickerSimulationTest.java index a40923c3581..87203f4f400 100644 --- a/forge-gui-desktop/src/test/java/forge/ai/simulation/SpellAbilityPickerSimulationTest.java +++ b/forge-gui-desktop/src/test/java/forge/ai/simulation/SpellAbilityPickerSimulationTest.java @@ -282,7 +282,7 @@ public class SpellAbilityPickerSimulationTest extends SimulationTest { // start with a hand with a basic, a tapland, and a card that can't be cast addCard("Forest", p); addCardToZone("Forest", p, ZoneType.Hand); - Card guildgate = addCardToZone("Simic Guildgate", p, ZoneType.Hand); + Card desired = addCardToZone("Simic Guildgate", p, ZoneType.Hand); addCardToZone("Centaur Courser", p, ZoneType.Hand); game.getPhaseHandler().devModeSet(PhaseType.MAIN1, p); game.getAction().checkStateEffects(true); @@ -290,7 +290,28 @@ public class SpellAbilityPickerSimulationTest extends SimulationTest { // ensure that the tapland is paid SpellAbilityPicker picker = new SpellAbilityPicker(game, p); SpellAbility sa = picker.chooseSpellAbilityToPlay(null); - AssertJUnit.assertEquals(guildgate, sa.getHostCard()); + AssertJUnit.assertEquals(desired, sa.getHostCard()); + } + + @Test + public void playBouncelandIfNoPlays() { + Game game = initAndCreateGame(); + Player p = game.getPlayers().get(1); + + // start with a hand with a basic, a bounceland, and a card that can't be cast + addCard("Forest", p); + addCardToZone("Forest", p, ZoneType.Hand); + Card desired = addCardToZone("Simic Growth Chamber", p, ZoneType.Hand); + addCardToZone("Centaur Courser", p, ZoneType.Hand); + game.getPhaseHandler().devModeSet(PhaseType.MAIN1, p); + game.getAction().checkStateEffects(true); + + System.out.println(new GameStateEvaluator().evalCard(game, null, desired)); + + // ensure that the tapland is paid + SpellAbilityPicker picker = new SpellAbilityPicker(game, p); + SpellAbility sa = picker.chooseSpellAbilityToPlay(null); + AssertJUnit.assertEquals(desired, sa.getHostCard()); } @Test