diff --git a/forge-game/src/main/java/forge/game/card/Card.java b/forge-game/src/main/java/forge/game/card/Card.java index 49ea1f44a23..15a875eaba3 100644 --- a/forge-game/src/main/java/forge/game/card/Card.java +++ b/forge-game/src/main/java/forge/game/card/Card.java @@ -205,6 +205,8 @@ public class Card extends GameEntity implements Comparable, IHasSVars, ITr private boolean tributed; private Card suspectedEffect = null; + private Map extraEffects = Maps.newHashMap(); + private boolean manifested; private boolean cloaked; @@ -3782,7 +3784,7 @@ public class Card extends GameEntity implements Comparable, IHasSVars, ITr public final void addLeavesPlayCommand(final GameCommand c) { leavePlayCommandList.add(c); } - + public void addStaticCommandList(Object[] objects) { staticCommandList.add(objects); } @@ -4174,6 +4176,9 @@ public class Card extends GameEntity implements Comparable, IHasSVars, ITr eff.addStaticAbility(s); GameCommand until = SpellAbilityEffect.exileEffectCommand(game, eff); + + extraEffects.put(eff, until); + addLeavesPlayCommand(until); addUnattachCommand(until); game.getAction().moveToCommand(eff, sa); @@ -4795,7 +4800,7 @@ public class Card extends GameEntity implements Comparable, IHasSVars, ITr public void addDraftAction(String s) { draftActions.add(s); } - + private int intensity = 0; public final void addIntensity(final int n) { intensity += n; @@ -6562,6 +6567,14 @@ public class Card extends GameEntity implements Comparable, IHasSVars, ITr return (c != null ? c.getImageKey() : ""); } + public Set getExtraEffects() { + return this.extraEffects.keySet(); + } + + public void setExtraEffects(Map map) { + this.extraEffects = map; + } + public final boolean isTributed() { return tributed; } public final void setTributed(final boolean b) { tributed = b; @@ -6750,11 +6763,13 @@ public class Card extends GameEntity implements Comparable, IHasSVars, ITr suspectedStatic.setSVar("SuspectedCantBlockBy", effect); GameCommand until = SpellAbilityEffect.exileEffectCommand(getGame(), suspectedEffect); + extraEffects.put(suspectedEffect, until); addLeavesPlayCommand(until); getGame().getAction().moveToCommand(suspectedEffect, null); } else { if (isSuspected()) { - getGame().getAction().exileEffect(suspectedEffect); + extraEffects.get(suspectedEffect).run(); + extraEffects.remove(suspectedEffect); suspectedEffect = null; } } diff --git a/forge-game/src/main/java/forge/game/card/CardCopyService.java b/forge-game/src/main/java/forge/game/card/CardCopyService.java index 7fb6b7fe9b7..f2b78957564 100644 --- a/forge-game/src/main/java/forge/game/card/CardCopyService.java +++ b/forge-game/src/main/java/forge/game/card/CardCopyService.java @@ -2,6 +2,8 @@ package forge.game.card; import com.google.common.collect.Lists; import com.google.common.collect.Maps; + +import forge.GameCommand; import forge.card.CardStateName; import forge.card.CardType; import forge.game.Game; @@ -173,14 +175,18 @@ public class CardCopyService { // ======================================================== // LKI functions - - public static List getLKICopyList(final Iterable in, Map cachedMap) { + @SuppressWarnings("unchecked") + public static List getLKICopyList(final Iterable in, Map cachedMap) { if (in == null) { return null; } - List result = Lists.newArrayList(); - for (final Card c : in) { - result.add(new CardCopyService(c).getLKICopy(cachedMap)); + List result = Lists.newArrayList(); + for (final T o : in) { + if (o instanceof Card c) { + result.add((T)new CardCopyService(c).getLKICopy(cachedMap)); + } else { + result.add(o); + } } return result; } @@ -277,6 +283,7 @@ public class CardCopyService { newCopy.turnFaceDownNoUpdate(); newCopy.setType(new CardType(copyFrom.getFaceDownState().getType())); } + newCopy.setRenderForUI(copyFrom.getRenderForUI()); // prevent StackDescription from revealing face newCopy.updateStateForView(); @@ -339,9 +346,15 @@ public class CardCopyService { newCopy.setIntensity(copyFrom.getIntensity(false)); newCopy.setPerpetual(copyFrom); - newCopy.addRemembered(copyFrom.getRemembered()); - newCopy.addImprintedCards(copyFrom.getImprintedCards()); - newCopy.setChosenCards(copyFrom.getChosenCards()); + Map extraEffects = Maps.newHashMap(); + for (Card e : copyFrom.getExtraEffects()) { // should not need to run the game commands for LKI + extraEffects.put(getLKICopy(e, cachedMap), null); + } + newCopy.setExtraEffects(extraEffects); + + newCopy.addRemembered(getLKICopyList(copyFrom.getRemembered(), cachedMap)); + newCopy.addImprintedCards(getLKICopyList(copyFrom.getImprintedCards(), cachedMap)); + newCopy.setChosenCards(getLKICopyList(copyFrom.getChosenCards(), cachedMap)); newCopy.setChosenType(copyFrom.getChosenType()); newCopy.setChosenType2(copyFrom.getChosenType2());