diff options
author | metamuffin <metamuffin@disroot.org> | 2025-10-06 19:47:04 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2025-10-06 19:47:04 +0200 |
commit | a251cf726551935b59072ffc01b87876968715c2 (patch) | |
tree | 699b21b981a99e19a4d51c085de772720d0b3fc8 | |
parent | 7640de980dd3fb7e6a6d9d9356dfe047552bcc95 (diff) | |
download | hurrycurry-a251cf726551935b59072ffc01b87876968715c2.tar hurrycurry-a251cf726551935b59072ffc01b87876968715c2.tar.bz2 hurrycurry-a251cf726551935b59072ffc01b87876968715c2.tar.zst |
Fix pizza dispose; refactor auto burn/trash code
-rw-r--r-- | data/recipes/default.js | 73 |
1 files changed, 38 insertions, 35 deletions
diff --git a/data/recipes/default.js b/data/recipes/default.js index 4688e9e3..22f4f037 100644 --- a/data/recipes/default.js +++ b/data/recipes/default.js @@ -54,35 +54,43 @@ function finish() { for (const r of k) console.log(r); } +function auto_info(name) { + if (name == "plate") return { dispose_out: "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 == "glass") return { dispose_tile: "sink" } + if (name == "burned") return { dispose_self: true, burnable: false } + return { dispose_self: true, burnable: true } +} function auto_trash() { for (const i of [...all_items]) { - if (i instanceof Container) continue - if (!i.container) out({ action: "instant", inputs: [i], outputs: [], tile: "trash" }) - else { - out({ - action: "instant", - inputs: [i], - outputs: [i.container.dispose ?? i.container], - tile: i.container.dispose_tile ?? "trash" - }) - } + const info = auto_info(i.container?.name ?? i.name) + if (!info) continue + if (!info.dispose_self && !i.container) continue + out({ + action: "instant", + inputs: [i], + outputs: info.dispose_self ? [] : [info.dispose_out ?? i.container], + tile: info.dispose_tile ?? "trash" + }) } } function auto_burn() { for (const i of [...all_items]) { - if (i instanceof Container) continue - if (i.container || i.name == "burned") continue - else { - out({ - action: "passive", - inputs: [i], - outputs: [new Item("burned")], - duration: 1.5, - revert_duration: 1.5, - warn: true, - tile: "stove" - }) - } + const info = auto_info(i.container?.name ?? i.name) + if (!info?.burnable) continue + out({ + action: "passive", + inputs: [i], + outputs: [new Item("burned")], + duration: 1.5, + revert_duration: 1.5, + warn: true, + tile: "stove" + }) } } class Item { @@ -100,17 +108,12 @@ class Item { } } -class Container extends Item { - constructor(name, dispose, dispose_tile) { - super(name); this.dispose = dispose; this.dispose_tile = dispose_tile; - } -} -const FP = new Container("foodprocessor") -const POT = new Container("pot") -const PAN = new Container("pan") -const PL = new Container("plate", new Container("dirty-plate")) -const GL = new Container("glass", undefined, "sink") -const BA = new Container("basket") +const FP = new Item("foodprocessor") +const POT = new Item("pot") +const PAN = new Item("pan") +const PL = new Item("plate") +const GL = new Item("glass") +const BA = new Item("basket") function crate(s) { const item = new Item(s); @@ -253,7 +256,7 @@ function sink_fill(c) { return o } -out({ action: "active", duration: 2, tile: "sink", inputs: [new Container("dirty-plate")], outputs: [PL] }) +out({ action: "active", duration: 2, tile: "sink", inputs: [new Item("dirty-plate")], outputs: [PL] }) const tomato = crate("tomato") const steak = crate("steak") |