Browse Source

initial wrapping stuff

presents
andy 4 years ago
parent
commit
fe0f7ba41e
  1. 47
      src/entity/item/weapon.rs

47
src/entity/item/weapon.rs

@ -1454,6 +1454,44 @@ pub enum WeaponModifier {
},
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum WrappingPaper {
White_Pink, // 0
Yellow_Blue,
Black_Yellow,
LightBlue_Orange,
Pink_YellowGreen,
Red_Green,
Magenta,
Blue,
Yellow,
Vermillion,
Green,
}
impl WrappingPaper {
pub fn value(&self) -> u8 {
*self as u8
}
pub fn from(data: u8) -> Option<WrappingPaper> {
match data {
0 => Some(WrappingPaper::White_Pink),
1 => Some(WrappingPaper::Yellow_Blue),
2 => Some(WrappingPaper::Black_Yellow),
3 => Some(WrappingPaper::LightBlue_Orange),
4 => Some(WrappingPaper::Pink_YellowGreen),
5 => Some(WrappingPaper::Red_Green),
6 => Some(WrappingPaper::Magenta),
7 => Some(WrappingPaper::Blue),
8 => Some(WrappingPaper::Yellow),
9 => Some(WrappingPaper::Vermillion),
10 => Some(WrappingPaper::Green),
_ => None,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Weapon {
pub weapon: WeaponType,
@ -1461,6 +1499,8 @@ pub struct Weapon {
pub grind: u8,
pub attrs: [Option<WeaponAttribute>; 3],
pub tekked: bool,
pub modifiers: Vec<WeaponModifier>,
pub wrapped: Option<WrappingPaper>,
}
@ -1472,6 +1512,8 @@ impl Weapon {
grind: 0,
attrs: [None; 3],
tekked: true,
modifiers: Vec::new(),
wrapped: None,
}
}
@ -1525,6 +1567,11 @@ impl Weapon {
result[0..3].copy_from_slice(&self.weapon.value());
result[3] = self.grind;
result[4] = self.special.map(|s| s.value()).unwrap_or(0);
if self.wrapped.is_some() {
result[4] += 0x40;
result[5] = self.wrapped.unwrap().value();
};
if self.tekked == false {
result[4] += 0x80

Loading…
Cancel
Save