Browse Source

move equipped flag to itemlocation::inventory

pbs
jake 5 years ago
parent
commit
a7434346db
  1. 1
      src/entity/item/armor.rs
  2. 1
      src/entity/item/mag.rs
  3. 1
      src/entity/item/mod.rs
  4. 1
      src/entity/item/shield.rs
  5. 1
      src/entity/item/unit.rs
  6. 2
      src/entity/item/weapon.rs
  7. 8
      src/login/character.rs
  8. 2
      src/main.rs
  9. 5
      src/ship/drops/generic_armor.rs
  10. 5
      src/ship/drops/generic_shield.rs
  11. 2
      src/ship/drops/generic_unit.rs
  12. 5
      src/ship/drops/generic_weapon.rs
  13. 5
      src/ship/drops/rare_drop_table.rs
  14. 36
      src/ship/items.rs

1
src/entity/item/armor.rs

@ -194,7 +194,6 @@ pub struct Armor {
pub dfp: u8, pub dfp: u8,
pub evp: u8, pub evp: u8,
pub slots: u8, pub slots: u8,
pub equipped: bool,
} }
impl Armor { impl Armor {

1
src/entity/item/mag.rs

@ -185,7 +185,6 @@ pub struct Mag {
pub iq: u8, pub iq: u8,
pub photon_blast: [Option<PhotonBlast>; 3], pub photon_blast: [Option<PhotonBlast>; 3],
// color // color
pub equipped: bool,
} }

1
src/entity/item/mod.rs

@ -17,6 +17,7 @@ pub enum ItemLocation {
Inventory { Inventory {
character_id: u32, character_id: u32,
index: usize, index: usize,
equipped: bool,
}, },
Bank { Bank {
character_id: u32, character_id: u32,

1
src/entity/item/shield.rs

@ -347,7 +347,6 @@ pub struct Shield {
pub shield: ShieldType, pub shield: ShieldType,
pub dfp: u8, pub dfp: u8,
pub evp: u8, pub evp: u8,
pub equipped: bool,
} }
impl Shield { impl Shield {

1
src/entity/item/unit.rs

@ -224,7 +224,6 @@ pub enum UnitModifier {
pub struct Unit { pub struct Unit {
pub unit: UnitType, pub unit: UnitType,
pub modifier: Option<UnitModifier>, pub modifier: Option<UnitModifier>,
pub equipped: bool,
} }

2
src/entity/item/weapon.rs

@ -860,7 +860,6 @@ pub struct Weapon {
pub special: Option<WeaponSpecial>, pub special: Option<WeaponSpecial>,
pub grind: u8, pub grind: u8,
pub attrs: [Option<WeaponAttribute>; 3], pub attrs: [Option<WeaponAttribute>; 3],
pub equipped: bool,
pub tekked: bool, pub tekked: bool,
} }
@ -872,7 +871,6 @@ impl Weapon {
special: None, special: None,
grind: 0, grind: 0,
attrs: [None; 3], attrs: [None; 3],
equipped: false,
tekked: true, tekked: true,
} }
} }

8
src/login/character.rs

@ -212,12 +212,12 @@ fn new_character<EG: EntityGateway>(entity_gateway: &mut EG, user: &UserAccount,
grind: 0, grind: 0,
special: None, special: None,
attrs: [None; 3], attrs: [None; 3],
equipped: true,
tekked: true, tekked: true,
}), }),
ItemLocation::Inventory { ItemLocation::Inventory {
character_id: char.id, character_id: char.id,
index: 0, index: 0,
equipped: true,
}); });
entity_gateway.new_item( entity_gateway.new_item(
@ -227,11 +227,11 @@ fn new_character<EG: EntityGateway>(entity_gateway: &mut EG, user: &UserAccount,
dfp: 0, dfp: 0,
evp: 0, evp: 0,
slots: 0, slots: 0,
equipped: true,
}), }),
ItemLocation::Inventory { ItemLocation::Inventory {
character_id: char.id, character_id: char.id,
index: 1, index: 1,
equipped: true,
}); });
entity_gateway.new_item( entity_gateway.new_item(
@ -245,11 +245,11 @@ fn new_character<EG: EntityGateway>(entity_gateway: &mut EG, user: &UserAccount,
synchro: 20, synchro: 20,
iq: 0, iq: 0,
photon_blast: [None; 3], photon_blast: [None; 3],
equipped: true,
}), }),
ItemLocation::Inventory { ItemLocation::Inventory {
character_id: char.id, character_id: char.id,
index: 2, index: 2,
equipped: true,
}); });
for _ in 0..4 { for _ in 0..4 {
@ -261,6 +261,7 @@ fn new_character<EG: EntityGateway>(entity_gateway: &mut EG, user: &UserAccount,
ItemLocation::Inventory { ItemLocation::Inventory {
character_id: char.id, character_id: char.id,
index: 3, index: 3,
equipped: false,
}); });
entity_gateway.new_item( entity_gateway.new_item(
ItemDetail::Tool ( ItemDetail::Tool (
@ -270,6 +271,7 @@ fn new_character<EG: EntityGateway>(entity_gateway: &mut EG, user: &UserAccount,
ItemLocation::Inventory { ItemLocation::Inventory {
character_id: char.id, character_id: char.id,
index: 4, index: 4,
equipped: false,
}); });
} }
} }

