diff options
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/ability.rs | 65 | ||||
-rw-r--r-- | src/shared/champion.rs | 16 | ||||
-rw-r--r-- | src/shared/imperative.rs | 5 |
3 files changed, 84 insertions, 2 deletions
diff --git a/src/shared/ability.rs b/src/shared/ability.rs new file mode 100644 index 0000000..8ef0c29 --- /dev/null +++ b/src/shared/ability.rs @@ -0,0 +1,65 @@ +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., + }, + } + } +} diff --git a/src/shared/champion.rs b/src/shared/champion.rs index ec27c62..8de12a5 100644 --- a/src/shared/champion.rs +++ b/src/shared/champion.rs @@ -1,3 +1,4 @@ +use crate::shared::ability::*; use crate::shared::*; use std::str::FromStr; @@ -37,3 +38,18 @@ impl Stats { } } } + +impl Champion { + pub fn to_ability(self, attack_key: AttackKey) -> Ability { + match self { + Champion::Meele => match attack_key { + AttackKey::Q => Ability::Directional(DirectionalAbility::Spear), + _ => Ability::Targeted(TargetedAbility::MeeleAttack), + }, + Champion::Ranged => match attack_key { + AttackKey::Q => Ability::Directional(DirectionalAbility::Spear), + _ => Ability::Targeted(TargetedAbility::RangedAttack), + }, + } + } +} diff --git a/src/shared/imperative.rs b/src/shared/imperative.rs index 61a4762..886355f 100644 --- a/src/shared/imperative.rs +++ b/src/shared/imperative.rs @@ -1,3 +1,4 @@ +use crate::shared::ability::*; use crate::shared::*; use serde::Deserialize; use serde::Serialize; @@ -6,8 +7,8 @@ use serde::Serialize; pub enum Imperative { Idle, WalkTo(Vec2), - AttackTarget(AttackKey, PlayerId), - AttackDirection(AttackKey, Vec2), + AttackTarget(TargetedAbility, PlayerId), + AttackDirection(DirectionalAbility, Vec2), } #[derive(Resource, Copy, Clone, PartialEq, Debug, Deserialize, Serialize)] |