Add statue puzzle

master
Talon 2021-11-10 22:11:30 +01:00
parent a048e3615c
commit 24e5650f09
3 changed files with 26 additions and 4 deletions

View File

@ -3,9 +3,10 @@ class State {
this.states = new Map(); this.states = new Map();
} }
get(key) { get(key, defaultValue = null) {
if (!this.states.has(key)) { if (!this.states.has(key)) {
return null; this.states.set(key, defaultValue);
return defaultValue;
} }
return this.states.get(key); return this.states.get(key);
} }

View File

@ -9,6 +9,17 @@ export default new ItemBuilder()
.isTakeable(false) .isTakeable(false)
.isUsable(true) .isUsable(true)
.withUseCallback(async function (context) { .withUseCallback(async function (context) {
context.print(`You press the button on the round device attached to the statue's arm.`) context.print(`You press the button on the round device attached to the statue's arm.`);
let value = context.state.get("statue1.pressed", 0);
value++;
context.state.set("statue1.pressed", value);
if (value == 3) {
context.print(`You hear a sattisfying click.`);
context.state.set("statues.unlocked", true);
}
if (context.state.get('statue1.pressed') > 2 && context.state.get('statue2.pressed') > 1) {
context.print(`You hear a low rumble somewhere deep within the bowels of the structure.`);
context.state.set("statues.unlocked", true);
}
}) })
.create(); .create();

View File

@ -9,6 +9,16 @@ export default new ItemBuilder()
.isTakeable(false) .isTakeable(false)
.isUsable(true) .isUsable(true)
.withUseCallback(async function (context) { .withUseCallback(async function (context) {
context.print(`You press the button on the rectangular device attached to the statue's arm.`) context.print(`You press the button on the rectangular device attached to the statue's arm.`);
let value = context.state.get("statue2.pressed", 0);
value++;
context.state.set("statue2.pressed", value);
if (value == 2) {
context.print(`You hear a sattisfying click.`);
}
if (context.state.get('statue1.pressed') > 2 && context.state.get('statue2.pressed') > 1) {
context.print(`You hear a low rumble somewhere deep within the bowels of the structure.`);
context.state.set("statues.unlocked", true);
}
}) })
.create(); .create();