2
src/main.rs

@ -89,13 +89,13 @@ fn main() {
grind: 5, grind: 5,
special: None, special: None,
attrs: [None; 3], attrs: [None; 3],
equipped: true,
tekked: true, tekked: true,
} }
), ),
ItemLocation::Inventory { ItemLocation::Inventory {
character_id: character.id, character_id: character.id,
index: 0, index: 0,
equipped: true,
} }
); );

5
src/ship/drops/generic_armor.rs

@ -108,7 +108,6 @@ impl GenericArmorTable {
dfp: dfp_modifier as u8, dfp: dfp_modifier as u8,
evp: evp_modifier as u8, evp: evp_modifier as u8,
slots: slots as u8, slots: slots as u8,
equipped: false,
})) }))
} }
} }
@ -127,28 +126,24 @@ mod test {
dfp: 0, dfp: 0,
evp: 0, evp: 0,
slots: 1, slots: 1,
equipped: false,
}))); })));
assert!(gat.get_drop(&MapVariantType::Caves3, &mut rng) == Some(ItemDetail::Armor(Armor { assert!(gat.get_drop(&MapVariantType::Caves3, &mut rng) == Some(ItemDetail::Armor(Armor {
armor: ArmorType::AbsorbArmor, armor: ArmorType::AbsorbArmor,
dfp: 1, dfp: 1,
evp: 1, evp: 1,
slots: 1, slots: 1,
equipped: false,
}))); })));
assert!(gat.get_drop(&MapVariantType::Forest2, &mut rng) == Some(ItemDetail::Armor(Armor { assert!(gat.get_drop(&MapVariantType::Forest2, &mut rng) == Some(ItemDetail::Armor(Armor {
armor: ArmorType::HyperFrame, armor: ArmorType::HyperFrame,
dfp: 0, dfp: 0,
evp: 0, evp: 0,
slots: 0, slots: 0,
equipped: false,
}))); })));
assert!(gat.get_drop(&MapVariantType::DarkFalz, &mut rng) == Some(ItemDetail::Armor(Armor { assert!(gat.get_drop(&MapVariantType::DarkFalz, &mut rng) == Some(ItemDetail::Armor(Armor {
armor: ArmorType::ImperialArmor, armor: ArmorType::ImperialArmor,
dfp: 2, dfp: 2,
evp: 1, evp: 1,
slots: 0, slots: 0,
equipped: false,
}))); })));
} }
} }

5
src/ship/drops/generic_shield.rs

@ -87,7 +87,6 @@ impl GenericShieldTable {
shield: shield_type, shield: shield_type,
dfp: dfp_modifier as u8, dfp: dfp_modifier as u8,
evp: evp_modifier as u8, evp: evp_modifier as u8,
equipped: false,
})) }))
} }
} }
@ -106,25 +105,21 @@ mod test {
shield: ShieldType::FreezeBarrier, shield: ShieldType::FreezeBarrier,
dfp: 4, dfp: 4,
evp: 1, evp: 1,
equipped: false,
}))); })));
assert!(gst.get_drop(&MapVariantType::Caves3, &mut rng) == Some(ItemDetail::Shield(Shield { assert!(gst.get_drop(&MapVariantType::Caves3, &mut rng) == Some(ItemDetail::Shield(Shield {
shield: ShieldType::PsychicBarrier, shield: ShieldType::PsychicBarrier,
dfp: 3, dfp: 3,
evp: 2, evp: 2,
equipped: false,
}))); })));
assert!(gst.get_drop(&MapVariantType::Mines2, &mut rng) == Some(ItemDetail::Shield(Shield { assert!(gst.get_drop(&MapVariantType::Mines2, &mut rng) == Some(ItemDetail::Shield(Shield {
shield: ShieldType::ImperialBarrier, shield: ShieldType::ImperialBarrier,
dfp: 0, dfp: 0,
evp: 4, evp: 4,
equipped: false,
}))); })));
assert!(gst.get_drop(&MapVariantType::DarkFalz, &mut rng) == Some(ItemDetail::Shield(Shield { assert!(gst.get_drop(&MapVariantType::DarkFalz, &mut rng) == Some(ItemDetail::Shield(Shield {
shield: ShieldType::DivinityBarrier, shield: ShieldType::DivinityBarrier,
dfp: 1, dfp: 1,
evp: 0, evp: 0,
equipped: false,
}))); })));
} }
} }

