From 6d012dbe6b13feddc1d2c03f953c541836fd4900 Mon Sep 17 00:00:00 2001 From: deadvey Date: Sat, 16 May 2026 14:06:49 +0100 Subject: [PATCH] added character documentation and split Clothing into a sub-struct of Character --- README.md | 1 + docs/CHARACTERS.md | 66 ++++++++++++++++++++++++++ server/src/character.rs | 41 +++++++++------- server/src/parsing/character_parse.rs | 2 + stories/characters.json | 23 +++++---- stories/test.zip | Bin 644 -> 650 bytes 6 files changed, 108 insertions(+), 25 deletions(-) create mode 100644 docs/CHARACTERS.md diff --git a/README.md b/README.md index 2cfc303..6833ddd 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,7 @@ This is done in the about.json file, } ``` #### Characters +See [Character documentation](/docs/CHARACTER.md] for more info Referencing a character using the @, @NARRATOR is reserved for the Narrator.
Customisation is done with @CHARACTER change \ into \
diff --git a/docs/CHARACTERS.md b/docs/CHARACTERS.md new file mode 100644 index 0000000..6669e85 --- /dev/null +++ b/docs/CHARACTERS.md @@ -0,0 +1,66 @@ +# Character features +| Feature | Examples | Notes | +| ------- | ------- | --- | +| Name | Timothy Sharpshooter | | +| Gender | Male, Female, NB, Other | | +| Skin Color | Khaki, #F0E68C, rgb(240, 230, 140) | CSS Color | +| Eye Color | LightBlue, #ADD8E6, rgb(173, 216, 230) | CSS Color | +| Hair Color | GoldenRod, #DAA520, rgb(218, 165, 32) | CSS Color | +| Pronoun Subject | He, She, They | See https://en.wikipedia.org/wiki/Pronoun | +| Pronoun Object | Him, Her, Them | See https://en.wikipedia.org/wiki/Pronoun | +| Pronoun Deppos | His, Her, Their | See https://en.wikipedia.org/wiki/Pronoun | +| Pronoun Indpos | His, Hers, Theirs | See https://en.wikipedia.org/wiki/Pronoun | +| Pronoun Reflex | Himself, Herself, Themselves | See https://en.wikipedia.org/wiki/Pronoun | +| Head Shape | | | +| Torso Shape | | | +| Arm Shape | | | +| Leg Shape | | | +| Hair Style | | | +| Clothing | See [Character Clothing](#Character Clothing) | | +> [!NOTE] +> Pronouns can be implied and unrequired with a recognised Gender value, however, custom values can be filled in if desired. + +# Character Clothing +| Appearal | Examples | Notes | +| --- | --- | --- | +| Top | | Shirt, Jumper, etc... | +| Bottom | | Trousers, tights, etc... | +| Shoes | | | +| Hat | | | +| Gloves | | | +| Neck | | Necklace, Scarf, etc... | + +# Characters.json +Characters are stored in the characters.json file which looks like this: +{ + "tim": { + "name": "Timothy Sharpshooter", + "gender": "Male", + "skin_color": "", + "eye_color": "", + "hair_color": "", + "pronoun_subject": "He", + "pronoun_object": "Him", + "pronoun_deppos": "His", + "pronoun_indpos": "His", + "pronoun_reflex": "Himself", + "head_shape": "", + "hair_style": "", + "torso_shape": "", + "arm_shape": "", + "leg_shape": "", + "clothing": { + "top": "", + "bottom": "", + "shoes": "", + "hat": "", + "gloves": "", + "neck": "" + } + }, + "bob": { + ... + } +} +> [!NOTE] +> MUST be valid JSON or it can't be deserialised. diff --git a/server/src/character.rs b/server/src/character.rs index 9fc4d13..53196ab 100644 --- a/server/src/character.rs +++ b/server/src/character.rs @@ -4,12 +4,14 @@ use crate::{ File, HashMap, debug, + info, Deserialize, Serialize, Mutex, Arc, }; -#[derive(Debug, Deserialize, Serialize, Clone)] +#[derive(Debug, Deserialize, Serialize, Clone, Default)] +#[serde(default)] pub struct Character { name: String, @@ -20,14 +22,20 @@ pub struct Character pronoun_deppos: String, pronoun_indpos: String, pronoun_reflex: String, - head: String, - hair: String, - torso: String, - arm: String, - leg: String, + head_shape: String, + hair_style: String, + torso_shape: String, + arm_shape: String, + leg_shape: String, hair_color: String, - top_clothing: String, - bottom_clothing: String, + clothing: Clothing, +} +#[derive(Debug,Deserialize,Serialize,Clone,Default)] +#[serde(default)] +pub struct Clothing +{ + top: String, + bottom: String, shoes: String, } impl Character { @@ -41,15 +49,15 @@ impl Character { "pronoun_deppos" => self.pronoun_deppos = value.to_string(), "pronoun_indpos" => self.pronoun_indpos = value.to_string(), "pronoun_reflex" => self.pronoun_reflex = value.to_string(), - "head" => self.head = value.to_string(), - "hair" => self.hair = value.to_string(), - "torso" => self.torso = value.to_string(), - "arm" => self.arm = value.to_string(), - "leg" => self.leg = value.to_string(), + "head_shape" => self.head_shape = value.to_string(), + "hair_style" => self.hair_style = value.to_string(), + "torso_shape" => self.torso_shape = value.to_string(), + "arm_shape" => self.arm_shape = value.to_string(), + "leg_shape" => self.leg_shape = value.to_string(), "hair_color" => self.hair_color = value.to_string(), - "top_clothing" => self.top_clothing = value.to_string(), - "bottom_clothing" => self.bottom_clothing = value.to_string(), - "shoes" => self.shoes = value.to_string(), + "clothing.top" => self.clothing.top = value.to_string(), + "clothing.bottom" => self.clothing.bottom = value.to_string(), + "clothing.shoes" => self.clothing.shoes = value.to_string(), _ => return Err(()), } @@ -72,6 +80,7 @@ pub fn character_parse(archive: &mut ZipArchive) let characters: HashMap = serde_json::from_str(&file_contents) .map_err (|err| format!("Invalid JSON in characters.json: {err}"))?; + info!("Parsed characters from characters.json"); debug!("{characters:?}"); Ok(Arc::new(Mutex::new(characters))) } diff --git a/server/src/parsing/character_parse.rs b/server/src/parsing/character_parse.rs index 14cb7f2..11d144f 100644 --- a/server/src/parsing/character_parse.rs +++ b/server/src/parsing/character_parse.rs @@ -71,6 +71,8 @@ pub fn character_parse drop(characters); api::modify_data(data_to_send, "change".to_string(), String::new(), character_name, vec![]); }, + // These two are mainly just actions performed by the frontend client, so just tell the client to move/animate + // the character and not much other processing needed on the serverside "to"|"animate" => { sum_index += 1; diff --git a/stories/characters.json b/stories/characters.json index 5580eb9..8de2708 100644 --- a/stories/characters.json +++ b/stories/characters.json @@ -4,19 +4,24 @@ "gender": "Male", "skin_color": "", "eye_color": "", + "hair_color": "", "pronoun_subject": "He", "pronoun_object": "Him", "pronoun_deppos": "His", "pronoun_indpos": "His", "pronoun_reflex": "Himself", - "head": "", - "hair": "", - "torso": "", - "arm": "", - "leg": "", - "hair_color": "", - "top_clothing": "", - "bottom_clothing": "", - "shoes": "" + "head_shape": "", + "hair_style": "", + "torso_shape": "", + "arm_shape": "", + "leg_shape": "", + "clothing": { + "top": "", + "bottom": "", + "shoes": "", + "hat": "", + "gloves": "", + "neck": "" + } } } diff --git a/stories/test.zip b/stories/test.zip index 1789229d5115593aaf7b19c856fe93b6824522e2..045234a4bee13795bb687ceb8508c83febbff5db 100644 GIT binary patch delta 304 zcmZo+?P8sv&$xf0!OD8)>VHAFsSW-Qw3keaz9 uHR7K`f!W8-dWHaRMkYDt$rl+zcu~S&vJsOe$hVW@m=xG9GBPkQFaQ8UO?e9d delta 304 zcmeBTZDF0D&$w@*!OHq4Q`g7zhHW?4%)r3V&&a^Q&mhB)oRL_Rm|T)tRIHa(oSzpO z!pXoa6T_aR62qQVTEWf0$nt`jfdNdEPB7#-GRw151k!dkhHP#(l6YFO%e($v?1TjOHzA$>9-mBT$wouOcp2S7dxqkbD%bw>Lx|!HJRO#j%lvL%8 seZd~!&B!FjEW*IRz`-#2E~6hWN*GMGVA2Hnc5(`n0^4au1_lNO0PhxVhyVZp