mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
Fix copying game objects with chosen things (for simulation AI).
This commit is contained in:
@@ -5,6 +5,7 @@ import java.util.Map.Entry;
|
|||||||
|
|
||||||
import com.google.common.collect.BiMap;
|
import com.google.common.collect.BiMap;
|
||||||
import com.google.common.collect.HashBiMap;
|
import com.google.common.collect.HashBiMap;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
import forge.LobbyPlayer;
|
import forge.LobbyPlayer;
|
||||||
import forge.ai.LobbyPlayerAi;
|
import forge.ai.LobbyPlayerAi;
|
||||||
@@ -254,10 +255,19 @@ public class GameCopier {
|
|||||||
newCard.addCounter(CounterType.valueOf(str), count, false);
|
newCard.addCounter(CounterType.valueOf(str), count, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO: Other chosen things...
|
|
||||||
if (c.getChosenPlayer() != null) {
|
if (c.getChosenPlayer() != null) {
|
||||||
newCard.setChosenPlayer(playerMap.get(c.getChosenPlayer()));
|
newCard.setChosenPlayer(playerMap.get(c.getChosenPlayer()));
|
||||||
}
|
}
|
||||||
|
if (!c.getChosenType().isEmpty()) {
|
||||||
|
newCard.setChosenType(c.getChosenType());
|
||||||
|
}
|
||||||
|
if (c.getChosenColors() != null) {
|
||||||
|
newCard.setChosenColors(Lists.newArrayList(c.getChosenColors()));
|
||||||
|
}
|
||||||
|
if (!c.getNamedCard().isEmpty()) {
|
||||||
|
newCard.setNamedCard(c.getNamedCard());
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: FIXME
|
// TODO: FIXME
|
||||||
if (c.hasRemembered()) {
|
if (c.hasRemembered()) {
|
||||||
for (Object o : c.getRemembered()) {
|
for (Object o : c.getRemembered()) {
|
||||||
|
|||||||
@@ -467,4 +467,22 @@ public class GameSimulatorTest extends TestCase {
|
|||||||
assertEquals(3, thopterSim.getCounters(CounterType.P1P1) + bearSim.getCounters(CounterType.P1P1));
|
assertEquals(3, thopterSim.getCounters(CounterType.P1P1) + bearSim.getCounters(CounterType.P1P1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testChosenColors() {
|
||||||
|
String bearCardName = "Runeclaw Bear";
|
||||||
|
|
||||||
|
Game game = initAndCreateGame();
|
||||||
|
Player p = game.getPlayers().get(1);
|
||||||
|
Card bear = addCard(bearCardName, p);
|
||||||
|
Card hall = addCard("Hall of Triumph", p);
|
||||||
|
hall.setChosenColors(Lists.newArrayList("green"));
|
||||||
|
game.getPhaseHandler().devModeSet(PhaseType.MAIN2, p);
|
||||||
|
game.getAction().checkStateEffects(true);
|
||||||
|
assertEquals(3, bear.getNetToughness());
|
||||||
|
|
||||||
|
GameCopier copier = new GameCopier(game);
|
||||||
|
Game copy = copier.makeCopy();
|
||||||
|
Card bearCopy = findCardWithName(copy, bearCardName);
|
||||||
|
assertEquals(3, bearCopy.getNetToughness());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user