use cryp::{Stat}; #[derive(Debug,Copy,Clone,Serialize,Deserialize)] pub enum SpecLevel { Common, Uncommon, Rare, } #[derive(Debug,Copy,Clone,Serialize,Deserialize)] pub struct Spec { pub affects: Stat, pub spec: SpecType, pub level: SpecLevel, } impl Spec { pub fn new(spec_type: SpecType) -> Spec { Spec { affects: spec_type.affects(), level: spec_type.level(), spec: spec_type, } } pub fn apply(&self, modified: u64, base: u64) -> u64 { match self.spec { SpecType::RedDamage5 => modified + (base * 5 / 100), SpecType::BlueDamage5 => modified + (base * 5 / 100), } } } #[derive(Debug,Copy,Clone,Serialize,Deserialize,PartialEq)] pub enum SpecType { RedDamage5, BlueDamage5, } impl SpecType { fn affects(&self) -> Stat { match *self { SpecType::RedDamage5 => Stat::RedDamage, SpecType::BlueDamage5 => Stat::BlueDamage, } } fn level(&self) -> SpecLevel { match *self { SpecType::RedDamage5 => SpecLevel::Common, SpecType::BlueDamage5 => SpecLevel::Common, } } }