mirror of
https://github.com/magefree/mage.git
synced 2025-12-28 22:42:03 -08:00
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:
parent
837d756746
commit
0241a788a0
1 changed files with 7 additions and 4 deletions
|
|
@ -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());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue