Add damage calculation
This commit is contained in:
parent
fade27c74f
commit
b6eeca37f3
1 changed files with 21 additions and 1 deletions
|
@ -8,9 +8,14 @@ use std::{
|
|||
str::FromStr,
|
||||
};
|
||||
|
||||
use crate::items::{ability_addon::AbilityAddonTypes, ability_book::AbilityBook, Rarities};
|
||||
use crate::{components::inventory::Storable, items::ItemSystem};
|
||||
use crate::{config::save_game::SaveGame, items::ability_book::Ability};
|
||||
use crate::{
|
||||
damage_type::DamageType,
|
||||
items::{ability_addon::AbilityAddonTypes, ability_book::AbilityBook, Rarities},
|
||||
};
|
||||
|
||||
use super::{character_status::CharacterStatus, statistics::Statistics};
|
||||
|
||||
macro_rules! load {
|
||||
($me: ident, $item_system:ident, $save_game:ident, $($index:literal,)+) => {
|
||||
|
@ -134,6 +139,21 @@ impl<A: Ability> AbilitySlots<A> {
|
|||
pub fn iter_mut(&mut self) -> IterMut<'_, Option<AbilityBook<A>>> {
|
||||
self.abilities.iter_mut()
|
||||
}
|
||||
|
||||
pub fn apply_damage(
|
||||
base_damage: u32,
|
||||
damage_type: DamageType,
|
||||
enemy_statistics: &Statistics,
|
||||
enemy_status: &mut CharacterStatus,
|
||||
) {
|
||||
let resistance = enemy_statistics.calculate_resistance(damage_type);
|
||||
|
||||
if resistance < base_damage {
|
||||
let damage = base_damage - resistance;
|
||||
|
||||
enemy_status.apply_damage(damage as f32);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<A: Ability + 'static> EntityComponent for AbilitySlots<A> {
|
||||
|
|
Loading…
Reference in a new issue