From e5c25f1cab8ae94cb754e85e40cc4d0458054213 Mon Sep 17 00:00:00 2001 From: Agetian Date: Fri, 16 Jan 2015 10:44:15 +0000 Subject: [PATCH] - Second attempt at fixing the keywords lingering longer than necessary, looks like there were actually two related problems - the data about equipments being copied over to a temporary copy that then became a card going to graveyard *and* the keywords from enchantments and such staying on the card (even the copied one, without any enchantment info being hard-copied) when going to graveyard. - A better fix for the second problem would be to actually find *why* (and where in the code) those keywords are not cleaned up and clean them up there, but I can't find where it is for now. Please review and update as necessary. --- .../src/main/java/forge/game/GameAction.java | 9 ++++++++- .../src/main/java/forge/game/card/CardFactory.java | 14 ++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/forge-game/src/main/java/forge/game/GameAction.java b/forge-game/src/main/java/forge/game/GameAction.java index 0c6cdf01f9f..d49b450b040 100644 --- a/forge-game/src/main/java/forge/game/GameAction.java +++ b/forge-game/src/main/java/forge/game/GameAction.java @@ -136,7 +136,14 @@ public class GameAction { c.updateStateForView(); } - copied = CardFactory.copyCard(c, false); + copied = CardFactory.copyCard(c, false, false); + + // clear any leftover keyword replacements from the card leaving battlefield + copied.removeChangedCardKeywords(copied.getTimestamp()); + copied.removeChangedCardTypes(copied.getTimestamp()); + copied.removeChangedTextColorWord(copied.getTimestamp()); + copied.removeChangedTextTypeWord(copied.getTimestamp()); + copied.setUnearthed(c.isUnearthed()); copied.setTapped(false); for (final Trigger trigger : copied.getTriggers()) { diff --git a/forge-game/src/main/java/forge/game/card/CardFactory.java b/forge-game/src/main/java/forge/game/card/CardFactory.java index 2d889f6cfaa..2cd70cb87ea 100644 --- a/forge-game/src/main/java/forge/game/card/CardFactory.java +++ b/forge-game/src/main/java/forge/game/card/CardFactory.java @@ -78,6 +78,10 @@ public class CardFactory { * @return a {@link forge.game.card.Card} object. */ public final static Card copyCard(final Card in, boolean assignNewId) { + return copyCard(in, assignNewId, true); + } + + public final static Card copyCard(final Card in, boolean assignNewId, boolean copyAttachmentData) { Card out; if (!(in.isToken() || in.getCopiedPermanent() != null)) { out = assignNewId ? getCard(in.getPaperCard(), in.getOwner(), in.getGame()) @@ -99,6 +103,16 @@ public class CardFactory { } out.setState(in.getCurrentStateName(), true); + if (copyAttachmentData) { + // I'm not sure if we really should be copying enchant/equip stuff over. + out.setEquipping(in.getEquipping()); + out.setEquippedBy(in.getEquippedBy(false)); + out.setFortifying(in.getFortifying()); + out.setFortifiedBy(in.getFortifiedBy(false)); + out.setEnchantedBy(in.getEnchantedBy(false)); + out.setEnchanting(in.getEnchanting()); + } + out.setClones(in.getClones()); out.setZone(in.getZone()); for (final Object o : in.getRemembered()) {