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
130
131
132
133
134
135
136
use crate::body::Body;
use crate::utils::{GameTimeC, ClothesGroupC};
impl Body {
/// Is player sleeping now
///
/// # Examples
/// ```
/// let value = person.body.is_sleeping();
/// ```
///
/// # Links
/// See [this wiki article](https://github.com/vagrod/zara-rust/wiki/Sleeping) for more info.
pub fn is_sleeping(&self) -> bool { self.is_sleeping.get() }
/// Cached warmth level value
///
/// # Examples
/// ```
/// let value = person.body.warmth_level();
/// ```
///
/// # Links
/// See [this wiki article](https://github.com/vagrod/zara-rust/wiki/Warmth-level) for more info.
pub fn warmth_level(&self) -> f32 { self.warmth_level.get() }
/// Cached wetness level value
///
/// # Examples
/// ```
/// let value = person.body.wetness_level();
/// ```
///
/// # Links
/// See [this wiki article](https://github.com/vagrod/zara-rust/wiki/Wetness-level) for more info.
pub fn wetness_level(&self) -> f32 { self.wetness_level.get() }
/// Last time slept (if any)
///
/// # Examples
/// ```
/// if let Some(sleep_time) = person.body.last_sleep_time() {
/// // ...
/// }
/// ```
///
/// # Links
/// See [this wiki article](https://github.com/vagrod/zara-rust/wiki/Sleeping) for more info.
pub fn last_sleep_time(&self) -> Option<GameTimeC> {
match self.last_sleep_time.borrow().as_ref()
{
Some(t) => Some(t.clone()),
_ => None
}
}
/// Duration of the last sleep (game hours)
///
/// # Examples
/// ```
/// let value = person.body.last_sleep_duration();
/// ```
///
/// # Links
/// See [this wiki article](https://github.com/vagrod/zara-rust/wiki/Sleeping) for more info.
pub fn last_sleep_duration(&self) -> f32 { self.last_sleep_duration.get() }
/// Returns copy of matched clothes group description contract.
///
/// # Examples
/// ```
/// if let Some(group) = person.body.clothes_group() {
/// // ...
/// }
/// ```
///
/// # Links
/// See [this wiki article](https://github.com/vagrod/zara-rust/wiki/Clothes-groups) for more info.
pub fn clothes_group(&self) -> Option<ClothesGroupC> {
self.clothes_group.borrow().clone()
}
/// Returns total 0..100 bonus cold resistance value calculated as a sum of all active clothes
/// cold resistance values plus cold resistance bonus from a matched clothes group, if any.
///
/// # Examples
/// ```
/// let value = person.body.total_cold_resistance();
/// ```
///
/// # Links
/// See [this wiki article](https://github.com/vagrod/zara-rust/wiki/Clothes#get-the-total-resistance-levels) for more info.
///
/// ## Notes
/// This value is not cached.
pub fn total_cold_resistance(&self) -> usize {
let mut result = 0;
for (_, data) in self.clothes_data.borrow().iter() {
result += data.cold_resistance;
}
if let Some(g) = self.clothes_group.borrow().as_ref() {
result += g.bonus_cold_resistance;
}
result
}
/// Returns total 0..100 bonus water resistance value calculated as a sum of all active clothes
/// water resistance values plus water resistance bonus from a matched clothes group, if any
///
/// # Examples
/// ```
/// let value = person.body.total_water_resistance();
/// ```
///
/// # Links
/// See [this wiki article](https://github.com/vagrod/zara-rust/wiki/Clothes#get-the-total-resistance-levels) for more info.
///
/// ## Notes
/// This value is not cached.
pub fn total_water_resistance(&self) -> usize {
let mut result = 0;
for (_, data) in self.clothes_data.borrow().iter() {
result += data.water_resistance;
}
if let Some(g) = self.clothes_group.borrow().as_ref() {
result += g.bonus_water_resistance;
}
result
}
}