mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-11 16:26:22 +00:00
Card: extraEffects for intrinsic Effects
This commit is contained in:
@@ -205,6 +205,8 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars, ITr
|
||||
private boolean tributed;
|
||||
private Card suspectedEffect = null;
|
||||
|
||||
private Map<Card, GameCommand> extraEffects = Maps.newHashMap();
|
||||
|
||||
private boolean manifested;
|
||||
private boolean cloaked;
|
||||
|
||||
@@ -3782,7 +3784,7 @@ public class Card extends GameEntity implements Comparable<Card>, 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<Card>, 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<Card>, 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<Card>, IHasSVars, ITr
|
||||
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 void setTributed(final boolean b) {
|
||||
tributed = b;
|
||||
@@ -6750,11 +6763,13 @@ public class Card extends GameEntity implements Comparable<Card>, 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<Card> getLKICopyList(final Iterable<Card> in, Map<Integer, Card> cachedMap) {
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> List<T> getLKICopyList(final Iterable<T> in, Map<Integer, Card> cachedMap) {
|
||||
if (in == null) {
|
||||
return null;
|
||||
}
|
||||
List<Card> result = Lists.newArrayList();
|
||||
for (final Card c : in) {
|
||||
result.add(new CardCopyService(c).getLKICopy(cachedMap));
|
||||
List<T> 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<Card, GameCommand> 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());
|
||||
|
||||
Reference in New Issue
Block a user