mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
[Simulated AI] Fix transformed state with a test and commit part of my fix from my previous change.
I forgot to actually commit the validation and activatedPlayer setting part of my last change, so this change contains that too.
This commit is contained in:
@@ -186,6 +186,7 @@ public class GameCopier {
|
||||
Card otherCard = cardMap.get(card);
|
||||
otherCard.setTimestamp(card.getTimestamp());
|
||||
otherCard.setSickness(card.hasSickness());
|
||||
otherCard.setState(card.getCurrentStateName(), false);
|
||||
if (card.isEnchanting()) {
|
||||
otherCard.setEnchanting(gameObjectMap.map(card.getEnchanting()));
|
||||
}
|
||||
|
||||
@@ -705,4 +705,40 @@ public class GameSimulatorTest extends TestCase {
|
||||
Card giantCopy = findCardWithName(copy, giantCardName);
|
||||
assertEquals(2, giantCopy.getDamage());
|
||||
}
|
||||
|
||||
public void testTransform() {
|
||||
Game game = initAndCreateGame();
|
||||
Player p = game.getPlayers().get(1);
|
||||
addCard("Swamp", p);
|
||||
addCard("Swamp", p);
|
||||
addCard("Swamp", p);
|
||||
String lilianaCardName = "Liliana, Heretical Healer";
|
||||
String lilianaPWName = "Liliana, Defiant Necromancer";
|
||||
Card lilianaInPlay = addCard(lilianaCardName, p);
|
||||
Card lilianaInHand = addCardToZone(lilianaCardName, p, ZoneType.Hand);
|
||||
|
||||
game.getPhaseHandler().devModeSet(PhaseType.MAIN2, p);
|
||||
game.getAction().checkStateEffects(true);
|
||||
|
||||
assertTrue(lilianaInPlay.isCreature());
|
||||
assertEquals(2, lilianaInPlay.getNetPower());
|
||||
assertEquals(3, lilianaInPlay.getNetToughness());
|
||||
|
||||
SpellAbility playLiliana = lilianaInHand.getSpellAbilities().get(0);
|
||||
GameSimulator sim = createSimulator(game, p);
|
||||
sim.simulateSpellAbility(playLiliana);
|
||||
Game simGame = sim.getSimulatedGameState();
|
||||
assertNull(findCardWithName(simGame, lilianaCardName));
|
||||
Card lilianaPW = findCardWithName(simGame, lilianaPWName);
|
||||
assertNotNull(lilianaPW);
|
||||
assertTrue(lilianaPW.isPlaneswalker());
|
||||
assertEquals(3, lilianaPW.getCurrentLoyalty());
|
||||
|
||||
GameCopier copier = new GameCopier(simGame);
|
||||
Game copy = copier.makeCopy();
|
||||
Card lilianaPWCopy = findCardWithName(copy, lilianaPWName);
|
||||
assertNotNull(lilianaPWCopy);
|
||||
assertTrue(lilianaPWCopy.isPlaneswalker());
|
||||
assertEquals(3, lilianaPWCopy.getCurrentLoyalty());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user