mirror of
https://github.com/correl/mage.git
synced 2024-12-24 11:50:45 +00:00
* Watcher - Fixed a problem copying HashMaps in watcher deep copy (fixes bug of Muldrotha, the Gravetide #6461).
This commit is contained in:
parent
7d91200612
commit
1d0059fb53
1 changed files with 8 additions and 14 deletions
|
@ -1,14 +1,12 @@
|
|||
|
||||
package mage.watchers;
|
||||
|
||||
import mage.constants.WatcherScope;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.*;
|
||||
import java.util.*;
|
||||
import mage.constants.WatcherScope;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
* watches for certain game events to occur and flags condition
|
||||
|
@ -24,7 +22,6 @@ public abstract class Watcher implements Serializable {
|
|||
protected boolean condition;
|
||||
protected final WatcherScope scope;
|
||||
|
||||
|
||||
public Watcher(WatcherScope scope) {
|
||||
this.scope = scope;
|
||||
}
|
||||
|
@ -114,7 +111,7 @@ public abstract class Watcher implements Serializable {
|
|||
if (field.getType() == Set.class) {
|
||||
((Set) field.get(watcher)).clear();
|
||||
((Set) field.get(watcher)).addAll((Set) field.get(this));
|
||||
} else if (field.getType() == Map.class) {
|
||||
} else if (field.getType() == Map.class || field.getType() == HashMap.class) {
|
||||
ParameterizedType parameterizedType = (ParameterizedType) field.getGenericType();
|
||||
Type valueType = parameterizedType.getActualTypeArguments()[1];
|
||||
if (valueType.getTypeName().contains("Set")) {
|
||||
|
@ -126,8 +123,7 @@ public abstract class Watcher implements Serializable {
|
|||
set.addAll(e.getValue());
|
||||
target.put(e.getKey(), set);
|
||||
}
|
||||
}
|
||||
else if (valueType.getTypeName().contains("List")) {
|
||||
} else if (valueType.getTypeName().contains("List")) {
|
||||
Map<Object, List<Object>> source = (Map<Object, List<Object>>) field.get(this);
|
||||
Map<Object, List<Object>> target = (Map<Object, List<Object>>) field.get(watcher);
|
||||
target.clear();
|
||||
|
@ -136,8 +132,7 @@ public abstract class Watcher implements Serializable {
|
|||
list.addAll(e.getValue());
|
||||
target.put(e.getKey(), list);
|
||||
}
|
||||
}
|
||||
else if (valueType.getTypeName().contains("Map")) {
|
||||
} else if (valueType.getTypeName().contains("Map")) {
|
||||
Map<Object, Map<Object, Object>> source = (Map<Object, Map<Object, Object>>) field.get(this);
|
||||
Map<Object, Map<Object, Object>> target = (Map<Object, Map<Object, Object>>) field.get(watcher);
|
||||
target.clear();
|
||||
|
@ -147,8 +142,7 @@ public abstract class Watcher implements Serializable {
|
|||
target.put(e.getKey(), map);
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
((Map) field.get(watcher)).putAll((Map) field.get(this));
|
||||
}
|
||||
} else if (field.getType() == List.class) {
|
||||
|
|
Loading…
Reference in a new issue