use crate::shared::ability::*; 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 { match s { "ranged" => Ok(Champion::Ranged), "meele" => Ok(Champion::Meele), _ => Err(format!("unknown champion: {}", s)), } } } impl Champion { pub fn to_ability(self, ability_slot: AbilitySlot) -> Ability { match self { Champion::Meele => match ability_slot { AbilitySlot::Q => Ability::Directional(DirectionalAbility::Spear), AbilitySlot::G => Ability::Activated(ActivatedAbility::Speed), _ => Ability::Targeted(TargetedAbility::MeeleAttack), }, Champion::Ranged => match ability_slot { AbilitySlot::Q => Ability::Directional(DirectionalAbility::Spear), AbilitySlot::G => Ability::Activated(ActivatedAbility::Speed), _ => Ability::Targeted(TargetedAbility::RangedAttack), }, } } }