mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 04:38:00 +00:00
[Simulated AI] Add support for cards that need multiple targets.
Note: Currently, no special optimizations are made to try to prune decision trees for these, even though they definitely can result in a lot of choices and really slow simulation AI performance.
This commit is contained in:
@@ -421,7 +421,7 @@ public class GameSimulatorTest extends SimulationTestCase {
|
||||
assertNotNull(sa);
|
||||
sa.setActivatingPlayer(p);
|
||||
|
||||
PossibleTargetSelector selector = new PossibleTargetSelector(sa);
|
||||
MultiTargetSelector selector = new MultiTargetSelector(sa, null);
|
||||
while (selector.selectNextTargets()) {
|
||||
GameSimulator sim = createSimulator(game, p);
|
||||
sim.simulateSpellAbility(sa);
|
||||
|
||||
@@ -171,4 +171,30 @@ public class SpellAbilityPickerTest extends SimulationTestCase {
|
||||
String expected = "Fiery Confluence -> " + dmgOppStr + " " + dmgOppStr + " " + dmgOppStr;
|
||||
assertEquals(expected, picker.getPlan().getDecisions().get(0).modesStr);
|
||||
}
|
||||
|
||||
public void testMultipleTargets() {
|
||||
Game game = initAndCreateGame();
|
||||
Player p = game.getPlayers().get(1);
|
||||
|
||||
addCard("Mountain", p);
|
||||
addCard("Mountain", p);
|
||||
Card spell = addCardToZone("Arc Trail", p, ZoneType.Hand);
|
||||
|
||||
Player opponent = game.getPlayers().get(0);
|
||||
Card bear = addCard("Runeclaw Bear", opponent);
|
||||
Card men = addCard("Flying Men", opponent);
|
||||
opponent.setLife(20, null);
|
||||
|
||||
game.getPhaseHandler().devModeSet(PhaseType.MAIN1, p);
|
||||
game.getAction().checkStateEffects(true);
|
||||
|
||||
SpellAbilityPicker picker = new SpellAbilityPicker(game, p);
|
||||
SpellAbility sa = picker.chooseSpellAbilityToPlay(null);
|
||||
assertEquals(spell.getSpellAbilities().get(0), sa);
|
||||
assertEquals(bear, sa.getTargetCard());
|
||||
assertEquals("2", sa.getParam("NumDmg"));
|
||||
SpellAbility subSa = sa.getSubAbility();
|
||||
assertEquals(men, subSa.getTargetCard());
|
||||
assertEquals("1", subSa.getParam("NumDmg"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user