2
src/ship/drops/generic_unit.rs

@ -91,7 +91,6 @@ impl GenericUnitTable {
ItemDetail::Unit(Unit { ItemDetail::Unit(Unit {
unit: unit_type, unit: unit_type,
modifier: unit_modifier, modifier: unit_modifier,
equipped: false,
}) })
}) })
} }
@ -118,7 +117,6 @@ mod test {
assert!(gut.get_drop(&area, &mut rng) == Some(ItemDetail::Unit(Unit { assert!(gut.get_drop(&area, &mut rng) == Some(ItemDetail::Unit(Unit {
unit: unit, unit: unit,
modifier: umod, modifier: umod,
equipped: false,
}))); })));
} }
} }

5
src/ship/drops/generic_weapon.rs

@ -505,7 +505,6 @@ impl GenericWeaponTable {
special: weapon_special, special: weapon_special,
grind: weapon_grind as u8, grind: weapon_grind as u8,
attrs: weapon_attributes, attrs: weapon_attributes,
equipped: false,
tekked: weapon_special.is_none(), tekked: weapon_special.is_none(),
})) }))
} }
@ -526,7 +525,6 @@ mod test {
special: None, special: None,
grind: 0, grind: 0,
attrs: [None, None, None], attrs: [None, None, None],
equipped: false,
tekked: true, tekked: true,
}))); })));
@ -536,7 +534,6 @@ mod test {
special: None, special: None,
grind: 2, grind: 2,
attrs: [None, None, None], attrs: [None, None, None],
equipped: false,
tekked: true, tekked: true,
}))); })));
@ -546,7 +543,6 @@ mod test {
special: Some(WeaponSpecial::Berserk), special: Some(WeaponSpecial::Berserk),
grind: 0, grind: 0,
attrs: [None, None, None], attrs: [None, None, None],
equipped: false,
tekked: false, tekked: false,
}))); })));
@ -556,7 +552,6 @@ mod test {
special: None, special: None,
grind: 0, grind: 0,
attrs: [Some(WeaponAttribute {attr: Attribute::ABeast, value: 30}), Some(WeaponAttribute {attr: Attribute::Dark, value: 30}), None], attrs: [Some(WeaponAttribute {attr: Attribute::ABeast, value: 30}), Some(WeaponAttribute {attr: Attribute::Dark, value: 30}), None],
equipped: false,
tekked: true, tekked: true,
}))); })));
} }

5
src/ship/drops/rare_drop_table.rs

@ -104,7 +104,6 @@ impl RareDropTable {
special: None, special: None,
grind: 0, grind: 0,
attrs: self.attribute_table.generate_rare_attributes(map_area, rng), attrs: self.attribute_table.generate_rare_attributes(map_area, rng),
equipped: false,
tekked: false, tekked: false,
}) })
@ -115,7 +114,6 @@ impl RareDropTable {
dfp: self.armor_stats.dfp_modifier(&armor, rng) as u8, dfp: self.armor_stats.dfp_modifier(&armor, rng) as u8,
evp: self.armor_stats.evp_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, slots: self.armor_stats.slots(map_area, rng) as u8,
equipped: false,
}) })
}, },
RareDropItem::Shield(shield) => { RareDropItem::Shield(shield) => {
@ -123,14 +121,12 @@ impl RareDropTable {
shield: shield, shield: shield,
dfp: self.shield_stats.dfp_modifier(&shield, rng) as u8, dfp: self.shield_stats.dfp_modifier(&shield, rng) as u8,
evp: self.shield_stats.evp_modifier(&shield, rng) as u8, evp: self.shield_stats.evp_modifier(&shield, rng) as u8,
equipped: false,
}) })
}, },
RareDropItem::Unit(unit) => { RareDropItem::Unit(unit) => {
ItemDetail::Unit(Unit { ItemDetail::Unit(Unit {
unit: unit, unit: unit,
modifier: None, modifier: None,
equipped: false,
}) })
}, },
RareDropItem::Tool(tool) => { RareDropItem::Tool(tool) => {
@ -148,7 +144,6 @@ impl RareDropTable {
iq: 0, iq: 0,
synchro: 20, synchro: 20,
photon_blast: [None; 3], photon_blast: [None; 3],
equipped: false,
}) })
} }
} }

36
src/ship/items.rs

