implemented bounceland test and fix

This commit is contained in:
marthinwurer
2023-01-25 22:28:44 -07:00
committed by Chris H
parent 7c4b6c5f27
commit 47c9d32435
2 changed files with 34 additions and 4 deletions

View File

@@ -6,9 +6,14 @@ import forge.game.card.Card;
import forge.game.card.CounterEnumType; import forge.game.card.CounterEnumType;
import forge.game.phase.PhaseType; import forge.game.phase.PhaseType;
import forge.game.player.Player; import forge.game.player.Player;
import forge.game.spellability.AbilityManaPart;
import forge.game.spellability.SpellAbility; import forge.game.spellability.SpellAbility;
import forge.game.zone.ZoneType; import forge.game.zone.ZoneType;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import static java.lang.Math.max; import static java.lang.Math.max;
public class GameStateEvaluator { 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 color a land generates for free, increase the value by one
// for each mana a land can produce, add one hundred. // for each mana a land can produce, add one hundred.
int max_produced = 0; int max_produced = 0;
int possible_colors = 0; Set<String> colors_produced = new HashSet<>();
for (SpellAbility m: c.getManaAbilities()) { 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 = 100 * max_produced;
value += colors_produced.size();
return value; return value;
} else if (c.isEnchantingCard()) { } else if (c.isEnchantingCard()) {
// TODO: Should provide value in whatever it's enchanting? // TODO: Should provide value in whatever it's enchanting?

View File

@@ -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 // start with a hand with a basic, a tapland, and a card that can't be cast
addCard("Forest", p); addCard("Forest", p);
addCardToZone("Forest", p, ZoneType.Hand); 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); addCardToZone("Centaur Courser", p, ZoneType.Hand);
game.getPhaseHandler().devModeSet(PhaseType.MAIN1, p); game.getPhaseHandler().devModeSet(PhaseType.MAIN1, p);
game.getAction().checkStateEffects(true); game.getAction().checkStateEffects(true);
@@ -290,7 +290,28 @@ public class SpellAbilityPickerSimulationTest extends SimulationTest {
// ensure that the tapland is paid // ensure that the tapland is paid
SpellAbilityPicker picker = new SpellAbilityPicker(game, p); SpellAbilityPicker picker = new SpellAbilityPicker(game, p);
SpellAbility sa = picker.chooseSpellAbilityToPlay(null); 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 @Test