diff options
-rw-r--r-- | Cargo.lock | 17 | ||||
-rw-r--r-- | data/recipes/default.ts | 58 | ||||
-rw-r--r-- | server/Cargo.toml | 1 | ||||
-rw-r--r-- | server/src/customer/mod.rs | 3 |
4 files changed, 50 insertions, 29 deletions
@@ -213,6 +213,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e8566979429cf69b49a5c740c60791108e86440e8be149bbea4fe54d2c32d6e2" [[package]] +name = "deunicode" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "339544cc9e2c4dc3fc7149fd630c5f22263a4fdf18a98afd0075784968b5cf00" + +[[package]] name = "digest" version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -252,6 +258,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] +name = "fake" +version = "2.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c25829bde82205da46e1823b2259db6273379f626fc211f126f65654a2669be" +dependencies = [ + "deunicode", + "rand 0.8.5", +] + +[[package]] name = "fnv" version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -848,6 +864,7 @@ dependencies = [ "anyhow", "clap", "env_logger", + "fake", "futures-util", "glam", "log", diff --git a/data/recipes/default.ts b/data/recipes/default.ts index 4efdb16a..f0a9ef6b 100644 --- a/data/recipes/default.ts +++ b/data/recipes/default.ts @@ -18,7 +18,7 @@ //? Is is a good idea? Probably not. -interface Recipe { +export interface Recipe { tile?: string, inputs: (string | null)[], outputs: (string | null)[], @@ -28,8 +28,8 @@ interface Recipe { warn?: boolean } -const all_items = new Set<string>() -function auto_trash() { +export const all_items = new Set<string>() +export function auto_trash() { for (const ifull of all_items) { let [i, ic] = get_container(ifull) if (i == "plate") continue @@ -46,7 +46,7 @@ function auto_trash() { } } -function out(r: Recipe) { +export 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) @@ -54,39 +54,39 @@ function out(r: Recipe) { console.log(`- ${JSON.stringify(r).replaceAll("\"active\"", "!active").replaceAll("\"passive\"", "!passive").replaceAll("\"instant\"", "!instant")}`); } -function cut(from: string, to?: string, to2?: string) { +export 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) { +export 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) { +export 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) { +export 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) { +export function crate(item: string) { out({ action: "instant", tile: item + "-crate", inputs: [], outputs: [item], }) } -function get_container(ifull: string): [string, string | null] { +export 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[]) { +export 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] }) @@ -117,27 +117,29 @@ function combine(container: string, ...inputs: string[]) { } } -out({ action: "active", duration: 2, tile: "sink", inputs: ["dirty-plate"], outputs: ["plate"] }) +if (import.meta.main) { + out({ action: "active", duration: 2, tile: "sink", inputs: ["dirty-plate"], outputs: ["plate"] }) -crate("tomato") -crate("raw-steak") -crate("flour") -crate("leek") + crate("tomato") + crate("raw-steak") + crate("flour") + crate("leek") -cut("tomato") + cut("tomato") -cook("raw-steak", "steak") + 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("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"] }) + 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") + combine("plate", "steak-pot", "sliced-tomato", "bread-slice") -auto_trash() + auto_trash() +} diff --git a/server/Cargo.toml b/server/Cargo.toml index 9b954908..f09bdf4e 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -18,3 +18,4 @@ serde_yaml = "0.9.34+deprecated" rand = "0.9.0-alpha.1" shlex = "1.3.0" clap = { version = "4.5.7", features = ["derive"] } +fake = "2.9.2" diff --git a/server/src/customer/mod.rs b/server/src/customer/mod.rs index 0b300b6e..7f32b094 100644 --- a/server/src/customer/mod.rs +++ b/server/src/customer/mod.rs @@ -25,6 +25,7 @@ use crate::{ state::State, }; use anyhow::{anyhow, Result}; +use fake::{faker, Fake}; use glam::{IVec2, Vec2}; use log::{debug, error, warn}; use movement::MovementBase; @@ -193,7 +194,7 @@ impl CustomerManager { packets_out.push(( id, PacketS::Join { - name: "George".to_string(), + name: faker::name::fr_fr::Name().fake(), character: -2, }, )); |