use crate::shared::projectile::*; use crate::shared::*; #[derive(Copy, Clone, PartialEq, Debug, Deserialize, Serialize)] pub enum Ability { Targeted(TargetedAbility), Directional(DirectionalAbility), } #[derive(Copy, Clone, PartialEq, Debug, Deserialize, Serialize)] pub enum TargetedAbility { MeeleAttack, RangedAttack, } impl TargetedAbility { pub fn to_projectile( self, source_player: PlayerId, position: Vec2, target_player: PlayerId, ) -> Projectile { match self { TargetedAbility::MeeleAttack => Projectile { type_: ProjectileType::Targeted(TargetedProjectile { target_player, position, }), source_player, damage: 5., }, TargetedAbility::RangedAttack => Projectile { type_: ProjectileType::Instant(InstantProjectile { target_player }), source_player, damage: 6., }, } } } #[derive(Copy, Clone, PartialEq, Debug, Deserialize, Serialize)] pub enum DirectionalAbility { Spear, } impl DirectionalAbility { pub fn to_projectile( self, source_player: PlayerId, position: Vec2, direction: Vec2, ) -> Projectile { match self { DirectionalAbility::Spear => Projectile { type_: ProjectileType::Free(FreeProjectile { position, direction, starting_position: position, }), source_player, damage: 15., }, } } }