Browse Source

wrap everything except armours

presents
andy 4 years ago
parent
commit
98b2ebfdd8
  1. 13
      data/quests.toml
  2. 9
      src/bin/main.rs
  3. 23
      src/entity/gateway/postgres/models.rs
  4. 1
      src/entity/item/armor.rs
  5. 18
      src/entity/item/esweapon.rs
  6. 18
      src/entity/item/mag.rs
  7. 2
      src/entity/item/mod.rs
  8. 13
      src/entity/item/shield.rs
  9. 5
      src/entity/item/tech.rs
  10. 11
      src/entity/item/tool.rs
  11. 16
      src/entity/item/unit.rs
  12. 38
      src/entity/item/weapon.rs
  13. 2
      src/login/character.rs
  14. 5
      src/ship/drops/generic_shield.rs
  15. 2
      src/ship/drops/generic_unit.rs
  16. 3
      src/ship/drops/rare_drop_table.rs
  17. 6
      src/ship/drops/tech_table.rs
  18. 3
      src/ship/drops/tool_table.rs
  19. 2
      src/ship/packet/builder/quest.rs
  20. 2
      src/ship/shops/armor.rs
  21. 15
      src/ship/shops/tool.rs
  22. 20
      tests/test_bank.rs
  23. 6
      tests/test_item_actions.rs
  24. 14
      tests/test_item_pickup.rs
  25. 13
      tests/test_item_use.rs
  26. 3
      tests/test_mags.rs
  27. 3
      tests/test_shops.rs

13
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"
#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"

9
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 {

23
src/entity/gateway/postgres/models.rs

@ -335,6 +335,7 @@ pub struct PgArmor {
dfp: u8,
evp: u8,
slots: u8,
// wrapping: Option<WrappingPaper>, // TODO: check if this clobbers slots
}
impl From<armor::Armor> for PgArmor {
@ -344,6 +345,7 @@ impl From<armor::Armor> for PgArmor {
dfp: other.dfp,
evp: other.evp,
slots: other.slots,
// wrapping: other.wrapping,
}
}
}
@ -355,6 +357,7 @@ impl Into<armor::Armor> 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<WrappingPaper>,
}
impl From<shield::Shield> for PgShield {
@ -372,6 +376,7 @@ impl From<shield::Shield> for PgShield {
shield: other.shield,
dfp: other.dfp,
evp: other.evp,
wrapping: other.wrapping,
}
}
}
@ -382,6 +387,7 @@ impl Into<shield::Shield> for PgShield {
shield: self.shield,
dfp: self.dfp,
evp: self.evp,
wrapping: self.wrapping,
}
}
}
@ -390,6 +396,7 @@ impl Into<shield::Shield> for PgShield {
pub struct PgUnit {
unit: unit::UnitType,
modifier: Option<unit::UnitModifier>,
wrapping: Option<WrappingPaper>,
}
impl From<unit::Unit> for PgUnit {
@ -397,6 +404,7 @@ impl From<unit::Unit> for PgUnit {
PgUnit {
unit: other.unit,
modifier: other.modifier,
wrapping: other.wrapping,
}
}
}
@ -406,6 +414,7 @@ impl Into<unit::Unit> for PgUnit {
unit::Unit {
unit: self.unit,
modifier: self.modifier,
wrapping: self.wrapping,
}
}
}
@ -413,12 +422,14 @@ impl Into<unit::Unit> for PgUnit {
#[derive(Debug, Serialize, Deserialize)]
pub struct PgTool {
pub tool: tool::ToolType,
wrapping: Option<WrappingPaper>,
}
impl From<tool::Tool> for PgTool {
fn from(other: tool::Tool) -> PgTool {
PgTool {
tool: other.tool,
wrapping: other.wrapping,
}
}
}
@ -427,6 +438,7 @@ impl Into<tool::Tool> for PgTool {
fn into(self) -> tool::Tool {
tool::Tool {
tool: self.tool,
wrapping: self.wrapping,
}
}
}
@ -435,6 +447,7 @@ impl Into<tool::Tool> for PgTool {
pub struct PgTechDisk {
tech: tech::Technique,
level: u32,
wrapping: Option<WrappingPaper>,
}
impl From<tech::TechniqueDisk> for PgTechDisk {
@ -442,6 +455,7 @@ impl From<tech::TechniqueDisk> for PgTechDisk {
PgTechDisk {
tech: other.tech,
level: other.level,
wrapping: other.wrapping,
}
}
}
@ -450,7 +464,8 @@ impl Into<tech::TechniqueDisk> 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<WrappingPaper>,
}
impl From<mag::Mag> for PgMag {
@ -468,6 +484,7 @@ impl From<mag::Mag> for PgMag {
mag: other.mag,
synchro: other.synchro,
color: other.color,
wrapping: other.wrapping,
}
}
}
@ -490,6 +507,7 @@ impl Into<mag::Mag> 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<esweapon::ESWeaponSpecial>,
name: String,
grind: u8,
wrapping: Option<WrappingPaper>,
}
impl From<esweapon::ESWeapon> for PgESWeapon {
@ -509,6 +528,7 @@ impl From<esweapon::ESWeapon> for PgESWeapon {
special: other.special,
name: other.name,
grind: other.grind,
wrapping: other.wrapping,
}
}
}
@ -520,6 +540,7 @@ impl Into<esweapon::ESWeapon> for PgESWeapon {
special: self.special,
name: self.name,
grind: self.grind,
wrapping: self.wrapping,
}
}
}

