DetachedCardEffect GameCopier copying

This commit is contained in:
Jetz
2024-08-25 16:40:58 -04:00
parent b97788d8eb
commit fd56341446
2 changed files with 12 additions and 2 deletions

View File

@@ -17,6 +17,7 @@ import forge.ai.LobbyPlayerAi;
import forge.card.CardRarity; import forge.card.CardRarity;
import forge.card.CardRules; import forge.card.CardRules;
import forge.game.*; import forge.game.*;
import forge.game.ability.effects.DetachedCardEffect;
import forge.game.card.*; import forge.game.card.*;
import forge.game.card.token.TokenInfo; import forge.game.card.token.TokenInfo;
import forge.game.combat.Combat; import forge.game.combat.Combat;
@@ -310,7 +311,11 @@ public class GameCopier {
// The issue is that it requires parsing the original card from scratch from the paper card. We should // The issue is that it requires parsing the original card from scratch from the paper card. We should
// improve the copier to accurately copy the card from its actual state, so that the paper card shouldn't // improve the copier to accurately copy the card from its actual state, so that the paper card shouldn't
// be needed. Once the below code accurately copies the card, remove the USE_FROM_PAPER_CARD code path. // be needed. Once the below code accurately copies the card, remove the USE_FROM_PAPER_CARD code path.
Card newCard = new Card(newGame.nextCardId(), c.getPaperCard(), newGame); Card newCard;
if (c instanceof DetachedCardEffect)
newCard = new DetachedCardEffect((DetachedCardEffect) c, newGame, true);
else
newCard = new Card(newGame.nextCardId(), c.getPaperCard(), newGame);
newCard.setOwner(newOwner); newCard.setOwner(newOwner);
newCard.setName(c.getName()); newCard.setName(c.getName());
newCard.setCommander(c.isCommander()); newCard.setCommander(c.isCommander());

View File

@@ -1,6 +1,7 @@
package forge.game.ability.effects; package forge.game.ability.effects;
import forge.card.GamePieceType; import forge.card.GamePieceType;
import forge.game.Game;
import forge.game.card.Card; import forge.game.card.Card;
import forge.game.player.Player; import forge.game.player.Player;
@@ -30,7 +31,11 @@ public class DetachedCardEffect extends Card {
} }
public DetachedCardEffect(DetachedCardEffect from, boolean assignNewId) { public DetachedCardEffect(DetachedCardEffect from, boolean assignNewId) {
super(assignNewId ? from.getGame().nextCardId() : from.id, from.getPaperCard(), from.getGame()); this(from, from.getGame(), assignNewId);
}
public DetachedCardEffect(DetachedCardEffect from, Game game, boolean assignNewId) {
super(assignNewId ? game.nextCardId() : from.id, from.getPaperCard(), from.getGame());
this.setName(from.getName()); this.setName(from.getName());
this.setOwner(from.getOwner()); this.setOwner(from.getOwner());
this.setGamePieceType(GamePieceType.EFFECT); this.setGamePieceType(GamePieceType.EFFECT);