From a7434346db1a49fd3a90939e1bf5d2357f757bc5 Mon Sep 17 00:00:00 2001 From: jake Date: Sun, 29 Mar 2020 10:45:01 -0700 Subject: [PATCH] move equipped flag to itemlocation::inventory --- src/entity/item/armor.rs | 1 - src/entity/item/mag.rs | 1 - src/entity/item/mod.rs | 1 + src/entity/item/shield.rs | 1 - src/entity/item/unit.rs | 1 - src/entity/item/weapon.rs | 2 -- src/login/character.rs | 8 ++++--- src/main.rs | 2 +- src/ship/drops/generic_armor.rs | 5 ----- src/ship/drops/generic_shield.rs | 5 ----- src/ship/drops/generic_unit.rs | 2 -- src/ship/drops/generic_weapon.rs | 5 ----- src/ship/drops/rare_drop_table.rs | 5 ----- src/ship/items.rs | 36 +++++++++++++++---------------- 14 files changed, 24 insertions(+), 51 deletions(-) diff --git a/src/entity/item/armor.rs b/src/entity/item/armor.rs index 50283ab..d37bce0 100644 --- a/src/entity/item/armor.rs +++ b/src/entity/item/armor.rs @@ -194,7 +194,6 @@ pub struct Armor { pub dfp: u8, pub evp: u8, pub slots: u8, - pub equipped: bool, } impl Armor { diff --git a/src/entity/item/mag.rs b/src/entity/item/mag.rs index 3ceab08..7aa9583 100644 --- a/src/entity/item/mag.rs +++ b/src/entity/item/mag.rs @@ -185,7 +185,6 @@ pub struct Mag { pub iq: u8, pub photon_blast: [Option; 3], // color - pub equipped: bool, } diff --git a/src/entity/item/mod.rs b/src/entity/item/mod.rs index 1516cee..3c0cb13 100644 --- a/src/entity/item/mod.rs +++ b/src/entity/item/mod.rs @@ -17,6 +17,7 @@ pub enum ItemLocation { Inventory { character_id: u32, index: usize, + equipped: bool, }, Bank { character_id: u32, diff --git a/src/entity/item/shield.rs b/src/entity/item/shield.rs index b324665..3eb5e30 100644 --- a/src/entity/item/shield.rs +++ b/src/entity/item/shield.rs @@ -347,7 +347,6 @@ pub struct Shield { pub shield: ShieldType, pub dfp: u8, pub evp: u8, - pub equipped: bool, } impl Shield { diff --git a/src/entity/item/unit.rs b/src/entity/item/unit.rs index cb9945f..617e79d 100644 --- a/src/entity/item/unit.rs +++ b/src/entity/item/unit.rs @@ -224,7 +224,6 @@ pub enum UnitModifier { pub struct Unit { pub unit: UnitType, pub modifier: Option, - pub equipped: bool, } diff --git a/src/entity/item/weapon.rs b/src/entity/item/weapon.rs index a1d1cd5..3cc2db9 100644 --- a/src/entity/item/weapon.rs +++ b/src/entity/item/weapon.rs @@ -860,7 +860,6 @@ pub struct Weapon { pub special: Option, pub grind: u8, pub attrs: [Option; 3], - pub equipped: bool, pub tekked: bool, } @@ -872,7 +871,6 @@ impl Weapon { special: None, grind: 0, attrs: [None; 3], - equipped: false, tekked: true, } } diff --git a/src/login/character.rs b/src/login/character.rs index ce8bbd4..818aeb1 100644 --- a/src/login/character.rs +++ b/src/login/character.rs @@ -212,12 +212,12 @@ fn new_character(entity_gateway: &mut EG, user: &UserAccount, grind: 0, special: None, attrs: [None; 3], - equipped: true, tekked: true, }), ItemLocation::Inventory { character_id: char.id, index: 0, + equipped: true, }); entity_gateway.new_item( @@ -227,11 +227,11 @@ fn new_character(entity_gateway: &mut EG, user: &UserAccount, dfp: 0, evp: 0, slots: 0, - equipped: true, }), ItemLocation::Inventory { character_id: char.id, index: 1, + equipped: true, }); entity_gateway.new_item( @@ -245,11 +245,11 @@ fn new_character(entity_gateway: &mut EG, user: &UserAccount, synchro: 20, iq: 0, photon_blast: [None; 3], - equipped: true, }), ItemLocation::Inventory { character_id: char.id, index: 2, + equipped: true, }); for _ in 0..4 { @@ -261,6 +261,7 @@ fn new_character(entity_gateway: &mut EG, user: &UserAccount, ItemLocation::Inventory { character_id: char.id, index: 3, + equipped: false, }); entity_gateway.new_item( ItemDetail::Tool ( @@ -270,6 +271,7 @@ fn new_character(entity_gateway: &mut EG, user: &UserAccount, ItemLocation::Inventory { character_id: char.id, index: 4, + equipped: false, }); } } diff --git a/src/main.rs b/src/main.rs index 105ad5a..3d506e1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -89,13 +89,13 @@ fn main() { grind: 5, special: None, attrs: [None; 3], - equipped: true, tekked: true, } ), ItemLocation::Inventory { character_id: character.id, index: 0, + equipped: true, } ); diff --git a/src/ship/drops/generic_armor.rs b/src/ship/drops/generic_armor.rs index cebf4e7..d24105c 100644 --- a/src/ship/drops/generic_armor.rs +++ b/src/ship/drops/generic_armor.rs @@ -108,7 +108,6 @@ impl GenericArmorTable { dfp: dfp_modifier as u8, evp: evp_modifier as u8, slots: slots as u8, - equipped: false, })) } } @@ -127,28 +126,24 @@ mod test { dfp: 0, evp: 0, slots: 1, - equipped: false, }))); assert!(gat.get_drop(&MapVariantType::Caves3, &mut rng) == Some(ItemDetail::Armor(Armor { armor: ArmorType::AbsorbArmor, dfp: 1, evp: 1, slots: 1, - equipped: false, }))); assert!(gat.get_drop(&MapVariantType::Forest2, &mut rng) == Some(ItemDetail::Armor(Armor { armor: ArmorType::HyperFrame, dfp: 0, evp: 0, slots: 0, - equipped: false, }))); assert!(gat.get_drop(&MapVariantType::DarkFalz, &mut rng) == Some(ItemDetail::Armor(Armor { armor: ArmorType::ImperialArmor, dfp: 2, evp: 1, slots: 0, - equipped: false, }))); } } diff --git a/src/ship/drops/generic_shield.rs b/src/ship/drops/generic_shield.rs index a9e34a3..94d36fa 100644 --- a/src/ship/drops/generic_shield.rs +++ b/src/ship/drops/generic_shield.rs @@ -87,7 +87,6 @@ impl GenericShieldTable { shield: shield_type, dfp: dfp_modifier as u8, evp: evp_modifier as u8, - equipped: false, })) } } @@ -106,25 +105,21 @@ mod test { shield: ShieldType::FreezeBarrier, dfp: 4, evp: 1, - equipped: false, }))); assert!(gst.get_drop(&MapVariantType::Caves3, &mut rng) == Some(ItemDetail::Shield(Shield { shield: ShieldType::PsychicBarrier, dfp: 3, evp: 2, - equipped: false, }))); assert!(gst.get_drop(&MapVariantType::Mines2, &mut rng) == Some(ItemDetail::Shield(Shield { shield: ShieldType::ImperialBarrier, dfp: 0, evp: 4, - equipped: false, }))); assert!(gst.get_drop(&MapVariantType::DarkFalz, &mut rng) == Some(ItemDetail::Shield(Shield { shield: ShieldType::DivinityBarrier, dfp: 1, evp: 0, - equipped: false, }))); } } diff --git a/src/ship/drops/generic_unit.rs b/src/ship/drops/generic_unit.rs index 39a5474..3124583 100644 --- a/src/ship/drops/generic_unit.rs +++ b/src/ship/drops/generic_unit.rs @@ -91,7 +91,6 @@ impl GenericUnitTable { ItemDetail::Unit(Unit { unit: unit_type, modifier: unit_modifier, - equipped: false, }) }) } @@ -118,7 +117,6 @@ mod test { assert!(gut.get_drop(&area, &mut rng) == Some(ItemDetail::Unit(Unit { unit: unit, modifier: umod, - equipped: false, }))); } } diff --git a/src/ship/drops/generic_weapon.rs b/src/ship/drops/generic_weapon.rs index 07db115..4b583e7 100644 --- a/src/ship/drops/generic_weapon.rs +++ b/src/ship/drops/generic_weapon.rs @@ -505,7 +505,6 @@ impl GenericWeaponTable { special: weapon_special, grind: weapon_grind as u8, attrs: weapon_attributes, - equipped: false, tekked: weapon_special.is_none(), })) } @@ -526,7 +525,6 @@ mod test { special: None, grind: 0, attrs: [None, None, None], - equipped: false, tekked: true, }))); @@ -536,7 +534,6 @@ mod test { special: None, grind: 2, attrs: [None, None, None], - equipped: false, tekked: true, }))); @@ -546,7 +543,6 @@ mod test { special: Some(WeaponSpecial::Berserk), grind: 0, attrs: [None, None, None], - equipped: false, tekked: false, }))); @@ -556,7 +552,6 @@ mod test { special: None, grind: 0, attrs: [Some(WeaponAttribute {attr: Attribute::ABeast, value: 30}), Some(WeaponAttribute {attr: Attribute::Dark, value: 30}), None], - equipped: false, tekked: true, }))); } diff --git a/src/ship/drops/rare_drop_table.rs b/src/ship/drops/rare_drop_table.rs index fc42d8d..b092b63 100644 --- a/src/ship/drops/rare_drop_table.rs +++ b/src/ship/drops/rare_drop_table.rs @@ -104,7 +104,6 @@ impl RareDropTable { special: None, grind: 0, attrs: self.attribute_table.generate_rare_attributes(map_area, rng), - equipped: false, tekked: false, }) @@ -115,7 +114,6 @@ impl RareDropTable { dfp: self.armor_stats.dfp_modifier(&armor, rng) as u8, evp: self.armor_stats.evp_modifier(&armor, rng) as u8, slots: self.armor_stats.slots(map_area, rng) as u8, - equipped: false, }) }, RareDropItem::Shield(shield) => { @@ -123,14 +121,12 @@ impl RareDropTable { shield: shield, dfp: self.shield_stats.dfp_modifier(&shield, rng) as u8, evp: self.shield_stats.evp_modifier(&shield, rng) as u8, - equipped: false, }) }, RareDropItem::Unit(unit) => { ItemDetail::Unit(Unit { unit: unit, modifier: None, - equipped: false, }) }, RareDropItem::Tool(tool) => { @@ -148,7 +144,6 @@ impl RareDropTable { iq: 0, synchro: 20, photon_blast: [None; 3], - equipped: false, }) } } diff --git a/src/ship/items.rs b/src/ship/items.rs index cc75e3e..838ae66 100644 --- a/src/ship/items.rs +++ b/src/ship/items.rs @@ -68,20 +68,12 @@ impl ActiveInventory { // does this do anything? inventory[index].equipped = match item.item { - StackedItem::Individual(Item {item: ItemDetail::Weapon(Weapon {equipped: true, ..}), ..}) => 1, - StackedItem::Individual(Item {item: ItemDetail::Armor(Armor {equipped: true, ..}), ..}) => 1, - StackedItem::Individual(Item {item: ItemDetail::Shield(Shield {equipped: true, ..}), ..}) => 1, - StackedItem::Individual(Item {item: ItemDetail::Unit(Unit{equipped: true, ..}), ..}) => 1, - StackedItem::Individual(Item {item: ItemDetail::Mag(Mag{equipped: true, ..}), ..}) => 1, + StackedItem::Individual(Item {location: ItemLocation::Inventory{ equipped: true, ..}, ..}) => 1, _ => 0, }; // because this actually equips the item inventory[index].flags |= match item.item { - StackedItem::Individual(Item {item: ItemDetail::Weapon(Weapon {equipped: true, ..}), ..}) => 8, - StackedItem::Individual(Item {item: ItemDetail::Armor(Armor {equipped: true, ..}), ..}) => 8, - StackedItem::Individual(Item {item: ItemDetail::Shield(Shield {equipped: true, ..}), ..}) => 8, - StackedItem::Individual(Item {item: ItemDetail::Unit(Unit {equipped: true, ..}), ..}) => 8, - StackedItem::Individual(Item {item: ItemDetail::Mag(Mag{equipped: true, ..}), ..}) => 8, + StackedItem::Individual(Item {location: ItemLocation::Inventory{ equipped: true, ..}, ..}) => 8, _ => 0, }; inventory @@ -189,13 +181,13 @@ mod test { location: ItemLocation::Inventory { character_id: 0, index: 0, + equipped: false, }, item: ItemDetail::Weapon(item::weapon::Weapon { weapon: item::weapon::WeaponType::Saber, grind: 0, special: None, attrs: [None; 3], - equipped: false, tekked: true, }) }; @@ -203,7 +195,8 @@ mod test { id: ItemEntityId(2), location: ItemLocation::Inventory { character_id: 0, - index: 1 + index: 1, + equipped: false, }, item: ItemDetail::Tool(Tool { tool: item::tool::ToolType::Monofluid, @@ -214,13 +207,13 @@ mod test { location: ItemLocation::Inventory { character_id: 0, index: 2, + equipped: false, }, item: ItemDetail::Weapon(item::weapon::Weapon { weapon: item::weapon::WeaponType::Handgun, grind: 12, special: None, attrs: [None; 3], - equipped: false, tekked: true, }) }; @@ -228,7 +221,8 @@ mod test { id: ItemEntityId(4), location: ItemLocation::Inventory { character_id: 0, - index: 1 + index: 1, + equipped: false, }, item: ItemDetail::Tool(Tool { tool: item::tool::ToolType::Monofluid, @@ -238,7 +232,8 @@ mod test { id: ItemEntityId(5), location: ItemLocation::Inventory { character_id: 0, - index: 1 + index: 1, + equipped: false, }, item: ItemDetail::Tool(Tool { tool: item::tool::ToolType::Monofluid, @@ -249,13 +244,13 @@ mod test { location: ItemLocation::Inventory { character_id: 0, index: 3, + equipped: false, }, item: ItemDetail::Weapon(item::weapon::Weapon { weapon: item::weapon::WeaponType::Handgun, grind: 12, special: None, attrs: [None; 3], - equipped: false, tekked: true, }) }; @@ -263,7 +258,8 @@ mod test { id: ItemEntityId(7), location: ItemLocation::Inventory { character_id: 0, - index: 4 + index: 4, + equipped: false, }, item: ItemDetail::Tool(Tool { tool: item::tool::ToolType::Monomate, @@ -273,7 +269,8 @@ mod test { id: ItemEntityId(8), location: ItemLocation::Inventory { character_id: 0, - index: 4 + index: 4, + equipped: false, }, item: ItemDetail::Tool(Tool { tool: item::tool::ToolType::Monomate, @@ -283,7 +280,8 @@ mod test { id: ItemEntityId(9), location: ItemLocation::Inventory { character_id: 0, - index: 4 + index: 4, + equipped: false, }, item: ItemDetail::Tool(Tool { tool: item::tool::ToolType::Monomate,