From f8f4c555b8e63070af168442f54b717704d97f3c Mon Sep 17 00:00:00 2001 From: Talon Date: Wed, 9 Feb 2022 14:38:34 +0100 Subject: [PATCH] Add change function --- src/engine/state.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/engine/state.js b/src/engine/state.js index 5d1488e..c8ddeb9 100644 --- a/src/engine/state.js +++ b/src/engine/state.js @@ -15,6 +15,12 @@ class State { return this.states.set(key, value); } + change(key, amount = 1) { + let val = this.get(key, 0); + val += amount; + this.set(key, val); + } + serialize() { const entries = this.states.entries(); const entrymap = [];