use crate::shared::ability::*; use crate::shared::shape::*; use crate::shared::stats::*; use crate::shared::*; use bevy::utils::*; use std::str::FromStr; #[derive(Component, Message, Clone, Copy, Serialize, Deserialize, PartialEq, Debug)] pub enum Champion { Meele, Ranged, Tower, Minion, Nexus, } 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), "tower" => Ok(Champion::Tower), "minion" => Ok(Champion::Minion), "nexus" => Ok(Champion::Nexus), _ => Err(format!("unknown champion: {}", s)), } } } impl Champion { pub fn base_stats(self) -> BaseStats { match self { Champion::Meele => BaseStats(Stats { attack_range: Shape::player().radius, attack_speed: 0.75, max_health: 150., movement_speed: 75., }), Champion::Ranged => BaseStats(Stats { attack_range: 50., attack_speed: 1.5, max_health: 100., movement_speed: 85., }), Champion::Tower => BaseStats(Stats { attack_range: 100., attack_speed: 4.5, max_health: 500., movement_speed: 0., }), Champion::Minion => BaseStats(Stats { attack_range: 30., attack_speed: 1., max_health: 50., movement_speed: 60., }), Champion::Nexus => BaseStats(Stats { attack_range: 0., attack_speed: 0., max_health: 2000., movement_speed: 0., }), } } pub fn ability(self, ability_slot: AbilitySlot) -> Ability { match self { Champion::Meele => match ability_slot { AbilitySlot::Q => Ability::Activated(ActivatedAbility::Shield(Shield { blocked_damage: 35., duration: 2., })), AbilitySlot::W => Ability::Directional(DirectionalAbility::Dash(Dash { max_distance: 60., damage: 15., })), AbilitySlot::E => Ability::Directional(DirectionalAbility::Pull(Pull { max_distance: 60., damage: 10., })), AbilitySlot::R => { Ability::Targeted(TargetedAbility::MeeleAttack(MeeleAttack { damage: 45. })) } AbilitySlot::F => { Ability::Directional(DirectionalAbility::Flash(Flash { max_distance: 100. })) } AbilitySlot::G => { Ability::Activated(ActivatedAbility::Speed(Speed { duration: 2.5 })) } _ => Ability::Targeted(TargetedAbility::MeeleAttack(MeeleAttack { damage: 5. })), }, Champion::Ranged => match ability_slot { AbilitySlot::E => Ability::Directional(DirectionalAbility::Spear(Spear { max_distance: 250., damage: 25., })), AbilitySlot::R => { Ability::Activated(ActivatedAbility::Focus(Focus { duration: 5. })) } AbilitySlot::F => { Ability::Directional(DirectionalAbility::Flash(Flash { max_distance: 100. })) } AbilitySlot::G => { Ability::Activated(ActivatedAbility::Speed(Speed { duration: 2.5 })) } _ => Ability::Targeted(TargetedAbility::RangedAttack(RangedAttack { damage: 8. })), }, Champion::Tower => match ability_slot { _ => { Ability::Targeted(TargetedAbility::RangedAttack(RangedAttack { damage: 100. })) } }, Champion::Minion => match ability_slot { _ => Ability::Targeted(TargetedAbility::RangedAttack(RangedAttack { damage: 2. })), }, Champion::Nexus => match ability_slot { _ => Ability::Targeted(TargetedAbility::MeeleAttack(MeeleAttack { damage: 0. })), }, } } pub fn base_cooldown(self) -> BaseCooldown { match self { Champion::Meele => { BaseCooldown([0., 5., 5., 10., 25., 50., 50.].map(Duration::from_secs_f32)) } Champion::Ranged => { BaseCooldown([0., 10., 10., 15., 35., 50., 50.].map(Duration::from_secs_f32)) } Champion::Tower => { BaseCooldown([10., 10., 10., 10., 10., 10., 10.].map(Duration::from_secs_f32)) } Champion::Minion => { BaseCooldown([1., 1., 1., 1., 1., 1., 1.].map(Duration::from_secs_f32)) } Champion::Nexus => { BaseCooldown([0., 0., 0., 0., 0., 0., 0.].map(Duration::from_secs_f32)) } } } }