// Copyright (C) 2025 Christian Mauduit <ufoot@ufoot.org>

#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
use uuid::Uuid;

#[derive(Debug, Clone)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Fighter {
    pub x: f32,
    pub y: f32,
    pub z: f32,
    pub health: f32,
    pub team_id: Uuid,
}

impl Fighter {
    pub fn new(team_id: Uuid, x: f32, y: f32, z: f32, health: f32) -> Self {
        Self {
            x,
            y,
            z,
            health: health.clamp(0.0, 1.0),
            team_id,
        }
    }

    pub fn position(&self) -> (f32, f32, f32) {
        (self.x, self.y, self.z)
    }

    pub fn is_alive(&self) -> bool {
        self.health > 0.0
    }
}
