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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
/*!
# Effect
This composes the various Effects in-game related to a character's Stats
*/
use std::fmt;
use std::fmt::Debug;
extern crate num;
use serde::{Deserialize, Serialize};
#[cfg(feature = "fltkform")]
use fltk::{prelude::*, *};
#[cfg(feature = "fltkform")]
use fltk_form_derive::*;
#[cfg(feature = "fltkform")]
use fltk_form::FltkForm;
use crate::random::Random;
/*
# Basic
*/
#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize, Serialize)]
#[cfg_attr(feature = "fltkform", derive(FltkForm))]
pub enum Basic {
/// no effect aka a player or something else that should not have an effect, like a key
None,
/// add or remove HP based on the attack/item/special's HP
HP,
/// add or remove MP based on the attack/item/special's MP
MP,
/// add or remove XP. enemies all have this effect
XP,
/// add or remove GP.
GP,
}
impl Default for Basic {
fn default() -> Self {
Self::None
}
}
impl fmt::Display for Basic {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let v:String;
match *self {
Basic::HP => v = String::from("HP"),
Basic::MP => v = String::from("MP"),
Basic::GP => v = String::from("GP"),
Basic::XP => v = String::from("XP"),
Basic::None => v = String::from("None"),
}
write!(f, "{}", v.as_str())
}
}
impl Random for Basic {
type Type = Basic;
fn random_type(&self) -> Self::Type {
let max = 4;
let val = self.random_rate(max);
match val {
0 => Basic::HP,
1 => Basic::MP,
2 => Basic::XP,
3 => Basic::GP,
_=> Basic::None,
}
}
}
/*
# Normal
*/
#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize, Serialize)]
#[cfg_attr(feature = "fltkform", derive(FltkForm))]
pub enum Normal {
/// no effect aka a player or something else that should not have an effect, like a key
None,
/// add or remove HP based on the attack/item/special's HP
HP,
/// add or remove MP based on the attack/item/special's MP
MP,
/// add or remove XP. enemies all have this effect
XP,
/// add or remove GP.
GP,
/// # These next five continously drain HP/MP until remedy, or duration runs out
/// hp drain
Burn,
/// hp drain, very minor mp drain
Poison,
/// minor hp drain, very minor mp drain, no movement
Freeze,
/// hp drain, minor mp drain
Sick,
/// mp drain
Sap,
/// # These next two continuously add HP/MP
/// mp add
Bless,
/// hp add
Heal,
/// # Blocker/locker effects
/// no movement
Stuck,
/// no attack
Bound,
/// no mana attack
Blocked,
/// a lock to prevent access
Locked,
}
impl Default for Normal {
fn default() -> Self {
Self::None
}
}
impl fmt::Display for Normal {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let v:String;
match *self {
Normal::None => v = "None".to_string(),
Normal::HP => v = "HP".to_string(),
Normal::MP => v = "MP".to_string(),
Normal::XP => v = "XP".to_string(),
Normal::GP => v = String::from("GP"),
Normal::Burn => v = "Burn".to_string(),
Normal::Poison => v = "Poison".to_string(),
Normal::Freeze => v = "Freeze".to_string(),
Normal::Sick => v = "Sick".to_string(),
Normal::Sap => v = "Sap".to_string(),
Normal::Bless => v = "Bless".to_string(),
Normal::Heal => v = "Heal".to_string(),
Normal::Stuck => v = "Stuck".to_string(),
Normal::Bound => v = "Bound".to_string(),
Normal::Blocked => v = "Blocked".to_string(),
Normal::Locked => v = "Locked".to_string(),
}
write!(f, "{}", v.as_str())
}
}
impl Random for Normal {
type Type = Normal;
fn random_type(&self) -> Self::Type {
let max = 15;
let val = self.random_rate(max);
match val {
0 => Normal::HP,
1 => Normal::MP,
2 => Normal::XP,
3 => Normal::GP,
4 => Normal::Burn,
5 => Normal::Poison,
7 => Normal::Freeze,
8 => Normal::Sick,
9 => Normal::Sap,
10 => Normal::Bless,
11 => Normal::Heal,
12 => Normal::Stuck,
13 => Normal::Bound,
14 => Normal::Blocked,
15 => Normal::Locked,
_=> Normal::None,
}
}
}
/*
# Advanced
*/
//TODO more effects
#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize, Serialize)]
#[cfg_attr(feature = "fltkform", derive(FltkForm))]
pub enum Advanced {
/// no effect aka a player or something else that should not have an effect, like a key
None,
/// add or remove HP based on the attack/item/special's HP
HP,
/// add or remove MP based on the attack/item/special's MP
MP,
/// add or remove XP. enemies all have this effect
XP,
/// add or remove GP.
GP,
/// # These next five continously drain HP/MP until remedy, or duration runs out
/// hp drain
Burn,
/// hp drain, very minor mp drain
Poison,
/// minor hp drain, very minor mp drain, no movement
Freeze,
/// hp drain, minor mp drain
Sick,
/// mp drain
Sap,
/// # These next two continuously add HP/MP
/// mp add
Bless,
/// hp add
Heal,
/// # Blocker/locker effects
/// no movement
Stuck,
/// no attack
Bound,
/// no mana attack
Blocked,
/// a lock to prevent access
Locked,
}
impl Default for Advanced {
fn default() -> Self {
Self::None
}
}
impl fmt::Display for Advanced {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let v:String;
match *self {
Advanced::None => v = "None".to_string(),
Advanced::HP => v = "HP".to_string(),
Advanced::MP => v = "MP".to_string(),
Advanced::XP => v = "XP".to_string(),
Advanced::GP => v = String::from("GP"),
Advanced::Burn => v = "Burn".to_string(),
Advanced::Poison => v = "Poison".to_string(),
Advanced::Freeze => v = "Freeze".to_string(),
Advanced::Sick => v = "Sick".to_string(),
Advanced::Sap => v = "Sap".to_string(),
Advanced::Bless => v = "Bless".to_string(),
Advanced::Heal => v = "Heal".to_string(),
Advanced::Stuck => v = "Stuck".to_string(),
Advanced::Bound => v = "Bound".to_string(),
Advanced::Blocked => v = "Blocked".to_string(),
Advanced::Locked => v = "Locked".to_string(),
}
write!(f, "{}", v.as_str())
}
}