added character documentation and split Clothing into a sub-struct
of Character
This commit is contained in:
@@ -68,6 +68,7 @@ This is done in the about.json file,
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
#### Characters
|
#### Characters
|
||||||
|
See [Character documentation](/docs/CHARACTER.md] for more info
|
||||||
Referencing a character using the @, @NARRATOR is reserved for the Narrator.<br/>
|
Referencing a character using the @, @NARRATOR is reserved for the Narrator.<br/>
|
||||||
Customisation is done with @CHARACTER change \<feature\> into \<feature name\><br/>
|
Customisation is done with @CHARACTER change \<feature\> into \<feature name\><br/>
|
||||||
|
|
||||||
|
|||||||
@@ -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.
|
||||||
+25
-16
@@ -4,12 +4,14 @@ use crate::{
|
|||||||
File,
|
File,
|
||||||
HashMap,
|
HashMap,
|
||||||
debug,
|
debug,
|
||||||
|
info,
|
||||||
Deserialize,
|
Deserialize,
|
||||||
Serialize,
|
Serialize,
|
||||||
Mutex,
|
Mutex,
|
||||||
Arc,
|
Arc,
|
||||||
};
|
};
|
||||||
#[derive(Debug, Deserialize, Serialize, Clone)]
|
#[derive(Debug, Deserialize, Serialize, Clone, Default)]
|
||||||
|
#[serde(default)]
|
||||||
pub struct Character
|
pub struct Character
|
||||||
{
|
{
|
||||||
name: String,
|
name: String,
|
||||||
@@ -20,14 +22,20 @@ pub struct Character
|
|||||||
pronoun_deppos: String,
|
pronoun_deppos: String,
|
||||||
pronoun_indpos: String,
|
pronoun_indpos: String,
|
||||||
pronoun_reflex: String,
|
pronoun_reflex: String,
|
||||||
head: String,
|
head_shape: String,
|
||||||
hair: String,
|
hair_style: String,
|
||||||
torso: String,
|
torso_shape: String,
|
||||||
arm: String,
|
arm_shape: String,
|
||||||
leg: String,
|
leg_shape: String,
|
||||||
hair_color: String,
|
hair_color: String,
|
||||||
top_clothing: String,
|
clothing: Clothing,
|
||||||
bottom_clothing: String,
|
}
|
||||||
|
#[derive(Debug,Deserialize,Serialize,Clone,Default)]
|
||||||
|
#[serde(default)]
|
||||||
|
pub struct Clothing
|
||||||
|
{
|
||||||
|
top: String,
|
||||||
|
bottom: String,
|
||||||
shoes: String,
|
shoes: String,
|
||||||
}
|
}
|
||||||
impl Character {
|
impl Character {
|
||||||
@@ -41,15 +49,15 @@ impl Character {
|
|||||||
"pronoun_deppos" => self.pronoun_deppos = value.to_string(),
|
"pronoun_deppos" => self.pronoun_deppos = value.to_string(),
|
||||||
"pronoun_indpos" => self.pronoun_indpos = value.to_string(),
|
"pronoun_indpos" => self.pronoun_indpos = value.to_string(),
|
||||||
"pronoun_reflex" => self.pronoun_reflex = value.to_string(),
|
"pronoun_reflex" => self.pronoun_reflex = value.to_string(),
|
||||||
"head" => self.head = value.to_string(),
|
"head_shape" => self.head_shape = value.to_string(),
|
||||||
"hair" => self.hair = value.to_string(),
|
"hair_style" => self.hair_style = value.to_string(),
|
||||||
"torso" => self.torso = value.to_string(),
|
"torso_shape" => self.torso_shape = value.to_string(),
|
||||||
"arm" => self.arm = value.to_string(),
|
"arm_shape" => self.arm_shape = value.to_string(),
|
||||||
"leg" => self.leg = value.to_string(),
|
"leg_shape" => self.leg_shape = value.to_string(),
|
||||||
"hair_color" => self.hair_color = value.to_string(),
|
"hair_color" => self.hair_color = value.to_string(),
|
||||||
"top_clothing" => self.top_clothing = value.to_string(),
|
"clothing.top" => self.clothing.top = value.to_string(),
|
||||||
"bottom_clothing" => self.bottom_clothing = value.to_string(),
|
"clothing.bottom" => self.clothing.bottom = value.to_string(),
|
||||||
"shoes" => self.shoes = value.to_string(),
|
"clothing.shoes" => self.clothing.shoes = value.to_string(),
|
||||||
|
|
||||||
_ => return Err(()),
|
_ => return Err(()),
|
||||||
}
|
}
|
||||||
@@ -72,6 +80,7 @@ pub fn character_parse(archive: &mut ZipArchive<File>)
|
|||||||
let characters: HashMap<String, Character> =
|
let characters: HashMap<String, Character> =
|
||||||
serde_json::from_str(&file_contents)
|
serde_json::from_str(&file_contents)
|
||||||
.map_err (|err| format!("Invalid JSON in characters.json: {err}"))?;
|
.map_err (|err| format!("Invalid JSON in characters.json: {err}"))?;
|
||||||
|
info!("Parsed characters from characters.json");
|
||||||
debug!("{characters:?}");
|
debug!("{characters:?}");
|
||||||
Ok(Arc::new(Mutex::new(characters)))
|
Ok(Arc::new(Mutex::new(characters)))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,6 +71,8 @@ pub fn character_parse
|
|||||||
drop(characters);
|
drop(characters);
|
||||||
api::modify_data(data_to_send, "change".to_string(), String::new(), character_name, vec![]);
|
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" =>
|
"to"|"animate" =>
|
||||||
{
|
{
|
||||||
sum_index += 1;
|
sum_index += 1;
|
||||||
|
|||||||
+14
-9
@@ -4,19 +4,24 @@
|
|||||||
"gender": "Male",
|
"gender": "Male",
|
||||||
"skin_color": "",
|
"skin_color": "",
|
||||||
"eye_color": "",
|
"eye_color": "",
|
||||||
|
"hair_color": "",
|
||||||
"pronoun_subject": "He",
|
"pronoun_subject": "He",
|
||||||
"pronoun_object": "Him",
|
"pronoun_object": "Him",
|
||||||
"pronoun_deppos": "His",
|
"pronoun_deppos": "His",
|
||||||
"pronoun_indpos": "His",
|
"pronoun_indpos": "His",
|
||||||
"pronoun_reflex": "Himself",
|
"pronoun_reflex": "Himself",
|
||||||
"head": "",
|
"head_shape": "",
|
||||||
"hair": "",
|
"hair_style": "",
|
||||||
"torso": "",
|
"torso_shape": "",
|
||||||
"arm": "",
|
"arm_shape": "",
|
||||||
"leg": "",
|
"leg_shape": "",
|
||||||
"hair_color": "",
|
"clothing": {
|
||||||
"top_clothing": "",
|
"top": "",
|
||||||
"bottom_clothing": "",
|
"bottom": "",
|
||||||
"shoes": ""
|
"shoes": "",
|
||||||
|
"hat": "",
|
||||||
|
"gloves": "",
|
||||||
|
"neck": ""
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user