red-life icon indicating copy to clipboard operation
red-life copied to clipboard

Replace Item name with ItemType

Open Eraden opened this issue 2 years ago • 0 comments

There's limited amount of items and they can be identified with enum, name can be retrieved when needed

This should also reduce code noise.

I suggest to create solution similar to Machine solution:

#[derive(Debug, Copy, Clone, serde::Serialize, serde::Deserialize)]
pub enum ItemType {
    SuperGlue = 0,
    Petrol = 1,
    // ...
}

impl ItemType {
    pub fn t(self, lng: Lang) -> 'static str {
        item_names(lng)[self as usize]
    }
}

Eraden avatar Jan 01 '23 20:01 Eraden