aboutsummaryrefslogtreecommitdiffstats
path: root/src/shared/ability.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared/ability.rs')
-rw-r--r--src/shared/ability.rs53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/shared/ability.rs b/src/shared/ability.rs
index 9639afe..cab7ae6 100644
--- a/src/shared/ability.rs
+++ b/src/shared/ability.rs
@@ -1,6 +1,8 @@
use crate::shared::player::*;
use crate::shared::projectile::*;
use crate::shared::*;
+use bevy::utils::Duration;
+use std::ops::*;
#[derive(Copy, Clone, PartialEq, Debug, Deserialize, Serialize)]
pub enum Ability {
@@ -64,3 +66,54 @@ impl DirectionalAbility {
}
}
}
+
+#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq)]
+pub enum AbilitySlot {
+ A,
+ Q,
+ W,
+ E,
+ R,
+ F,
+ G,
+}
+
+impl AbilitySlot {
+ pub fn to_label(self) -> &'static str {
+ match self {
+ AbilitySlot::A => "A",
+ AbilitySlot::Q => "Q",
+ AbilitySlot::W => "W",
+ AbilitySlot::E => "E",
+ AbilitySlot::R => "R",
+ AbilitySlot::F => "F",
+ AbilitySlot::G => "G",
+ }
+ }
+
+ pub fn all() -> Vec<Self> {
+ vec![
+ AbilitySlot::A,
+ AbilitySlot::Q,
+ AbilitySlot::W,
+ AbilitySlot::E,
+ AbilitySlot::R,
+ AbilitySlot::F,
+ AbilitySlot::G,
+ ]
+ }
+}
+
+impl Index<AbilitySlot> for [Duration; 7] {
+ type Output = Duration;
+
+ fn index(&self, ability_slot: AbilitySlot) -> &Self::Output {
+ &self[ability_slot as usize]
+ }
+}
+
+impl IndexMut<AbilitySlot> for [Duration; 7] {
+ fn index_mut(&mut self, ability_slot: AbilitySlot) -> &mut Self::Output {
+ &mut self[ability_slot as usize]
+ }
+}