diff --git a/js/game.js b/js/game.js index 8832d76..a1b2402 100644 --- a/js/game.js +++ b/js/game.js @@ -1013,14 +1013,17 @@ export class Level { let type = TILE_TYPES[name]; if (type.is_key) { - actor.keyring ||= {}; - actor.keyring[name] ||= 0; - actor.keyring[name] += 1; + if (! actor.keyring) { + actor.keyring = {}; + } + actor.keyring[name] = (actor.keyring[name] ?? 0) + 1; this.pending_undo.push(() => actor.keyring[name] -= 1); } else { // tool, presumably - actor.toolbelt ||= []; + if (! actor.toolbelt) { + actor.toolbelt = []; + } actor.toolbelt.push(name); this.pending_undo.push(() => actor.toolbelt.pop()); }