mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 20:58:03 +00:00
Fix copying of emblems for simulated AI along with a test.
This commit is contained in:
@@ -28,6 +28,7 @@ import forge.game.spellability.AbilityActivated;
|
|||||||
import forge.game.spellability.SpellAbility;
|
import forge.game.spellability.SpellAbility;
|
||||||
import forge.game.spellability.SpellAbilityRestriction;
|
import forge.game.spellability.SpellAbilityRestriction;
|
||||||
import forge.game.spellability.SpellAbilityStackInstance;
|
import forge.game.spellability.SpellAbilityStackInstance;
|
||||||
|
import forge.game.staticability.StaticAbility;
|
||||||
import forge.game.trigger.TriggerType;
|
import forge.game.trigger.TriggerType;
|
||||||
import forge.game.zone.PlayerZoneBattlefield;
|
import forge.game.zone.PlayerZoneBattlefield;
|
||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
@@ -188,14 +189,13 @@ public class GameCopier {
|
|||||||
|
|
||||||
private static final boolean USE_FROM_PAPER_CARD = true;
|
private static final boolean USE_FROM_PAPER_CARD = true;
|
||||||
private Card createCardCopy(Game newGame, Player newOwner, Card c) {
|
private Card createCardCopy(Game newGame, Player newOwner, Card c) {
|
||||||
if (c.isToken()) {
|
if (c.isToken() && !c.isEmblem()) {
|
||||||
String tokenStr = new CardFactory.TokenInfo(c).toString();
|
String tokenStr = new CardFactory.TokenInfo(c).toString();
|
||||||
// TODO: Use a version of the API that doesn't return a list (i.e. these shouldn't be affected
|
// TODO: Use a version of the API that doesn't return a list (i.e. these shouldn't be affected
|
||||||
// by doubling season, etc).
|
// by doubling season, etc).
|
||||||
return CardFactory.makeToken(CardFactory.TokenInfo.fromString(tokenStr), newOwner).get(0);
|
return CardFactory.makeToken(CardFactory.TokenInfo.fromString(tokenStr), newOwner).get(0);
|
||||||
}
|
}
|
||||||
|
if (USE_FROM_PAPER_CARD && !c.isEmblem()) {
|
||||||
if (USE_FROM_PAPER_CARD) {
|
|
||||||
return Card.fromPaperCard(c.getPaperCard(), newOwner);
|
return Card.fromPaperCard(c.getPaperCard(), newOwner);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -209,6 +209,9 @@ public class GameCopier {
|
|||||||
for (String type : c.getType()) {
|
for (String type : c.getType()) {
|
||||||
newCard.addType(type);
|
newCard.addType(type);
|
||||||
}
|
}
|
||||||
|
for (StaticAbility stAb : c.getStaticAbilities()) {
|
||||||
|
newCard.addStaticAbilityCopy(stAb);
|
||||||
|
}
|
||||||
for (SpellAbility sa : c.getSpellAbilities()) {
|
for (SpellAbility sa : c.getSpellAbilities()) {
|
||||||
SpellAbility saCopy;
|
SpellAbility saCopy;
|
||||||
|
|
||||||
|
|||||||
@@ -3457,6 +3457,11 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
public final StaticAbility addStaticAbilityCopy(final StaticAbility stAb) {
|
||||||
|
final StaticAbility stAbCopy = new StaticAbility(stAb, this);
|
||||||
|
currentState.addStaticAbility(stAbCopy);
|
||||||
|
return stAbCopy;
|
||||||
|
}
|
||||||
public final void removeStaticAbility(StaticAbility stAb) {
|
public final void removeStaticAbility(StaticAbility stAb) {
|
||||||
currentState.removeStaticAbility(stAb);
|
currentState.removeStaticAbility(stAb);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -215,6 +215,13 @@ public class StaticAbility extends CardTraitBase implements Comparable<StaticAbi
|
|||||||
this.hostCard = host;
|
this.hostCard = host;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public StaticAbility(StaticAbility stAb, Card host) {
|
||||||
|
this.originalMapParams.putAll(stAb.originalMapParams);
|
||||||
|
this.mapParams.putAll(stAb.mapParams);
|
||||||
|
this.layers = this.generateLayer();
|
||||||
|
this.hostCard = host;
|
||||||
|
}
|
||||||
|
|
||||||
public final CardCollectionView applyContinuousAbility(final StaticAbilityLayer layer) {
|
public final CardCollectionView applyContinuousAbility(final StaticAbilityLayer layer) {
|
||||||
if (!shouldApplyContinuousAbility(layer, false)) {
|
if (!shouldApplyContinuousAbility(layer, false)) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -340,7 +340,37 @@ public class GameSimulatorTest extends TestCase {
|
|||||||
assertFalse(minusTwoCopy.canPlay());
|
assertFalse(minusTwoCopy.canPlay());
|
||||||
assertEquals(1, minusTwoCopy.getActivationsThisTurn());
|
assertEquals(1, minusTwoCopy.getActivationsThisTurn());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testPlaneswalkerEmblems() {
|
||||||
|
Game game = initAndCreateGame();
|
||||||
|
Player p = game.getPlayers().get(1);
|
||||||
|
String bearCardName = "Runeclaw Bear";
|
||||||
|
addCard(bearCardName, p);
|
||||||
|
Card gideon = addCard("Gideon, Ally of Zendikar", p);
|
||||||
|
gideon.addCounter(CounterType.LOYALTY, 4, false);
|
||||||
|
|
||||||
|
game.getPhaseHandler().devModeSet(PhaseType.MAIN2, p);
|
||||||
|
game.getAction().checkStateEffects(true);
|
||||||
|
|
||||||
|
CardCollection cards = ComputerUtilAbility.getAvailableCards(game, p);
|
||||||
|
List<SpellAbility> abilities = ComputerUtilAbility.getSpellAbilities(cards, p);
|
||||||
|
SpellAbility minusFour = findSAWithPrefix(abilities, "-4: You get an emblem");
|
||||||
|
assertNotNull(minusFour);
|
||||||
|
minusFour.setActivatingPlayer(p);
|
||||||
|
assertTrue(minusFour.canPlay());
|
||||||
|
|
||||||
|
GameSimulator sim = createSimulator(game, p);
|
||||||
|
sim.simulateSpellAbility(minusFour);
|
||||||
|
Game simGame = sim.getSimulatedGameState();
|
||||||
|
Card simBear = findCardWithName(simGame, bearCardName);
|
||||||
|
assertEquals(3, simBear.getNetPower());
|
||||||
|
|
||||||
|
GameCopier copier = new GameCopier(simGame);
|
||||||
|
Game copy = copier.makeCopy();
|
||||||
|
Card copyBear = findCardWithName(copy, bearCardName);
|
||||||
|
assertEquals(3, copyBear.getNetPower());
|
||||||
|
}
|
||||||
|
|
||||||
public void testManifest() {
|
public void testManifest() {
|
||||||
Game game = initAndCreateGame();
|
Game game = initAndCreateGame();
|
||||||
Player p = game.getPlayers().get(1);
|
Player p = game.getPlayers().get(1);
|
||||||
|
|||||||
Reference in New Issue
Block a user