|
@ -1,11 +1,13 @@ |
|
|
// TODO: actually use this
|
|
|
// TODO: actually use this
|
|
|
pub enum SrankError {
|
|
|
|
|
|
InvalidSrankType,
|
|
|
|
|
|
InvalidSrankSpecial,
|
|
|
|
|
|
InvalidSrankName,
|
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
|
|
pub enum ESWeaponError {
|
|
|
|
|
|
InvalidESWeaponType,
|
|
|
|
|
|
InvalidESWeaponSpecial,
|
|
|
|
|
|
InvalidESWeaponName,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
pub enum SrankType {
|
|
|
|
|
|
|
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
|
|
|
|
|
pub enum ESWeaponType {
|
|
|
Saber = 0,
|
|
|
Saber = 0,
|
|
|
Sword,
|
|
|
Sword,
|
|
|
Blade,
|
|
|
Blade,
|
|
@ -38,49 +40,50 @@ pub enum SrankType { |
|
|
Axe,
|
|
|
Axe,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
impl SrankType {
|
|
|
|
|
|
|
|
|
impl ESWeaponType {
|
|
|
pub fn to_value(&self) -> u8 {
|
|
|
pub fn to_value(&self) -> u8 {
|
|
|
*self as u8
|
|
|
*self as u8
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
pub fn from_value(value: u8) -> Result<SrankType, SRankError> {
|
|
|
|
|
|
|
|
|
pub fn from_value(value: u8) -> Result<ESWeaponType, ESWeaponError> {
|
|
|
match value {
|
|
|
match value {
|
|
|
0 => Ok(SrankType::Saber),
|
|
|
|
|
|
1 => Ok(SrankType::Sword),
|
|
|
|
|
|
2 => Ok(SrankType::Blade),
|
|
|
|
|
|
3 => Ok(SrankType::Partisan),
|
|
|
|
|
|
4 => Ok(SrankType::Slicer),
|
|
|
|
|
|
5 => Ok(SrankType::Gun),
|
|
|
|
|
|
6 => Ok(SrankType::Rifle),
|
|
|
|
|
|
7 => Ok(SrankType::Mechgun),
|
|
|
|
|
|
8 => Ok(SrankType::Shot),
|
|
|
|
|
|
9 => Ok(SrankType::Can),
|
|
|
|
|
|
10 => Ok(SrankType::Rod),
|
|
|
|
|
|
11 => Ok(SrankType::Wand),
|
|
|
|
|
|
12 => Ok(SrankType::Twin),
|
|
|
|
|
|
13 => Ok(SrankType::Claw),
|
|
|
|
|
|
14 => Ok(SrankType::Bazooka),
|
|
|
|
|
|
15 => Ok(SrankType::Needle),
|
|
|
|
|
|
16 => Ok(SrankType::Scythe),
|
|
|
|
|
|
17 => Ok(SrankType::Hammer),
|
|
|
|
|
|
18 => Ok(SrankType::Moon),
|
|
|
|
|
|
19 => Ok(SrankType::Psychogun),
|
|
|
|
|
|
20 => Ok(SrankType::Punch),
|
|
|
|
|
|
21 => Ok(SrankType::Windmill),
|
|
|
|
|
|
22 => Ok(SrankType::Harisen),
|
|
|
|
|
|
23 => Ok(SrankType::Katana),
|
|
|
|
|
|
24 => Ok(SrankType::JCutter),
|
|
|
|
|
|
25 => Ok(SrankType::Swords),
|
|
|
|
|
|
26 => Ok(SrankType::Launcher),
|
|
|
|
|
|
27 => Ok(SrankType::Cards),
|
|
|
|
|
|
28 => Ok(SrankType::Knuckle),
|
|
|
|
|
|
29 => Ok(SrankType::Axe),
|
|
|
|
|
|
_ => Err(SrankError::InvalidSrankype),
|
|
|
|
|
|
|
|
|
0 => Ok(ESWeaponType::Saber),
|
|
|
|
|
|
1 => Ok(ESWeaponType::Sword),
|
|
|
|
|
|
2 => Ok(ESWeaponType::Blade),
|
|
|
|
|
|
3 => Ok(ESWeaponType::Partisan),
|
|
|
|
|
|
4 => Ok(ESWeaponType::Slicer),
|
|
|
|
|
|
5 => Ok(ESWeaponType::Gun),
|
|
|
|
|
|
6 => Ok(ESWeaponType::Rifle),
|
|
|
|
|
|
7 => Ok(ESWeaponType::Mechgun),
|
|
|
|
|
|
8 => Ok(ESWeaponType::Shot),
|
|
|
|
|
|
9 => Ok(ESWeaponType::Can),
|
|
|
|
|
|
10 => Ok(ESWeaponType::Rod),
|
|
|
|
|
|
11 => Ok(ESWeaponType::Wand),
|
|
|
|
|
|
12 => Ok(ESWeaponType::Twin),
|
|
|
|
|
|
13 => Ok(ESWeaponType::Claw),
|
|
|
|
|
|
14 => Ok(ESWeaponType::Bazooka),
|
|
|
|
|
|
15 => Ok(ESWeaponType::Needle),
|
|
|
|
|
|
16 => Ok(ESWeaponType::Scythe),
|
|
|
|
|
|
17 => Ok(ESWeaponType::Hammer),
|
|
|
|
|
|
18 => Ok(ESWeaponType::Moon),
|
|
|
|
|
|
19 => Ok(ESWeaponType::Psychogun),
|
|
|
|
|
|
20 => Ok(ESWeaponType::Punch),
|
|
|
|
|
|
21 => Ok(ESWeaponType::Windmill),
|
|
|
|
|
|
22 => Ok(ESWeaponType::Harisen),
|
|
|
|
|
|
23 => Ok(ESWeaponType::Katana),
|
|
|
|
|
|
24 => Ok(ESWeaponType::JCutter),
|
|
|
|
|
|
25 => Ok(ESWeaponType::Swords),
|
|
|
|
|
|
26 => Ok(ESWeaponType::Launcher),
|
|
|
|
|
|
27 => Ok(ESWeaponType::Cards),
|
|
|
|
|
|
28 => Ok(ESWeaponType::Knuckle),
|
|
|
|
|
|
29 => Ok(ESWeaponType::Axe),
|
|
|
|
|
|
_ => Err(ESWeaponError::InvalidESWeaponType),
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
pub enum SrankSpecial {
|
|
|
|
|
|
|
|
|
#[derive(Clone, Copy, Debug, PartialEq)]
|
|
|
|
|
|
pub enum ESWeaponSpecial {
|
|
|
Jellen = 0,
|
|
|
Jellen = 0,
|
|
|
Zalure,
|
|
|
Zalure,
|
|
|
HPRegen,
|
|
|
HPRegen,
|
|
@ -99,45 +102,46 @@ pub enum SrankSpecial { |
|
|
Kings,
|
|
|
Kings,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
impl SrankSpecial {
|
|
|
|
|
|
|
|
|
impl ESWeaponSpecial {
|
|
|
pub fn to_value(&self) -> u8 {
|
|
|
pub fn to_value(&self) -> u8 {
|
|
|
*self as u8
|
|
|
*self as u8
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
pub fn from_value(value: u8) -> Result<SrankSpecial, SrankError> {
|
|
|
|
|
|
|
|
|
pub fn from_value(value: u8) -> Result<ESWeaponSpecial, ESWeaponError> {
|
|
|
match value{
|
|
|
match value{
|
|
|
0 => Ok(SrankSpecial::Jellen),
|
|
|
|
|
|
1 => Ok(SrankSpecial::Zalure),
|
|
|
|
|
|
2 => Ok(SrankSpecial::HPRegen),
|
|
|
|
|
|
3 => Ok(SrankSpecial::TPRegen),
|
|
|
|
|
|
4 => Ok(SrankSpecial::Burning),
|
|
|
|
|
|
5 => Ok(SrankSpecial::Tempest),
|
|
|
|
|
|
6 => Ok(SrankSpecial::Blizzard),
|
|
|
|
|
|
7 => Ok(SrankSpecial::Arrest),
|
|
|
|
|
|
8 => Ok(SrankSpecial::Chaos),
|
|
|
|
|
|
9 => Ok(SrankSpecial::Hell),
|
|
|
|
|
|
10 => Ok(SrankSpecial::Spirit),
|
|
|
|
|
|
11 => Ok(SrankSpecial::Berserk),
|
|
|
|
|
|
12 => Ok(SrankSpecial::Demons),
|
|
|
|
|
|
13 => Ok(SrankSpecial::Gush),
|
|
|
|
|
|
14 => Ok(SrankSpecial::Geist),
|
|
|
|
|
|
15 => Ok(SrankSpecial::Kings),
|
|
|
|
|
|
_ => Err(SrankError::InvalidSrankSpecial),
|
|
|
|
|
|
|
|
|
0 => Ok(ESWeaponSpecial::Jellen),
|
|
|
|
|
|
1 => Ok(ESWeaponSpecial::Zalure),
|
|
|
|
|
|
2 => Ok(ESWeaponSpecial::HPRegen),
|
|
|
|
|
|
3 => Ok(ESWeaponSpecial::TPRegen),
|
|
|
|
|
|
4 => Ok(ESWeaponSpecial::Burning),
|
|
|
|
|
|
5 => Ok(ESWeaponSpecial::Tempest),
|
|
|
|
|
|
6 => Ok(ESWeaponSpecial::Blizzard),
|
|
|
|
|
|
7 => Ok(ESWeaponSpecial::Arrest),
|
|
|
|
|
|
8 => Ok(ESWeaponSpecial::Chaos),
|
|
|
|
|
|
9 => Ok(ESWeaponSpecial::Hell),
|
|
|
|
|
|
10 => Ok(ESWeaponSpecial::Spirit),
|
|
|
|
|
|
11 => Ok(ESWeaponSpecial::Berserk),
|
|
|
|
|
|
12 => Ok(ESWeaponSpecial::Demons),
|
|
|
|
|
|
13 => Ok(ESWeaponSpecial::Gush),
|
|
|
|
|
|
14 => Ok(ESWeaponSpecial::Geist),
|
|
|
|
|
|
15 => Ok(ESWeaponSpecial::Kings),
|
|
|
|
|
|
_ => Err(ESWeaponError::InvalidESWeaponSpecial),
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
pub struct SRankWeapon {
|
|
|
|
|
|
pub type: SrankType,
|
|
|
|
|
|
pub special: Option<SrankSpecial>,
|
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, PartialEq)]
|
|
|
|
|
|
pub struct ESWeapon {
|
|
|
|
|
|
pub esweapon: ESWeaponType,
|
|
|
|
|
|
pub special: Option<ESWeaponSpecial>,
|
|
|
pub name: String,
|
|
|
pub name: String,
|
|
|
pub grind: u8,
|
|
|
pub grind: u8,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
impl SRankWeapon {
|
|
|
|
|
|
pub fn new(t: SrankType) -> SRankWeapon {
|
|
|
|
|
|
SRankWeapon {
|
|
|
|
|
|
type: t,
|
|
|
|
|
|
|
|
|
impl ESWeapon {
|
|
|
|
|
|
pub fn new(t: ESWeaponType) -> ESWeapon {
|
|
|
|
|
|
ESWeapon {
|
|
|
|
|
|
esweapon: t,
|
|
|
special: None,
|
|
|
special: None,
|
|
|
name: "".to_owned(),
|
|
|
name: "".to_owned(),
|
|
|
grind: 0,
|
|
|
grind: 0,
|
|
@ -195,24 +199,24 @@ impl SRankWeapon { |
|
|
|
|
|
|
|
|
pub fn as_bytes(&self) -> [u8; 16] {
|
|
|
pub fn as_bytes(&self) -> [u8; 16] {
|
|
|
let mut result = [0u8; 16];
|
|
|
let mut result = [0u8; 16];
|
|
|
result[1] = 0x70 + self.type.to_value();
|
|
|
|
|
|
result[2] = self.special.to_value();
|
|
|
|
|
|
|
|
|
result[1] = 0x70 + self.esweapon.to_value();
|
|
|
|
|
|
result[2] = self.special.map(|s| s.to_value()).unwrap_or(0);
|
|
|
result[3] = self.grind;
|
|
|
result[3] = self.grind;
|
|
|
//result[4] = tekked/untekked flag
|
|
|
//result[4] = tekked/untekked flag
|
|
|
result[6..12].clone_from_slice(self.name.bytes_from_name());
|
|
|
|
|
|
|
|
|
result[6..12].clone_from_slice(&self.bytes_from_name());
|
|
|
result
|
|
|
result
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
// TODO: return Result<SRankWeapon, SRankError>
|
|
|
|
|
|
pub fn from_bytes(bytes: [u8; 16]) -> SRankWeapon {
|
|
|
|
|
|
let type = SrankType.from_value(bytes[1] - 0x70).unwrap();
|
|
|
|
|
|
let special = SrankSpecial.from_value(bytes[2]).unwrap();
|
|
|
|
|
|
|
|
|
// TODO: return Result<ESWeapon, ESWeaponError>
|
|
|
|
|
|
pub fn from_bytes(bytes: [u8; 16]) -> ESWeapon {
|
|
|
|
|
|
let esweapon = ESWeaponType::from_value(bytes[1] - 0x70).unwrap();
|
|
|
|
|
|
let special = ESWeaponSpecial::from_value(bytes[2]);
|
|
|
let grind = bytes[3];
|
|
|
let grind = bytes[3];
|
|
|
let name = SRankWeapon::name_from_bytes(bytes[6..12]);
|
|
|
|
|
|
|
|
|
let name = ESWeapon::name_from_bytes(&bytes[6..12]);
|
|
|
|
|
|
|
|
|
SRankWeapon {
|
|
|
|
|
|
type: type,
|
|
|
|
|
|
special: special,
|
|
|
|
|
|
|
|
|
ESWeapon {
|
|
|
|
|
|
esweapon: esweapon,
|
|
|
|
|
|
special: special.ok(),
|
|
|
grind: grind,
|
|
|
grind: grind,
|
|
|
name: name,
|
|
|
name: name,
|
|
|
}
|
|
|
}
|
|
|