1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
use crate::format::producer::Producer;
use crate::format::release::{ExtLink, Release};
use crate::format::schema::{Language, Platform};
use crate::format::vn::*;
use serde::{Deserialize, Serialize};
use serde_repr::*;

#[derive(Deserialize, Serialize, Debug)]
pub struct Character {
    pub id: Option<String>,
    pub name: Option<String>,
    /// Name in the original script
    pub original: Option<String>,
    pub aliases: Option<Vec<String>>,
    /// May contain formatting codes
    pub description: Option<String>,
    /// Same sub-fields as the image visual novel fields except for thumbnail and thumbnail_dims
    /// because character images are currently always limited to 256x300px
    /// but that is subject to change in the future
    pub image: Option<CharacterImage>,
    pub blood_type: Option<String>,
    pub height: Option<u32>,
    pub weight: Option<u32>,
    pub bust: Option<u32>,
    pub waist: Option<u32>,
    pub hips: Option<u32>,
    pub cup: Option<String>,
    pub age: Option<u32>,
    /// [month, day]
    pub birthday: Option<Vec<u8>>,
    /// The character’s apparent (non-spoiler) sex and the character’s real (spoiler) sex
    pub gender: Option<CharacterGenderWrapper>,
    pub vns: Option<Vec<CharacterVnRelation>>,
    pub traits: Option<Vec<CharacterTrait>>,
}

#[derive(Deserialize, Serialize, Debug)]
pub struct CharacterImage {
    /// includes vn image fields excluding thumbnail and thumbnail_dims
    pub id: Option<String>,
    pub url: Option<String>,
    pub dims: Option<Vec<u32>>,
    pub sexual: Option<f32>,
    pub violence: Option<f32>,
    pub votecount: Option<u32>,
}

#[derive(Deserialize, Serialize, Debug)]
#[serde(untagged)]
pub enum CharacterGenderWrapper {
    Appearance(CharacterGender),
    Real(CharacterGender),
}

#[derive(Deserialize, Serialize, Debug)]
pub enum CharacterGender {
    #[serde(rename = "m")]
    Male,
    #[serde(rename = "f")]
    Female,
    #[serde(rename = "b")]
    Both,
}

#[derive(Deserialize, Serialize, Debug)]
pub struct CharacterVnRelation {
    pub spoiler: Option<u32>,
    pub role: Option<CharacterRole>,
    /// Takes all /vn fields
    pub id: Option<String>,
    pub title: Option<String>,
    pub alttitle: Option<String>,
    pub titles: Option<Vec<VnTitle>>,
    pub aliases: Option<Vec<String>>,
    pub olang: Option<Language>,
    pub devstatus: Option<VnDevStatus>,
    pub released: Option<String>,
    pub languages: Option<Vec<Language>>,
    pub platforms: Option<Vec<Platform>>,
    pub image: Option<VnImage>,
    pub length: Option<VnLength>,
    pub length_minutes: Option<u32>,
    pub length_votes: Option<u32>,
    pub description: Option<String>,
    pub rating: Option<f32>,
    pub votecount: Option<u32>,
    pub screenshots: Option<Vec<VnScreenShot>>,
    pub relations: Option<Vec<VnRelation>>,
    pub tags: Option<Vec<VnTag>>,
    pub developers: Option<Vec<Producer>>,
    pub editions: Option<Vec<VnEdition>>,
    pub staff: Option<Vec<VnStaff>>,
    pub va: Option<Vec<VnVoiceActor>>,
    pub extlinks: Option<Vec<ExtLink>>,
    pub release: Option<Release>,
}

#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "lowercase")]
pub enum CharacterRole {
    Main,
    Primary,
    Side,
    Appears,
}

#[derive(Deserialize, Serialize, Debug)]
pub struct CharacterTrait {
    pub spoiler: Option<CharacterTraitSpoiler>,
    pub lie: Option<bool>,
    /// All /trait fields available here
    pub id: Option<String>,
    pub name: Option<String>,
    pub aliases: Option<Vec<String>>,
    pub description: Option<String>,
    pub searchable: Option<bool>,
    pub applicable: Option<bool>,
    pub group_id: Option<String>,
    pub group_name: Option<String>,
    pub char_count: Option<u32>,
}

#[derive(Deserialize_repr, Serialize_repr, PartialEq, Debug)]
#[repr(u8)]
pub enum CharacterTraitSpoiler {
    None = 0,
    Medium = 1,
    Big = 2,
}