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 1789229..045234a 100644 Binary files a/stories/test.zip and b/stories/test.zip differ