diff --git a/Mage/src/mage/abilities/effects/Effect.java b/Mage/src/mage/abilities/effects/Effect.java index b3ad0bda78..ea0cc70c7c 100644 --- a/Mage/src/mage/abilities/effects/Effect.java +++ b/Mage/src/mage/abilities/effects/Effect.java @@ -51,6 +51,8 @@ public interface Effect> extends Serializable { public EffectType getEffectType(); public void setTargetPointer(TargetPointer targetPointer); public TargetPointer getTargetPointer(); + public void setValue(String key, Object value); + public Object getValue(String key); public T copy(); diff --git a/Mage/src/mage/abilities/effects/EffectImpl.java b/Mage/src/mage/abilities/effects/EffectImpl.java index b79dd59ac8..7e2428e1ae 100644 --- a/Mage/src/mage/abilities/effects/EffectImpl.java +++ b/Mage/src/mage/abilities/effects/EffectImpl.java @@ -28,6 +28,8 @@ package mage.abilities.effects; +import java.util.HashMap; +import java.util.Map; import java.util.UUID; import mage.Constants.EffectType; import mage.Constants.Outcome; @@ -46,6 +48,7 @@ public abstract class EffectImpl> implements Effect { protected EffectType effectType; protected TargetPointer targetPointer = FirstTargetPointer.getInstance(); protected String staticText = ""; + protected Map values; public EffectImpl(Outcome outcome) { this.id = UUID.randomUUID(); @@ -58,6 +61,13 @@ public abstract class EffectImpl> implements Effect { this.effectType = effect.effectType; this.staticText = effect.staticText; this.targetPointer = effect.targetPointer.copy(); + if (effect.values != null) { + values = new HashMap(); + Map map = effect.values; + for (Map.Entry entry : map.entrySet()) { + values.put(entry.getKey(), entry.getValue()); + } + } } @Override @@ -107,4 +117,24 @@ public abstract class EffectImpl> implements Effect { public void newId() { this.id = UUID.randomUUID(); } + + @Override + public void setValue(String key, Object value) { + if (values == null) { + synchronized (this) { + if (values == null) { + values = new HashMap(); + } + } + } + values.put(key, value); + } + + @Override + public Object getValue(String key) { + if (values == null) { // no value was set + return null; + } + return values.get(key); + } }