td

damage.rs at trunk
Login

damage.rs at trunk

File src/behavior/damage.rs artifact 836c452627 on branch trunk


use crate::enemy::Enemy;

pub struct Damage {}
impl Damage {
    pub const PHYSICAL: i32 = 0;
    pub const ACID: i32 = 1;
}

/// A damage type's magnitude rule: "how much damage does this deal against *this* target".
/// Deliberately a pure function of `(base, target)` — no `Command` access, no `&mut self`
/// state, no knowledge of the projectile or status system. That constraint is what keeps
/// damage types a leaf in the behavior graph instead of another nesting point: a damage type
/// can never trigger another behavior, it can only answer "how much".
pub trait DamageBehavior: Send + Sync {
    fn compute(&self, base: f32, target: &Enemy) -> f32;
}

#[derive(Clone)]
pub struct Physical;
impl DamageBehavior for Physical {
    fn compute(&self, base: f32, _target: &Enemy) -> f32 {
        base
    }
}

#[derive(Clone)]
pub struct Acid;
impl DamageBehavior for Acid {
    fn compute(&self, base: f32, _target: &Enemy) -> f32 {
        base
    }
}

#[derive(Clone)]
pub struct Poison;
impl DamageBehavior for Poison {
    fn compute(&self, base: f32, _target: &Enemy) -> f32 {
        base
    }
}