use serde::{Serialize, Deserialize}; #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize, enum_utils::FromStr, derive_more::Display, strum_macros::EnumIter)] pub enum Technique { Foie, Gifoie, Rafoie, Zonde, Gizonde, Razonde, Barta, Gibarta, Rabarta, Grants, Deband, Jellen, Zalure, Shifta, Ryuker, Resta, Anti, Reverser, Megid, } impl Technique { pub fn as_value(&self) -> u8 { match self { Technique::Foie => 0, Technique::Gifoie => 1, Technique::Rafoie => 2, Technique::Barta => 3, Technique::Gibarta => 4, Technique::Rabarta => 5, Technique::Zonde => 6, Technique::Gizonde => 7, Technique::Razonde => 8, Technique::Grants => 9, Technique::Deband => 10, Technique::Jellen => 11, Technique::Zalure => 12, Technique::Shifta => 13, Technique::Ryuker => 14, Technique::Resta => 15, Technique::Anti => 16, Technique::Reverser => 17, Technique::Megid => 18, } } pub fn from_value(value: u8) -> Technique { match value { 0 => Technique::Foie, 1 => Technique::Gifoie, 2 => Technique::Rafoie, 3 => Technique::Barta, 4 => Technique::Gibarta, 5 => Technique::Rabarta, 6 => Technique::Zonde, 7 => Technique::Gizonde, 8 => Technique::Razonde, 9 => Technique::Grants, 10 => Technique::Deband, 11 => Technique::Jellen, 12 => Technique::Zalure, 13 => Technique::Shifta, 14 => Technique::Ryuker, 15 => Technique::Resta, 16 => Technique::Anti, 17 => Technique::Reverser, 18 => Technique::Megid, _ => panic!() } } } #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] pub struct TechniqueDisk { pub tech: Technique, pub level: u32, } impl TechniqueDisk { pub fn as_bytes(&self) -> [u8; 16] { let mut result = [0; 16]; result[0] = 3; result[1] = 2; result[2] = self.level as u8 - 1; result[4] = self.tech.as_value(); result } }