TestCase: fix Manifest test

This commit is contained in:
Hans Mackowiak
2021-02-09 22:47:31 +01:00
parent c830641bc9
commit a82f035211
4 changed files with 11 additions and 11 deletions

View File

@@ -294,11 +294,6 @@ public class GameCopier {
newCard.turnFaceDown(true); newCard.turnFaceDown(true);
if (c.isManifested()) { if (c.isManifested()) {
newCard.setManifested(true); newCard.setManifested(true);
// TODO: Should be able to copy other abilities...
if (isCreature && hasManaCost) {
newCard.getState(CardStateName.Original).addSpellAbility(
CardFactoryUtil.abilityManifestFaceUp(newCard, newCard.getManaCost()));
}
} }
} }
if (c.isMonstrous()) { if (c.isMonstrous()) {

View File

@@ -17,7 +17,6 @@ import forge.game.player.Player;
import forge.game.spellability.SpellAbility; import forge.game.spellability.SpellAbility;
import forge.game.spellability.TargetChoices; import forge.game.spellability.TargetChoices;
import forge.game.spellability.TargetRestrictions; import forge.game.spellability.TargetRestrictions;
import forge.util.TextUtil;
public class GameSimulator { public class GameSimulator {
public static boolean COPY_STACK = false; public static boolean COPY_STACK = false;
@@ -125,11 +124,13 @@ public class GameSimulator {
} }
private SpellAbility findSaInSimGame(SpellAbility sa) { private SpellAbility findSaInSimGame(SpellAbility sa) {
// is already an ability from sim game
if (sa.getHostCard().getGame().equals(this.simGame)) {
return sa;
}
Card origHostCard = sa.getHostCard(); Card origHostCard = sa.getHostCard();
Card hostCard = (Card) copier.find(origHostCard); Card hostCard = (Card) copier.find(origHostCard);
String desc = sa.getDescription(); String desc = sa.getDescription();
// FIXME: This is a hack that makes testManifest pass - figure out why it's needed.
desc = TextUtil.fastReplace(desc, "Unmanifest {0}", "Unmanifest no cost");
for (SpellAbility cSa : hostCard.getSpellAbilities()) { for (SpellAbility cSa : hostCard.getSpellAbilities()) {
if (desc.startsWith(cSa.getDescription())) { if (desc.startsWith(cSa.getDescription())) {
return cSa; return cSa;

View File

@@ -177,7 +177,7 @@ public class CardFactoryUtil {
// Cost need to be set later // Cost need to be set later
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("ST$ SetState | Cost$ 0 | CostDesc$ Unmanifest ").append(costDesc); sb.append("ST$ SetState | Cost$ 0 | CostDesc$ Unmanifest ").append(costDesc);
sb.append(" | ManifestUp$ True | Secondary$ True | IsPresent$ Card.Self+faceDown+manifested"); sb.append(" | ManifestUp$ True | Secondary$ True | PresentDefined$ Self | IsPresent$ Card.faceDown+manifested");
sb.append(" | Mode$ TurnFace | SpellDescription$ (Turn this face up any time for its mana cost.)"); sb.append(" | Mode$ TurnFace | SpellDescription$ (Turn this face up any time for its mana cost.)");
final SpellAbility manifestUp = AbilityFactory.getAbility(sb.toString(), sourceCard); final SpellAbility manifestUp = AbilityFactory.getAbility(sb.toString(), sourceCard);

View File

@@ -304,14 +304,18 @@ public class GameSimulatorTest extends SimulationTestCase {
Card manifestedCreature = findCardWithName(simGame, ""); Card manifestedCreature = findCardWithName(simGame, "");
assertNotNull(manifestedCreature); assertNotNull(manifestedCreature);
SpellAbility unmanifestSA = findSAWithPrefix(manifestedCreature, "Unmanifest"); SpellAbility unmanifestSA = findSAWithPrefix(manifestedCreature.getAllPossibleAbilities(p, false), "Unmanifest");
assertNotNull(unmanifestSA); assertNotNull(unmanifestSA);
assertEquals(2, manifestedCreature.getNetPower()); assertEquals(2, manifestedCreature.getNetPower());
assertFalse(manifestedCreature.hasKeyword("Flying")); assertFalse(manifestedCreature.hasKeyword("Flying"));
GameSimulator sim2 = createSimulator(simGame, simGame.getPlayers().get(1)); GameSimulator sim2 = createSimulator(simGame, simGame.getPlayers().get(1));
sim2.simulateSpellAbility(unmanifestSA);
Game simGame2 = sim2.getSimulatedGameState(); Game simGame2 = sim2.getSimulatedGameState();
manifestedCreature = findCardWithName(simGame2, "");
unmanifestSA = findSAWithPrefix(manifestedCreature.getAllPossibleAbilities(simGame2.getPlayers().get(1), false), "Unmanifest");
sim2.simulateSpellAbility(unmanifestSA);
Card ornithopter = findCardWithName(simGame2, "Ornithopter"); Card ornithopter = findCardWithName(simGame2, "Ornithopter");
assertEquals(0, ornithopter.getNetPower()); assertEquals(0, ornithopter.getNetPower());
assertTrue(ornithopter.hasKeyword("Flying")); assertTrue(ornithopter.hasKeyword("Flying"));