diff options
| author | metamuffin <metamuffin@disroot.org> | 2025-10-13 01:07:12 +0200 |
|---|---|---|
| committer | metamuffin <metamuffin@disroot.org> | 2025-10-13 01:07:12 +0200 |
| commit | ad945d8b64d5ebe65346307347689f8de8be0c2c (patch) | |
| tree | cefc0f7ba212d14dfe471c4fd0424e047db3116d /data | |
| parent | 584c392211514406ba5202d24fc01074271c946f (diff) | |
| download | hurrycurry-ad945d8b64d5ebe65346307347689f8de8be0c2c.tar hurrycurry-ad945d8b64d5ebe65346307347689f8de8be0c2c.tar.bz2 hurrycurry-ad945d8b64d5ebe65346307347689f8de8be0c2c.tar.zst | |
Fix bug where dirty plate could be burned and trashed
Diffstat (limited to 'data')
| -rw-r--r-- | data/recipes/default.js | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/data/recipes/default.js b/data/recipes/default.js index 701dccef..2cb163e3 100644 --- a/data/recipes/default.js +++ b/data/recipes/default.js @@ -57,24 +57,23 @@ function finish() { console.log(r); } function auto_info(name) { - if (name == "plate") return { dispose_out: "dirty-plate" } + if (name == "plate") return { dispose_out: new Item("dirty-plate") } if (name == "foodprocessor") return {} if (name == "pan") return {} if (name == "pot") return {} if (name == "basket") return {} - if (name == "dirty-plate") return undefined + if (name == "dirty-plate") return {} if (name == "glass") return { dispose_tile: "sink" } - if (name == "burned") return { dispose_self: true, burnable: false } + if (name == "burned") return { dispose_self: true } return { dispose_self: true, burnable: true } } function auto_trash() { for (const i of [...all_items]) { const info = auto_info(i.container?.name ?? i.name) - if (!info) continue if (!info.dispose_self && !i.container) continue out({ action: "instant", - inputs: [i], + inputs: [new Item(i.name, i.container)], outputs: info.dispose_self ? [] : [info.dispose_out ?? i.container], tile: info.dispose_tile ?? "trash" }) @@ -83,10 +82,10 @@ function auto_trash() { function auto_burn() { for (const i of [...all_items]) { const info = auto_info(i.container?.name ?? i.name) - if (!info?.burnable) continue + if (!info.burnable) continue out({ action: "passive", - inputs: [i], + inputs: [new Item(i.name, i.container)], outputs: [new Item("burned")], duration: 1.5, revert_duration: 1.5, @@ -96,7 +95,12 @@ function auto_burn() { } } class Item { - constructor(name, container) { this.name = name; this.container = container } + constructor(name, container) { + if (typeof name != "string") throw new Error("" + name); + if (container && !(container instanceof Item)) throw new Error("" + container); + this.name = name; + this.container = container + } as(s) { this.name = s; return this } tr_nested(container) { const o = new Item(this.toString(), container) @@ -105,7 +109,7 @@ class Item { } tr(container) { const o = new Item(this.name, container) - if (this.container == container) return o + if (this.container?.name == container?.name) return o if (this.container) out({ action: "instant", inputs: [this, container], outputs: [this.container, o] }) else out({ action: "instant", inputs: [container, this], outputs: [o] }) return o @@ -159,7 +163,7 @@ function sear(s, duration = 15) { } function bake(s, duration = 25) { const o = s.container == "rolled-dough" - ? new Item(s.name, `pizza`) + ? new Item(s.name, new Item("pizza")) : new Item(`baked-${s.name}`, s.container) out({ action: "passive", duration, revert_duration: duration * 2, tile: "oven", inputs: [s], outputs: [o] }) out({ action: "passive", duration: duration / 2, revert_duration: duration / 4, tile: "oven", inputs: [o], outputs: [new Item("burned")], warn: true }) @@ -218,7 +222,7 @@ function edible(group, ...items) { } function either(a, b) { if (a.name != b.name) throw new Error("either options are named differently"); - if (a.container != b.container) throw new Error("either options are contained differently"); + if (a.container?.name != b.container?.name) throw new Error("either options are contained differently"); return a } function sink_fill(c) { |