wotw_seedgen 0.2.1

Seed Generator for the Ori and the Will of the Wisps Randomizer
use std::fmt;

use num_enum::TryFromPrimitive;
use wotw_seedgen_derive::FromStr;

use crate::util::{Icon, MapIcon};

#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy, TryFromPrimitive, FromStr)]
#[repr(u8)]
pub enum Resource {
    Health = 0,
    Energy = 1,
    Ore = 2,
    Keystone = 3,
    ShardSlot = 4,
}
impl fmt::Display for Resource {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        match self {
            Resource::Health => write!(f, "Health Fragment"),
            Resource::Energy => write!(f, "Energy Fragment"),
            Resource::Ore => write!(f, "Gorlek Ore"),
            Resource::Keystone => write!(f, "Keystone"),
            Resource::ShardSlot => write!(f, "Shard Slot"),
        }
    }
}
impl Resource {
    pub fn icon(self) -> Option<Icon> {
        Some(match self {
            Resource::Health => Icon::File(String::from("assets/icons/game/healthfragment.png")),
            Resource::Energy => Icon::File(String::from("assets/icons/game/energyfragment.png")),
            Resource::Ore => Icon::File(String::from("assets/icons/game/gorlekore.png")),
            Resource::Keystone => Icon::File(String::from("assets/icons/game/keystone.png")),
            Resource::ShardSlot => Icon::File(String::from("assets/icons/game/shardslot.png")),
        })
    }
    pub fn map_icon(&self) -> MapIcon {
        match self {
            Resource::Health => MapIcon::Health,
            Resource::Energy => MapIcon::Energy,
            Resource::Ore => MapIcon::Ore,
            Resource::Keystone => MapIcon::Keystone,
            Resource::ShardSlot => MapIcon::ShardSlot,
        }
    }
}