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
use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize)]
pub struct Run {
game_title: String,
category: String,
offset: Option<u128>,
pb: u128,
splits: Vec<String>,
pb_times: Vec<u128>,
gold_times: Vec<u128>,
sum_times: Vec<(u128, u128)>,
}
impl Run {
pub fn empty() -> Self {
Run {
game_title: "".to_owned(),
category: "".to_owned(),
offset: None,
pb: 0,
splits: vec![],
pb_times: vec![],
gold_times: vec![],
sum_times: vec![],
}
}
pub fn new<S>(
game_title: S,
category: S,
offset: Option<u128>,
pb: u128,
splits: &Vec<String>,
pb_times: &Vec<u128>,
gold_times: &Vec<u128>,
sum_times: &Vec<(u128, u128)>,
) -> Self
where
S: ToString,
{
Run {
game_title: game_title.to_string(),
category: category.to_string(),
offset,
pb,
splits: splits.to_owned(),
pb_times: pb_times.to_owned(),
gold_times: gold_times.to_owned(),
sum_times: sum_times.to_owned(),
}
}
pub fn game_title(&self) -> &str {
&self.game_title
}
pub fn category(&self) -> &str {
&self.category
}
pub fn offset(&self) -> Option<u128> {
self.offset
}
pub fn pb(&self) -> u128 {
self.pb
}
pub fn splits(&self) -> &Vec<String> {
&self.splits
}
pub fn pb_times(&self) -> &Vec<u128> {
&self.pb_times
}
pub fn gold_times(&self) -> &Vec<u128> {
&self.gold_times
}
pub fn sum_times(&self) -> &Vec<(u128, u128)> {
&self.sum_times
}
pub fn set_game_title<S>(&mut self, new: S)
where
S: ToString,
{
self.game_title = new.to_string();
}
pub fn set_category<S>(&mut self, new: S)
where
S: ToString,
{
self.category = new.to_string();
}
pub fn set_offset(&mut self, new: Option<u128>) {
self.offset = new;
}
pub fn set_pb(&mut self, new: u128) {
self.pb = new;
}
pub fn set_splits(&mut self, new: &Vec<String>) {
self.splits = new.to_owned();
}
pub fn set_pb_times(&mut self, new: &Vec<u128>) {
self.pb_times = new.to_owned();
}
pub fn set_gold_times(&mut self, new: &Vec<u128>) {
self.gold_times = new.to_owned();
}
pub fn set_gold_time(&mut self, new: u128, idx: usize) {
self.gold_times[idx] = new;
}
pub fn set_sum_times(&mut self, new: &Vec<(u128, u128)>) {
self.sum_times = new.to_owned();
}
}