use proto::{Resource, ResourceItemBin};

pub struct ResourceItem {
    pub template_id: u32,
    pub num: i32,
}

impl ResourceItem {
    pub fn from_bin(bin: ResourceItemBin) -> Self {
        Self {
            template_id: bin.template_id,
            num: bin.num,
        }
    }

    pub fn to_bin(&self) -> ResourceItemBin {
        ResourceItemBin {
            template_id: self.template_id,
            num: self.num,
        }
    }

    pub fn to_client(&self) -> Resource {
        Resource {
            template_id: self.template_id,
            num: self.num,
        }
    }
}
