From 98b2ebfdd8b3b2f08a18202e247c06b89f294306 Mon Sep 17 00:00:00 2001 From: andy Date: Mon, 7 Dec 2020 02:12:24 +0000 Subject: [PATCH] wrap everything except armours --- data/quests.toml | 13 +++++++-- src/bin/main.rs | 9 +++++++ src/entity/gateway/postgres/models.rs | 23 +++++++++++++++- src/entity/item/armor.rs | 1 + src/entity/item/esweapon.rs | 18 ++++++++++++- src/entity/item/mag.rs | 18 +++++++++++-- src/entity/item/mod.rs | 2 +- src/entity/item/shield.rs | 13 +++++++++ src/entity/item/tech.rs | 5 ++++ src/entity/item/tool.rs | 11 +++++++- src/entity/item/unit.rs | 16 +++++++++++ src/entity/item/weapon.rs | 38 --------------------------- src/login/character.rs | 2 ++ src/ship/drops/generic_shield.rs | 5 ++++ src/ship/drops/generic_unit.rs | 2 ++ src/ship/drops/rare_drop_table.rs | 3 +++ src/ship/drops/tech_table.rs | 6 +++-- src/ship/drops/tool_table.rs | 3 ++- src/ship/packet/builder/quest.rs | 2 ++ src/ship/shops/armor.rs | 2 ++ src/ship/shops/tool.rs | 15 ++++++----- tests/test_bank.rs | 20 ++++++++++++++ tests/test_item_actions.rs | 6 +++++ tests/test_item_pickup.rs | 14 +++++++--- tests/test_item_use.rs | 13 ++++++--- tests/test_mags.rs | 3 +++ tests/test_shops.rs | 3 ++- 27 files changed, 203 insertions(+), 63 deletions(-) diff --git a/data/quests.toml b/data/quests.toml index a316475..5d1c8f9 100644 --- a/data/quests.toml +++ b/data/quests.toml @@ -1,6 +1,6 @@ [Extermination] list_order = 1 -description = "I am a description" +description = "kill some shit" [[Extermination.quests]] bin = "q058-ret-bb.bin" @@ -32,4 +32,13 @@ dat = "q233-ext-bb.dat" [[Retrieval.quests]] bin = "q236-ext-bb.bin" dat = "q236-ext-bb.dat" -#drop_table = "q102-drops" \ No newline at end of file +#drop_table = "q102-drops" + +[Shop] +list_order = 3 +description = "buy some shit" + +[[Shop.quests]] +bin = "q219-shp-bb.bin" +dat = "q219-shp-bb.dat" +#drop_table = "q204-drops" diff --git a/src/bin/main.rs b/src/bin/main.rs index 7d5c4f5..cb20e41 100644 --- a/src/bin/main.rs +++ b/src/bin/main.rs @@ -100,6 +100,7 @@ fn main() { item: ItemDetail::Tool ( item::tool::Tool { tool: item::tool::ToolType::Monomate, + wrapping: None, } ), location: item::ItemLocation::Bank { @@ -214,6 +215,7 @@ fn main() { item: ItemDetail::Tool ( item::tool::Tool { tool: item::tool::ToolType::Monomate, + wrapping: None, } ), location: item::ItemLocation::FedToMag { @@ -229,6 +231,7 @@ fn main() { item: ItemDetail::Tool ( item::tool::Tool { tool: item::tool::ToolType::CellOfMag502, + wrapping: None, } ), location: item::ItemLocation::Inventory { @@ -240,6 +243,7 @@ fn main() { item: ItemDetail::Tool ( item::tool::Tool { tool: item::tool::ToolType::CellOfMag502, + wrapping: None, } ), location: item::ItemLocation::Consumed, @@ -287,6 +291,7 @@ fn main() { shield: item::shield::ShieldType::Barrier, dfp: 0, evp: 0, + wrapping: None, } ), location: ItemLocation::Inventory { @@ -300,6 +305,7 @@ fn main() { item::unit::Unit { unit: item::unit::UnitType::PriestMind, modifier: Some(item::unit::UnitModifier::Minus), + wrapping: None, } ), location: ItemLocation::Inventory { @@ -313,6 +319,7 @@ fn main() { item::unit::Unit { unit: item::unit::UnitType::PriestMind, modifier: Some(item::unit::UnitModifier::Minus), + wrapping: None, } ), location: ItemLocation::Inventory { @@ -326,6 +333,7 @@ fn main() { item::unit::Unit { unit: item::unit::UnitType::PriestMind, modifier: Some(item::unit::UnitModifier::Minus), + wrapping: None, } ), location: ItemLocation::Inventory { @@ -339,6 +347,7 @@ fn main() { item::unit::Unit { unit: item::unit::UnitType::PriestMind, modifier: Some(item::unit::UnitModifier::Minus), + wrapping: None, } ), location: ItemLocation::Inventory { diff --git a/src/entity/gateway/postgres/models.rs b/src/entity/gateway/postgres/models.rs index fe055db..d6f0c83 100644 --- a/src/entity/gateway/postgres/models.rs +++ b/src/entity/gateway/postgres/models.rs @@ -335,6 +335,7 @@ pub struct PgArmor { dfp: u8, evp: u8, slots: u8, + // wrapping: Option, // TODO: check if this clobbers slots } impl From for PgArmor { @@ -344,6 +345,7 @@ impl From for PgArmor { dfp: other.dfp, evp: other.evp, slots: other.slots, + // wrapping: other.wrapping, } } } @@ -355,6 +357,7 @@ impl Into for PgArmor { dfp: self.dfp, evp: self.evp, slots: self.slots, + // wrapping: self.wrapping, } } } @@ -364,6 +367,7 @@ pub struct PgShield { shield: shield::ShieldType, dfp: u8, evp: u8, + wrapping: Option, } impl From for PgShield { @@ -372,6 +376,7 @@ impl From for PgShield { shield: other.shield, dfp: other.dfp, evp: other.evp, + wrapping: other.wrapping, } } } @@ -382,6 +387,7 @@ impl Into for PgShield { shield: self.shield, dfp: self.dfp, evp: self.evp, + wrapping: self.wrapping, } } } @@ -390,6 +396,7 @@ impl Into for PgShield { pub struct PgUnit { unit: unit::UnitType, modifier: Option, + wrapping: Option, } impl From for PgUnit { @@ -397,6 +404,7 @@ impl From for PgUnit { PgUnit { unit: other.unit, modifier: other.modifier, + wrapping: other.wrapping, } } } @@ -406,6 +414,7 @@ impl Into for PgUnit { unit::Unit { unit: self.unit, modifier: self.modifier, + wrapping: self.wrapping, } } } @@ -413,12 +422,14 @@ impl Into for PgUnit { #[derive(Debug, Serialize, Deserialize)] pub struct PgTool { pub tool: tool::ToolType, + wrapping: Option, } impl From for PgTool { fn from(other: tool::Tool) -> PgTool { PgTool { tool: other.tool, + wrapping: other.wrapping, } } } @@ -427,6 +438,7 @@ impl Into for PgTool { fn into(self) -> tool::Tool { tool::Tool { tool: self.tool, + wrapping: self.wrapping, } } } @@ -435,6 +447,7 @@ impl Into for PgTool { pub struct PgTechDisk { tech: tech::Technique, level: u32, + wrapping: Option, } impl From for PgTechDisk { @@ -442,6 +455,7 @@ impl From for PgTechDisk { PgTechDisk { tech: other.tech, level: other.level, + wrapping: other.wrapping, } } } @@ -450,7 +464,8 @@ impl Into for PgTechDisk { fn into(self) -> tech::TechniqueDisk { tech::TechniqueDisk { tech: self.tech, - level: self.level + level: self.level, + wrapping: self.wrapping, } } } @@ -460,6 +475,7 @@ pub struct PgMag { mag: mag::MagType, synchro: u8, color: u8, + wrapping: Option, } impl From for PgMag { @@ -468,6 +484,7 @@ impl From for PgMag { mag: other.mag, synchro: other.synchro, color: other.color, + wrapping: other.wrapping, } } } @@ -490,6 +507,7 @@ impl Into for PgMag { let mut mag = mag::Mag::baby_mag(self.color as u16); mag.mag = self.mag; mag.synchro = self.synchro; + mag.wrapping = self.wrapping; mag } } @@ -500,6 +518,7 @@ pub struct PgESWeapon { special: Option, name: String, grind: u8, + wrapping: Option, } impl From for PgESWeapon { @@ -509,6 +528,7 @@ impl From for PgESWeapon { special: other.special, name: other.name, grind: other.grind, + wrapping: other.wrapping, } } } @@ -520,6 +540,7 @@ impl Into for PgESWeapon { special: self.special, name: self.name, grind: self.grind, + wrapping: self.wrapping, } } } diff --git a/src/entity/item/armor.rs b/src/entity/item/armor.rs index 83c900b..9a2d925 100644 --- a/src/entity/item/armor.rs +++ b/src/entity/item/armor.rs @@ -303,6 +303,7 @@ pub struct Armor { pub dfp: u8, pub evp: u8, pub slots: u8, + // pub wrapping: Option, // clobbers slots } impl Armor { diff --git a/src/entity/item/esweapon.rs b/src/entity/item/esweapon.rs index 73e54e1..2b71150 100644 --- a/src/entity/item/esweapon.rs +++ b/src/entity/item/esweapon.rs @@ -176,6 +176,7 @@ pub struct ESWeapon { pub special: Option, pub name: String, pub grind: u8, + pub wrapping: Option } impl ESWeapon { @@ -185,6 +186,7 @@ impl ESWeapon { special: None, name: "".to_owned(), grind: 0, + wrapping: None, } } @@ -242,7 +244,10 @@ impl ESWeapon { result[1] = 0x70 + self.esweapon.to_value(); result[2] = self.special.map(|s| s.to_value()).unwrap_or(0); result[3] = self.grind; - //result[4] = tekked/untekked flag + if self.wrapping.is_some() { + result[4] += 0x40; + result[5] = self.wrapping.unwrap().value(); + } result[6..12].clone_from_slice(&self.bytes_from_name()); result } @@ -253,12 +258,20 @@ impl ESWeapon { let special = ESWeaponSpecial::from_value(bytes[2]); let grind = bytes[3]; let name = ESWeapon::name_from_bytes(&bytes[6..12]); + let wrapping = { + if bytes[4] & 0x40 == 0x40 { + WrappingPaper::from(bytes[5]) + } else { + None + } + }; ESWeapon { esweapon: esweapon, special: special.ok(), grind: grind, name: name, + wrapping: wrapping, } } } @@ -277,6 +290,7 @@ mod test { special: Some(ESWeaponSpecial::Berserk), grind: 137u8, name: "JAKESERV".to_owned(), + wrapping: None, }); } @@ -288,6 +302,7 @@ mod test { special: Some(ESWeaponSpecial::Chaos), grind: 72u8, name: "PSYCHO".to_owned(), + wrapping: None, }; let bytes = testweapon.as_bytes(); assert_eq!(bytes, [0x00, 0x7B, 0x09, 0x48, 0x00, 0x00, 0x82, 0x13, 0xE4, 0x68, 0xBC, 0x00, 0x00, 0x00, 0x00, 0x00]); @@ -301,6 +316,7 @@ mod test { special: Some(ESWeaponSpecial::Spirit), grind: 105u8, name: "YUGIOH".to_owned(), + wrapping: None, }; let bytes = testweapon.as_bytes(); assert_eq!(bytes, [0x00, 0xA7, 0x0B, 0x69, 0x00, 0x00, 0x83, 0x35, 0x9D, 0x2F, 0xA0, 0x00, 0x00, 0x00, 0x00, 0x00]); diff --git a/src/entity/item/mag.rs b/src/entity/item/mag.rs index 3501aac..e3a350a 100644 --- a/src/entity/item/mag.rs +++ b/src/entity/item/mag.rs @@ -543,6 +543,7 @@ pub struct Mag { //modifiers: Vec, pub class: CharacterClass, pub id: SectionID, + pub wrapping: Option, } @@ -561,6 +562,7 @@ impl Mag { //modifiers: Vec::new(), class: CharacterClass::HUmar, id: SectionID::Viridia, + wrapping: None, } } @@ -575,6 +577,9 @@ impl Mag { result[12] = self.synchro; result[13] = self.iq; result[14] = self.photon_blast_count(); + if self.wrapping.is_some() { + result[14] += 0x40; + } result[15] = self.color; result } @@ -648,6 +653,13 @@ impl Mag { let sync = data[12] % 121; // TODO: handle invalid values. let iq = data[13] % 201; // TODO: handle invalid values. + let wp = { + if data[14] & 0x40 == 0x40 { + WrappingPaper::from(data[15] % 10) // % 10 to have valid wrapping paper colour. + } else { + None + } + }; Ok(Mag{ mag: m.unwrap(), @@ -660,8 +672,9 @@ impl Mag { photon_blast: [None, None, None], // TODO: actually get PBs from bytes color: data[15] % 18, //modifiers: Vec::new(), - class: CharacterClass::HUmar, - id: SectionID::Viridia, + class: CharacterClass::HUmar, // TODO: determine character class + id: SectionID::Viridia, // TODO: determine section id + wrapping: wp, }) } else { @@ -1167,6 +1180,7 @@ mod test { color: 0, class: CharacterClass::FOmarl, id: SectionID::Whitill, + wrapping: None, }); } diff --git a/src/entity/item/mod.rs b/src/entity/item/mod.rs index 8aa3155..c6bf5ec 100644 --- a/src/entity/item/mod.rs +++ b/src/entity/item/mod.rs @@ -331,7 +331,7 @@ impl BankEntity { } } -#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)] +#[derive(Debug, Clone, Copy, Eq, Hash, PartialEq, Serialize, Deserialize)] pub enum WrappingPaper { White_Pink, // 0 Yellow_Blue, // 1 diff --git a/src/entity/item/shield.rs b/src/entity/item/shield.rs index 7f4a1e6..22ce3d2 100644 --- a/src/entity/item/shield.rs +++ b/src/entity/item/shield.rs @@ -525,12 +525,17 @@ pub struct Shield { pub shield: ShieldType, pub dfp: u8, pub evp: u8, + pub wrapping: Option, } impl Shield { pub fn as_bytes(&self) -> [u8; 16] { let mut result = [0; 16]; result[0..3].copy_from_slice(&self.shield.value()); + if self.wrapping.is_some() { + result[4] += 0x40; + result[5] = self.wrapping.unwrap().value(); + }; result[6] = self.dfp; result[8] = self.evp; result @@ -538,11 +543,19 @@ impl Shield { pub fn from_bytes(data: [u8; 16]) -> Result { let s = ShieldType::parse_type([data[0], data[1], data[2]]); + let wrapping = { + if data[4] & 0x40 == 0x40 { + WrappingPaper::from(data[5]) + } else { + None + } + }; if s.is_ok() { Ok(Shield{ shield: s.unwrap(), dfp: data[6], evp: data[8], + wrapping: wrapping, }) } else { diff --git a/src/entity/item/tech.rs b/src/entity/item/tech.rs index 4cd3290..91f5296 100644 --- a/src/entity/item/tech.rs +++ b/src/entity/item/tech.rs @@ -80,6 +80,7 @@ impl Technique { pub struct TechniqueDisk { pub tech: Technique, pub level: u32, + pub wrapping: Option, // TODO: validate if this clobbers tech value? } impl TechniqueDisk { @@ -89,6 +90,10 @@ impl TechniqueDisk { result[1] = 2; result[2] = self.level as u8 - 1; result[4] = self.tech.as_value(); + if self.wrapping.is_some() { + result[4] += 0x40; + result[5] = self.wrapping.unwrap().value(); + }; result } } diff --git a/src/entity/item/tool.rs b/src/entity/item/tool.rs index 688aa7d..4079c3c 100644 --- a/src/entity/item/tool.rs +++ b/src/entity/item/tool.rs @@ -652,6 +652,7 @@ impl ToolType { #[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct Tool { pub tool: ToolType, + pub wrapping: Option, // TODO: what happens if a present is N monomates and the inventory already has 10? } impl Tool { @@ -669,10 +670,18 @@ impl Tool { } pub fn from_bytes(data: [u8; 16]) -> Result { - let t = ToolType::parse_type([data[0], data[1], data[2]]); + let t = ToolType::parse_type([data[0], data[1], data[2]]); + let w = { + if data[4] & 0x40 == 0x40 { + WrappingPaper::from(data[5]) + } else { + None + } + }; if t.is_ok() { Ok(Tool { tool: t.unwrap(), + wrapping: w, }) } else { diff --git a/src/entity/item/unit.rs b/src/entity/item/unit.rs index a39b9ad..401d1cf 100644 --- a/src/entity/item/unit.rs +++ b/src/entity/item/unit.rs @@ -336,6 +336,7 @@ pub enum UnitModifier { pub struct Unit { pub unit: UnitType, pub modifier: Option, + pub wrapping: Option, } @@ -362,6 +363,12 @@ impl Unit { }, } } + + if self.wrapping.is_some() { + result[4] += 0x40; + result[5] = self.wrapping.unwrap().value(); + } + result } @@ -376,9 +383,18 @@ impl Unit { _ => None, }; + let w = { + if data[4] & 0x40 == 0x40 { + WrappingPaper::from(data[5]) + } else { + None + } + }; + Ok(Unit{ unit: u.unwrap(), modifier: m, + wrapping: w, }) } else { diff --git a/src/entity/item/weapon.rs b/src/entity/item/weapon.rs index 1d7071e..45640ae 100644 --- a/src/entity/item/weapon.rs +++ b/src/entity/item/weapon.rs @@ -1454,44 +1454,6 @@ pub enum WeaponModifier { }, } -// #[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)] -// pub enum WrappingPaper { -// White_Pink, // 0 -// Yellow_Blue, -// Black_Yellow, -// LightBlue_Orange, -// Pink_YellowGreen, -// Red_Green, -// Magenta, -// Blue, -// Yellow, -// Vermillion, -// Green, -// } - -// impl WrappingPaper { -// pub fn value(&self) -> u8 { -// *self as u8 -// } - -// pub fn from(data: u8) -> Option { -// match data { -// 0 => Some(WrappingPaper::White_Pink), -// 1 => Some(WrappingPaper::Yellow_Blue), -// 2 => Some(WrappingPaper::Black_Yellow), -// 3 => Some(WrappingPaper::LightBlue_Orange), -// 4 => Some(WrappingPaper::Pink_YellowGreen), -// 5 => Some(WrappingPaper::Red_Green), -// 6 => Some(WrappingPaper::Magenta), -// 7 => Some(WrappingPaper::Blue), -// 8 => Some(WrappingPaper::Yellow), -// 9 => Some(WrappingPaper::Vermillion), -// 10 => Some(WrappingPaper::Green), -// _ => None, -// } -// } -// } - #[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)] pub struct Weapon { pub weapon: WeaponType, diff --git a/src/login/character.rs b/src/login/character.rs index 821380c..9d9969a 100644 --- a/src/login/character.rs +++ b/src/login/character.rs @@ -261,6 +261,7 @@ async fn new_character(entity_gateway: &mut EG, user: &UserAc item: ItemDetail::Tool ( Tool { tool: item::tool::ToolType::Monomate, + wrapping: None, }), location: ItemLocation::Inventory { character_id: character.id, @@ -274,6 +275,7 @@ async fn new_character(entity_gateway: &mut EG, user: &UserAc item: ItemDetail::Tool ( Tool { tool: item::tool::ToolType::Monofluid, + wrapping: None, }), location: ItemLocation::Inventory { character_id: character.id, diff --git a/src/ship/drops/generic_shield.rs b/src/ship/drops/generic_shield.rs index 9eec585..9980ead 100644 --- a/src/ship/drops/generic_shield.rs +++ b/src/ship/drops/generic_shield.rs @@ -86,6 +86,7 @@ impl GenericShieldTable { shield: shield_type, dfp: dfp_modifier as u8, evp: evp_modifier as u8, + wrapping: None, })) } } @@ -105,21 +106,25 @@ mod test { shield: ShieldType::FreezeBarrier, dfp: 4, evp: 1, + wrapping: None, }))); assert!(gst.get_drop(&MapArea::Caves3, &mut rng) == Some(ItemDropType::Shield(Shield { shield: ShieldType::PsychicBarrier, dfp: 3, evp: 2, + wrapping: None, }))); assert!(gst.get_drop(&MapArea::Mines2, &mut rng) == Some(ItemDropType::Shield(Shield { shield: ShieldType::ImperialBarrier, dfp: 0, evp: 4, + wrapping: None, }))); assert!(gst.get_drop(&MapArea::DarkFalz, &mut rng) == Some(ItemDropType::Shield(Shield { shield: ShieldType::DivinityBarrier, dfp: 1, evp: 0, + wrapping: None, }))); } } diff --git a/src/ship/drops/generic_unit.rs b/src/ship/drops/generic_unit.rs index 73bc4a6..e7a9965 100644 --- a/src/ship/drops/generic_unit.rs +++ b/src/ship/drops/generic_unit.rs @@ -89,6 +89,7 @@ impl GenericUnitTable { ItemDropType::Unit(Unit { unit: unit_type, modifier: unit_modifier, + wrapping: None, }) }) } @@ -116,6 +117,7 @@ mod test { assert!(gut.get_drop(&area, &mut rng) == Some(ItemDropType::Unit(Unit { unit: unit, modifier: umod, + wrapping: None, }))); } } diff --git a/src/ship/drops/rare_drop_table.rs b/src/ship/drops/rare_drop_table.rs index c44a95d..450c9ef 100644 --- a/src/ship/drops/rare_drop_table.rs +++ b/src/ship/drops/rare_drop_table.rs @@ -121,17 +121,20 @@ impl RareDropTable { shield: shield, dfp: self.shield_stats.dfp_modifier(&shield, rng) as u8, evp: self.shield_stats.evp_modifier(&shield, rng) as u8, + wrapping: None, }) }, RareDropItem::Unit(unit) => { ItemDropType::Unit(Unit { unit: unit, modifier: None, + wrapping: None, }) }, RareDropItem::Tool(tool) => { ItemDropType::Tool(Tool { tool: tool, + wrapping: None, }) }, RareDropItem::Mag(_mag) => { diff --git a/src/ship/drops/tech_table.rs b/src/ship/drops/tech_table.rs index 6e6396f..24df009 100644 --- a/src/ship/drops/tech_table.rs +++ b/src/ship/drops/tech_table.rs @@ -103,7 +103,8 @@ impl TechniqueTable { Some(ItemDropType::TechniqueDisk(TechniqueDisk { tech: *tech, - level: level as u32 + level: level as u32, + wrapping: None, })) } } @@ -127,7 +128,8 @@ mod test { assert!(tt.get_drop(&area, &mut rng) == Some(ItemDropType::TechniqueDisk( TechniqueDisk { tech: tech, - level: level + level: level, + wrapping: None, }))); } } diff --git a/src/ship/drops/tool_table.rs b/src/ship/drops/tool_table.rs index 69a14cd..1840e1b 100644 --- a/src/ship/drops/tool_table.rs +++ b/src/ship/drops/tool_table.rs @@ -158,7 +158,8 @@ impl ToolTable { }; Some(ItemDropType::Tool(Tool { - tool: tool_type + tool: tool_type, + wrapping: None, })) } } diff --git a/src/ship/packet/builder/quest.rs b/src/ship/packet/builder/quest.rs index 089fe56..1882ea6 100644 --- a/src/ship/packet/builder/quest.rs +++ b/src/ship/packet/builder/quest.rs @@ -13,6 +13,7 @@ pub fn quest_category_list(quests: &QuestList) -> QuestCategoryList { option_id: i as u32, name: utf8_to_utf16_array!(category.name, 32), description: utf8_to_utf16_array!(category.description, 122), + // description: utf8_to_utf16_array!(category.description, 244), } }) .collect(); @@ -31,6 +32,7 @@ pub fn quest_list(category_id: u32, quests: &Vec) -> QuestOptionList { quest_id: quest.id, name: utf8_to_utf16_array!(quest.name, 32), description: utf8_to_utf16_array!(quest.description, 122), + // description: utf8_to_utf16_array!(quest.description, 244), } }) .collect(); diff --git a/src/ship/shops/armor.rs b/src/ship/shops/armor.rs index 2a6314f..feb1705 100644 --- a/src/ship/shops/armor.rs +++ b/src/ship/shops/armor.rs @@ -78,12 +78,14 @@ impl ShopItem for ArmorShopItem { shield: *barrier, dfp: 0, evp: 0, + wrapping: None, }) }, ArmorShopItem::Unit(unit) => { ItemDetail::Unit(Unit { unit: *unit, modifier: None, + wrapping: None, }) }, } diff --git a/src/ship/shops/tool.rs b/src/ship/shops/tool.rs index 7eecd3d..190639e 100644 --- a/src/ship/shops/tool.rs +++ b/src/ship/shops/tool.rs @@ -22,11 +22,11 @@ pub enum ToolShopItem { impl Ord for ToolShopItem { fn cmp(&self, other: &ToolShopItem) -> std::cmp::Ordering { let a = match self { - ToolShopItem::Tool(t) => Tool{tool : *t}.as_individual_bytes(), + ToolShopItem::Tool(t) => Tool{tool : *t, wrapping: None,}.as_individual_bytes(), ToolShopItem::Tech(t) => t.as_bytes(), }; let b = match other { - ToolShopItem::Tool(t) => Tool{tool : *t}.as_individual_bytes(), + ToolShopItem::Tool(t) => Tool{tool : *t, wrapping: None,}.as_individual_bytes(), ToolShopItem::Tech(t) => t.as_bytes(), }; @@ -37,11 +37,11 @@ impl Ord for ToolShopItem { impl PartialOrd for ToolShopItem { fn partial_cmp(&self, other: &ToolShopItem) -> Option { let a = match self { - ToolShopItem::Tool(t) => Tool{tool : *t}.as_individual_bytes(), + ToolShopItem::Tool(t) => Tool{tool : *t, wrapping: None,}.as_individual_bytes(), ToolShopItem::Tech(t) => t.as_bytes(), }; let b = match other { - ToolShopItem::Tool(t) => Tool{tool : *t}.as_individual_bytes(), + ToolShopItem::Tool(t) => Tool{tool : *t, wrapping: None,}.as_individual_bytes(), ToolShopItem::Tech(t) => t.as_bytes(), }; @@ -73,7 +73,8 @@ impl ShopItem for ToolShopItem { match self { ToolShopItem::Tool(tool) => { Tool { - tool: *tool + tool: *tool, + wrapping: None, }.as_individual_bytes()[0..12].try_into().unwrap() }, ToolShopItem::Tech(tech) => { @@ -86,7 +87,8 @@ impl ShopItem for ToolShopItem { match self { ToolShopItem::Tool(tool) => { ItemDetail::Tool(Tool { - tool: *tool + tool: *tool, + wrapping: None, }) }, ToolShopItem::Tech(tech) => { @@ -262,6 +264,7 @@ impl ToolShop { ToolShopItem::Tech(TechniqueDisk { tech: tech, level: level as u32, + wrapping: None, }) }) .collect() diff --git a/tests/test_bank.rs b/tests/test_bank.rs index c5eaf29..8687faf 100644 --- a/tests/test_bank.rs +++ b/tests/test_bank.rs @@ -118,6 +118,7 @@ async fn test_request_stacked_bank_items() { item: item::ItemDetail::Tool ( item::tool::Tool { tool: item::tool::ToolType::Monomate, + wrapping: None, } ), location: item::ItemLocation::Bank { @@ -180,6 +181,7 @@ async fn test_request_bank_items_sorted() { item: item::ItemDetail::Tool ( item::tool::Tool { tool: item::tool::ToolType::Monomate, + wrapping: None, } ), location: item::ItemLocation::Bank { @@ -326,6 +328,7 @@ async fn test_deposit_stacked_item() { item: item::ItemDetail::Tool( item::tool::Tool { tool: item::tool::ToolType::Monomate, + wrapping: None, } ), location: item::ItemLocation::Inventory { @@ -390,6 +393,7 @@ async fn test_deposit_partial_stacked_item() { item: item::ItemDetail::Tool( item::tool::Tool { tool: item::tool::ToolType::Monomate, + wrapping: None, } ), location: item::ItemLocation::Inventory { @@ -464,6 +468,7 @@ async fn test_deposit_stacked_item_with_stack_already_in_bank() { item: item::ItemDetail::Tool( item::tool::Tool { tool: item::tool::ToolType::Monomate, + wrapping: None, } ), location: item::ItemLocation::Inventory { @@ -476,6 +481,7 @@ async fn test_deposit_stacked_item_with_stack_already_in_bank() { item: item::ItemDetail::Tool( item::tool::Tool { tool: item::tool::ToolType::Monomate, + wrapping: None, } ), location: item::ItemLocation::Bank { @@ -541,6 +547,7 @@ async fn test_deposit_stacked_item_with_full_stack_in_bank() { item: item::ItemDetail::Tool( item::tool::Tool { tool: item::tool::ToolType::Monomate, + wrapping: None, } ), location: item::ItemLocation::Inventory { @@ -556,6 +563,7 @@ async fn test_deposit_stacked_item_with_full_stack_in_bank() { item: item::ItemDetail::Tool( item::tool::Tool { tool: item::tool::ToolType::Monomate, + wrapping: None, } ), location: item::ItemLocation::Bank { @@ -703,6 +711,7 @@ async fn test_deposit_stacked_item_in_full_bank() { item: item::ItemDetail::Tool( item::tool::Tool { tool: item::tool::ToolType::Monomate, + wrapping: None, } ), location: item::ItemLocation::Inventory { @@ -784,6 +793,7 @@ async fn test_deposit_stacked_item_in_full_bank_with_partial_stack() { item: item::ItemDetail::Tool( item::tool::Tool { tool: item::tool::ToolType::Monomate, + wrapping: None, } ), location: item::ItemLocation::Inventory { @@ -799,6 +809,7 @@ async fn test_deposit_stacked_item_in_full_bank_with_partial_stack() { item: item::ItemDetail::Tool( item::tool::Tool { tool: item::tool::ToolType::Monomate, + wrapping: None, } ), location: item::ItemLocation::Bank { @@ -1062,6 +1073,7 @@ async fn test_withdraw_stacked_item() { item: item::ItemDetail::Tool( item::tool::Tool { tool: item::tool::ToolType::Monomate, + wrapping: None, } ), location: item::ItemLocation::Bank { @@ -1126,6 +1138,7 @@ async fn test_withdraw_partial_stacked_item() { item: item::ItemDetail::Tool( item::tool::Tool { tool: item::tool::ToolType::Monomate, + wrapping: None, } ), location: item::ItemLocation::Bank { @@ -1197,6 +1210,7 @@ async fn test_withdraw_stacked_item_with_stack_already_in_inventory() { item: item::ItemDetail::Tool( item::tool::Tool { tool: item::tool::ToolType::Monomate, + wrapping: None, } ), location: item::ItemLocation::Inventory { @@ -1209,6 +1223,7 @@ async fn test_withdraw_stacked_item_with_stack_already_in_inventory() { item: item::ItemDetail::Tool( item::tool::Tool { tool: item::tool::ToolType::Monomate, + wrapping: None, } ), location: item::ItemLocation::Bank { @@ -1276,6 +1291,7 @@ async fn test_withdraw_stacked_item_with_full_stack_in_inventory() { item: item::ItemDetail::Tool( item::tool::Tool { tool: item::tool::ToolType::Monomate, + wrapping: None, } ), location: item::ItemLocation::Bank { @@ -1292,6 +1308,7 @@ async fn test_withdraw_stacked_item_with_full_stack_in_inventory() { item: item::ItemDetail::Tool( item::tool::Tool { tool: item::tool::ToolType::Monomate, + wrapping: None, } ), location: item::ItemLocation::Inventory { @@ -1434,6 +1451,7 @@ async fn test_withdraw_stacked_item_in_full_inventory() { item: item::ItemDetail::Tool( item::tool::Tool { tool: item::tool::ToolType::Monomate, + wrapping: None, } ), location: item::ItemLocation::Bank { @@ -1516,6 +1534,7 @@ async fn test_withdraw_stacked_item_in_full_inventory_with_partial_stack() { item: item::ItemDetail::Tool( item::tool::Tool { tool: item::tool::ToolType::Monomate, + wrapping: None, } ), location: item::ItemLocation::Bank { @@ -1553,6 +1572,7 @@ async fn test_withdraw_stacked_item_in_full_inventory_with_partial_stack() { item: item::ItemDetail::Tool( item::tool::Tool { tool: item::tool::ToolType::Monomate, + wrapping: None, } ), location: item::ItemLocation::Inventory { diff --git a/tests/test_item_actions.rs b/tests/test_item_actions.rs index 1cbaf6d..3bc531a 100644 --- a/tests/test_item_actions.rs +++ b/tests/test_item_actions.rs @@ -37,6 +37,7 @@ async fn test_equip_unit_from_equip_menu() { item::unit::Unit{ unit: item::unit::UnitType::KnightPower, modifier: None, + wrapping: None, }), location: item::ItemLocation::Inventory { character_id: char1.id, @@ -49,6 +50,7 @@ async fn test_equip_unit_from_equip_menu() { item::unit::Unit{ unit: item::unit::UnitType::KnightPower, modifier: Some(item::unit::UnitModifier::Plus), + wrapping: None, }), location: item::ItemLocation::Inventory { character_id: char1.id, @@ -123,6 +125,7 @@ async fn test_unequip_armor_with_units() { item::unit::Unit{ unit: item::unit::UnitType::KnightPower, modifier: None, + wrapping: None, }), location: item::ItemLocation::Inventory { character_id: char1.id, @@ -135,6 +138,7 @@ async fn test_unequip_armor_with_units() { item::unit::Unit{ unit: item::unit::UnitType::KnightPower, modifier: Some(item::unit::UnitModifier::Plus), + wrapping: None, }), location: item::ItemLocation::Inventory { character_id: char1.id, @@ -200,6 +204,7 @@ async fn test_sort_items() { item::unit::Unit{ unit: item::unit::UnitType::KnightPower, modifier: None, + wrapping: None, }), location: item::ItemLocation::Inventory { character_id: char1.id, @@ -212,6 +217,7 @@ async fn test_sort_items() { item::unit::Unit{ unit: item::unit::UnitType::KnightPower, modifier: Some(item::unit::UnitModifier::Plus), + wrapping: None, }), location: item::ItemLocation::Inventory { character_id: char1.id, diff --git a/tests/test_item_pickup.rs b/tests/test_item_pickup.rs index 8359331..2aef112 100644 --- a/tests/test_item_pickup.rs +++ b/tests/test_item_pickup.rs @@ -22,7 +22,8 @@ async fn test_pick_up_item_stack_of_items_already_in_inventory() { item::NewItemEntity { item: item::ItemDetail::Tool( item::tool::Tool { - tool: item::tool::ToolType::Monomate + tool: item::tool::ToolType::Monomate, + wrapping: None, } ), location: item::ItemLocation::Inventory { @@ -38,7 +39,8 @@ async fn test_pick_up_item_stack_of_items_already_in_inventory() { item::NewItemEntity { item: item::ItemDetail::Tool( item::tool::Tool { - tool: tool + tool: tool, + wrapping: None, } ), location: item::ItemLocation::Inventory { @@ -104,7 +106,8 @@ async fn test_pick_up_item_stack_of_items_not_already_held() { item::NewItemEntity { item: item::ItemDetail::Tool( item::tool::Tool { - tool: item::tool::ToolType::Monomate + tool: item::tool::ToolType::Monomate, + wrapping: None, } ), location: item::ItemLocation::Inventory { @@ -266,6 +269,7 @@ async fn test_pick_up_partial_stacked_item_when_inventory_is_otherwise_full() { item: item::ItemDetail::Tool( item::tool::Tool { tool: item::tool::ToolType::Monomate, + wrapping: None, } ), location: item::ItemLocation::Inventory { @@ -279,6 +283,7 @@ async fn test_pick_up_partial_stacked_item_when_inventory_is_otherwise_full() { item: item::ItemDetail::Tool( item::tool::Tool { tool: item::tool::ToolType::Monomate, + wrapping: None, } ), location: item::ItemLocation::Inventory { @@ -480,6 +485,7 @@ async fn test_pick_up_stack_that_would_exceed_stack_limit() { item: item::ItemDetail::Tool( item::tool::Tool { tool: item::tool::ToolType::Monomate, + wrapping: None, } ), location: item::ItemLocation::Inventory { @@ -495,6 +501,7 @@ async fn test_pick_up_stack_that_would_exceed_stack_limit() { item: item::ItemDetail::Tool( item::tool::Tool { tool: item::tool::ToolType::Monomate, + wrapping: None, } ), location: item::ItemLocation::Inventory { @@ -675,6 +682,7 @@ async fn test_player_drops_partial_stack_and_other_player_picks_it_up() { item: item::ItemDetail::Tool( item::tool::Tool { tool: item::tool::ToolType::Monomate, + wrapping: None, } ), location: item::ItemLocation::Inventory { diff --git a/tests/test_item_use.rs b/tests/test_item_use.rs index 03cb935..ef80e82 100644 --- a/tests/test_item_use.rs +++ b/tests/test_item_use.rs @@ -26,7 +26,8 @@ async fn test_use_monomate() { item::NewItemEntity { item: item::ItemDetail::Tool( item::tool::Tool { - tool: tool + tool: tool, + wrapping: None, } ), location: item::ItemLocation::Inventory { @@ -76,7 +77,8 @@ async fn test_use_monomate_twice() { item::NewItemEntity { item: item::ItemDetail::Tool( item::tool::Tool { - tool: tool + tool: tool, + wrapping: None, } ), location: item::ItemLocation::Inventory { @@ -129,7 +131,8 @@ async fn test_use_last_monomate() { item::NewItemEntity { item: item::ItemDetail::Tool( item::tool::Tool { - tool: tool + tool: tool, + wrapping: None, } ), location: item::ItemLocation::Inventory { @@ -174,6 +177,7 @@ async fn test_use_nonstackable_tool() { item: item::ItemDetail::Tool( item::tool::Tool { tool: item::tool::ToolType::MagicStoneIritista, + wrapping: None, } ), location: item::ItemLocation::Inventory { @@ -214,7 +218,8 @@ async fn test_use_materials() { item::NewItemEntity { item: item::ItemDetail::Tool( item::tool::Tool { - tool: tool + tool: tool, + wrapping: None, } ), location: item::ItemLocation::Inventory { diff --git a/tests/test_mags.rs b/tests/test_mags.rs index 51675cf..0e5b1fa 100644 --- a/tests/test_mags.rs +++ b/tests/test_mags.rs @@ -35,6 +35,7 @@ async fn test_mag_feed() { item: item::ItemDetail::Tool( item::tool::Tool { tool: item::tool::ToolType::Monomate, + wrapping: None, } ), location: item::ItemLocation::Inventory { @@ -180,6 +181,7 @@ async fn test_mag_cell() { item: item::ItemDetail::Tool ( item::tool::Tool { tool: item::tool::ToolType::Monomate, + wrapping: None, } ), location: item::ItemLocation::FedToMag { @@ -193,6 +195,7 @@ async fn test_mag_cell() { item: item::ItemDetail::Tool( item::tool::Tool { tool: item::tool::ToolType::CellOfMag502, + wrapping: None, } ), location: item::ItemLocation::Inventory { diff --git a/tests/test_shops.rs b/tests/test_shops.rs index 79aa438..873488c 100644 --- a/tests/test_shops.rs +++ b/tests/test_shops.rs @@ -318,7 +318,8 @@ async fn test_other_clients_see_stacked_purchase() { item::NewItemEntity { item: item::ItemDetail::Tool( item::tool::Tool { - tool: item::tool::ToolType::Monomate + tool: item::tool::ToolType::Monomate, + wrapping: None, } ), location: item::ItemLocation::Inventory {