From 0267e963e9f85f24fd311a20b8e1ef550768ac04 Mon Sep 17 00:00:00 2001 From: magenoxx Date: Fri, 19 Aug 2011 08:55:27 +0400 Subject: [PATCH] Since now use effect.setValue(key, object) instead of gameState.setValue(key, object). --- Mage/src/mage/abilities/effects/Effect.java | 2 ++ .../mage/abilities/effects/EffectImpl.java | 30 +++++++++++++++++++ 2 files changed, 32 insertions(+) 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); + } }