This commit is contained in:
fireshoes 2016-10-17 23:45:47 -05:00
parent b733f911f7
commit 89dd981075
287 changed files with 3420 additions and 2315 deletions

View file

@ -32,6 +32,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.LinkedList;
@ -182,7 +183,11 @@ public class GameState implements Serializable, Copyable<GameState> {
this.turnMods = state.turnMods.copy();
this.watchers = state.watchers.copy();
for (Map.Entry<String, Object> entry : state.values.entrySet()) {
this.values.put(entry.getKey(), entry.getValue());
if (entry.getValue() instanceof HashSet) {
this.values.put(entry.getKey(), (HashSet) ((HashSet) entry.getValue()).clone());
} else {
this.values.put(entry.getKey(), entry.getValue());
}
}
this.zones.putAll(state.zones);
this.simultaneousEvents.addAll(state.simultaneousEvents);
@ -893,8 +898,10 @@ public class GameState implements Serializable, Copyable<GameState> {
/**
* Best only use immutable objects, otherwise the states/values of the
* object may be changed by AI simulation, because the Value objects are not
* copied as the state class is copied.
* object may be changed by AI simulation or rollbacks, because the Value
* objects are not copied as the state class is copied. Mutable supported:
* HashSet with immutable entries (e.g. HashSet< UUID > or HashSet< String
* >)
*
* @param valueId
* @param value