add a couple null check to Modes' value Key creation

normal game usage should have no issue, but the Pillar Custom mode
initializing a Delayed Trigger at game init can not have a real source set up.

Might revisit 'game init' trigger in a better way in the future.
For now this fix is enough to avoid a NPE using the Pillar game mode.
This commit is contained in:
Susucre 2023-11-16 11:08:11 +01:00
parent 837d756746
commit 0241a788a0

View file

@ -483,12 +483,16 @@ public class Modes extends LinkedHashMap<UUID, Mode> implements Copyable<Modes>
return res;
}
private String getKeyPrefix(Game game, Ability source) {
return source == null || source.getSourceId() == null ? "" : source.getSourceId().toString() + game.getState().getZoneChangeCounter(source.getSourceId());
}
private String getSelectedModesKey(Ability source, Game game, UUID modeId) {
return source.getSourceId().toString() + game.getState().getZoneChangeCounter(source.getSourceId()) + modeId.toString();
return getKeyPrefix(game, source) + modeId.toString();
}
private String getOnceTurnNumKey(Ability source, Game game) {
return source.getSourceId().toString() + game.getState().getZoneChangeCounter(source.getSourceId()) + "turnNum";
return getKeyPrefix(game, source) + "turnNum";
}
private int getOnceTurnNum(Game game, Ability source) {
@ -500,8 +504,7 @@ public class Modes extends LinkedHashMap<UUID, Mode> implements Copyable<Modes>
}
private void setOnceTurnNum(Game game, Ability source) {
String key = source.getSourceId().toString() + game.getState().getZoneChangeCounter(source.getSourceId()) + "turnNum";
game.getState().setValue(key, game.getTurnNum());
game.getState().setValue(getOnceTurnNumKey(source, game), game.getTurnNum());
}
/**