@ -68,20 +68,12 @@ impl ActiveInventory {
// does this do anything? // does this do anything?
inventory[index].equipped = match item.item { 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, _ => 0,
}; };
// because this actually equips the item // because this actually equips the item
inventory[index].flags |= match item.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, _ => 0,
}; };
inventory inventory
@ -189,13 +181,13 @@ mod test {
location: ItemLocation::Inventory { location: ItemLocation::Inventory {
character_id: 0, character_id: 0,
index: 0, index: 0,
equipped: false,
}, },
item: ItemDetail::Weapon(item::weapon::Weapon { item: ItemDetail::Weapon(item::weapon::Weapon {
weapon: item::weapon::WeaponType::Saber, weapon: item::weapon::WeaponType::Saber,
grind: 0, grind: 0,
special: None, special: None,
attrs: [None; 3], attrs: [None; 3],
equipped: false,
tekked: true, tekked: true,
}) })
}; };
@ -203,7 +195,8 @@ mod test {
id: ItemEntityId(2), id: ItemEntityId(2),
location: ItemLocation::Inventory { location: ItemLocation::Inventory {
character_id: 0, character_id: 0,
index: 1
index: 1,
equipped: false,
}, },
item: ItemDetail::Tool(Tool { item: ItemDetail::Tool(Tool {
tool: item::tool::ToolType::Monofluid, tool: item::tool::ToolType::Monofluid,
@ -214,13 +207,13 @@ mod test {
location: ItemLocation::Inventory { location: ItemLocation::Inventory {
character_id: 0, character_id: 0,
index: 2, index: 2,
equipped: false,
}, },
item: ItemDetail::Weapon(item::weapon::Weapon { item: ItemDetail::Weapon(item::weapon::Weapon {
weapon: item::weapon::WeaponType::Handgun, weapon: item::weapon::WeaponType::Handgun,
grind: 12, grind: 12,
special: None, special: None,
attrs: [None; 3], attrs: [None; 3],
equipped: false,
tekked: true, tekked: true,
}) })
}; };
@ -228,7 +221,8 @@ mod test {
id: ItemEntityId(4), id: ItemEntityId(4),
location: ItemLocation::Inventory { location: ItemLocation::Inventory {
character_id: 0, character_id: 0,
index: 1
index: 1,
equipped: false,
}, },
item: ItemDetail::Tool(Tool { item: ItemDetail::Tool(Tool {
tool: item::tool::ToolType::Monofluid, tool: item::tool::ToolType::Monofluid,
@ -238,7 +232,8 @@ mod test {
id: ItemEntityId(5), id: ItemEntityId(5),
location: ItemLocation::Inventory { location: ItemLocation::Inventory {
character_id: 0, character_id: 0,
index: 1
index: 1,
equipped: false,
}, },
item: ItemDetail::Tool(Tool { item: ItemDetail::Tool(Tool {
tool: item::tool::ToolType::Monofluid, tool: item::tool::ToolType::Monofluid,
@ -249,13 +244,13 @@ mod test {
location: ItemLocation::Inventory { location: ItemLocation::Inventory {
character_id: 0, character_id: 0,
index: 3, index: 3,
equipped: false,
}, },
item: ItemDetail::Weapon(item::weapon::Weapon { item: ItemDetail::Weapon(item::weapon::Weapon {
weapon: item::weapon::WeaponType::Handgun, weapon: item::weapon::WeaponType::Handgun,
grind: 12, grind: 12,
special: None, special: None,
attrs: [None; 3], attrs: [None; 3],
equipped: false,
tekked: true, tekked: true,
}) })
}; };
@ -263,7 +258,8 @@ mod test {
id: ItemEntityId(7), id: ItemEntityId(7),
location: ItemLocation::Inventory { location: ItemLocation::Inventory {
character_id: 0, character_id: 0,
index: 4
index: 4,
equipped: false,
}, },
item: ItemDetail::Tool(Tool { item: ItemDetail::Tool(Tool {
tool: item::tool::ToolType::Monomate, tool: item::tool::ToolType::Monomate,
@ -273,7 +269,8 @@ mod test {
id: ItemEntityId(8), id: ItemEntityId(8),
location: ItemLocation::Inventory { location: ItemLocation::Inventory {
character_id: 0, character_id: 0,
index: 4
index: 4,
equipped: false,
}, },
item: ItemDetail::Tool(Tool { item: ItemDetail::Tool(Tool {
tool: item::tool::ToolType::Monomate, tool: item::tool::ToolType::Monomate,
@ -283,7 +280,8 @@ mod test {
id: ItemEntityId(9), id: ItemEntityId(9),
location: ItemLocation::Inventory { location: ItemLocation::Inventory {
character_id: 0, character_id: 0,
index: 4
index: 4,
equipped: false,
}, },
item: ItemDetail::Tool(Tool { item: ItemDetail::Tool(Tool {
tool: item::tool::ToolType::Monomate, tool: item::tool::ToolType::Monomate,

Loading…
Cancel
Save