aboutsummaryrefslogtreecommitdiff
path: root/data/recipes/default.js
diff options
context:
space:
mode:
Diffstat (limited to 'data/recipes/default.js')
-rw-r--r--data/recipes/default.js104
1 files changed, 39 insertions, 65 deletions
diff --git a/data/recipes/default.js b/data/recipes/default.js
index 22f4f037..6bcfb315 100644
--- a/data/recipes/default.js
+++ b/data/recipes/default.js
@@ -45,6 +45,8 @@ function finish() {
s += ` inputs: [${r.inputs.map(e => JSON.stringify(e.toString())).join(",")}]\n`
s += ` outputs: [${r.outputs.map(e => JSON.stringify(e.toString())).join(",")}]\n`
if (r.warn) s += ` warn: true\n`
+ if (r.group) s += ` group: ${r.group}\n`
+ if (r.inputs[0]?.group_hidden) s += ` group_hidden: true\n`
if (r.duration) s += ` duration: ${r.duration}\n`
if (r.revert_duration) s += ` revert_duration: ${r.revert_duration}\n`
if (r.points) s += ` points: ${r.points}\n`
@@ -96,6 +98,11 @@ function auto_burn() {
class Item {
constructor(name, container) { this.name = name; this.container = container }
as(s) { this.name = s; return this }
+ tr_nested(container) {
+ const o = new Item(this.toString(), container)
+ out({ action: "instant", inputs: [container, this], outputs: [o] })
+ return o
+ }
tr(container) {
const o = new Item(this.name, container)
if (this.container == container) return o
@@ -151,7 +158,9 @@ function sear(s, duration = 15) {
return o
}
function bake(s, duration = 25) {
- const o = new Item(`baked-${s.name}`, s.container)
+ const o = s.container == "rolled-dough"
+ ? new Item(s.name, `baked-${s.container}`)
+ : 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 })
return o
@@ -201,48 +210,9 @@ function combine(c, ...items) {
}
return result
}
-// function combine(container, ...items) {
-// items.push(container)
-// const open = items.map(i => [i.name])
-// const seen = new Set()
-// let final_result
-// let components_before
-// while ((components_before = open.pop())) {
-// for (const new_item of items) {
-// if (components_before.includes(new_item.name)) continue
-
-// // generate key `old,old,old#new` to avoid duplicated recipes
-// const dedup_key = components_before.join(",") + "#" + new_item
-// if (seen.has(dedup_key)) continue
-// seen.add(dedup_key)
-
-// if (new_item.container && !components_before.includes(container.name))
-// continue // new item is likely a liquid and needs target container to be there already
-
-// const components_after = [...components_before, new_item.name]
-// components_after.sort()
-// open.push(components_after)
-
-// const content_in = components_before.filter(e => e != container.name).join(",")
-// const item_in = content_in == "" ? container : new Item(content_in, components_before.includes(container.name) ? container : null)
-// const content_out = components_after.filter(e => e != container.name).join(",")
-// const item_out = content_out == "" ? container : new Item(content_out, components_after.includes(container.name) ? container : null)
-
-// if (components_after.length == items.length) final_result = item_out
-// out({
-// action: "instant",
-// inputs: [item_in, new_item],
-// outputs: new_item == container // put result in containers positions if container was added
-// ? [null, item_out] : [item_out, new_item.container]
-// })
-// }
-// }
-// console.error(final_result);
-// return final_result
-// }
-function edible(...items) {
+function edible(group, ...items) {
for (const i of items) {
- out({ action: "demand", inputs: [i], outputs: [i.container?.dispose ?? i.container], duration: 10 })
+ out({ action: "demand", inputs: [i], outputs: [i.container?.dispose ?? i.container], duration: 10, group })
}
}
function either(a, b) {
@@ -255,8 +225,12 @@ function sink_fill(c) {
out({ action: "active", inputs: [c], outputs: [o], tile: "sink", duration: 1 })
return o
}
+function group_hidden(i) {
+ i.group_hidden = true
+ return i
+}
-out({ action: "active", duration: 2, tile: "sink", inputs: [new Item("dirty-plate")], outputs: [PL] })
+out({ group: "cleanup", action: "active", duration: 2, tile: "sink", inputs: [new Item("dirty-plate")], outputs: [PL] })
const tomato = crate("tomato")
const steak = crate("steak")
@@ -278,9 +252,9 @@ const dough = process(flour.tr(FP)).as("dough").tr()
// Pizza
const pizza_dough = roll(dough)
-edible(
- bake(combine(pizza_dough, tomato_juice, cut(cheese))).tr(PL),
- bake(combine(pizza_dough, tomato_juice, cut(cheese), cut(mushroom))).tr(PL),
+edible("pizza",
+ bake(combine(pizza_dough, tomato_juice, cut(cheese), cut(mushroom))).tr_nested(PL),
+ group_hidden(bake(combine(pizza_dough, tomato_juice, cut(cheese))).tr_nested(PL))
// bake(combine(pizza_dough, patty, cut(cheese))).tr(PL),
// bake(combine(pizza_dough, patty, leek)).tr(PL),
)
@@ -291,9 +265,9 @@ edible(
// Steak
const french_fries = deep_fry(cut(potato).tr(BA)).as("french-fries");
const bun = either(bake(dough).as("bun"), crate("bun"))
-edible(
- bun.tr(PL),
- french_fries.tr(PL),
+edible("steak",
+ group_hidden(bun.tr(PL)),
+ group_hidden(french_fries.tr(PL)),
combine(PL, sear(steak), bun),
combine(PL, sear(steak), french_fries),
// combine(PL, sear(steak), cook(potato.tr(POT))),
@@ -303,32 +277,32 @@ edible(
)
// Salad
-edible(
+edible("salad",
combine(PL, cut(tomato), cut(lettuce)),
combine(PL, cut(lettuce)),
)
// Burger
-edible(
- combine(PL, cut(bun), sear(patty), cut(cheese)),
- combine(PL, cut(bun), sear(patty), cut(cheese), cut(lettuce)),
+edible("burger",
combine(PL, cut(bun), sear(patty), cut(tomato), cut(lettuce)),
combine(PL, cut(bun), sear(patty), cut(cheese), cut(tomato)),
- combine(PL, cut(bun), cut(cheese), cut(lettuce), cut(tomato)),
- combine(PL, cut(bun), cut(lettuce), cut(tomato)),
- combine(PL, cut(bun), cut(fish))
+ group_hidden(combine(PL, cut(bun), sear(patty), cut(cheese))),
+ group_hidden(combine(PL, cut(bun), sear(patty), cut(cheese), cut(lettuce))),
+ group_hidden(combine(PL, cut(bun), cut(cheese), cut(lettuce), cut(tomato))),
+ group_hidden(combine(PL, cut(bun), cut(lettuce), cut(tomato))),
+ group_hidden(combine(PL, cut(bun), cut(fish)))
)
// Noodles
const noodle = cook(cut(roll(dough)).as("noodles").tr(POT))
-edible(
+edible("noodles",
combine(PL, noodle, tomato_juice),
combine(PL, noodle, tomato_juice, cut(cheese)),
// combine(PL, noodle, tomato_juice, cut(cheese), sear(patty)),
)
// Soup
-edible(
+edible("soups",
cook(combine(POT, tomato_juice)).as("tomato-soup").tr(PL),
cook(combine(POT, cut(mushroom))).as("mushroom-soup").tr(PL),
cook(combine(POT, cheese, cut(leek))).as("cheese-leek-soup").tr(PL),
@@ -336,9 +310,9 @@ edible(
)
// Rice and nigiri
-edible(
+edible("nigiri",
container_add(cut(fish), cook(rice.tr(POT))).as("nigiri").tr(PL),
- container_add(cook(rice.tr(POT).tr(PL)), cut(fish)).as("nigiri")
+ container_add(cook(rice.tr(POT)).tr(PL), cut(fish)).as("nigiri"),
)
// coconut milk and strawberry puree
@@ -350,19 +324,19 @@ const strawberry_shake = either(
)
// Doughnut (Pfannkuchen)
-edible(deep_fry(dough.tr(BA)).as("doughnut").tr(PL))
+edible("doughnut", deep_fry(dough.tr(BA)).as("doughnut").tr(PL))
// Icecream
-edible(freeze(strawberry_shake.tr(GL)).as("strawberry-icecream"))
+edible("icecream", freeze(strawberry_shake.tr(GL)).as("strawberry-icecream"))
// Mochi
const rice_flour = process(rice.tr(FP)).as("rice-flour")
const mochi_dough = cook(rice_flour.tr(POT), 5).as("mochi-dough")
const strawberry_mochi = container_add(strawberry, mochi_dough).as("strawberry-mochi")
-edible(strawberry_mochi.tr(PL))
+edible("mochi", strawberry_mochi.tr(PL))
// Drinks
-edible(
+edible("drinks",
strawberry_shake.tr(GL),
tomato_juice.tr(GL),
sink_fill(GL)
@@ -370,7 +344,7 @@ edible(
// Curry
const curry_with_rice = combine(PL, cook(rice.tr(POT)), cook(combine(POT, milk, tomato, leek)).as("curry"))
-edible(curry_with_rice)
+edible("curry", curry_with_rice)
auto_trash()
auto_burn()