aboutsummaryrefslogtreecommitdiffstats
path: root/src/shared/champion.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared/champion.rs')
-rw-r--r--src/shared/champion.rs39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/shared/champion.rs b/src/shared/champion.rs
new file mode 100644
index 0000000..ec27c62
--- /dev/null
+++ b/src/shared/champion.rs
@@ -0,0 +1,39 @@
+use crate::shared::*;
+use std::str::FromStr;
+
+#[derive(Component, Message, Clone, Copy, Serialize, Deserialize, PartialEq, Debug)]
+pub enum Champion {
+ Meele,
+ Ranged,
+}
+
+impl Default for Champion {
+ fn default() -> Champion {
+ Champion::Meele
+ }
+}
+
+impl FromStr for Champion {
+ type Err = String;
+
+ fn from_str(s: &str) -> Result<Champion, String> {
+ match s {
+ "ranged" => Ok(Champion::Ranged),
+ "meele" => Ok(Champion::Meele),
+ _ => Err(format!("unknown champion: {}", s)),
+ }
+ }
+}
+
+pub struct Stats {
+ pub attack_range: f32,
+}
+
+impl Stats {
+ pub fn from_champion(champion: Champion) -> Self {
+ match champion {
+ Champion::Meele => Stats { attack_range: 25. },
+ Champion::Ranged => Stats { attack_range: 60. },
+ }
+ }
+}