remove armor midstruct
This commit is contained in:
parent
76829dd16d
commit
e72caebbf8
@ -194,6 +194,7 @@ 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 {
|
||||||
|
@ -35,13 +35,6 @@ pub enum ItemLocation {
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
|
||||||
pub struct Armor {
|
|
||||||
pub equipped: bool,
|
|
||||||
pub armor: armor::Armor,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq)]
|
||||||
pub struct Shield {
|
pub struct Shield {
|
||||||
pub equipped: bool,
|
pub equipped: bool,
|
||||||
@ -70,7 +63,7 @@ impl Tool {
|
|||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq)]
|
||||||
pub enum ItemDetail {
|
pub enum ItemDetail {
|
||||||
Weapon(weapon::Weapon),
|
Weapon(weapon::Weapon),
|
||||||
Armor(Armor),
|
Armor(armor::Armor),
|
||||||
Shield(Shield),
|
Shield(Shield),
|
||||||
Unit(Unit),
|
Unit(Unit),
|
||||||
Tool(Tool),
|
Tool(Tool),
|
||||||
@ -87,7 +80,7 @@ impl ItemDetail {
|
|||||||
pub fn as_bytes(&self) -> [u8; 16] {
|
pub fn as_bytes(&self) -> [u8; 16] {
|
||||||
match self {
|
match self {
|
||||||
ItemDetail::Weapon(weapon) => weapon.as_bytes(),
|
ItemDetail::Weapon(weapon) => weapon.as_bytes(),
|
||||||
ItemDetail::Armor(armor) => armor.armor.as_bytes(),
|
ItemDetail::Armor(armor) => armor.as_bytes(),
|
||||||
ItemDetail::Shield(shield) => shield.shield.as_bytes(),
|
ItemDetail::Shield(shield) => shield.shield.as_bytes(),
|
||||||
ItemDetail::Unit(unit) => unit.unit.as_bytes(),
|
ItemDetail::Unit(unit) => unit.unit.as_bytes(),
|
||||||
ItemDetail::Tool(tool) => tool.as_bytes(),
|
ItemDetail::Tool(tool) => tool.as_bytes(),
|
||||||
|
@ -17,8 +17,9 @@ use libpso::{utf8_to_array, utf8_to_utf16_array};
|
|||||||
|
|
||||||
use crate::entity::gateway::EntityGateway;
|
use crate::entity::gateway::EntityGateway;
|
||||||
use crate::entity::account::{UserAccount, USERFLAG_NEWCHAR, USERFLAG_DRESSINGROOM};
|
use crate::entity::account::{UserAccount, USERFLAG_NEWCHAR, USERFLAG_DRESSINGROOM};
|
||||||
use crate::entity::item::{ItemDetail, ItemLocation, Armor, Tool};
|
use crate::entity::item::{ItemDetail, ItemLocation, Tool};
|
||||||
use crate::entity::item::weapon::Weapon;
|
use crate::entity::item::weapon::Weapon;
|
||||||
|
use crate::entity::item::armor::Armor;
|
||||||
use crate::entity::character::{Character, CharacterClass, Technique, TechLevel};
|
use crate::entity::character::{Character, CharacterClass, Technique, TechLevel};
|
||||||
|
|
||||||
use crate::login::login::get_login_status;
|
use crate::login::login::get_login_status;
|
||||||
@ -219,13 +220,11 @@ fn new_character<EG: EntityGateway>(entity_gateway: &mut EG, user: &UserAccount,
|
|||||||
entity_gateway.new_item(
|
entity_gateway.new_item(
|
||||||
ItemDetail::Armor (
|
ItemDetail::Armor (
|
||||||
Armor {
|
Armor {
|
||||||
|
armor: item::armor::ArmorType::Frame,
|
||||||
|
dfp: 0,
|
||||||
|
evp: 0,
|
||||||
|
slots: 0,
|
||||||
equipped: true,
|
equipped: true,
|
||||||
armor: item::armor::Armor {
|
|
||||||
armor: item::armor::ArmorType::Frame,
|
|
||||||
dfp: 0,
|
|
||||||
evp: 0,
|
|
||||||
slots: 0,
|
|
||||||
}
|
|
||||||
}),
|
}),
|
||||||
ItemLocation::Inventory {
|
ItemLocation::Inventory {
|
||||||
character_id: char.id,
|
character_id: char.id,
|
||||||
|
@ -3,7 +3,7 @@ use serde::{Serialize, Deserialize};
|
|||||||
use rand::{Rng, SeedableRng};
|
use rand::{Rng, SeedableRng};
|
||||||
use rand::distributions::{WeightedIndex, Distribution};
|
use rand::distributions::{WeightedIndex, Distribution};
|
||||||
|
|
||||||
use crate::entity::item::{ItemDetail, Armor as ArmorDetail};
|
use crate::entity::item::ItemDetail;
|
||||||
use crate::entity::item::armor::{ArmorType, Armor};
|
use crate::entity::item::armor::{ArmorType, Armor};
|
||||||
use crate::ship::room::{Difficulty, Episode};
|
use crate::ship::room::{Difficulty, Episode};
|
||||||
use crate::ship::map::MapVariantType;
|
use crate::ship::map::MapVariantType;
|
||||||
@ -105,14 +105,12 @@ impl GenericArmorTable {
|
|||||||
let evp_modifier = self.dfp_modifier(&armor_type, rng);
|
let evp_modifier = self.dfp_modifier(&armor_type, rng);
|
||||||
|
|
||||||
|
|
||||||
Some(ItemDetail::Armor(ArmorDetail {
|
Some(ItemDetail::Armor(Armor {
|
||||||
|
armor: armor_type,
|
||||||
|
dfp: dfp_modifier as u8,
|
||||||
|
evp: evp_modifier as u8,
|
||||||
|
slots: slots as u8,
|
||||||
equipped: false,
|
equipped: false,
|
||||||
armor: Armor {
|
|
||||||
armor: armor_type,
|
|
||||||
dfp: dfp_modifier as u8,
|
|
||||||
evp: evp_modifier as u8,
|
|
||||||
slots: slots as u8
|
|
||||||
}
|
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -126,41 +124,33 @@ mod test {
|
|||||||
let mut rng = rand_chacha::ChaCha20Rng::from_seed([23;32]);
|
let mut rng = rand_chacha::ChaCha20Rng::from_seed([23;32]);
|
||||||
|
|
||||||
let gat = GenericArmorTable::new(Episode::One, Difficulty::Ultimate, SectionID::Skyly);
|
let gat = GenericArmorTable::new(Episode::One, Difficulty::Ultimate, SectionID::Skyly);
|
||||||
assert!(gat.get_drop(&MapVariantType::Mines1, &mut rng) == Some(ItemDetail::Armor(ArmorDetail {
|
assert!(gat.get_drop(&MapVariantType::Mines1, &mut rng) == Some(ItemDetail::Armor(Armor {
|
||||||
|
armor: ArmorType::GeneralArmor,
|
||||||
|
dfp: 0,
|
||||||
|
evp: 0,
|
||||||
|
slots: 1,
|
||||||
equipped: false,
|
equipped: false,
|
||||||
armor: Armor {
|
|
||||||
armor: ArmorType::GeneralArmor,
|
|
||||||
dfp: 0,
|
|
||||||
evp: 0,
|
|
||||||
slots: 1,
|
|
||||||
}
|
|
||||||
})));
|
})));
|
||||||
assert!(gat.get_drop(&MapVariantType::Caves3, &mut rng) == Some(ItemDetail::Armor(ArmorDetail {
|
assert!(gat.get_drop(&MapVariantType::Caves3, &mut rng) == Some(ItemDetail::Armor(Armor {
|
||||||
|
armor: ArmorType::AbsorbArmor,
|
||||||
|
dfp: 1,
|
||||||
|
evp: 1,
|
||||||
|
slots: 1,
|
||||||
equipped: false,
|
equipped: false,
|
||||||
armor: Armor {
|
|
||||||
armor: ArmorType::AbsorbArmor,
|
|
||||||
dfp: 1,
|
|
||||||
evp: 1,
|
|
||||||
slots: 1,
|
|
||||||
}
|
|
||||||
})));
|
})));
|
||||||
assert!(gat.get_drop(&MapVariantType::Forest2, &mut rng) == Some(ItemDetail::Armor(ArmorDetail {
|
assert!(gat.get_drop(&MapVariantType::Forest2, &mut rng) == Some(ItemDetail::Armor(Armor {
|
||||||
|
armor: ArmorType::HyperFrame,
|
||||||
|
dfp: 0,
|
||||||
|
evp: 0,
|
||||||
|
slots: 0,
|
||||||
equipped: false,
|
equipped: false,
|
||||||
armor: Armor {
|
|
||||||
armor: ArmorType::HyperFrame,
|
|
||||||
dfp: 0,
|
|
||||||
evp: 0,
|
|
||||||
slots: 0,
|
|
||||||
}
|
|
||||||
})));
|
})));
|
||||||
assert!(gat.get_drop(&MapVariantType::DarkFalz, &mut rng) == Some(ItemDetail::Armor(ArmorDetail {
|
assert!(gat.get_drop(&MapVariantType::DarkFalz, &mut rng) == Some(ItemDetail::Armor(Armor {
|
||||||
|
armor: ArmorType::ImperialArmor,
|
||||||
|
dfp: 2,
|
||||||
|
evp: 1,
|
||||||
|
slots: 0,
|
||||||
equipped: false,
|
equipped: false,
|
||||||
armor: Armor {
|
|
||||||
armor: ArmorType::ImperialArmor,
|
|
||||||
dfp: 2,
|
|
||||||
evp: 1,
|
|
||||||
slots: 0,
|
|
||||||
}
|
|
||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,15 +3,16 @@ use std::hash::{Hash, Hasher};
|
|||||||
|
|
||||||
use libpso::character::character::InventoryItem;
|
use libpso::character::character::InventoryItem;
|
||||||
|
|
||||||
use crate::entity::item::{Item, ItemDetail, ItemLocation, Armor, Shield};
|
use crate::entity::item::{Item, ItemDetail, ItemLocation, Shield};
|
||||||
use crate::entity::item::weapon::Weapon;
|
use crate::entity::item::weapon::Weapon;
|
||||||
|
use crate::entity::item::armor::Armor;
|
||||||
use crate::entity::item::tool::StackedTool;
|
use crate::entity::item::tool::StackedTool;
|
||||||
|
|
||||||
|
|
||||||
fn are_items_same_type(itema: &Item, itemb: &Item) -> bool {
|
fn are_items_same_type(itema: &Item, itemb: &Item) -> bool {
|
||||||
match (&itema.item, &itemb.item) {
|
match (&itema.item, &itemb.item) {
|
||||||
(ItemDetail::Weapon(a), ItemDetail::Weapon(b)) => a.weapon == b.weapon,
|
(ItemDetail::Weapon(a), ItemDetail::Weapon(b)) => a.weapon == b.weapon,
|
||||||
(ItemDetail::Armor(a), ItemDetail::Armor(b)) => a.armor.armor == b.armor.armor,
|
(ItemDetail::Armor(a), ItemDetail::Armor(b)) => a.armor == b.armor,
|
||||||
(ItemDetail::Shield(a), ItemDetail::Shield(b)) => a.shield.shield == b.shield.shield,
|
(ItemDetail::Shield(a), ItemDetail::Shield(b)) => a.shield.shield == b.shield.shield,
|
||||||
(ItemDetail::Tool(a), ItemDetail::Tool(b)) => a.tool == b.tool,
|
(ItemDetail::Tool(a), ItemDetail::Tool(b)) => a.tool == b.tool,
|
||||||
_ => false
|
_ => false
|
||||||
@ -107,7 +108,7 @@ impl Hash for StackedItemKey {
|
|||||||
fn hash<H: Hasher>(&self, hasher: &mut H) {
|
fn hash<H: Hasher>(&self, hasher: &mut H) {
|
||||||
match &self.0.item {
|
match &self.0.item {
|
||||||
ItemDetail::Weapon(w) => w.weapon.value().hash(hasher),
|
ItemDetail::Weapon(w) => w.weapon.value().hash(hasher),
|
||||||
ItemDetail::Armor(a) => a.armor.armor.value().hash(hasher),
|
ItemDetail::Armor(a) => a.armor.value().hash(hasher),
|
||||||
ItemDetail::Shield(s) => s.shield.shield.value().hash(hasher),
|
ItemDetail::Shield(s) => s.shield.shield.value().hash(hasher),
|
||||||
ItemDetail::Unit(u) => u.unit.unit.value().hash(hasher),
|
ItemDetail::Unit(u) => u.unit.unit.value().hash(hasher),
|
||||||
ItemDetail::Tool(t) => t.tool.value().hash(hasher),
|
ItemDetail::Tool(t) => t.tool.value().hash(hasher),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user