use cryp::{StatKind, Roll}; #[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)] pub enum Skill { Stoney, Evasive, } impl Skill { pub fn apply(&self, roll: Roll) -> Roll { match self { Skill::Stoney => stoney(self, roll), Skill::Evasive => evasive(self, roll), } } } fn stoney(_s: &Skill, mut roll: Roll) -> Roll { let effect = 0b11110000; match roll.kind { StatKind::Def => { // println!("{:064b} | <- {:?}", effect, s); roll.result = roll.result | effect; roll }, _ => roll, } } fn evasive(_s: &Skill, mut roll: Roll) -> Roll { match roll.kind { StatKind::Def => { if roll.result.is_power_of_two() { roll.result = u64::max_value() } roll }, _ => roll, } }