diff --git a/src/bin/main.rs b/src/bin/main.rs index f5b7823..05da369 100644 --- a/src/bin/main.rs +++ b/src/bin/main.rs @@ -84,6 +84,7 @@ fn main() { special: None, attrs: [None, None, None], tekked: true, + wrapping: None, } ), location: item::ItemLocation::Bank { @@ -119,6 +120,7 @@ fn main() { Some(item::weapon::WeaponAttribute{attr: item::weapon::Attribute::Dark, value: 30}), None,], tekked: false, + wrapping: Some(item::weapon::WrappingPaper::Black_Yellow), } ), location: ItemLocation::Inventory { @@ -136,6 +138,7 @@ fn main() { Some(item::weapon::WeaponAttribute{attr: item::weapon::Attribute::Dark, value: 30}), None,], tekked: true, + wrapping: None, } ), location: ItemLocation::Inventory { @@ -153,6 +156,7 @@ fn main() { Some(item::weapon::WeaponAttribute{attr: item::weapon::Attribute::Dark, value: 100}), None,], tekked: true, + wrapping: None, } ), location: ItemLocation::Inventory { @@ -170,6 +174,7 @@ fn main() { Some(item::weapon::WeaponAttribute{attr: item::weapon::Attribute::Dark, value: 100}), None,], tekked: true, + wrapping: None, } ), location: ItemLocation::Inventory { @@ -187,6 +192,7 @@ fn main() { Some(item::weapon::WeaponAttribute{attr: item::weapon::Attribute::Dark, value: 100}), Some(item::weapon::WeaponAttribute{attr: item::weapon::Attribute::Native, value: 100}),], tekked: true, + wrapping: None, } ), location: ItemLocation::Inventory { @@ -251,6 +257,7 @@ fn main() { Some(item::weapon::WeaponAttribute{attr: item::weapon::Attribute::Dark, value: 80}), None,], tekked: false, + wrapping: None, } ), location: ItemLocation::Bank { diff --git a/src/entity/gateway/postgres/models.rs b/src/entity/gateway/postgres/models.rs index 892fa24..b3a6136 100644 --- a/src/entity/gateway/postgres/models.rs +++ b/src/entity/gateway/postgres/models.rs @@ -286,6 +286,7 @@ pub struct PgWeapon { grind: u8, attrs: HashMap, tekked: bool, + wrapping: Option, } impl From for PgWeapon { @@ -296,6 +297,7 @@ impl From for PgWeapon { grind: other.grind, attrs: other.attrs.iter().flatten().map(|attr| (attr.attr, attr.value)).collect(), tekked: other.tekked, + wrapping: other.wrapping, } } } @@ -316,6 +318,7 @@ impl Into for PgWeapon { grind: self.grind, attrs: attrs, tekked: self.tekked, + wrapping: self.wrapping, } } } diff --git a/src/entity/item/weapon.rs b/src/entity/item/weapon.rs index 186c701..cf59255 100644 --- a/src/entity/item/weapon.rs +++ b/src/entity/item/weapon.rs @@ -1454,7 +1454,7 @@ pub enum WeaponModifier { }, } -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)] pub enum WrappingPaper { White_Pink, // 0 Yellow_Blue, @@ -1499,8 +1499,7 @@ pub struct Weapon { pub grind: u8, pub attrs: [Option; 3], pub tekked: bool, - pub modifiers: Vec, - pub wrapped: Option, + pub wrapping: Option, } @@ -1512,8 +1511,7 @@ impl Weapon { grind: 0, attrs: [None; 3], tekked: true, - modifiers: Vec::new(), - wrapped: None, + wrapping: None, } } @@ -1568,9 +1566,9 @@ impl Weapon { result[3] = self.grind; result[4] = self.special.map(|s| s.value()).unwrap_or(0); - if self.wrapped.is_some() { + if self.wrapping.is_some() { result[4] += 0x40; - result[5] = self.wrapped.unwrap().value(); + result[5] = self.wrapping.unwrap().value(); }; if self.tekked == false { @@ -1590,16 +1588,21 @@ impl Weapon { if w.is_ok() { let mut s = None; let mut t = true; + let mut p = None; // wrapping paper let g = data[3]; - if data[4] >= 0x81 && data[4] <= 0xA8 { + if data[4] & 0x80 == 0x80 { s = WeaponSpecial::from(data[4] - 0x80); t = false; } - else if data[4] >= 0x01 && data[4] <= 0x28 { - s = WeaponSpecial::from(data[4]); - t = true; + + if data[4] & 0x40 == 0x40 { + p = WrappingPaper::from(data[5]); } + // else if data[4] >= 0x01 && data[4] <= 0x28 { + // s = WeaponSpecial::from(data[4]); + // t = true; + // } // else { // return Err(ItemParseError::InvalidSpecial) // } @@ -1632,6 +1635,7 @@ impl Weapon { a[2], ], tekked: t, + wrapping: p, }) } else { diff --git a/src/login/character.rs b/src/login/character.rs index 82a9e28..821380c 100644 --- a/src/login/character.rs +++ b/src/login/character.rs @@ -220,6 +220,7 @@ async fn new_character(entity_gateway: &mut EG, user: &UserAc special: None, attrs: [None; 3], tekked: true, + wrapping: None, }), location: ItemLocation::Inventory { character_id: character.id, diff --git a/src/ship/drops/generic_weapon.rs b/src/ship/drops/generic_weapon.rs index 71e578c..c7d5e45 100644 --- a/src/ship/drops/generic_weapon.rs +++ b/src/ship/drops/generic_weapon.rs @@ -503,6 +503,7 @@ impl GenericWeaponTable { grind: weapon_grind as u8, attrs: weapon_attributes, tekked: weapon_special.is_none(), + wrapping: None, })) } } @@ -524,6 +525,7 @@ mod test { grind: 0, attrs: [None, None, None], tekked: true, + wrapping: None, }))); let gwt = GenericWeaponTable::new(Episode::One, Difficulty::Hard, SectionID::Skyly); @@ -533,6 +535,7 @@ mod test { grind: 2, attrs: [None, None, None], tekked: true, + wrapping: None, }))); let gwt = GenericWeaponTable::new(Episode::One, Difficulty::VeryHard, SectionID::Skyly); @@ -542,6 +545,7 @@ mod test { grind: 0, attrs: [None, None, None], tekked: false, + wrapping: None, }))); let gwt = GenericWeaponTable::new(Episode::One, Difficulty::Ultimate, SectionID::Skyly); @@ -551,6 +555,7 @@ mod test { grind: 0, attrs: [Some(WeaponAttribute {attr: Attribute::ABeast, value: 30}), Some(WeaponAttribute {attr: Attribute::Dark, value: 30}), None], tekked: true, + wrapping: None, }))); } } diff --git a/src/ship/drops/rare_drop_table.rs b/src/ship/drops/rare_drop_table.rs index df9ec8d..c44a95d 100644 --- a/src/ship/drops/rare_drop_table.rs +++ b/src/ship/drops/rare_drop_table.rs @@ -104,6 +104,7 @@ impl RareDropTable { grind: 0, attrs: self.attribute_table.generate_rare_attributes(map_area, rng), tekked: false, + wrapping: None, }) }, diff --git a/src/ship/shops/weapon.rs b/src/ship/shops/weapon.rs index ea2642e..a56bef2 100644 --- a/src/ship/shops/weapon.rs +++ b/src/ship/shops/weapon.rs @@ -142,6 +142,7 @@ impl ShopItem for WeaponShopItem { grind: self.grind as u8, attrs: [self.attributes[0], self.attributes[1], None], tekked: true, + wrapping: None, } ) }