Merge pull request 'weapon_bytes' (#102) from weapon_bytes into master
Reviewed-by: jake <jake@sharnoth.com>
This commit is contained in:
commit
b92b118fc4
@ -3,7 +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 {
|
||||||
Native,
|
Native = 1,
|
||||||
ABeast,
|
ABeast,
|
||||||
Machine,
|
Machine,
|
||||||
Dark,
|
Dark,
|
||||||
@ -16,10 +16,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 {
|
||||||
Draw,
|
Draw = 1,
|
||||||
Drain,
|
Drain,
|
||||||
Fill,
|
Fill,
|
||||||
Gush,
|
Gush,
|
||||||
@ -61,6 +67,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 +891,16 @@ 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.map(|s| s.value()).unwrap_or(0);
|
||||||
|
|
||||||
|
if self.tekked == false {
|
||||||
|
result[4] += 0x80
|
||||||
|
};
|
||||||
|
|
||||||
|
result[6..8].copy_from_slice(&self.attrs[0].map(|s| s.value()).unwrap_or([0,0]));
|
||||||
|
result[8..10].copy_from_slice(&self.attrs[1].map(|s| s.value()).unwrap_or([0,0]));
|
||||||
|
result[10..12].copy_from_slice(&self.attrs[2].map(|s| s.value()).unwrap_or([0,0]));
|
||||||
|
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -87,8 +87,10 @@ fn main() {
|
|||||||
item::weapon::Weapon {
|
item::weapon::Weapon {
|
||||||
weapon: item::weapon::WeaponType::Handgun,
|
weapon: item::weapon::WeaponType::Handgun,
|
||||||
grind: 5,
|
grind: 5,
|
||||||
special: None,
|
special: Some(item::weapon::WeaponSpecial::Hell),
|
||||||
attrs: [None; 3],
|
attrs: [Some(item::weapon::WeaponAttribute{attr: item::weapon::Attribute::Hit, value: 100}),
|
||||||
|
None,
|
||||||
|
None,],
|
||||||
tekked: true,
|
tekked: true,
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user