1use crate::cock_parts::{
2 Abnormalities, Aesthetic, Balls, Circumcision, Curvature, Inches, Shape, Size,
3 Veininess,
4};
5use crate::FromString;
6
7#[derive(Debug, Clone, serde::Deserialize)]
10pub struct CockStruct {
11 pub size: Size,
12 pub aesthetic: Aesthetic,
13 pub balls: Balls,
14 pub shape: Shape,
15 pub curvature: Curvature,
16 pub circumcision: Circumcision,
17 pub veininess: Veininess,
18 pub abnormalities: Abnormalities,
19}
20
21impl CockStruct {
22 pub fn new(
25 size: Size,
26 aesthetic: Aesthetic,
27 balls: Balls,
28 shape: Shape,
29 curvature: Curvature,
30 circumcision: Circumcision,
31 veininess: Veininess,
32 abnormalities: Abnormalities,
33 ) -> CockStruct {
34 CockStruct {
35 size,
36 aesthetic,
37 balls,
38 shape,
39 curvature,
40 circumcision,
41 veininess,
42 abnormalities,
43 }
44 }
45
46 pub fn default() -> CockStruct {
48 CockStruct {
49 size: Size {
50 length: 0.0,
51 girth: 0.0,
52 size_type: Inches,
53 },
54 aesthetic: Aesthetic::Normal,
55 balls: Balls::Normal,
56 shape: Shape::Other(String::from("")),
57 curvature: Curvature::Other(String::from("")),
58 circumcision: Circumcision::Uncircumcised,
59 veininess: Veininess::Normal,
60 abnormalities: Abnormalities::None,
61 }
62 }
63
64 pub fn from_str_part(&mut self, part: &str, new: &str) {
68 match part {
69 "Abnormalities" => self.abnormalities = Abnormalities::from_string(new),
70 "Aesthetic" => self.aesthetic = Aesthetic::from_string(new),
71 "Balls" => self.balls = Balls::from_string(new),
72 "Circumcision" => self.circumcision = Circumcision::from_string(new),
73 "Curvature" => self.curvature = Curvature::from_string(new),
74 "Shape" => self.shape = Shape::from_string(new),
75 "Veininess" => self.veininess = Veininess::from_string(new),
76 _ => panic!("Invalid part"),
77 }
78 }
79
80 pub fn get_custom(&mut self, part: &str, item: &str, new: &str) {
86 match item {
87 "Major" => self.abnormalities = Abnormalities::Major(new.to_string()),
88 "Minor" => self.abnormalities = Abnormalities::Minor(new.to_string()),
89 "Other" => match part {
90 "Shape" => self.shape = Shape::Other(new.to_string()),
91 "Curvature" => self.curvature = Curvature::Other(new.to_string()),
92 _ => panic!("Invalid part"),
93 },
94 _ => panic!("Invalid item"),
95 }
96 }
97}
98
99impl std::fmt::Display for CockStruct {
101 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
103 writeln!(f, "Size: {}", self.size)?;
104 writeln!(f, "Aesthetic: {}", self.aesthetic)?;
105 writeln!(f, "Balls: {}", self.balls)?;
106 writeln!(f, "Shape: {}", self.shape)?;
107 writeln!(f, "Curvature: {}", self.curvature)?;
108 writeln!(f, "Circumcision: {}", self.circumcision)?;
109 writeln!(f, "Veininess: {}", self.veininess)?;
110 write!(f, "Abnormalities: {}", self.abnormalities)
111 }
112}
113
114#[cfg(test)]
115mod tests {
116 use super::*;
117 use crate::cock_parts::Inches;
118
119 #[test]
120 fn cock_struct_test() {
121 let cock = CockStruct::new(
122 Size {
123 length: 5.6,
124 girth: 4.1,
125 size_type: Inches,
126 },
127 Aesthetic::UglyButUsable,
128 Balls::PossibleCancer,
129 Shape::Other(String::from("test")),
130 Curvature::Right,
131 Circumcision::Circumcised,
132 Veininess::HealthyPumper,
133 Abnormalities::Major(String::from("Active case of herpes")),
134 );
135
136 assert_eq!(cock.size.length, 5.6);
137 assert_eq!(cock.size.girth, 4.1);
138 assert_eq!(cock.size.size_type, Inches);
139 assert_eq!(cock.aesthetic, Aesthetic::UglyButUsable);
140 assert_eq!(cock.balls, Balls::PossibleCancer);
141 assert_eq!(cock.shape.get_shape(), "test");
142 assert_eq!(cock.curvature, Curvature::Right);
143 assert_eq!(cock.circumcision, Circumcision::Circumcised);
144 assert_eq!(cock.veininess, Veininess::HealthyPumper);
145 assert_eq!(
146 cock.abnormalities.get_abnormality(),
147 "Active case of herpes"
148 );
149 }
150}