implemented tron test and fix

This commit is contained in:
marthinwurer
2023-01-25 21:43:53 -07:00
committed by Chris H
parent 270f7116ec
commit 7c4b6c5f27
3 changed files with 46 additions and 2 deletions

View File

@@ -6,8 +6,11 @@ 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.SpellAbility;
import forge.game.zone.ZoneType; import forge.game.zone.ZoneType;
import static java.lang.Math.max;
public class GameStateEvaluator { public class GameStateEvaluator {
private boolean debugging = false; private boolean debugging = false;
private SimulationCreatureEvaluator eval = new SimulationCreatureEvaluator(); private SimulationCreatureEvaluator eval = new SimulationCreatureEvaluator();
@@ -153,7 +156,16 @@ public class GameStateEvaluator {
if (c.isCreature()) { if (c.isCreature()) {
return eval.evaluateCreature(c); return eval.evaluateCreature(c);
} else if (c.isLand()) { } else if (c.isLand()) {
return 100; int value = 100;
// 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;
for (SpellAbility m: c.getManaAbilities()) {
max_produced = max(max_produced, m.amountOfManaGenerated(false));
}
value = 100 * max_produced;
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?
// Else the computer would think that casting a Lifelink enchantment // Else the computer would think that casting a Lifelink enchantment

View File

@@ -1657,7 +1657,16 @@ public class AbilityUtils {
final String s2 = applyAbilityTextChangeEffects(s, ctb); final String s2 = applyAbilityTextChangeEffects(s, ctb);
final String[] l = s2.split("/"); final String[] l = s2.split("/");
final String expr = CardFactoryUtil.extractOperators(s2); final String expr = CardFactoryUtil.extractOperators(s2);
final Player player = ctb == null ? null : ctb instanceof SpellAbility ? ((SpellAbility)ctb).getActivatingPlayer() : ctb.getHostCard().getController();
Player player = null;
if (ctb != null) {
if (ctb instanceof SpellAbility) {
player = ((SpellAbility)ctb).getActivatingPlayer();
}
if (player == null) {
player = ctb.getHostCard().getController();
}
}
// accept straight numbers // accept straight numbers
if (l[0].startsWith("Number$")) { if (l[0].startsWith("Number$")) {

View File

@@ -279,6 +279,7 @@ public class SpellAbilityPickerSimulationTest extends SimulationTest {
Game game = initAndCreateGame(); Game game = initAndCreateGame();
Player p = game.getPlayers().get(1); Player p = game.getPlayers().get(1);
// 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 guildgate = addCardToZone("Simic Guildgate", p, ZoneType.Hand);
@@ -286,11 +287,33 @@ public class SpellAbilityPickerSimulationTest extends SimulationTest {
game.getPhaseHandler().devModeSet(PhaseType.MAIN1, p); game.getPhaseHandler().devModeSet(PhaseType.MAIN1, p);
game.getAction().checkStateEffects(true); game.getAction().checkStateEffects(true);
// 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(guildgate, sa.getHostCard());
} }
@Test
public void playTronOverBasic() {
Game game = initAndCreateGame();
Player p = game.getPlayers().get(1);
// start with a hand with a basic, a Tron land, and a card that can't be cast
addCard("Urza's Tower", p);
addCard("Urza's Mine", p);
addCardToZone("Forest", p, ZoneType.Hand);
Card desired = addCardToZone("Urza's Power Plant", p, ZoneType.Hand);
addCardToZone("Opt", p, ZoneType.Hand);
game.getPhaseHandler().devModeSet(PhaseType.MAIN1, p);
game.getAction().checkStateEffects(true);
AssertJUnit.assertEquals(p, desired.getController());
// ensure that the tapland is paid
SpellAbilityPicker picker = new SpellAbilityPicker(game, p);
SpellAbility sa = picker.chooseSpellAbilityToPlay(null);
AssertJUnit.assertEquals(desired, sa.getHostCard());
}
@Test @Test
public void testPlayRememberedCardsLand() { public void testPlayRememberedCardsLand() {
Game game = initAndCreateGame(); Game game = initAndCreateGame();