From e6e2950a6e3af1cef69101130d888f78b0bcf623 Mon Sep 17 00:00:00 2001 From: asvitkine Date: Sat, 10 Dec 2022 01:09:16 -0500 Subject: [PATCH] Fix crash in AI simulation code caused by a not found token. --- .../src/main/java/forge/ai/simulation/GameCopier.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/forge-ai/src/main/java/forge/ai/simulation/GameCopier.java b/forge-ai/src/main/java/forge/ai/simulation/GameCopier.java index 0ab07f2b306..63f37a8b06c 100644 --- a/forge-ai/src/main/java/forge/ai/simulation/GameCopier.java +++ b/forge-ai/src/main/java/forge/ai/simulation/GameCopier.java @@ -124,12 +124,17 @@ public class GameCopier { if (origCard.hasRemembered()) { for (Object o : origCard.getRemembered()) { if (o instanceof GameObject) { - c.addRemembered(find((GameObject)o)); + // Sometimes, a spell can "remember" a token card that's not in any zone + // (and thus wouldn't have been copied) - for example Swords to Plowshares + // remembering its target for LKI. Skip these to not crash in find(). + if (o instanceof Card && ((Card)o).getZone() == null) { + continue; + } + c.addRemembered(find((GameObject) o)); } else { System.err.println(c + " Remembered: " + o + "/" + o.getClass()); c.addRemembered(o); } - } } for (SpellAbility sa : c.getSpellAbilities()) {