Card: extraEffects for intrinsic Effects

This commit is contained in:
Hans Mackowiak
2025-04-06 16:07:58 +02:00
parent 2cc2ae421a
commit 4ebbb57340
2 changed files with 39 additions and 11 deletions

View File

@@ -205,6 +205,8 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars, ITr
private boolean tributed; private boolean tributed;
private Card suspectedEffect = null; private Card suspectedEffect = null;
private Map<Card, GameCommand> extraEffects = Maps.newHashMap();
private boolean manifested; private boolean manifested;
private boolean cloaked; private boolean cloaked;
@@ -4174,6 +4176,9 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars, ITr
eff.addStaticAbility(s); eff.addStaticAbility(s);
GameCommand until = SpellAbilityEffect.exileEffectCommand(game, eff); GameCommand until = SpellAbilityEffect.exileEffectCommand(game, eff);
extraEffects.put(eff, until);
addLeavesPlayCommand(until); addLeavesPlayCommand(until);
addUnattachCommand(until); addUnattachCommand(until);
game.getAction().moveToCommand(eff, sa); game.getAction().moveToCommand(eff, sa);
@@ -6562,6 +6567,14 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars, ITr
return (c != null ? c.getImageKey() : ""); return (c != null ? c.getImageKey() : "");
} }
public Set<Card> getExtraEffects() {
return this.extraEffects.keySet();
}
public void setExtraEffects(Map<Card, GameCommand> map) {
this.extraEffects = map;
}
public final boolean isTributed() { return tributed; } public final boolean isTributed() { return tributed; }
public final void setTributed(final boolean b) { public final void setTributed(final boolean b) {
tributed = b; tributed = b;
@@ -6750,11 +6763,13 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars, ITr
suspectedStatic.setSVar("SuspectedCantBlockBy", effect); suspectedStatic.setSVar("SuspectedCantBlockBy", effect);
GameCommand until = SpellAbilityEffect.exileEffectCommand(getGame(), suspectedEffect); GameCommand until = SpellAbilityEffect.exileEffectCommand(getGame(), suspectedEffect);
extraEffects.put(suspectedEffect, until);
addLeavesPlayCommand(until); addLeavesPlayCommand(until);
getGame().getAction().moveToCommand(suspectedEffect, null); getGame().getAction().moveToCommand(suspectedEffect, null);
} else { } else {
if (isSuspected()) { if (isSuspected()) {
getGame().getAction().exileEffect(suspectedEffect); extraEffects.get(suspectedEffect).run();
extraEffects.remove(suspectedEffect);
suspectedEffect = null; suspectedEffect = null;
} }
} }

View File

@@ -2,6 +2,8 @@ package forge.game.card;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import forge.GameCommand;
import forge.card.CardStateName; import forge.card.CardStateName;
import forge.card.CardType; import forge.card.CardType;
import forge.game.Game; import forge.game.Game;
@@ -173,14 +175,18 @@ public class CardCopyService {
// ======================================================== // ========================================================
// LKI functions // LKI functions
@SuppressWarnings("unchecked")
public static List<Card> getLKICopyList(final Iterable<Card> in, Map<Integer, Card> cachedMap) { public static <T> List<T> getLKICopyList(final Iterable<T> in, Map<Integer, Card> cachedMap) {
if (in == null) { if (in == null) {
return null; return null;
} }
List<Card> result = Lists.newArrayList(); List<T> result = Lists.newArrayList();
for (final Card c : in) { for (final T o : in) {
result.add(new CardCopyService(c).getLKICopy(cachedMap)); if (o instanceof Card c) {
result.add((T)new CardCopyService(c).getLKICopy(cachedMap));
} else {
result.add(o);
}
} }
return result; return result;
} }
@@ -277,6 +283,7 @@ public class CardCopyService {
newCopy.turnFaceDownNoUpdate(); newCopy.turnFaceDownNoUpdate();
newCopy.setType(new CardType(copyFrom.getFaceDownState().getType())); newCopy.setType(new CardType(copyFrom.getFaceDownState().getType()));
} }
newCopy.setRenderForUI(copyFrom.getRenderForUI());
// prevent StackDescription from revealing face // prevent StackDescription from revealing face
newCopy.updateStateForView(); newCopy.updateStateForView();
@@ -339,9 +346,15 @@ public class CardCopyService {
newCopy.setIntensity(copyFrom.getIntensity(false)); newCopy.setIntensity(copyFrom.getIntensity(false));
newCopy.setPerpetual(copyFrom); newCopy.setPerpetual(copyFrom);
newCopy.addRemembered(copyFrom.getRemembered()); Map<Card, GameCommand> extraEffects = Maps.newHashMap();
newCopy.addImprintedCards(copyFrom.getImprintedCards()); for (Card e : copyFrom.getExtraEffects()) { // should not need to run the game commands for LKI
newCopy.setChosenCards(copyFrom.getChosenCards()); 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.setChosenType(copyFrom.getChosenType());
newCopy.setChosenType2(copyFrom.getChosenType2()); newCopy.setChosenType2(copyFrom.getChosenType2());