mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
- "AddReplacementEffects" in static ability (experimental)
- Added Pulmonic Sliver
This commit is contained in:
@@ -8203,10 +8203,11 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
* @param replacementEffect
|
||||
* the rE
|
||||
*/
|
||||
public void addReplacementEffect(final ReplacementEffect replacementEffect) {
|
||||
public ReplacementEffect addReplacementEffect(final ReplacementEffect replacementEffect) {
|
||||
final ReplacementEffect replacementEffectCopy = replacementEffect.getCopy(); // doubtful - every caller provides a newly parsed instance, why copy?
|
||||
replacementEffectCopy.setHostCard(this);
|
||||
this.getCharacteristics().getReplacementEffects().add(replacementEffectCopy);
|
||||
return replacementEffectCopy;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -247,4 +247,27 @@ public abstract class ReplacementEffect extends TriggerReplacementBase {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** The temporary. */
|
||||
private boolean temporary = false;
|
||||
|
||||
/**
|
||||
* Sets the temporary.
|
||||
*
|
||||
* @param temp
|
||||
* the new temporary
|
||||
*/
|
||||
public final void setTemporary(final boolean temp) {
|
||||
this.temporary = temp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is temporary.
|
||||
*
|
||||
* @return true, if is temporary
|
||||
*/
|
||||
public final boolean isTemporary() {
|
||||
return this.temporary;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,14 @@ import forge.util.FileSection;
|
||||
*
|
||||
*/
|
||||
public class ReplacementHandler {
|
||||
private final Game game;
|
||||
/**
|
||||
* ReplacementHandler.
|
||||
* @param gameState
|
||||
*/
|
||||
public ReplacementHandler(Game gameState) {
|
||||
game = gameState;
|
||||
}
|
||||
|
||||
//private final List<ReplacementEffect> tmpEffects = new ArrayList<ReplacementEffect>();
|
||||
|
||||
@@ -281,4 +289,24 @@ public class ReplacementHandler {
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: Write javadoc for this method.
|
||||
*/
|
||||
public void cleanUpTemporaryReplacements() {
|
||||
final List<Card> absolutelyAllCards = game.getCardsInGame();
|
||||
for (final Card c : absolutelyAllCards) {
|
||||
for (int i = 0; i < c.getReplacementEffects().size(); i++) {
|
||||
if (c.getReplacementEffects().get(i).isTemporary()) {
|
||||
c.getReplacementEffects().remove(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (final Card c : absolutelyAllCards) {
|
||||
for (int i = 0; i < c.getReplacementEffects().size(); i++) {
|
||||
c.getReplacementEffects().get(i).setTemporarilySuppressed(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ public class StaticAbility {
|
||||
|
||||
if (this.params.containsKey("AddKeyword") || this.params.containsKey("AddAbility")
|
||||
|| this.params.containsKey("AddTrigger") || this.params.containsKey("RemoveTriggers")
|
||||
|| this.params.containsKey("RemoveKeyword")) {
|
||||
|| this.params.containsKey("RemoveKeyword") || this.params.containsKey("AddReplacementEffects")) {
|
||||
return 7; // Layer 6 (dependent)
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,8 @@ import forge.card.TriggerReplacementBase;
|
||||
import forge.card.ability.AbilityFactory;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.cardfactory.CardFactoryUtil;
|
||||
import forge.card.replacement.ReplacementEffect;
|
||||
import forge.card.replacement.ReplacementHandler;
|
||||
import forge.card.spellability.AbilityActivated;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.trigger.Trigger;
|
||||
@@ -86,6 +88,7 @@ public class StaticAbilityContinuous {
|
||||
String[] addHiddenKeywords = null;
|
||||
String[] removeKeywords = null;
|
||||
String[] addAbilities = null;
|
||||
String[] addReplacements = null;
|
||||
String[] addSVars = null;
|
||||
String[] addTypes = null;
|
||||
String[] removeTypes = null;
|
||||
@@ -186,6 +189,14 @@ public class StaticAbilityContinuous {
|
||||
addAbilities = sVars;
|
||||
}
|
||||
|
||||
if (params.containsKey("AddReplacementEffects")) {
|
||||
final String[] sVars = params.get("AddReplacementEffects").split(" & ");
|
||||
for (int i = 0; i < sVars.length; i++) {
|
||||
sVars[i] = hostCard.getSVar(sVars[i]);
|
||||
}
|
||||
addReplacements = sVars;
|
||||
}
|
||||
|
||||
if (params.containsKey("AddSVar")) {
|
||||
addSVars = params.get("AddSVar").split(" & ");
|
||||
}
|
||||
@@ -417,6 +428,14 @@ public class StaticAbilityContinuous {
|
||||
}
|
||||
}
|
||||
|
||||
// add Replacement effects
|
||||
if (addReplacements != null) {
|
||||
for (String rep : addReplacements) {
|
||||
final ReplacementEffect actualRep = ReplacementHandler.parseReplacement(rep, affectedCard);
|
||||
affectedCard.addReplacementEffect(actualRep).setTemporary(true);;
|
||||
}
|
||||
}
|
||||
|
||||
// add Types
|
||||
if ((addTypes != null) || (removeTypes != null)) {
|
||||
affectedCard.addChangedCardTypes(addTypes, removeTypes, removeSuperTypes, removeCardTypes,
|
||||
|
||||
@@ -70,7 +70,7 @@ public class Game {
|
||||
public final MagicStack stack;
|
||||
private final StaticEffects staticEffects = new StaticEffects();
|
||||
private final TriggerHandler triggerHandler = new TriggerHandler(this);
|
||||
private final ReplacementHandler replacementHandler = new ReplacementHandler();
|
||||
private final ReplacementHandler replacementHandler = new ReplacementHandler(this);
|
||||
private Combat combat = new Combat();
|
||||
private final EventBus events = new EventBus();
|
||||
private final GameLog gameLog = new GameLog();
|
||||
|
||||
@@ -797,6 +797,7 @@ public class GameAction {
|
||||
// remove old effects
|
||||
game.getStaticEffects().clearStaticEffects();
|
||||
game.getTriggerHandler().cleanUpTemporaryTriggers();
|
||||
game.getReplacementHandler().cleanUpTemporaryReplacements();
|
||||
|
||||
// search for cards with static abilities
|
||||
final List<Card> allCards = game.getCardsInGame();
|
||||
|
||||
@@ -32,13 +32,10 @@ import javax.swing.JOptionPane;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
import forge.Card;
|
||||
import forge.Constant.Preferences;
|
||||
import forge.Singletons;
|
||||
import forge.card.CardBlock;
|
||||
import forge.card.CardDb;
|
||||
import forge.card.CardEdition;
|
||||
import forge.card.IUnOpenedProduct;
|
||||
import forge.card.SealedProductTemplate;
|
||||
@@ -50,7 +47,6 @@ import forge.item.IPaperCard;
|
||||
import forge.item.ItemPool;
|
||||
import forge.item.ItemPoolView;
|
||||
import forge.properties.NewConstants;
|
||||
import forge.util.Aggregates;
|
||||
import forge.util.FileUtil;
|
||||
import forge.util.HttpUtil;
|
||||
import forge.util.storage.IStorageView;
|
||||
|
||||
Reference in New Issue
Block a user