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.rs65
1 files changed, 65 insertions, 0 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.,
+ },
+ }
+ }
+}