use serde::{Deserialize, Serialize};

#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
pub struct TileData {
    letter: char,
    value: u8,
    count: u8,
}

impl TileData {
    pub fn letter(&self) -> char {
        self.letter
    }

    pub fn value(&self) -> u8 {
        self.value
    }

    pub fn count(&self) -> u8 {
        self.count
    }
}

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct BagData {
    tiles: Vec<TileData>,
}

impl BagData {
    pub fn load_from_json(json: &str) -> serde_json::Result<Self> {
        serde_json::from_str(json)
    }

    pub fn tiles(&self) -> &Vec<TileData> {
        &self.tiles
    }
}
