use serde::Deserialize;

use crate::tile_like::TileLike;

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Deserialize)]
pub struct TileTuple(pub u32, pub u32, pub u8);

impl TileTuple {
    #[must_use]
    pub const fn new(x: u32, y: u32, z: u8) -> Self {
        Self(x, y, z)
    }
}

impl From<(u32, u32, u8)> for TileTuple {
    fn from(xyz: (u32, u32, u8)) -> Self {
        Self(xyz.0, xyz.1, xyz.2)
    }
}

impl TileLike for TileTuple {
    fn x(&self) -> u32 {
        self.0
    }

    fn y(&self) -> u32 {
        self.1
    }

    fn z(&self) -> u8 {
        self.2
    }
}
