mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
implemented bounceland test and fix
This commit is contained in:
@@ -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<String> 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?
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user