send all the weapon bytes

This commit is contained in:
Andy Newjack 2020-04-08 19:41:12 -03:00
parent 806aab7d21
commit a2dca1d5fe

View File

@ -3,6 +3,7 @@ use serde::{Serialize, Deserialize};
#[derive(Debug, Copy, Clone, PartialEq, Eq, Ord, PartialOrd)]
pub enum Attribute {
None,
Native,
ABeast,
Machine,
@ -16,9 +17,16 @@ pub struct WeaponAttribute {
pub value: i8,
}
impl WeaponAttribute {
pub fn value(&self) -> [u8; 2] {
[self.attr as u8, self.value as u8]
}
}
#[derive(Debug, Copy, Clone, PartialEq)]
pub enum WeaponSpecial {
None,
Draw,
Drain,
Fill,
@ -61,6 +69,12 @@ pub enum WeaponSpecial {
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)]
pub enum WeaponType {
Saber,
@ -879,7 +893,15 @@ impl Weapon {
let mut result = [0u8; 16];
result[0..3].copy_from_slice(&self.weapon.value());
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
}
}