1use rand::{thread_rng, Rng};
2pub trait Random {
3 type Type;
4 fn random_type(&self) -> Self::Type;
5 fn random_rate(&self,value:u32) -> u32 {
6 let mut rng = thread_rng();
7 let n: u32 = rng.gen_range(0..value);
8 n
9 }
10 fn random(&self, min:f64, max:f64) -> f64 {
11 let mut rng = thread_rng();
12 let n: f64 = rng.gen_range(min..max);
13 (n * 0.5).round() / 0.5
14 }
15 fn half(&self) -> bool {
17 if self.random_rate(1) == 1 {
18 return true
19 }
20 false
21 }
22 fn usually(&self) -> bool {
24 if self.random_rate(9) > 1 {
25 return true
26 }
27 false
28 }
29 fn often(&self) -> bool {
31 if self.random_rate(3) > 0 {
32 return true
33 }
34 false
35 }
36 fn hardly(&self) -> bool {
38 if self.random_rate(3) == 0 {
39 return true
40 }
41 false
42 }
43 fn barely(&self) -> bool {
45 if self.random_rate(9) == 0 {
46 return true
47 }
48 false
49 }
50}
51pub fn random_0max(value:u32) -> u32 {
52 let mut rng = thread_rng();
53 let n: u32 = rng.gen_range(0..value);
54 n
55}
56pub fn random_character_name() ->String {
57 let max = 8;
58 let val = random_0max(max);
59 let mut name:String = match val {
60 0 => String::from("Ax"),
61 1 => String::from("Morph"),
62 2 => String::from("Dri"),
63 3 => String::from("Cor"),
64 4 => String::from("Mig"),
65 5 => String::from("Den"),
66 7 => String::from("Por"),
67 8 => String::from("Bel"),
68 _=> String::from("Rust"),
69 };
70 let val = random_0max(max);
71 let name_second:String = match val {
72 0 => String::from("atlin"),
73 1 => String::from("eleous"),
74 2 => String::from("manthus"),
75 3 => String::from("timbrle"),
76 4 => String::from("darlis"),
77 5 => String::from("gerar"),
78 7 => String::from("trid"),
79 8 => String::from("toph"),
80 _=> String::from("ferris"),
81 };
82 name.push_str(name_second.as_str());
83 name
84}
85pub fn random_creature_name() -> String {
86 let max = 8;
87 let val = random_0max(max);
88 let mut name:String = match val {
90 0 => String::from("Arc"),
91 1 => String::from("Molt"),
92 2 => String::from("Dynar"),
93 3 => String::from("Megas"),
94 4 => String::from("Gibor"),
95 5 => String::from("Dend"),
96 7 => String::from("Egal"),
97 8 => String::from("Bend"),
98 _=> String::from("Apt"), };
100 let val = random_0max(max);
102 let name_second:String = match val {
103 0 => String::from("ion"),
104 1 => String::from("acron"),
105 2 => String::from("os"),
106 3 => String::from("aya"),
107 4 => String::from("on"),
108 5 => String::from("ine"),
109 7 => String::from("aur"),8 => String::from("ate"),
111 _=> String::from("ay"),
112 };
113 name.push_str(name_second.as_str());
114 name
115}