Browse Source

send all the weapon bytes

pbs
Andy Newjack 5 years ago
parent
commit
a2dca1d5fe
  1. 24
      src/entity/item/weapon.rs

24
src/entity/item/weapon.rs

@ -3,6 +3,7 @@ use serde::{Serialize, Deserialize};
#[derive(Debug, Copy, Clone, PartialEq, Eq, Ord, PartialOrd)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Ord, PartialOrd)]
pub enum Attribute { pub enum Attribute {
None,
Native, Native,
ABeast, ABeast,
Machine, Machine,
@ -16,9 +17,16 @@ pub struct WeaponAttribute {
pub value: i8, pub value: i8,
} }
impl WeaponAttribute {
pub fn value(&self) -> [u8; 2] {
[self.attr as u8, self.value as u8]
}
}
#[derive(Debug, Copy, Clone, PartialEq)] #[derive(Debug, Copy, Clone, PartialEq)]
pub enum WeaponSpecial { pub enum WeaponSpecial {
None,
Draw, Draw,
Drain, Drain,
Fill, Fill,
@ -61,6 +69,12 @@ pub enum WeaponSpecial {
Demons, Demons,
} }
impl WeaponSpecial {
pub fn value(&self) -> u8 {
*self as u8
}
}
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, enum_utils::FromStr, derive_more::Display)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, enum_utils::FromStr, derive_more::Display)]
pub enum WeaponType { pub enum WeaponType {
Saber, Saber,
@ -879,7 +893,15 @@ impl Weapon {
let mut result = [0u8; 16]; let mut result = [0u8; 16];
result[0..3].copy_from_slice(&self.weapon.value()); result[0..3].copy_from_slice(&self.weapon.value());
result[3] = self.grind; result[3] = self.grind;
// TODO: percents
result[4] = self.special.unwrap().value();
if self.tekked == false {
result[4] += 0x80
};
result[6..8].copy_from_slice(&self.attrs[0].unwrap_or(WeaponAttribute{attr: Attribute::None, value: 0}).value());
result[8..10].copy_from_slice(&self.attrs[1].unwrap_or(WeaponAttribute{attr: Attribute::None, value: 0}).value());
result[10..12].copy_from_slice(&self.attrs[2].unwrap_or(WeaponAttribute{attr: Attribute::None, value: 0}).value());
result result
} }
} }

Loading…
Cancel
Save