aboutsummaryrefslogtreecommitdiffstats
path: root/src/server.rs
diff options
context:
space:
mode:
authorLibravatar Alexander Foremny <aforemny@posteo.de>2024-03-19 05:50:53 +0100
committerLibravatar Alexander Foremny <aforemny@posteo.de>2024-03-19 05:50:53 +0100
commite9dce64b009455163f2a262ed481c37300917c4a (patch)
treeca747f68d8e46e1de938ff3d54fe009249836cd4 /src/server.rs
parent6805c6db39c1a9409b39aaf601f78db92b684c0d (diff)
chore: tweak champions
Diffstat (limited to 'src/server.rs')
-rw-r--r--src/server.rs38
1 files changed, 17 insertions, 21 deletions
diff --git a/src/server.rs b/src/server.rs
index 8507244..b3c2a30 100644
--- a/src/server.rs
+++ b/src/server.rs
@@ -262,7 +262,7 @@ fn imperative_attack_attack(
};
match *imperative {
Imperative::AttackTarget(ability_slot, target_player) => {
- let Ability::Targeted(ability) = champion.to_ability(ability_slot) else {
+ let Ability::Targeted(ability) = champion.ability(ability_slot) else {
*imperative = Imperative::Idle;
continue;
};
@@ -282,7 +282,7 @@ fn imperative_attack_attack(
*imperative = Imperative::Idle;
continue;
};
- let base_cooldown = BaseCooldown::from_champion(*champion);
+ let base_cooldown = champion.base_cooldown();
if cooldown.0[ability_slot].is_zero() {
cooldown.0[ability_slot] = base_cooldown.0[ability_slot];
commands.spawn(ProjectileBundle::new(ability.to_projectile(
@@ -297,24 +297,20 @@ fn imperative_attack_attack(
}
}
Imperative::AttackDirection(ability_slot, direction) => {
- let Ability::Directional(ability) = champion.to_ability(ability_slot) else {
+ let Ability::Directional(ability) = champion.ability(ability_slot) else {
*imperative = Imperative::Idle;
continue;
};
- match ability.activate() {
- DirectionalAbilityActivation(run) => {
- let Ok(mut cooldown) = cooldowns.get_mut(*entity) else {
- *imperative = Imperative::Idle;
- continue;
- };
- let base_cooldown = BaseCooldown::from_champion(*champion);
- if cooldown.0[ability_slot].is_zero() {
- cooldown.0[ability_slot] = base_cooldown.0[ability_slot];
- run(&mut commands, *id, direction);
- }
- *imperative = Imperative::Idle;
- }
+ let Ok(mut cooldown) = cooldowns.get_mut(*entity) else {
+ *imperative = Imperative::Idle;
+ continue;
+ };
+ let base_cooldown = champion.base_cooldown();
+ if cooldown.0[ability_slot].is_zero() {
+ cooldown.0[ability_slot] = base_cooldown.0[ability_slot];
+ ability.activate()(&mut commands, *id, direction);
}
+ *imperative = Imperative::Idle;
}
_ => {}
}
@@ -340,7 +336,7 @@ fn activation(
*activation = Activation::None;
continue;
};
- let Ability::Activated(ability) = champion.to_ability(ability_slot) else {
+ let Ability::Activated(ability) = champion.ability(ability_slot) else {
*activation = Activation::None;
continue;
};
@@ -349,11 +345,11 @@ fn activation(
continue;
};
match ability {
- ActivatedAbility::Speed => {
- let base_cooldown = BaseCooldown::from_champion(*champion);
+ ActivatedAbility::Speed(Speed { duration }) => {
+ let base_cooldown = champion.base_cooldown();
if cooldown.0[ability_slot].is_zero() {
cooldown.0[ability_slot] = base_cooldown.0[ability_slot];
- buffs.speed = Some(Timer::from_seconds(2., TimerMode::Once));
+ buffs.speed = Some(Timer::from_seconds(duration, TimerMode::Once));
*activation = Activation::None;
}
}
@@ -524,7 +520,7 @@ fn effective_stats(
mut effective_statses: Query<(&Champion, &mut EffectiveStats, &Buffs, &mut Health)>,
) {
for (champion, mut effective_stats, buffs, mut health) in effective_statses.iter_mut() {
- let mut stats = BaseStats::from_champion(*champion).0;
+ let mut stats = champion.base_stats().0;
if buffs.slow.is_some() {
stats.movement_speed *= 0.85;
}