Mana Maze - fixed game error on usage (closes #11572, closes #11575);

This commit is contained in:
Oleg Agafonov 2024-01-13 07:31:09 +04:00
parent 6939886680
commit 95481cd736
8 changed files with 42 additions and 28 deletions

View file

@ -1758,6 +1758,15 @@ public final class CardUtil {
|| o instanceof Enum;
}
/**
* Make deep copy of any object (supported by xmage)
* <p>
* Warning, don't use self reference objects because it will raise StackOverflowError
*
* @param value
* @return
* @param <T>
*/
public static <T> T deepCopyObject(T value) {
if (isImmutableObject(value)) {
return value;
@ -1789,6 +1798,7 @@ public final class CardUtil {
AbstractMap.SimpleImmutableEntry entryValue = (AbstractMap.SimpleImmutableEntry) value;
return (T) new AbstractMap.SimpleImmutableEntry(deepCopyObject(entryValue.getKey()), deepCopyObject(entryValue.getValue()));
} else {
// warning, do not add unnecessarily new data types and structures to game engine, try to use only standard types (see above)
throw new IllegalStateException("Unhandled object " + value.getClass().getSimpleName() + " during deep copy, must add explicit handling of all Object types");
}
}