1
src/entity/item/armor.rs

@ -303,6 +303,7 @@ pub struct Armor {
pub dfp: u8,
pub evp: u8,
pub slots: u8,
// pub wrapping: Option<WrappingPaper>, // clobbers slots
}
impl Armor {

18
src/entity/item/esweapon.rs

@ -176,6 +176,7 @@ pub struct ESWeapon {
pub special: Option<ESWeaponSpecial>,
pub name: String,
pub grind: u8,
pub wrapping: Option<WrappingPaper>
}
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]);

18
src/entity/item/mag.rs

@ -543,6 +543,7 @@ pub struct Mag {
//modifiers: Vec<MagModifier>,
pub class: CharacterClass,
pub id: SectionID,
pub wrapping: Option<WrappingPaper>,
}
@ -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,
});
}

2
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

13
src/entity/item/shield.rs

@ -525,12 +525,17 @@ pub struct Shield {
pub shield: ShieldType,
pub dfp: u8,
pub evp: u8,
pub wrapping: Option<WrappingPaper>,
}
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<Shield, ItemParseError> {
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 {

5
src/entity/item/tech.rs

@ -80,6 +80,7 @@ impl Technique {
pub struct TechniqueDisk {
pub tech: Technique,
pub level: u32,
pub wrapping: Option<WrappingPaper>, // 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
}
}

11
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<WrappingPaper>, // 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<Tool, ItemParseError> {
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 {

16
src/entity/item/unit.rs

@ -336,6 +336,7 @@ pub enum UnitModifier {
pub struct Unit {
pub unit: UnitType,
pub modifier: Option<UnitModifier>,
pub wrapping: Option<WrappingPaper>,
}
@ -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 {

38
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<WrappingPaper> {
// 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,

2
src/login/character.rs

@ -261,6 +261,7 @@ async fn new_character<EG: EntityGateway>(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<EG: EntityGateway>(entity_gateway: &mut EG, user: &UserAc
item: ItemDetail::Tool (
Tool {
tool: item::tool::ToolType::Monofluid,
wrapping: None,
}),
location: ItemLocation::Inventory {
character_id: character.id,

5
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,
})));
}
}

2
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,
})));
}
}

3
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) => {

6
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,
})));
}
}

3
src/ship/drops/tool_table.rs

@ -158,7 +158,8 @@ impl ToolTable {
};
Some(ItemDropType::Tool(Tool {
tool: tool_type
tool: tool_type,
wrapping: None,
}))
}
}

2
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<Quest>) -> 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();

2
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,
})
},
}

15
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<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(),
};
@ -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<R: Rng + SeedableRng> ToolShop<R> {
ToolShopItem::Tech(TechniqueDisk {
tech: tech,
level: level as u32,
wrapping: None,
})
})
.collect()

20
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 {

6
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,

14
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 {

13
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 {

3
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 {

3
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 {

Loading…
Cancel
Save