From 4dc15a1e86ef1ae985fdf36f1a84d07b1de99ea7 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Tue, 25 Jun 2024 23:34:10 +0200 Subject: server can change map at runtime --- data/demands.yaml | 26 --------- data/demands/default.yaml | 26 +++++++++ data/demands/none.yaml | 0 data/index.yaml | 14 +++++ data/makefile | 4 ++ data/map.yaml | 77 ------------------------- data/maps/big.yaml | 77 +++++++++++++++++++++++++ data/maps/lobby.yaml | 55 ++++++++++++++++++ data/maps/small.yaml | 78 +++++++++++++++++++++++++ data/recipes.ts | 143 ---------------------------------------------- data/recipes/.gitignore | 1 + data/recipes/default.ts | 143 ++++++++++++++++++++++++++++++++++++++++++++++ data/recipes/none.ts | 1 + 13 files changed, 399 insertions(+), 246 deletions(-) delete mode 100644 data/demands.yaml create mode 100644 data/demands/default.yaml create mode 100644 data/demands/none.yaml create mode 100644 data/index.yaml create mode 100644 data/makefile delete mode 100644 data/map.yaml create mode 100644 data/maps/big.yaml create mode 100644 data/maps/lobby.yaml create mode 100644 data/maps/small.yaml delete mode 100644 data/recipes.ts create mode 100644 data/recipes/.gitignore create mode 100644 data/recipes/default.ts create mode 100644 data/recipes/none.ts (limited to 'data') diff --git a/data/demands.yaml b/data/demands.yaml deleted file mode 100644 index f6be0911..00000000 --- a/data/demands.yaml +++ /dev/null @@ -1,26 +0,0 @@ -# Undercooked - a game about cooking -# Copyright 2024 metamuffin -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, version 3 of the License only. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -- { from: bread-slice-plate, to: dirty-plate, duration: 10 } -- { from: steak-plate, to: dirty-plate, duration: 10 } -- { from: sliced-tomato-plate, to: dirty-plate, duration: 10 } - -- { from: bread-slice-steak-plate, to: dirty-plate, duration: 15 } -- { from: bread-slice-sliced-tomato-plate, to: dirty-plate, duration: 15 } -- { from: sliced-tomato-steak-plate, to: dirty-plate, duration: 15 } - -- { from: bread-slice-sliced-tomato-steak-plate, to: dirty-plate, duration: 20 } - -- { from: tomato-soup-plate, to: dirty-plate, duration: 20 } diff --git a/data/demands/default.yaml b/data/demands/default.yaml new file mode 100644 index 00000000..f6be0911 --- /dev/null +++ b/data/demands/default.yaml @@ -0,0 +1,26 @@ +# Undercooked - a game about cooking +# Copyright 2024 metamuffin +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, version 3 of the License only. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +- { from: bread-slice-plate, to: dirty-plate, duration: 10 } +- { from: steak-plate, to: dirty-plate, duration: 10 } +- { from: sliced-tomato-plate, to: dirty-plate, duration: 10 } + +- { from: bread-slice-steak-plate, to: dirty-plate, duration: 15 } +- { from: bread-slice-sliced-tomato-plate, to: dirty-plate, duration: 15 } +- { from: sliced-tomato-steak-plate, to: dirty-plate, duration: 15 } + +- { from: bread-slice-sliced-tomato-steak-plate, to: dirty-plate, duration: 20 } + +- { from: tomato-soup-plate, to: dirty-plate, duration: 20 } diff --git a/data/demands/none.yaml b/data/demands/none.yaml new file mode 100644 index 00000000..e69de29b diff --git a/data/index.yaml b/data/index.yaml new file mode 100644 index 00000000..e00ff9f2 --- /dev/null +++ b/data/index.yaml @@ -0,0 +1,14 @@ +initial: [null, lobby, null] + +demands: + - none + - default + +maps: + - lobby + - big + - small + +recipes: + - none + - default diff --git a/data/makefile b/data/makefile new file mode 100644 index 00000000..b5984dd7 --- /dev/null +++ b/data/makefile @@ -0,0 +1,4 @@ + +all: $(patsubst %.ts,%.yaml,$(wildcard recipes/*.ts)) +recipes/%.yaml: recipes/%.ts + deno run $< > $@ diff --git a/data/map.yaml b/data/map.yaml deleted file mode 100644 index 207a4f90..00000000 --- a/data/map.yaml +++ /dev/null @@ -1,77 +0,0 @@ -# Undercooked - a game about cooking -# Copyright 2024 metamuffin -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, version 3 of the License only. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -map: - - "'''''*'''*'''''*'''*'''*'''*''*'" - - "'''*''''*'*'**'''*''**''**''*'''" - - "''██v███v███v███v███v███v██v██*'" - - "''vctc.ctc.ctc.ctc.ctc█⌷....sv**" - - "''█.....c.............█⌷....s█''" - - "'*vc...c...████www██dd█⌷.⌷.⌷⌷v*'" - - "*'█tc.ctc..█⌷.C...ff..d..⌷..H█''" - - "''█c...c...█⌷.C.....~.d..⌷..R█'*" - - "*'vc.......w..⌷⌷⌷⌷⌷⌷⌷⌷█⌷.⌷..Tv*'" - - "'*█tc......w..........d..⌷..F█*'" - - "''vc.....ct█⌷S⌷S⌷S⌷⌷oo█⌷⌷⌷..Xv*'" - - "*'██v█dd█v███v██████v███v██v██*'" - - "''''''__''''''''''''''''''''''''" - - "*'''''___________________!______" - - "''''''__________________________" - - "''''''''''''''''''''''''''''''''" - -tiles: - "⌷": counter - "f": counter - "t": table - "w": counter-window - "v": wall-window - "s": sink - "o": oven - "S": stove - "C": cuttingboard - "R": raw-steak-crate - "T": tomato-crate - "F": flour-crate - "H": leek-crate - "X": trash - - "c": chair - "~": floor - ".": floor - "'": grass - "*": tree - "!": path - "_": path - "d": door - "█": wall - -items: - "S": pot - "w": plate - "f": foodprocessor - -chef_spawn: "~" -customer_spawn: "!" - -walkable: - - door - - floor - - chair - - grass - - path - -collider: - - wall - - tree diff --git a/data/maps/big.yaml b/data/maps/big.yaml new file mode 100644 index 00000000..46527a87 --- /dev/null +++ b/data/maps/big.yaml @@ -0,0 +1,77 @@ +# Undercooked - a game about cooking +# Copyright 2024 metamuffin +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, version 3 of the License only. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +map: + - "'''''*'''*'''''*'''*'''*'''*''*'" + - "'''*''''*'*'**'''*''**''**''*'''" + - "''██▒██▒██▒███▒███▒████▒██▒███*'" + - "''█ctc.ctc.ctc.ctc.ctc█⌷....s█**" + - "''█.....c.............█⌷....s█''" + - "'*▒c...c...████www██dd█⌷.⌷.⌷⌷█*'" + - "*'█tc.ctc..█⌷.C...ff..d..⌷..L█''" + - "''▒c...c...█⌷.C.....~.d..⌷..R█'*" + - "*'█c.......w..⌷⌷⌷⌷⌷⌷⌷⌷█⌷.⌷..T█*'" + - "'*▒tc......w..........d..⌷..F█''" + - "''█c.....ct█⌷S⌷S⌷S⌷⌷oo█⌷⌷⌷..X█*'" + - "*'████dd██████████▒███████▒███'*" + - "'''*''__''''''''''''''''''''''''" + - "*'''*'___________________!______" + - "'*''''__________________________" + - "*''*''''''''''''''''''''''''''''" + +tiles: + "⌷": counter + "f": counter + "t": table + "w": counter-window + "s": sink + "o": oven + "S": stove + "C": cuttingboard + "R": raw-steak-crate + "T": tomato-crate + "F": flour-crate + "L": leek-crate + "X": trash + + "c": chair + "~": floor + ".": floor + "'": grass + "*": tree + "!": path + "_": path + "d": door + "█": wall + "▒": wall-window + +items: + "S": pot + "w": plate + "f": foodprocessor + +chef_spawn: "~" +customer_spawn: "!" + +walkable: + - door + - floor + - chair + - grass + - path + +collider: + - wall + - tree diff --git a/data/maps/lobby.yaml b/data/maps/lobby.yaml new file mode 100644 index 00000000..b35d5839 --- /dev/null +++ b/data/maps/lobby.yaml @@ -0,0 +1,55 @@ +# Undercooked - a game about cooking +# Copyright 2024 metamuffin +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, version 3 of the License only. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +map: + - "'''''*'''*''''" + - "'''*''''*'*'*'" + - "''██████████*'" + - "''█...ctc.c█**" + - "''█c...c.cT█''" + - "'*█tc.....c█*'" + - "*'█c..~..ct█''" + - "''█......cT█'*" + - "*'█.c.....c█*'" + - "'*█cTc..c..█'*" + - "''█.c..ctc.█*'" + - "*'██████████*'" + - "'*'''*'''*''*'" + - "*''*''**'''**'" + +tiles: + "t": table + "T": table + "s": sink + "c": chair + "~": floor + ".": floor + "'": grass + "*": tree + "█": wall + +items: + "t": tomato-soup-plate + "T": bread-slice-plate + +chef_spawn: "~" +customer_spawn: "!" + +walkable: + - floor + - chair + - grass +collider: + - wall diff --git a/data/maps/small.yaml b/data/maps/small.yaml new file mode 100644 index 00000000..c45a1d19 --- /dev/null +++ b/data/maps/small.yaml @@ -0,0 +1,78 @@ +# Undercooked - a game about cooking +# Copyright 2024 metamuffin +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, version 3 of the License only. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +map: + - "'''''*'''*'''''*'''*'''*'" + - "'''*''''*'*'**'''*''**'''" + - "''████▒████▒████▒████▒█*'" + - "''█ctc.ctc.ctc.ctc.ctc█**" + - "''▒.....c.............█''" + - "'*█c...c...████ww██dd██*'" + - "*'█tc.ctc..█sCC..f⌷..L█''" + - "''▒c...c...█........~R█'*" + - "*'█c.......█⌷⌷⌷⌷⌷⌷⌷..T█*'" + - "'*█tc......w.........F█'*" + - "''█c.....ct█⌷oo⌷⌷SSS⌷X█*'" + - "*'████dd██████▒████▒███*'" + - "'*''''__'''''''''''''''''" + - "*'''''___________________" + - "'''*''__________________!" + - "'*'''''''''''''''''''''''" + +tiles: + "⌷": counter + "f": counter + "t": table + "w": counter-window + "s": sink + "o": oven + "S": stove + "C": cuttingboard + "R": raw-steak-crate + "T": tomato-crate + "F": flour-crate + "L": leek-crate + "X": trash + + "c": chair + "~": floor + ".": floor + "'": grass + "*": tree + "!": path + "_": path + "d": door + "▒": wall-window + "█": wall + +items: + "S": pot + "w": plate + "f": foodprocessor + +chef_spawn: "~" +customer_spawn: "!" + +walkable: + - door + - floor + - chair + - grass + - path + +collider: + - wall + - wall-window + - tree diff --git a/data/recipes.ts b/data/recipes.ts deleted file mode 100644 index c3c764f6..00000000 --- a/data/recipes.ts +++ /dev/null @@ -1,143 +0,0 @@ -/* - Undercooked - a game about cooking - Copyright 2024 metamuffin - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, version 3 of the License only. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . - -*/ - -//? Is is a good idea? Probably not. - -interface Recipe { - tile?: string, - inputs: (string | null)[], - outputs: (string | null)[], - action: "instant" | "passive" | "active" - duration?: number - revert_duration?: number, - warn?: boolean -} - -const all_items = new Set() -function auto_trash() { - for (const ifull of all_items) { - let [i, ic] = get_container(ifull) - if (i == "plate") continue - if (i == "pot") continue - if (i == "foodprocessor") continue - if (i == "dirty") continue - if (ic == "plate") ic = "dirty-plate" - out({ - action: "instant", - tile: "trash", - inputs: [ifull], - outputs: [ic] - }) - } -} - -function out(r: Recipe) { - r.inputs.forEach(i => i ? all_items.add(i) : void 0) - r.outputs.forEach(i => i ? all_items.add(i) : void 0) - r.inputs = r.inputs.filter(e => e) - r.outputs = r.outputs.filter(e => e) - console.log(`- ${JSON.stringify(r).replaceAll("\"active\"", "!active").replaceAll("\"passive\"", "!passive").replaceAll("\"instant\"", "!instant")}`); -} - -function cut(from: string, to?: string, to2?: string) { - out({ action: "active", duration: 2, tile: "cuttingboard", inputs: [from], outputs: [to ?? ("sliced-" + from), to2 ?? null] }) -} -function cook(from: string, to?: string) { - const i = from.endsWith("-pot") ? from : from + "-pot" - const o = (to ?? ("cooked-" + from)) + "-pot" - if (!from.endsWith("-pot")) out({ action: "instant", inputs: ["pot", from], outputs: [i] }) - out({ action: "passive", duration: 20, revert_duration: 40, tile: "stove", inputs: [i], outputs: [o] }) - out({ action: "passive", duration: 5, revert_duration: 10, tile: "stove", inputs: [o], outputs: ["burned-pot"], warn: true }) -} -function process(from: string, to?: string) { - const i = from + "-foodprocessor" - const o = (to ?? (from + "-juice")) + "-foodprocessor" - out({ action: "instant", inputs: ["foodprocessor", from], outputs: [i] }) - out({ action: "active", duration: 3, inputs: [i], outputs: [o] }) -} -function bake(from: string, to?: string) { - const o = (to ?? ("cooked-" + from)) - out({ action: "passive", duration: 25, tile: "oven", inputs: [from], outputs: [o] }) - out({ action: "passive", duration: 15, revert_duration: 20, tile: "oven", inputs: [o], outputs: ["burned"], warn: true }) -} -function crate(item: string) { - out({ action: "instant", tile: item + "-crate", inputs: [], outputs: [item], }) -} - -function get_container(ifull: string): [string, string | null] { - const iparts = ifull.split("-") - const ic = iparts.pop() - if (ic && iparts.length && ["pot", "plate", "foodprocessor"].includes(ic)) return [iparts.join("-"), ic] - return [ifull, null] -} - -function combine(container: string, ...inputs: string[]) { - const open = inputs.map(ifull => { - const [i, ic] = get_container(ifull) - out({ action: "instant", inputs: [container, ifull], outputs: [i + "-" + container, ic] }) - return [i] - }) - const seen = new Set() - while (1) { - const cur = open.pop() - if (!cur) break; - const c = cur.join("-") + "-" + container - for (const ifull of inputs) { - const [i, ic] = get_container(ifull) - if (cur.includes(i)) continue - const rkey = cur.join("-") + "#" + i - if (seen.has(rkey)) continue - seen.add(rkey) - - const parts = [...cur, i] - parts.sort() - const o = parts.join("-") + "-" + container - open.push(parts) - out({ - action: "instant", - inputs: [c, ifull], - outputs: [o, ic] - }) - } - } -} - -out({ action: "active", duration: 2, tile: "sink", inputs: ["dirty-plate"], outputs: ["plate"] }) - -crate("tomato") -crate("raw-steak") -crate("flour") -crate("leek") - -cut("tomato") - -cook("raw-steak", "steak") - -process("flour", "dough") -out({ action: "instant", inputs: ["dough-foodprocessor"], outputs: ["foodprocessor", "dough"] }) -bake("dough", "bread") -cut("bread", "bread-slice", "bread-slice") - -process("tomato") -combine("pot", "leek", "tomato-juice-foodprocessor") -cook("leek-tomato-juice-pot", "tomato-soup") -out({ action: "instant", inputs: ["tomato-soup-pot", "plate"], outputs: ["pot", "tomato-soup-plate"] }) - -combine("plate", "steak-pot", "sliced-tomato", "bread-slice") - -auto_trash() diff --git a/data/recipes/.gitignore b/data/recipes/.gitignore new file mode 100644 index 00000000..1e82fc7d --- /dev/null +++ b/data/recipes/.gitignore @@ -0,0 +1 @@ +*.yaml diff --git a/data/recipes/default.ts b/data/recipes/default.ts new file mode 100644 index 00000000..4efdb16a --- /dev/null +++ b/data/recipes/default.ts @@ -0,0 +1,143 @@ +/* + Undercooked - a game about cooking + Copyright 2024 metamuffin + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, version 3 of the License only. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + +//? Is is a good idea? Probably not. + +interface Recipe { + tile?: string, + inputs: (string | null)[], + outputs: (string | null)[], + action: "instant" | "passive" | "active" | "demand" + duration?: number + revert_duration?: number, + warn?: boolean +} + +const all_items = new Set() +function auto_trash() { + for (const ifull of all_items) { + let [i, ic] = get_container(ifull) + if (i == "plate") continue + if (i == "pot") continue + if (i == "foodprocessor") continue + if (i == "dirty") continue + if (ic == "plate") ic = "dirty-plate" + out({ + action: "instant", + tile: "trash", + inputs: [ifull], + outputs: [ic] + }) + } +} + +function out(r: Recipe) { + r.inputs.forEach(i => i ? all_items.add(i) : void 0) + r.outputs.forEach(i => i ? all_items.add(i) : void 0) + r.inputs = r.inputs.filter(e => e) + r.outputs = r.outputs.filter(e => e) + console.log(`- ${JSON.stringify(r).replaceAll("\"active\"", "!active").replaceAll("\"passive\"", "!passive").replaceAll("\"instant\"", "!instant")}`); +} + +function cut(from: string, to?: string, to2?: string) { + out({ action: "active", duration: 2, tile: "cuttingboard", inputs: [from], outputs: [to ?? ("sliced-" + from), to2 ?? null] }) +} +function cook(from: string, to?: string) { + const i = from.endsWith("-pot") ? from : from + "-pot" + const o = (to ?? ("cooked-" + from)) + "-pot" + if (!from.endsWith("-pot")) out({ action: "instant", inputs: ["pot", from], outputs: [i] }) + out({ action: "passive", duration: 20, revert_duration: 40, tile: "stove", inputs: [i], outputs: [o] }) + out({ action: "passive", duration: 5, revert_duration: 10, tile: "stove", inputs: [o], outputs: ["burned-pot"], warn: true }) +} +function process(from: string, to?: string) { + const i = from + "-foodprocessor" + const o = (to ?? (from + "-juice")) + "-foodprocessor" + out({ action: "instant", inputs: ["foodprocessor", from], outputs: [i] }) + out({ action: "active", duration: 3, inputs: [i], outputs: [o] }) +} +function bake(from: string, to?: string) { + const o = (to ?? ("cooked-" + from)) + out({ action: "passive", duration: 25, tile: "oven", inputs: [from], outputs: [o] }) + out({ action: "passive", duration: 15, revert_duration: 20, tile: "oven", inputs: [o], outputs: ["burned"], warn: true }) +} +function crate(item: string) { + out({ action: "instant", tile: item + "-crate", inputs: [], outputs: [item], }) +} + +function get_container(ifull: string): [string, string | null] { + const iparts = ifull.split("-") + const ic = iparts.pop() + if (ic && iparts.length && ["pot", "plate", "foodprocessor"].includes(ic)) return [iparts.join("-"), ic] + return [ifull, null] +} + +function combine(container: string, ...inputs: string[]) { + const open = inputs.map(ifull => { + const [i, ic] = get_container(ifull) + out({ action: "instant", inputs: [container, ifull], outputs: [i + "-" + container, ic] }) + return [i] + }) + const seen = new Set() + while (1) { + const cur = open.pop() + if (!cur) break; + const c = cur.join("-") + "-" + container + for (const ifull of inputs) { + const [i, ic] = get_container(ifull) + if (cur.includes(i)) continue + const rkey = cur.join("-") + "#" + i + if (seen.has(rkey)) continue + seen.add(rkey) + + const parts = [...cur, i] + parts.sort() + const o = parts.join("-") + "-" + container + open.push(parts) + out({ + action: "instant", + inputs: [c, ifull], + outputs: [o, ic] + }) + } + } +} + +out({ action: "active", duration: 2, tile: "sink", inputs: ["dirty-plate"], outputs: ["plate"] }) + +crate("tomato") +crate("raw-steak") +crate("flour") +crate("leek") + +cut("tomato") + +cook("raw-steak", "steak") + +process("flour", "dough") +out({ action: "instant", inputs: ["dough-foodprocessor"], outputs: ["foodprocessor", "dough"] }) +bake("dough", "bread") +cut("bread", "bread-slice", "bread-slice") + +process("tomato") +combine("pot", "leek", "tomato-juice-foodprocessor") +cook("leek-tomato-juice-pot", "tomato-soup") +out({ action: "instant", inputs: ["tomato-soup-pot", "plate"], outputs: ["pot", "tomato-soup-plate"] }) + +combine("plate", "steak-pot", "sliced-tomato", "bread-slice") + +auto_trash() diff --git a/data/recipes/none.ts b/data/recipes/none.ts new file mode 100644 index 00000000..3338909f --- /dev/null +++ b/data/recipes/none.ts @@ -0,0 +1 @@ +// This scripts generates no recipes. Interesting, isn't it? -- cgit v1.2.3-70-g09d2