Skip to content

Commit

Permalink
fixed NPE
Browse files Browse the repository at this point in the history
  • Loading branch information
JayDi85 committed Nov 3, 2023
1 parent cafac90 commit 8895b63
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ public void watch(GameEvent event, Game game) {
playerMap.compute(event.getPlayerId(), CardUtil::setOrIncrementValue);

tokenCreatedMap.putIfAbsent(event.getPlayerId(), new HashMap<>());
Permanent token = game.getPermanent(event.getTargetId());
Permanent token = game.getPermanentOrLKIBattlefield(event.getTargetId());
if (token == null) {
// if you catch this then must research
throw new IllegalStateException("Wrong code usage: found created token event, but can't find a real token in battlefield or lki");
}
Map<SubType, Integer> playersTokens = tokenCreatedMap.getOrDefault(event.getPlayerId(), new EnumMap<>(SubType.class));
// TODO: this doesn't handle tokens that are all creature types
for (SubType subType : token.getSubtype(game)) {
Expand Down

0 comments on commit 8895b63

Please sign in to comment.