diff --git a/Cargo.toml b/Cargo.toml index 741fd94..33e1b71 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,7 +42,7 @@ patch_server = { path = "./src/patch_server" } login_server = { path = "./src/login_server" } ship_server = { path = "./src/ship_server" } -libpso = { git = "http://git.sharnoth.com/jake/libpso", rev="552f7d5" } +libpso = { git = "http://git.sharnoth.com/jake/libpso", rev="0e2cac0" } async-std = { version = "1.9.0", features = ["unstable", "attributes"] } futures = "0.3.5" diff --git a/src/bin/main.rs b/src/bin/main.rs index ec67554..abd60db 100644 --- a/src/bin/main.rs +++ b/src/bin/main.rs @@ -7,6 +7,8 @@ use login_server::character::CharacterServerState; use patch_server::{PatchServerState, generate_patch_tree, load_config, load_motd}; use ship_server::ShipServerStateBuilder; +use libpso::item::weapon::{Weapon, WeaponType, WeaponSpecial, WeaponAttribute, Attribute}; + use maps::Holiday; use entity::gateway::{EntityGateway, InMemoryGateway}; use entity::account::{NewUserAccountEntity, NewUserSettingsEntity}; @@ -81,8 +83,8 @@ fn main() { entity_gateway.create_item( item::NewItemEntity { item: item::ItemDetail::Weapon( - item::weapon::Weapon { - weapon: item::weapon::WeaponType::Vulcan, + Weapon { + weapon: WeaponType::Vulcan, grind: 0, special: None, attrs: [None, None, None], @@ -106,12 +108,12 @@ fn main() { let item0 = entity_gateway.create_item( NewItemEntity { item: ItemDetail::Weapon( - item::weapon::Weapon { - weapon: item::weapon::WeaponType::Raygun, + Weapon { + weapon: WeaponType::Raygun, grind: 5, - special: Some(item::weapon::WeaponSpecial::Hell), - attrs: [Some(item::weapon::WeaponAttribute{attr: item::weapon::Attribute::Hit, value: 40}), - Some(item::weapon::WeaponAttribute{attr: item::weapon::Attribute::Dark, value: 30}), + special: Some(WeaponSpecial::Hell), + attrs: [Some(WeaponAttribute{attr: Attribute::Hit, value: 40}), + Some(WeaponAttribute{attr: Attribute::Dark, value: 30}), None,], tekked: false, } @@ -120,12 +122,12 @@ fn main() { let item1 = entity_gateway.create_item( NewItemEntity { item: ItemDetail::Weapon( - item::weapon::Weapon { - weapon: item::weapon::WeaponType::Handgun, + Weapon { + weapon: WeaponType::Handgun, grind: 5, - special: Some(item::weapon::WeaponSpecial::Charge), - attrs: [Some(item::weapon::WeaponAttribute{attr: item::weapon::Attribute::Hit, value: 40}), - Some(item::weapon::WeaponAttribute{attr: item::weapon::Attribute::Dark, value: 30}), + special: Some(WeaponSpecial::Charge), + attrs: [Some(WeaponAttribute{attr: Attribute::Hit, value: 40}), + Some(WeaponAttribute{attr: Attribute::Dark, value: 30}), None,], tekked: true, } @@ -134,12 +136,12 @@ fn main() { let item2_w = entity_gateway.create_item( NewItemEntity { item: ItemDetail::Weapon( - item::weapon::Weapon { - weapon: item::weapon::WeaponType::Vjaya, + Weapon { + weapon: WeaponType::Vjaya, grind: 5, - special: Some(item::weapon::WeaponSpecial::Charge), - attrs: [Some(item::weapon::WeaponAttribute{attr: item::weapon::Attribute::Hit, value: 40}), - Some(item::weapon::WeaponAttribute{attr: item::weapon::Attribute::Dark, value: 100}), + special: Some(WeaponSpecial::Charge), + attrs: [Some(WeaponAttribute{attr: Attribute::Hit, value: 40}), + Some(WeaponAttribute{attr: Attribute::Dark, value: 100}), None,], tekked: true, } @@ -148,12 +150,12 @@ fn main() { let item3 = entity_gateway.create_item( NewItemEntity { item: ItemDetail::Weapon( - item::weapon::Weapon { - weapon: item::weapon::WeaponType::Vulcan, + Weapon { + weapon: WeaponType::Vulcan, grind: 5, - special: Some(item::weapon::WeaponSpecial::Charge), - attrs: [Some(item::weapon::WeaponAttribute{attr: item::weapon::Attribute::Hit, value: 100}), - Some(item::weapon::WeaponAttribute{attr: item::weapon::Attribute::Dark, value: 100}), + special: Some(WeaponSpecial::Charge), + attrs: [Some(WeaponAttribute{attr: Attribute::Hit, value: 100}), + Some(WeaponAttribute{attr: Attribute::Dark, value: 100}), None,], tekked: true, } @@ -162,13 +164,13 @@ fn main() { let item4 = entity_gateway.create_item( NewItemEntity { item: ItemDetail::Weapon( - item::weapon::Weapon { - weapon: item::weapon::WeaponType::DarkFlow, + Weapon { + weapon: WeaponType::DarkFlow, grind: 0, special: None, - attrs: [Some(item::weapon::WeaponAttribute{attr: item::weapon::Attribute::Hit, value: 100}), - Some(item::weapon::WeaponAttribute{attr: item::weapon::Attribute::Dark, value: 100}), - Some(item::weapon::WeaponAttribute{attr: item::weapon::Attribute::Native, value: 100}),], + attrs: [Some(WeaponAttribute{attr: Attribute::Hit, value: 100}), + Some(WeaponAttribute{attr: Attribute::Dark, value: 100}), + Some(WeaponAttribute{attr: Attribute::Native, value: 100}),], tekked: true, } ), @@ -289,13 +291,13 @@ fn main() { let item14 = entity_gateway.create_item( NewItemEntity { item: ItemDetail::Weapon( - item::weapon::Weapon { - weapon: item::weapon::WeaponType::Vulcan, + Weapon { + weapon: WeaponType::Vulcan, grind: 5, - special: Some(item::weapon::WeaponSpecial::Charge), - attrs: [Some(item::weapon::WeaponAttribute{attr: item::weapon::Attribute::Hit, value: 100}), - Some(item::weapon::WeaponAttribute{attr: item::weapon::Attribute::Dark, value: 100}), - Some(item::weapon::WeaponAttribute{attr: item::weapon::Attribute::Native, value: 100}),], + special: Some(WeaponSpecial::Charge), + attrs: [Some(WeaponAttribute{attr: Attribute::Hit, value: 100}), + Some(WeaponAttribute{attr: Attribute::Dark, value: 100}), + Some(WeaponAttribute{attr: Attribute::Native, value: 100}),], tekked: true, } ), diff --git a/src/drops/src/generic_weapon.rs b/src/drops/src/generic_weapon.rs index b2a9199..03ef15f 100644 --- a/src/drops/src/generic_weapon.rs +++ b/src/drops/src/generic_weapon.rs @@ -5,7 +5,7 @@ use rand::distributions::{WeightedIndex, Distribution}; use rand::seq::SliceRandom; use libpso::character::SectionID; -use entity::item::weapon::{Weapon, WeaponType, Attribute, WeaponAttribute, WeaponSpecial}; +use libpso::item::weapon::{Weapon, WeaponType, Attribute, WeaponAttribute, WeaponSpecial}; use maps::room::{Difficulty, Episode}; use maps::area::MapArea; use crate::{ItemDropType, load_data_file}; diff --git a/src/drops/src/lib.rs b/src/drops/src/lib.rs index c27bb19..2945d7c 100644 --- a/src/drops/src/lib.rs +++ b/src/drops/src/lib.rs @@ -33,7 +33,8 @@ use crate::tool_table::ToolTable; use crate::rare_drop_table::RareDropTable; use crate::box_drop_table::BoxDropTable; use maps::object::MapObject; -use entity::item::{ItemType, weapon, armor, shield, unit, mag, tool, tech, esweapon}; +use entity::item::{ItemType, armor, shield, unit, mag, tool, tech, esweapon}; +use libpso::item::weapon; fn data_file_path(episode: Episode, difficulty: Difficulty, section_id: SectionID, filename: &str) -> PathBuf { diff --git a/src/drops/src/rare_drop_table.rs b/src/drops/src/rare_drop_table.rs index 906d453..e4ce4fb 100644 --- a/src/drops/src/rare_drop_table.rs +++ b/src/drops/src/rare_drop_table.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use rand::Rng; use serde::{Serialize, Deserialize}; -use entity::item::weapon::{Weapon, WeaponType}; +use libpso::item::weapon::{Weapon, WeaponType}; use entity::item::armor::{Armor, ArmorType}; use entity::item::shield::{Shield, ShieldType}; use entity::item::unit::{Unit, UnitType}; diff --git a/src/entity/src/gateway/inmemory.rs b/src/entity/src/gateway/inmemory.rs index 970beed..2c1b051 100644 --- a/src/entity/src/gateway/inmemory.rs +++ b/src/entity/src/gateway/inmemory.rs @@ -271,7 +271,7 @@ fn apply_modifiers(items: &BTreeMap, ItemDetail::Weapon(mut weapon) => { if let Some(weapon_modifiers) = weapon_modifiers.get(&item.id) { for weapon_modifier in weapon_modifiers.iter() { - weapon.apply_modifier(weapon_modifier); + weapon::apply_modifier(&mut weapon, weapon_modifier); } } ItemDetail::Weapon(weapon) diff --git a/src/entity/src/gateway/postgres/models.rs b/src/entity/src/gateway/postgres/models.rs index ca9c05d..cae9922 100644 --- a/src/entity/src/gateway/postgres/models.rs +++ b/src/entity/src/gateway/postgres/models.rs @@ -8,6 +8,8 @@ use crate::account::*; use crate::character::*; use libpso::character::{CharacterClass, SectionID}; use crate::item::*; +use crate::item::weapon::WeaponModifier; +use libpso::item::weapon; use crate::room::*; use maps::area::MapArea; use maps::room::{Episode, Difficulty}; @@ -327,7 +329,7 @@ impl From for weapon::Weapon { #[derive(Debug, sqlx::FromRow)] pub struct PgWeaponModifier { pub weapon: i32, - pub modifier: sqlx::types::Json, + pub modifier: sqlx::types::Json, } #[derive(Debug, Serialize, Deserialize)] diff --git a/src/entity/src/gateway/postgres/postgres.rs b/src/entity/src/gateway/postgres/postgres.rs index f1219ba..de3d39e 100644 --- a/src/entity/src/gateway/postgres/postgres.rs +++ b/src/entity/src/gateway/postgres/postgres.rs @@ -92,7 +92,7 @@ async fn apply_item_modifications(conn: &mut sqlx::PgConnection, item: ItemEntit weapon_modifiers.for_each(|modifier| async move { if let Ok(modifier) = modifier { - weapon.apply_modifier(&modifier.modifier); + weapon::apply_modifier(&mut weapon, &modifier.modifier); } }).await; diff --git a/src/entity/src/item/esweapon.rs b/src/entity/src/item/esweapon.rs index 2997780..208366a 100644 --- a/src/entity/src/item/esweapon.rs +++ b/src/entity/src/item/esweapon.rs @@ -9,7 +9,7 @@ pub enum ItemParseError { InvalidESWeaponName, } -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize, strum_macros::EnumIter)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] pub enum ESWeaponType { Saber = 0, Sword, @@ -121,7 +121,7 @@ impl ESWeaponType { } } -#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize, strum_macros::EnumIter)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum ESWeaponSpecial { Jellen = 1, Zalure, diff --git a/src/entity/src/item/mod.rs b/src/entity/src/item/mod.rs index d418579..265af8e 100644 --- a/src/entity/src/item/mod.rs +++ b/src/entity/src/item/mod.rs @@ -1,4 +1,3 @@ -#![allow(dead_code)] pub mod weapon; pub mod armor; pub mod shield; @@ -13,6 +12,7 @@ use crate::character::CharacterEntityId; use crate::room::RoomEntityId; use maps::area::MapArea; use maps::monster::MonsterType; +use libpso::item::ItemBytes; //use crate::ship::drops::ItemDropType; #[derive(PartialEq, Eq, Copy, Clone, Debug, Hash, PartialOrd, Ord, Serialize, Deserialize)] @@ -108,7 +108,7 @@ impl Meseta { #[derive(Clone, Debug, PartialEq, Eq, Hash)] pub enum ItemType { - Weapon(weapon::WeaponType), + Weapon(libpso::item::weapon::WeaponType), Armor(armor::ArmorType), Shield(shield::ShieldType), Unit(unit::UnitType), @@ -125,7 +125,7 @@ pub enum ItemParseError { #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum ItemDetail { - Weapon(weapon::Weapon), + Weapon(libpso::item::weapon::Weapon), Armor(armor::Armor), Shield(shield::Shield), Unit(unit::Unit), diff --git a/src/entity/src/item/weapon.rs b/src/entity/src/item/weapon.rs index a5753d6..622aa66 100644 --- a/src/entity/src/item/weapon.rs +++ b/src/entity/src/item/weapon.rs @@ -1,1427 +1,8 @@ -use crate::item::ItemEntityId; use serde::{Serialize, Deserialize}; +use crate::item::ItemEntityId; +use libpso::item::weapon::*; -#[derive(Debug, Copy, Clone)] -pub enum ItemParseError { - InvalidWeaponBytes, - InvalidWeaponType, - InvalidWeaponGrind, - InvalidWeaponSpecial, - InvalidWeaponAttribute, -} - -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)] -pub enum Attribute { - Native = 1, - ABeast, - Machine, - Dark, - Hit -} - -impl Attribute { - pub fn from(data: u8) -> Option { - match data { - 1 => Some(Attribute::Native), - 2 => Some(Attribute::ABeast), - 3 => Some(Attribute::Machine), - 4 => Some(Attribute::Dark), - 5 => Some(Attribute::Hit), - _ => None, - } - } -} - -#[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)] -pub struct WeaponAttribute { - pub attr: Attribute, - pub value: i8, -} - -impl WeaponAttribute { - pub fn value(&self) -> [u8; 2] { - [self.attr as u8, self.value as u8] - } -} - - -#[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, strum_macros::EnumIter)] -pub enum WeaponSpecial { - Draw = 1, - Drain, - Fill, - Gush, - Heart, - Mind, - Soul, - Geist, - Masters, - Lords, - Kings, - Charge, - Spirit, - Berserk, - Ice, - Frost, - Freeze, - Blizzard, - Bind, - Hold, - Seize, - Arrest, - Heat, - Fire, - Flame, - Burning, - Shock, - Thunder, - Storm, - Tempest, - Dim, - Shadow, - Dark, - Hell, - Panic, - Riot, - Havoc, - Chaos, - Devils, - Demons, -} - -impl WeaponSpecial { - pub fn value(&self) -> u8 { - *self as u8 - } - - #[must_use] - pub fn rank_up(&self) -> WeaponSpecial { - match self { - WeaponSpecial::Draw => WeaponSpecial::Drain, - WeaponSpecial::Drain => WeaponSpecial::Fill, - WeaponSpecial::Fill => WeaponSpecial::Gush, - WeaponSpecial::Gush => WeaponSpecial::Gush, - WeaponSpecial::Heart => WeaponSpecial::Mind, - WeaponSpecial::Mind => WeaponSpecial::Soul, - WeaponSpecial::Soul => WeaponSpecial::Geist, - WeaponSpecial::Geist => WeaponSpecial::Geist, - WeaponSpecial::Masters => WeaponSpecial::Lords, - WeaponSpecial::Lords => WeaponSpecial::Kings, - WeaponSpecial::Kings => WeaponSpecial::Kings, - WeaponSpecial::Charge => WeaponSpecial::Charge, - WeaponSpecial::Spirit => WeaponSpecial::Spirit, - WeaponSpecial::Berserk => WeaponSpecial::Berserk, - WeaponSpecial::Ice => WeaponSpecial::Frost, - WeaponSpecial::Frost => WeaponSpecial::Freeze, - WeaponSpecial::Freeze => WeaponSpecial::Blizzard, - WeaponSpecial::Blizzard => WeaponSpecial::Blizzard, - WeaponSpecial::Bind => WeaponSpecial::Hold, - WeaponSpecial::Hold => WeaponSpecial::Seize, - WeaponSpecial::Seize => WeaponSpecial::Arrest, - WeaponSpecial::Arrest => WeaponSpecial::Arrest, - WeaponSpecial::Heat => WeaponSpecial::Fire, - WeaponSpecial::Fire => WeaponSpecial::Flame, - WeaponSpecial::Flame => WeaponSpecial::Burning, - WeaponSpecial::Burning => WeaponSpecial::Burning, - WeaponSpecial::Shock => WeaponSpecial::Thunder, - WeaponSpecial::Thunder => WeaponSpecial::Storm, - WeaponSpecial::Storm => WeaponSpecial::Tempest, - WeaponSpecial::Tempest => WeaponSpecial::Tempest, - WeaponSpecial::Dim => WeaponSpecial::Shadow, - WeaponSpecial::Shadow => WeaponSpecial::Dark, - WeaponSpecial::Dark => WeaponSpecial::Hell, - WeaponSpecial::Hell => WeaponSpecial::Hell, - WeaponSpecial::Panic => WeaponSpecial::Riot, - WeaponSpecial::Riot => WeaponSpecial::Havoc, - WeaponSpecial::Havoc => WeaponSpecial::Chaos, - WeaponSpecial::Chaos => WeaponSpecial::Chaos, - WeaponSpecial::Devils => WeaponSpecial::Demons, - WeaponSpecial::Demons => WeaponSpecial::Demons, - } - } - - #[must_use] - pub fn rank_down(&self) -> WeaponSpecial { - match self { - WeaponSpecial::Draw => WeaponSpecial::Draw, - WeaponSpecial::Drain => WeaponSpecial::Draw, - WeaponSpecial::Fill => WeaponSpecial::Drain, - WeaponSpecial::Gush => WeaponSpecial::Fill, - WeaponSpecial::Heart => WeaponSpecial::Heart, - WeaponSpecial::Mind => WeaponSpecial::Heart, - WeaponSpecial::Soul => WeaponSpecial::Mind, - WeaponSpecial::Geist => WeaponSpecial::Soul, - WeaponSpecial::Masters => WeaponSpecial::Masters, - WeaponSpecial::Lords => WeaponSpecial::Masters, - WeaponSpecial::Kings => WeaponSpecial::Lords, - WeaponSpecial::Charge => WeaponSpecial::Charge, - WeaponSpecial::Spirit => WeaponSpecial::Spirit, - WeaponSpecial::Berserk => WeaponSpecial::Berserk, - WeaponSpecial::Ice => WeaponSpecial::Ice, - WeaponSpecial::Frost => WeaponSpecial::Ice, - WeaponSpecial::Freeze => WeaponSpecial::Frost, - WeaponSpecial::Blizzard => WeaponSpecial::Freeze, - WeaponSpecial::Bind => WeaponSpecial::Bind, - WeaponSpecial::Hold => WeaponSpecial::Bind, - WeaponSpecial::Seize => WeaponSpecial::Hold, - WeaponSpecial::Arrest => WeaponSpecial::Seize, - WeaponSpecial::Heat => WeaponSpecial::Heat, - WeaponSpecial::Fire => WeaponSpecial::Heat, - WeaponSpecial::Flame => WeaponSpecial::Fire, - WeaponSpecial::Burning => WeaponSpecial::Flame, - WeaponSpecial::Shock => WeaponSpecial::Shock, - WeaponSpecial::Thunder => WeaponSpecial::Shock, - WeaponSpecial::Storm => WeaponSpecial::Thunder, - WeaponSpecial::Tempest => WeaponSpecial::Storm, - WeaponSpecial::Dim => WeaponSpecial::Dim, - WeaponSpecial::Shadow => WeaponSpecial::Dim, - WeaponSpecial::Dark => WeaponSpecial::Shadow, - WeaponSpecial::Hell => WeaponSpecial::Dark, - WeaponSpecial::Panic => WeaponSpecial::Panic, - WeaponSpecial::Riot => WeaponSpecial::Panic, - WeaponSpecial::Havoc => WeaponSpecial::Riot, - WeaponSpecial::Chaos => WeaponSpecial::Havoc, - WeaponSpecial::Devils => WeaponSpecial::Devils, - WeaponSpecial::Demons => WeaponSpecial::Devils, - } - } - - pub fn from(data: u8) -> Option { - match data { - 1 => Some(WeaponSpecial::Draw), - 2 => Some(WeaponSpecial::Drain), - 3 => Some(WeaponSpecial::Fill), - 4 => Some(WeaponSpecial::Gush), - 5 => Some(WeaponSpecial::Heart), - 6 => Some(WeaponSpecial::Mind), - 7 => Some(WeaponSpecial::Soul), - 8 => Some(WeaponSpecial::Geist), - 9 => Some(WeaponSpecial::Masters), - 10 => Some(WeaponSpecial::Lords), - 11 => Some(WeaponSpecial::Kings), - 12 => Some(WeaponSpecial::Charge), - 13 => Some(WeaponSpecial::Spirit), - 14 => Some(WeaponSpecial::Berserk), - 15 => Some(WeaponSpecial::Ice), - 16 => Some(WeaponSpecial::Frost), - 17 => Some(WeaponSpecial::Freeze), - 18 => Some(WeaponSpecial::Blizzard), - 19 => Some(WeaponSpecial::Bind), - 20 => Some(WeaponSpecial::Hold), - 21 => Some(WeaponSpecial::Seize), - 22 => Some(WeaponSpecial::Arrest), - 23 => Some(WeaponSpecial::Heat), - 24 => Some(WeaponSpecial::Fire), - 25 => Some(WeaponSpecial::Flame), - 26 => Some(WeaponSpecial::Burning), - 27 => Some(WeaponSpecial::Shock), - 28 => Some(WeaponSpecial::Thunder), - 29 => Some(WeaponSpecial::Storm), - 30 => Some(WeaponSpecial::Tempest), - 31 => Some(WeaponSpecial::Dim), - 32 => Some(WeaponSpecial::Shadow), - 33 => Some(WeaponSpecial::Dark), - 34 => Some(WeaponSpecial::Hell), - 35 => Some(WeaponSpecial::Panic), - 36 => Some(WeaponSpecial::Riot), - 37 => Some(WeaponSpecial::Havoc), - 38 => Some(WeaponSpecial::Chaos), - 39 => Some(WeaponSpecial::Devils), - 40 => Some(WeaponSpecial::Demons), - _ => None, - } - } -} - -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, enum_utils::FromStr, derive_more::Display, strum_macros::EnumIter)] -pub enum WeaponType { - Saber, - Brand, - Buster, - Pallasch, - Gladius, - DbsSaber, - Kaladbolg, - Durandal, - Galatine, - Sword, - Gigush, - Breaker, - Claymore, - Calibur, - FlowensSword, - LastSurvivor, - DragonSlayer, - Dagger, - Knife, - Blade, - Edge, - Ripper, - BladeDance, - BloodyArt, - CrossScar, - ZeroDivide, - TwoKamui, - Partisan, - Halbert, - Glaive, - Berdys, - Gungnir, - Brionac, - Vjaya, - GaeBolg, - AsteronBelt, - Slicer, - Spinner, - Cutter, - Sawcer, - Diska, - SlicerOfAssassin, - DiskaOfLiberator, - DiskaOfBraveman, - Izmaela, - Handgun, - Autogun, - Lockgun, - Railgun, - Raygun, - Varista, - CustomRayVerOo, - Bravace, - TensionBlaster, - Rifle, - Sniper, - Blaster, - Beam, - Laser, - Visk235W, - WalsMk2, - Justy23St, - Rianov303snr, - Rianov303snr1, - Rianov303snr2, - Rianov303snr3, - Rianov303snr4, - Rianov303snr5, - Mechgun, - Assault, - Repeater, - Gatling, - Vulcan, - MA60Vise, - HS25Justice, - LK14Combat, - Shot, - Spread, - Cannon, - Launcher, - Arms, - CrushBullet, - MeteorSmash, - FinalImpact, - Cane, - Stick, - Mace, - Club, - ClubOfLaconium, - MaceOfAdaman, - ClubOfZumiuran, - Lollipop, - Rod, - Pole, - Pillar, - Striker, - BattleVerge, - BraveHammer, - AliveAqhu, - Valkyrie, - Wand, - Staff, - Baton, - Scepter, - FireScepterAgni, - IceStaffDagon, - StormWandIndra, - EarthWandBrownie, - PhotonClaw, - SilenceClaw, - NeisClaw, - PhoenixClaw, - DoubleSaber, - StagCutlery, - TwinBrand, - BraveKnuckle, - AngryFist, - GodHand, - SonicKnuckle, - Login, - Orotiagito, - Agito1975, - Agito1983, - Agito2001, - Agito1991, - Agito1977, - Agito1980, - Raikiri, - SoulEater, - SoulBanish, - SpreadNeedle, - HolyRay, - InfernoBazooka, - RamblingMay, - LK38Combat, - FlameVisit, - BurningVisit, - AkikosFryingPan, - SorcerersCane, - SBeatsBlade, - PArmsBlade, - DelsabersBuster, - BringersRifle, - EggBlaster, - PsychoWand, - HeavenPunisher, - LavisCannon, - VictorAxe, - LaconiumAxe, - ChainSawd, - Caduceus, - MercuriusRod, - StingTip, - MagicalPiece, - TechnicalCrozier, - SuppressedGun, - AncientSaber, - HarisenBattleFan, - Yamigarasu, - AkikosWok, - ToyHammer, - Elysion, - RedSaber, - MeteorCudgel, - MonkeyKingBar, - BlackKingBar, - DoubleCannon, - Girasole, - HugeBattleFan, - TsumikiriJSword, - SealedJSword, - RedSword, - CrazyTune, - TwinChakram, - WokOfAkikosShop, - LavisBlade, - RedDagger, - MadamsParasol, - MadamsUmbrella, - ImperialPick, - Berdysh, - RedPartisan, - FlightCutter, - FlightFan, - RedSlicer, - HandgunGuld, - MasterRaven, - HandgunMilla, - LastSwan, - RedHandgun, - FrozenShooter, - SnowQueen, - AntiAndroidRifle, - RocketPunch, - SambaMaracas, - TwinPsychogun, - DrillLauncher, - GuldMilla, - DualBird, - RedMechgun, - BelraCannon, - PanzerFaust, - IronFaust, - SummitMoon, - Windmill, - EvilCurst, - FlowerCane, - HildebearsCane, - HildebluesCane, - RabbitWand, - PlantainLeaf, - Fatsia, - DemonicFork, - StrikerOfChao, - Broom, - ProphetsOfMotav, - TheSighOfAGod, - TwinkleStar, - PlantainFan, - TwinBlaze, - MarinasBag, - DragonsClaw, - PanthersClaw, - SRedsBlade, - PlantainHugeFan, - ChameleonScythe, - Yasminkov3000R, - AnoRifle, - BaranzLauncher, - BranchOfPakupaku, - HeartOfPoumn, - Yasminkov2000H, - Yasminkov7000V, - Yasminkov9000M, - MaserBeam, - PowerMaser, - GameMagazne, - Login2, - FlowerBouquet, - Musashi, - Yamato, - Asuka, - SangeYasha, - Sange, - Yasha, - Kamui, - PhotonLauncher, - GuiltyLight, - RedScorpio, - PhononMaser, - Talis, - Mahu, - Hitogata, - DancingHitogata, - Kunai, - Nug2000Bazooka, - SBerillsHands0, - SBerillsHands1, - FlowensSword3060, - FlowensSword3064, - FlowensSword3067, - FlowensSword3073, - FlowensSword3077, - FlowensSword3082, - FlowensSword3083, - FlowensSword3084, - FlowensSword3079, - DbsSaber3062, - DbsSaber3067, - DbsSaber3069Chris, - DbsSaber3064, - DbsSaber3069Torato, - DbsSaber3073, - DbsSaber3070, - DbsSaber3075, - DbsSaber3077, - GiGueBazooka, - Guardianna, - ViridiaCard, - GreenillCard, - SkylyCard, - BluefullCard, - PurplenumCard, - PinkalCard, - RedriaCard, - OranCard, - YellowbozeCard, - WhitillCard, - MorningGlory, - PartisanOfLightning, - GalWind, - Zanba, - RikasClaw, - AngelHarp, - DemolitionComet, - NeisClaw2, - RainbowBaton, - DarkFlow, - DarkMeteor, - DarkBridge, - GAssassinsSabers, - RappysFan, - BoomasClaw, - GoboomasClaw, - GigoboomasClaw, - RubyBullet, - AmoreRose, - SlicerOfFanatic, - LameDArgent, - Excalibur, - RageDeFeu, - RageDeFeu2, - RageDeFeu3, - RageDeFeu4, - DaisyChain, - OphelieSeize, - MilleMarteaux, - LeCogneur, - CommanderBlade, - Vivienne, - Kusanagi, - SacredDuster, - Guren, - Shouren, - Jizai, - Flamberge, - Yunchang, - SnakeSpire, - FlapjackFlapper, - Getsugasan, - Maguwa, - HeavenStriker, - CannonRouge, - MeteorRouge, - Solferino, - Clio, - SirenGlassHammer, - GlideDivine, - Shichishito, - Murasame, - DaylightScar, - Decalog, - FifthAnnivBlade, - TyrellsParasol, - AkikosCleaver, - Tanegashima, - TreeClippers, - NiceShot, - Unknown3, - Unknown4, - AnoBazooka, - Synthesizer, - BambooSpear, - KaneiTsuho, - Jitte, - ButterflyNet, - Syringe, - Battledore, - Racket, - Hammer, - GreatBouquet, - TypesaSaber, - TypeslSaber, - TypeslSlicer, - TypeslClaw, - TypeslKatana, - TypejsSaber, - TypejsSlicer, - TypejsJSword, - TypeswSword, - TypeswSlicer, - TypeswJSword, - TyperoSword, - TyperoHalbert, - TyperoRod, - TypeblBlade, - TypeknBlade, - TypeknClaw, - TypehaHalbert, - TypehaRod, - TypedsDSaber, - TypedsRod, - Typeds, - TypeclClaw, - TypessSw, - TypeguHand, - TypeguMechgun, - TyperiRifle, - TypemeMechgun, - TypeshShot, - TypewaWand, -} - -impl WeaponType { - pub fn value(&self) -> [u8; 3] { - match self { - WeaponType::Saber => [0x00, 0x01, 0x00], - WeaponType::Brand => [0x00, 0x01, 0x01], - WeaponType::Buster => [0x00, 0x01, 0x02], - WeaponType::Pallasch => [0x00, 0x01, 0x03], - WeaponType::Gladius => [0x00, 0x01, 0x04], - WeaponType::DbsSaber => [0x00, 0x01, 0x05], - WeaponType::Kaladbolg => [0x00, 0x01, 0x06], - WeaponType::Durandal => [0x00, 0x01, 0x07], - WeaponType::Galatine => [0x00, 0x01, 0x08], - WeaponType::Sword => [0x00, 0x02, 0x00], - WeaponType::Gigush => [0x00, 0x02, 0x01], - WeaponType::Breaker => [0x00, 0x02, 0x02], - WeaponType::Claymore => [0x00, 0x02, 0x03], - WeaponType::Calibur => [0x00, 0x02, 0x04], - WeaponType::FlowensSword => [0x00, 0x02, 0x05], - WeaponType::LastSurvivor => [0x00, 0x02, 0x06], - WeaponType::DragonSlayer => [0x00, 0x02, 0x07], - WeaponType::Dagger => [0x00, 0x03, 0x00], - WeaponType::Knife => [0x00, 0x03, 0x01], - WeaponType::Blade => [0x00, 0x03, 0x02], - WeaponType::Edge => [0x00, 0x03, 0x03], - WeaponType::Ripper => [0x00, 0x03, 0x04], - WeaponType::BladeDance => [0x00, 0x03, 0x05], - WeaponType::BloodyArt => [0x00, 0x03, 0x06], - WeaponType::CrossScar => [0x00, 0x03, 0x07], - WeaponType::ZeroDivide => [0x00, 0x03, 0x08], - WeaponType::TwoKamui => [0x00, 0x03, 0x09], - WeaponType::Partisan => [0x00, 0x04, 0x00], - WeaponType::Halbert => [0x00, 0x04, 0x01], - WeaponType::Glaive => [0x00, 0x04, 0x02], - WeaponType::Berdys => [0x00, 0x04, 0x03], - WeaponType::Gungnir => [0x00, 0x04, 0x04], - WeaponType::Brionac => [0x00, 0x04, 0x05], - WeaponType::Vjaya => [0x00, 0x04, 0x06], - WeaponType::GaeBolg => [0x00, 0x04, 0x07], - WeaponType::AsteronBelt => [0x00, 0x04, 0x08], - WeaponType::Slicer => [0x00, 0x05, 0x00], - WeaponType::Spinner => [0x00, 0x05, 0x01], - WeaponType::Cutter => [0x00, 0x05, 0x02], - WeaponType::Sawcer => [0x00, 0x05, 0x03], - WeaponType::Diska => [0x00, 0x05, 0x04], - WeaponType::SlicerOfAssassin => [0x00, 0x05, 0x05], - WeaponType::DiskaOfLiberator => [0x00, 0x05, 0x06], - WeaponType::DiskaOfBraveman => [0x00, 0x05, 0x07], - WeaponType::Izmaela => [0x00, 0x05, 0x08], - WeaponType::Handgun => [0x00, 0x06, 0x00], - WeaponType::Autogun => [0x00, 0x06, 0x01], - WeaponType::Lockgun => [0x00, 0x06, 0x02], - WeaponType::Railgun => [0x00, 0x06, 0x03], - WeaponType::Raygun => [0x00, 0x06, 0x04], - WeaponType::Varista => [0x00, 0x06, 0x05], - WeaponType::CustomRayVerOo => [0x00, 0x06, 0x06], - WeaponType::Bravace => [0x00, 0x06, 0x07], - WeaponType::TensionBlaster => [0x00, 0x06, 0x08], - WeaponType::Rifle => [0x00, 0x07, 0x00], - WeaponType::Sniper => [0x00, 0x07, 0x01], - WeaponType::Blaster => [0x00, 0x07, 0x02], - WeaponType::Beam => [0x00, 0x07, 0x03], - WeaponType::Laser => [0x00, 0x07, 0x04], - WeaponType::Visk235W => [0x00, 0x07, 0x05], - WeaponType::WalsMk2 => [0x00, 0x07, 0x06], - WeaponType::Justy23St => [0x00, 0x07, 0x07], - WeaponType::Rianov303snr => [0x00, 0x07, 0x08], - WeaponType::Rianov303snr1 => [0x00, 0x07, 0x09], - WeaponType::Rianov303snr2 => [0x00, 0x07, 0x0A], - WeaponType::Rianov303snr3 => [0x00, 0x07, 0x0B], - WeaponType::Rianov303snr4 => [0x00, 0x07, 0x0C], - WeaponType::Rianov303snr5 => [0x00, 0x07, 0x0D], - WeaponType::Mechgun => [0x00, 0x08, 0x00], - WeaponType::Assault => [0x00, 0x08, 0x01], - WeaponType::Repeater => [0x00, 0x08, 0x02], - WeaponType::Gatling => [0x00, 0x08, 0x03], - WeaponType::Vulcan => [0x00, 0x08, 0x04], - WeaponType::MA60Vise => [0x00, 0x08, 0x05], - WeaponType::HS25Justice => [0x00, 0x08, 0x06], - WeaponType::LK14Combat => [0x00, 0x08, 0x07], - WeaponType::Shot => [0x00, 0x09, 0x00], - WeaponType::Spread => [0x00, 0x09, 0x01], - WeaponType::Cannon => [0x00, 0x09, 0x02], - WeaponType::Launcher => [0x00, 0x09, 0x03], - WeaponType::Arms => [0x00, 0x09, 0x04], - WeaponType::CrushBullet => [0x00, 0x09, 0x05], - WeaponType::MeteorSmash => [0x00, 0x09, 0x06], - WeaponType::FinalImpact => [0x00, 0x09, 0x07], - WeaponType::Cane => [0x00, 0x0A, 0x00], - WeaponType::Stick => [0x00, 0x0A, 0x01], - WeaponType::Mace => [0x00, 0x0A, 0x02], - WeaponType::Club => [0x00, 0x0A, 0x03], - WeaponType::ClubOfLaconium => [0x00, 0x0A, 0x04], - WeaponType::MaceOfAdaman => [0x00, 0x0A, 0x05], - WeaponType::ClubOfZumiuran => [0x00, 0x0A, 0x06], - WeaponType::Lollipop => [0x00, 0x0A, 0x07], - WeaponType::Rod => [0x00, 0x0B, 0x00], - WeaponType::Pole => [0x00, 0x0B, 0x01], - WeaponType::Pillar => [0x00, 0x0B, 0x02], - WeaponType::Striker => [0x00, 0x0B, 0x03], - WeaponType::BattleVerge => [0x00, 0x0B, 0x04], - WeaponType::BraveHammer => [0x00, 0x0B, 0x05], - WeaponType::AliveAqhu => [0x00, 0x0B, 0x06], - WeaponType::Valkyrie => [0x00, 0x0B, 0x07], - WeaponType::Wand => [0x00, 0x0C, 0x00], - WeaponType::Staff => [0x00, 0x0C, 0x01], - WeaponType::Baton => [0x00, 0x0C, 0x02], - WeaponType::Scepter => [0x00, 0x0C, 0x03], - WeaponType::FireScepterAgni => [0x00, 0x0C, 0x04], - WeaponType::IceStaffDagon => [0x00, 0x0C, 0x05], - WeaponType::StormWandIndra => [0x00, 0x0C, 0x06], - WeaponType::EarthWandBrownie => [0x00, 0x0C, 0x07], - WeaponType::PhotonClaw => [0x00, 0x0D, 0x00], - WeaponType::SilenceClaw => [0x00, 0x0D, 0x01], - WeaponType::NeisClaw => [0x00, 0x0D, 0x02], - WeaponType::PhoenixClaw => [0x00, 0x0D, 0x03], - WeaponType::DoubleSaber => [0x00, 0x0E, 0x00], - WeaponType::StagCutlery => [0x00, 0x0E, 0x01], - WeaponType::TwinBrand => [0x00, 0x0E, 0x02], - WeaponType::BraveKnuckle => [0x00, 0x0F, 0x00], - WeaponType::AngryFist => [0x00, 0x0F, 0x01], - WeaponType::GodHand => [0x00, 0x0F, 0x02], - WeaponType::SonicKnuckle => [0x00, 0x0F, 0x03], - WeaponType::Login => [0x00, 0x0F, 0x04], - WeaponType::Orotiagito => [0x00, 0x10, 0x00], - WeaponType::Agito1975 => [0x00, 0x10, 0x01], - WeaponType::Agito1983 => [0x00, 0x10, 0x02], - WeaponType::Agito2001 => [0x00, 0x10, 0x03], - WeaponType::Agito1991 => [0x00, 0x10, 0x04], - WeaponType::Agito1977 => [0x00, 0x10, 0x05], - WeaponType::Agito1980 => [0x00, 0x10, 0x06], - WeaponType::Raikiri => [0x00, 0x10, 0x07], - WeaponType::SoulEater => [0x00, 0x11, 0x00], - WeaponType::SoulBanish => [0x00, 0x11, 0x01], - WeaponType::SpreadNeedle => [0x00, 0x12, 0x00], - WeaponType::HolyRay => [0x00, 0x13, 0x00], - WeaponType::InfernoBazooka => [0x00, 0x14, 0x00], - WeaponType::RamblingMay => [0x00, 0x14, 0x01], - WeaponType::LK38Combat => [0x00, 0x14, 0x02], - WeaponType::FlameVisit => [0x00, 0x15, 0x00], - WeaponType::BurningVisit => [0x00, 0x15, 0x01], - WeaponType::AkikosFryingPan => [0x00, 0x16, 0x00], - WeaponType::SorcerersCane => [0x00, 0x17, 0x00], - WeaponType::SBeatsBlade => [0x00, 0x18, 0x00], - WeaponType::PArmsBlade => [0x00, 0x19, 0x00], - WeaponType::DelsabersBuster => [0x00, 0x1A, 0x00], - WeaponType::BringersRifle => [0x00, 0x1B, 0x00], - WeaponType::EggBlaster => [0x00, 0x1C, 0x00], - WeaponType::PsychoWand => [0x00, 0x1D, 0x00], - WeaponType::HeavenPunisher => [0x00, 0x1E, 0x00], - WeaponType::LavisCannon => [0x00, 0x1F, 0x00], - WeaponType::VictorAxe => [0x00, 0x20, 0x00], - WeaponType::LaconiumAxe => [0x00, 0x20, 0x01], - WeaponType::ChainSawd => [0x00, 0x21, 0x00], - WeaponType::Caduceus => [0x00, 0x22, 0x00], - WeaponType::MercuriusRod => [0x00, 0x22, 0x01], - WeaponType::StingTip => [0x00, 0x23, 0x00], - WeaponType::MagicalPiece => [0x00, 0x24, 0x00], - WeaponType::TechnicalCrozier => [0x00, 0x25, 0x00], - WeaponType::SuppressedGun => [0x00, 0x26, 0x00], - WeaponType::AncientSaber => [0x00, 0x27, 0x00], - WeaponType::HarisenBattleFan => [0x00, 0x28, 0x00], - WeaponType::Yamigarasu => [0x00, 0x29, 0x00], - WeaponType::AkikosWok => [0x00, 0x2A, 0x00], - WeaponType::ToyHammer => [0x00, 0x2B, 0x00], - WeaponType::Elysion => [0x00, 0x2C, 0x00], - WeaponType::RedSaber => [0x00, 0x2D, 0x00], - WeaponType::MeteorCudgel => [0x00, 0x2E, 0x00], - WeaponType::MonkeyKingBar => [0x00, 0x2F, 0x00], - WeaponType::BlackKingBar => [0x00, 0x2F, 0x01], - WeaponType::DoubleCannon => [0x00, 0x30, 0x00], - WeaponType::Girasole => [0x00, 0x30, 0x01], - WeaponType::HugeBattleFan => [0x00, 0x31, 0x00], - WeaponType::TsumikiriJSword => [0x00, 0x32, 0x00], - WeaponType::SealedJSword => [0x00, 0x33, 0x00], - WeaponType::RedSword => [0x00, 0x34, 0x00], - WeaponType::CrazyTune => [0x00, 0x35, 0x00], - WeaponType::TwinChakram => [0x00, 0x36, 0x00], - WeaponType::WokOfAkikosShop => [0x00, 0x37, 0x00], - WeaponType::LavisBlade => [0x00, 0x38, 0x00], - WeaponType::RedDagger => [0x00, 0x39, 0x00], - WeaponType::MadamsParasol => [0x00, 0x3A, 0x00], - WeaponType::MadamsUmbrella => [0x00, 0x3B, 0x00], - WeaponType::ImperialPick => [0x00, 0x3C, 0x00], - WeaponType::Berdysh => [0x00, 0x3D, 0x00], - WeaponType::RedPartisan => [0x00, 0x3E, 0x00], - WeaponType::FlightCutter => [0x00, 0x3F, 0x00], - WeaponType::FlightFan => [0x00, 0x40, 0x00], - WeaponType::RedSlicer => [0x00, 0x41, 0x00], - WeaponType::HandgunGuld => [0x00, 0x42, 0x00], - WeaponType::MasterRaven => [0x00, 0x42, 0x01], - WeaponType::HandgunMilla => [0x00, 0x43, 0x00], - WeaponType::LastSwan => [0x00, 0x43, 0x01], - WeaponType::RedHandgun => [0x00, 0x44, 0x00], - WeaponType::FrozenShooter => [0x00, 0x45, 0x00], - WeaponType::SnowQueen => [0x00, 0x45, 0x01], - WeaponType::AntiAndroidRifle => [0x00, 0x46, 0x00], - WeaponType::RocketPunch => [0x00, 0x47, 0x00], - WeaponType::SambaMaracas => [0x00, 0x48, 0x00], - WeaponType::TwinPsychogun => [0x00, 0x49, 0x00], - WeaponType::DrillLauncher => [0x00, 0x4A, 0x00], - WeaponType::GuldMilla => [0x00, 0x4B, 0x00], - WeaponType::DualBird => [0x00, 0x4B, 0x01], - WeaponType::RedMechgun => [0x00, 0x4C, 0x00], - WeaponType::BelraCannon => [0x00, 0x4D, 0x00], - WeaponType::PanzerFaust => [0x00, 0x4E, 0x00], - WeaponType::IronFaust => [0x00, 0x4E, 0x01], - WeaponType::SummitMoon => [0x00, 0x4F, 0x00], - WeaponType::Windmill => [0x00, 0x50, 0x00], - WeaponType::EvilCurst => [0x00, 0x51, 0x00], - WeaponType::FlowerCane => [0x00, 0x52, 0x00], - WeaponType::HildebearsCane => [0x00, 0x53, 0x00], - WeaponType::HildebluesCane => [0x00, 0x54, 0x00], - WeaponType::RabbitWand => [0x00, 0x55, 0x00], - WeaponType::PlantainLeaf => [0x00, 0x56, 0x00], - WeaponType::Fatsia => [0x00, 0x56, 0x01], - WeaponType::DemonicFork => [0x00, 0x57, 0x00], - WeaponType::StrikerOfChao => [0x00, 0x58, 0x00], - WeaponType::Broom => [0x00, 0x59, 0x00], - WeaponType::ProphetsOfMotav => [0x00, 0x5A, 0x00], - WeaponType::TheSighOfAGod => [0x00, 0x5B, 0x00], - WeaponType::TwinkleStar => [0x00, 0x5C, 0x00], - WeaponType::PlantainFan => [0x00, 0x5D, 0x00], - WeaponType::TwinBlaze => [0x00, 0x5E, 0x00], - WeaponType::MarinasBag => [0x00, 0x5F, 0x00], - WeaponType::DragonsClaw => [0x00, 0x60, 0x00], - WeaponType::PanthersClaw => [0x00, 0x61, 0x00], - WeaponType::SRedsBlade => [0x00, 0x62, 0x00], - WeaponType::PlantainHugeFan => [0x00, 0x63, 0x00], - WeaponType::ChameleonScythe => [0x00, 0x64, 0x00], - WeaponType::Yasminkov3000R => [0x00, 0x65, 0x00], - WeaponType::AnoRifle => [0x00, 0x66, 0x00], - WeaponType::BaranzLauncher => [0x00, 0x67, 0x00], - WeaponType::BranchOfPakupaku => [0x00, 0x68, 0x00], - WeaponType::HeartOfPoumn => [0x00, 0x69, 0x00], - WeaponType::Yasminkov2000H => [0x00, 0x6A, 0x00], - WeaponType::Yasminkov7000V => [0x00, 0x6B, 0x00], - WeaponType::Yasminkov9000M => [0x00, 0x6C, 0x00], - WeaponType::MaserBeam => [0x00, 0x6D, 0x00], - WeaponType::PowerMaser => [0x00, 0x6D, 0x01], - WeaponType::GameMagazne => [0x00, 0x6E, 0x00], - WeaponType::Login2 => [0x00, 0x6E, 0x01], - WeaponType::FlowerBouquet => [0x00, 0x6F, 0x00], - WeaponType::Musashi => [0x00, 0x89, 0x00], - WeaponType::Yamato => [0x00, 0x89, 0x01], - WeaponType::Asuka => [0x00, 0x89, 0x02], - WeaponType::SangeYasha => [0x00, 0x89, 0x03], - WeaponType::Sange => [0x00, 0x8A, 0x00], - WeaponType::Yasha => [0x00, 0x8A, 0x01], - WeaponType::Kamui => [0x00, 0x8A, 0x02], - WeaponType::PhotonLauncher => [0x00, 0x8B, 0x00], - WeaponType::GuiltyLight => [0x00, 0x8B, 0x01], - WeaponType::RedScorpio => [0x00, 0x8B, 0x02], - WeaponType::PhononMaser => [0x00, 0x8B, 0x03], - WeaponType::Talis => [0x00, 0x8C, 0x00], - WeaponType::Mahu => [0x00, 0x8C, 0x01], - WeaponType::Hitogata => [0x00, 0x8C, 0x02], - WeaponType::DancingHitogata => [0x00, 0x8C, 0x03], - WeaponType::Kunai => [0x00, 0x8C, 0x04], - WeaponType::Nug2000Bazooka => [0x00, 0x8D, 0x00], - WeaponType::SBerillsHands0 => [0x00, 0x8E, 0x00], - WeaponType::SBerillsHands1 => [0x00, 0x8E, 0x01], - WeaponType::FlowensSword3060 => [0x00, 0x8F, 0x00], - WeaponType::FlowensSword3064 => [0x00, 0x8F, 0x01], - WeaponType::FlowensSword3067 => [0x00, 0x8F, 0x02], - WeaponType::FlowensSword3073 => [0x00, 0x8F, 0x03], - WeaponType::FlowensSword3077 => [0x00, 0x8F, 0x04], - WeaponType::FlowensSword3082 => [0x00, 0x8F, 0x05], - WeaponType::FlowensSword3083 => [0x00, 0x8F, 0x06], - WeaponType::FlowensSword3084 => [0x00, 0x8F, 0x07], - WeaponType::FlowensSword3079 => [0x00, 0x8F, 0x08], - WeaponType::DbsSaber3062 => [0x00, 0x90, 0x00], - WeaponType::DbsSaber3067 => [0x00, 0x90, 0x01], - WeaponType::DbsSaber3069Chris => [0x00, 0x90, 0x02], - WeaponType::DbsSaber3064 => [0x00, 0x90, 0x03], - WeaponType::DbsSaber3069Torato => [0x00, 0x90, 0x04], - WeaponType::DbsSaber3073 => [0x00, 0x90, 0x05], - WeaponType::DbsSaber3070 => [0x00, 0x90, 0x06], - WeaponType::DbsSaber3075 => [0x00, 0x90, 0x07], - WeaponType::DbsSaber3077 => [0x00, 0x90, 0x08], - WeaponType::GiGueBazooka => [0x00, 0x91, 0x00], - WeaponType::Guardianna => [0x00, 0x92, 0x00], - WeaponType::ViridiaCard => [0x00, 0x93, 0x00], - WeaponType::GreenillCard => [0x00, 0x93, 0x01], - WeaponType::SkylyCard => [0x00, 0x93, 0x02], - WeaponType::BluefullCard => [0x00, 0x93, 0x03], - WeaponType::PurplenumCard => [0x00, 0x93, 0x04], - WeaponType::PinkalCard => [0x00, 0x93, 0x05], - WeaponType::RedriaCard => [0x00, 0x93, 0x06], - WeaponType::OranCard => [0x00, 0x93, 0x07], - WeaponType::YellowbozeCard => [0x00, 0x93, 0x08], - WeaponType::WhitillCard => [0x00, 0x93, 0x09], - WeaponType::MorningGlory => [0x00, 0x94, 0x00], - WeaponType::PartisanOfLightning => [0x00, 0x95, 0x00], - WeaponType::GalWind => [0x00, 0x96, 0x00], - WeaponType::Zanba => [0x00, 0x97, 0x00], - WeaponType::RikasClaw => [0x00, 0x98, 0x00], - WeaponType::AngelHarp => [0x00, 0x99, 0x00], - WeaponType::DemolitionComet => [0x00, 0x9A, 0x00], - WeaponType::NeisClaw2 => [0x00, 0x9B, 0x00], - WeaponType::RainbowBaton => [0x00, 0x9C, 0x00], - WeaponType::DarkFlow => [0x00, 0x9D, 0x00], - WeaponType::DarkMeteor => [0x00, 0x9E, 0x00], - WeaponType::DarkBridge => [0x00, 0x9F, 0x00], - WeaponType::GAssassinsSabers => [0x00, 0xA0, 0x00], - WeaponType::RappysFan => [0x00, 0xA1, 0x00], - WeaponType::BoomasClaw => [0x00, 0xA2, 0x00], - WeaponType::GoboomasClaw => [0x00, 0xA2, 0x01], - WeaponType::GigoboomasClaw => [0x00, 0xA2, 0x02], - WeaponType::RubyBullet => [0x00, 0xA3, 0x00], - WeaponType::AmoreRose => [0x00, 0xA4, 0x00], - WeaponType::SlicerOfFanatic => [0x00, 0xAA, 0x00], - WeaponType::LameDArgent => [0x00, 0xAB, 0x00], - WeaponType::Excalibur => [0x00, 0xAC, 0x00], - WeaponType::RageDeFeu => [0x00, 0xAD, 0x00], - WeaponType::RageDeFeu2 => [0x00, 0xAD, 0x01], - WeaponType::RageDeFeu3 => [0x00, 0xAD, 0x02], - WeaponType::RageDeFeu4 => [0x00, 0xAD, 0x03], - WeaponType::DaisyChain => [0x00, 0xAE, 0x00], - WeaponType::OphelieSeize => [0x00, 0xAF, 0x00], - WeaponType::MilleMarteaux => [0x00, 0xB0, 0x00], - WeaponType::LeCogneur => [0x00, 0xB1, 0x00], - WeaponType::CommanderBlade => [0x00, 0xB2, 0x00], - WeaponType::Vivienne => [0x00, 0xB3, 0x00], - WeaponType::Kusanagi => [0x00, 0xB4, 0x00], - WeaponType::SacredDuster => [0x00, 0xB5, 0x00], - WeaponType::Guren => [0x00, 0xB6, 0x00], - WeaponType::Shouren => [0x00, 0xB7, 0x00], - WeaponType::Jizai => [0x00, 0xB8, 0x00], - WeaponType::Flamberge => [0x00, 0xB9, 0x00], - WeaponType::Yunchang => [0x00, 0xBA, 0x00], - WeaponType::SnakeSpire => [0x00, 0xBB, 0x00], - WeaponType::FlapjackFlapper => [0x00, 0xBC, 0x00], - WeaponType::Getsugasan => [0x00, 0xBD, 0x00], - WeaponType::Maguwa => [0x00, 0xBE, 0x00], - WeaponType::HeavenStriker => [0x00, 0xBF, 0x00], - WeaponType::CannonRouge => [0x00, 0xC0, 0x00], - WeaponType::MeteorRouge => [0x00, 0xC1, 0x00], - WeaponType::Solferino => [0x00, 0xC2, 0x00], - WeaponType::Clio => [0x00, 0xC3, 0x00], - WeaponType::SirenGlassHammer => [0x00, 0xC4, 0x00], - WeaponType::GlideDivine => [0x00, 0xC5, 0x00], - WeaponType::Shichishito => [0x00, 0xC6, 0x00], - WeaponType::Murasame => [0x00, 0xC7, 0x00], - WeaponType::DaylightScar => [0x00, 0xC8, 0x00], - WeaponType::Decalog => [0x00, 0xC9, 0x00], - WeaponType::FifthAnnivBlade => [0x00, 0xCA, 0x00], - WeaponType::TyrellsParasol => [0x00, 0xCB, 0x00], - WeaponType::AkikosCleaver => [0x00, 0xCC, 0x00], - WeaponType::Tanegashima => [0x00, 0xCD, 0x00], - WeaponType::TreeClippers => [0x00, 0xCE, 0x00], - WeaponType::NiceShot => [0x00, 0xCF, 0x00], - WeaponType::Unknown3 => [0x00, 0xD0, 0x00], - WeaponType::Unknown4 => [0x00, 0xD1, 0x00], - WeaponType::AnoBazooka => [0x00, 0xD2, 0x00], - WeaponType::Synthesizer => [0x00, 0xD3, 0x00], - WeaponType::BambooSpear => [0x00, 0xD4, 0x00], - WeaponType::KaneiTsuho => [0x00, 0xD5, 0x00], - WeaponType::Jitte => [0x00, 0xD6, 0x00], - WeaponType::ButterflyNet => [0x00, 0xD7, 0x00], - WeaponType::Syringe => [0x00, 0xD8, 0x00], - WeaponType::Battledore => [0x00, 0xD9, 0x00], - WeaponType::Racket => [0x00, 0xDA, 0x00], - WeaponType::Hammer => [0x00, 0xDB, 0x00], - WeaponType::GreatBouquet => [0x00, 0xDC, 0x00], - WeaponType::TypesaSaber => [0x00, 0xDD, 0x00], - WeaponType::TypeslSaber => [0x00, 0xDE, 0x00], - WeaponType::TypeslSlicer => [0x00, 0xDE, 0x01], - WeaponType::TypeslClaw => [0x00, 0xDE, 0x02], - WeaponType::TypeslKatana => [0x00, 0xDE, 0x03], - WeaponType::TypejsSaber => [0x00, 0xDF, 0x00], - WeaponType::TypejsSlicer => [0x00, 0xDF, 0x01], - WeaponType::TypejsJSword => [0x00, 0xDF, 0x02], - WeaponType::TypeswSword => [0x00, 0xE0, 0x00], - WeaponType::TypeswSlicer => [0x00, 0xE0, 0x01], - WeaponType::TypeswJSword => [0x00, 0xE0, 0x02], - WeaponType::TyperoSword => [0x00, 0xE1, 0x00], - WeaponType::TyperoHalbert => [0x00, 0xE1, 0x01], - WeaponType::TyperoRod => [0x00, 0xE1, 0x02], - WeaponType::TypeblBlade => [0x00, 0xE2, 0x00], - WeaponType::TypeknBlade => [0x00, 0xE3, 0x00], - WeaponType::TypeknClaw => [0x00, 0xE3, 0x01], - WeaponType::TypehaHalbert => [0x00, 0xE4, 0x00], - WeaponType::TypehaRod => [0x00, 0xE4, 0x01], - WeaponType::TypedsDSaber => [0x00, 0xE5, 0x00], - WeaponType::TypedsRod => [0x00, 0xE5, 0x01], - WeaponType::Typeds => [0x00, 0xE5, 0x02], - WeaponType::TypeclClaw => [0x00, 0xE6, 0x00], - WeaponType::TypessSw => [0x00, 0xE7, 0x00], - WeaponType::TypeguHand => [0x00, 0xE8, 0x00], - WeaponType::TypeguMechgun => [0x00, 0xE8, 0x01], - WeaponType::TyperiRifle => [0x00, 0xE9, 0x00], - WeaponType::TypemeMechgun => [0x00, 0xEA, 0x00], - WeaponType::TypeshShot => [0x00, 0xEB, 0x00], - WeaponType::TypewaWand => [0x00, 0xEC, 0x00], - } - } - pub fn parse_type(data: [u8; 3]) -> Result { - match data { - [0x00, 0x01, 0x00] => Ok(WeaponType::Saber), - [0x00, 0x01, 0x01] => Ok(WeaponType::Brand), - [0x00, 0x01, 0x02] => Ok(WeaponType::Buster), - [0x00, 0x01, 0x03] => Ok(WeaponType::Pallasch), - [0x00, 0x01, 0x04] => Ok(WeaponType::Gladius), - [0x00, 0x01, 0x05] => Ok(WeaponType::DbsSaber), - [0x00, 0x01, 0x06] => Ok(WeaponType::Kaladbolg), - [0x00, 0x01, 0x07] => Ok(WeaponType::Durandal), - [0x00, 0x01, 0x08] => Ok(WeaponType::Galatine), - [0x00, 0x02, 0x00] => Ok(WeaponType::Sword), - [0x00, 0x02, 0x01] => Ok(WeaponType::Gigush), - [0x00, 0x02, 0x02] => Ok(WeaponType::Breaker), - [0x00, 0x02, 0x03] => Ok(WeaponType::Claymore), - [0x00, 0x02, 0x04] => Ok(WeaponType::Calibur), - [0x00, 0x02, 0x05] => Ok(WeaponType::FlowensSword), - [0x00, 0x02, 0x06] => Ok(WeaponType::LastSurvivor), - [0x00, 0x02, 0x07] => Ok(WeaponType::DragonSlayer), - [0x00, 0x03, 0x00] => Ok(WeaponType::Dagger), - [0x00, 0x03, 0x01] => Ok(WeaponType::Knife), - [0x00, 0x03, 0x02] => Ok(WeaponType::Blade), - [0x00, 0x03, 0x03] => Ok(WeaponType::Edge), - [0x00, 0x03, 0x04] => Ok(WeaponType::Ripper), - [0x00, 0x03, 0x05] => Ok(WeaponType::BladeDance), - [0x00, 0x03, 0x06] => Ok(WeaponType::BloodyArt), - [0x00, 0x03, 0x07] => Ok(WeaponType::CrossScar), - [0x00, 0x03, 0x08] => Ok(WeaponType::ZeroDivide), - [0x00, 0x03, 0x09] => Ok(WeaponType::TwoKamui), - [0x00, 0x04, 0x00] => Ok(WeaponType::Partisan), - [0x00, 0x04, 0x01] => Ok(WeaponType::Halbert), - [0x00, 0x04, 0x02] => Ok(WeaponType::Glaive), - [0x00, 0x04, 0x03] => Ok(WeaponType::Berdys), - [0x00, 0x04, 0x04] => Ok(WeaponType::Gungnir), - [0x00, 0x04, 0x05] => Ok(WeaponType::Brionac), - [0x00, 0x04, 0x06] => Ok(WeaponType::Vjaya), - [0x00, 0x04, 0x07] => Ok(WeaponType::GaeBolg), - [0x00, 0x04, 0x08] => Ok(WeaponType::AsteronBelt), - [0x00, 0x05, 0x00] => Ok(WeaponType::Slicer), - [0x00, 0x05, 0x01] => Ok(WeaponType::Spinner), - [0x00, 0x05, 0x02] => Ok(WeaponType::Cutter), - [0x00, 0x05, 0x03] => Ok(WeaponType::Sawcer), - [0x00, 0x05, 0x04] => Ok(WeaponType::Diska), - [0x00, 0x05, 0x05] => Ok(WeaponType::SlicerOfAssassin), - [0x00, 0x05, 0x06] => Ok(WeaponType::DiskaOfLiberator), - [0x00, 0x05, 0x07] => Ok(WeaponType::DiskaOfBraveman), - [0x00, 0x05, 0x08] => Ok(WeaponType::Izmaela), - [0x00, 0x06, 0x00] => Ok(WeaponType::Handgun), - [0x00, 0x06, 0x01] => Ok(WeaponType::Autogun), - [0x00, 0x06, 0x02] => Ok(WeaponType::Lockgun), - [0x00, 0x06, 0x03] => Ok(WeaponType::Railgun), - [0x00, 0x06, 0x04] => Ok(WeaponType::Raygun), - [0x00, 0x06, 0x05] => Ok(WeaponType::Varista), - [0x00, 0x06, 0x06] => Ok(WeaponType::CustomRayVerOo), - [0x00, 0x06, 0x07] => Ok(WeaponType::Bravace), - [0x00, 0x06, 0x08] => Ok(WeaponType::TensionBlaster), - [0x00, 0x07, 0x00] => Ok(WeaponType::Rifle), - [0x00, 0x07, 0x01] => Ok(WeaponType::Sniper), - [0x00, 0x07, 0x02] => Ok(WeaponType::Blaster), - [0x00, 0x07, 0x03] => Ok(WeaponType::Beam), - [0x00, 0x07, 0x04] => Ok(WeaponType::Laser), - [0x00, 0x07, 0x05] => Ok(WeaponType::Visk235W), - [0x00, 0x07, 0x06] => Ok(WeaponType::WalsMk2), - [0x00, 0x07, 0x07] => Ok(WeaponType::Justy23St), - [0x00, 0x07, 0x08] => Ok(WeaponType::Rianov303snr), - [0x00, 0x07, 0x09] => Ok(WeaponType::Rianov303snr1), - [0x00, 0x07, 0x0A] => Ok(WeaponType::Rianov303snr2), - [0x00, 0x07, 0x0B] => Ok(WeaponType::Rianov303snr3), - [0x00, 0x07, 0x0C] => Ok(WeaponType::Rianov303snr4), - [0x00, 0x07, 0x0D] => Ok(WeaponType::Rianov303snr5), - [0x00, 0x08, 0x00] => Ok(WeaponType::Mechgun), - [0x00, 0x08, 0x01] => Ok(WeaponType::Assault), - [0x00, 0x08, 0x02] => Ok(WeaponType::Repeater), - [0x00, 0x08, 0x03] => Ok(WeaponType::Gatling), - [0x00, 0x08, 0x04] => Ok(WeaponType::Vulcan), - [0x00, 0x08, 0x05] => Ok(WeaponType::MA60Vise), - [0x00, 0x08, 0x06] => Ok(WeaponType::HS25Justice), - [0x00, 0x08, 0x07] => Ok(WeaponType::LK14Combat), - [0x00, 0x09, 0x00] => Ok(WeaponType::Shot), - [0x00, 0x09, 0x01] => Ok(WeaponType::Spread), - [0x00, 0x09, 0x02] => Ok(WeaponType::Cannon), - [0x00, 0x09, 0x03] => Ok(WeaponType::Launcher), - [0x00, 0x09, 0x04] => Ok(WeaponType::Arms), - [0x00, 0x09, 0x05] => Ok(WeaponType::CrushBullet), - [0x00, 0x09, 0x06] => Ok(WeaponType::MeteorSmash), - [0x00, 0x09, 0x07] => Ok(WeaponType::FinalImpact), - [0x00, 0x0A, 0x00] => Ok(WeaponType::Cane), - [0x00, 0x0A, 0x01] => Ok(WeaponType::Stick), - [0x00, 0x0A, 0x02] => Ok(WeaponType::Mace), - [0x00, 0x0A, 0x03] => Ok(WeaponType::Club), - [0x00, 0x0A, 0x04] => Ok(WeaponType::ClubOfLaconium), - [0x00, 0x0A, 0x05] => Ok(WeaponType::MaceOfAdaman), - [0x00, 0x0A, 0x06] => Ok(WeaponType::ClubOfZumiuran), - [0x00, 0x0A, 0x07] => Ok(WeaponType::Lollipop), - [0x00, 0x0B, 0x00] => Ok(WeaponType::Rod), - [0x00, 0x0B, 0x01] => Ok(WeaponType::Pole), - [0x00, 0x0B, 0x02] => Ok(WeaponType::Pillar), - [0x00, 0x0B, 0x03] => Ok(WeaponType::Striker), - [0x00, 0x0B, 0x04] => Ok(WeaponType::BattleVerge), - [0x00, 0x0B, 0x05] => Ok(WeaponType::BraveHammer), - [0x00, 0x0B, 0x06] => Ok(WeaponType::AliveAqhu), - [0x00, 0x0B, 0x07] => Ok(WeaponType::Valkyrie), - [0x00, 0x0C, 0x00] => Ok(WeaponType::Wand), - [0x00, 0x0C, 0x01] => Ok(WeaponType::Staff), - [0x00, 0x0C, 0x02] => Ok(WeaponType::Baton), - [0x00, 0x0C, 0x03] => Ok(WeaponType::Scepter), - [0x00, 0x0C, 0x04] => Ok(WeaponType::FireScepterAgni), - [0x00, 0x0C, 0x05] => Ok(WeaponType::IceStaffDagon), - [0x00, 0x0C, 0x06] => Ok(WeaponType::StormWandIndra), - [0x00, 0x0C, 0x07] => Ok(WeaponType::EarthWandBrownie), - [0x00, 0x0D, 0x00] => Ok(WeaponType::PhotonClaw), - [0x00, 0x0D, 0x01] => Ok(WeaponType::SilenceClaw), - [0x00, 0x0D, 0x02] => Ok(WeaponType::NeisClaw), - [0x00, 0x0D, 0x03] => Ok(WeaponType::PhoenixClaw), - [0x00, 0x0E, 0x00] => Ok(WeaponType::DoubleSaber), - [0x00, 0x0E, 0x01] => Ok(WeaponType::StagCutlery), - [0x00, 0x0E, 0x02] => Ok(WeaponType::TwinBrand), - [0x00, 0x0F, 0x00] => Ok(WeaponType::BraveKnuckle), - [0x00, 0x0F, 0x01] => Ok(WeaponType::AngryFist), - [0x00, 0x0F, 0x02] => Ok(WeaponType::GodHand), - [0x00, 0x0F, 0x03] => Ok(WeaponType::SonicKnuckle), - [0x00, 0x0F, 0x04] => Ok(WeaponType::Login), - [0x00, 0x10, 0x00] => Ok(WeaponType::Orotiagito), - [0x00, 0x10, 0x01] => Ok(WeaponType::Agito1975), - [0x00, 0x10, 0x02] => Ok(WeaponType::Agito1983), - [0x00, 0x10, 0x03] => Ok(WeaponType::Agito2001), - [0x00, 0x10, 0x04] => Ok(WeaponType::Agito1991), - [0x00, 0x10, 0x05] => Ok(WeaponType::Agito1977), - [0x00, 0x10, 0x06] => Ok(WeaponType::Agito1980), - [0x00, 0x10, 0x07] => Ok(WeaponType::Raikiri), - [0x00, 0x11, 0x00] => Ok(WeaponType::SoulEater), - [0x00, 0x11, 0x01] => Ok(WeaponType::SoulBanish), - [0x00, 0x12, 0x00] => Ok(WeaponType::SpreadNeedle), - [0x00, 0x13, 0x00] => Ok(WeaponType::HolyRay), - [0x00, 0x14, 0x00] => Ok(WeaponType::InfernoBazooka), - [0x00, 0x14, 0x01] => Ok(WeaponType::RamblingMay), - [0x00, 0x14, 0x02] => Ok(WeaponType::LK38Combat), - [0x00, 0x15, 0x00] => Ok(WeaponType::FlameVisit), - [0x00, 0x15, 0x01] => Ok(WeaponType::BurningVisit), - [0x00, 0x16, 0x00] => Ok(WeaponType::AkikosFryingPan), - [0x00, 0x17, 0x00] => Ok(WeaponType::SorcerersCane), - [0x00, 0x18, 0x00] => Ok(WeaponType::SBeatsBlade), - [0x00, 0x19, 0x00] => Ok(WeaponType::PArmsBlade), - [0x00, 0x1A, 0x00] => Ok(WeaponType::DelsabersBuster), - [0x00, 0x1B, 0x00] => Ok(WeaponType::BringersRifle), - [0x00, 0x1C, 0x00] => Ok(WeaponType::EggBlaster), - [0x00, 0x1D, 0x00] => Ok(WeaponType::PsychoWand), - [0x00, 0x1E, 0x00] => Ok(WeaponType::HeavenPunisher), - [0x00, 0x1F, 0x00] => Ok(WeaponType::LavisCannon), - [0x00, 0x20, 0x00] => Ok(WeaponType::VictorAxe), - [0x00, 0x20, 0x01] => Ok(WeaponType::LaconiumAxe), - [0x00, 0x21, 0x00] => Ok(WeaponType::ChainSawd), - [0x00, 0x22, 0x00] => Ok(WeaponType::Caduceus), - [0x00, 0x22, 0x01] => Ok(WeaponType::MercuriusRod), - [0x00, 0x23, 0x00] => Ok(WeaponType::StingTip), - [0x00, 0x24, 0x00] => Ok(WeaponType::MagicalPiece), - [0x00, 0x25, 0x00] => Ok(WeaponType::TechnicalCrozier), - [0x00, 0x26, 0x00] => Ok(WeaponType::SuppressedGun), - [0x00, 0x27, 0x00] => Ok(WeaponType::AncientSaber), - [0x00, 0x28, 0x00] => Ok(WeaponType::HarisenBattleFan), - [0x00, 0x29, 0x00] => Ok(WeaponType::Yamigarasu), - [0x00, 0x2A, 0x00] => Ok(WeaponType::AkikosWok), - [0x00, 0x2B, 0x00] => Ok(WeaponType::ToyHammer), - [0x00, 0x2C, 0x00] => Ok(WeaponType::Elysion), - [0x00, 0x2D, 0x00] => Ok(WeaponType::RedSaber), - [0x00, 0x2E, 0x00] => Ok(WeaponType::MeteorCudgel), - [0x00, 0x2F, 0x00] => Ok(WeaponType::MonkeyKingBar), - [0x00, 0x2F, 0x01] => Ok(WeaponType::BlackKingBar), - [0x00, 0x30, 0x00] => Ok(WeaponType::DoubleCannon), - [0x00, 0x30, 0x01] => Ok(WeaponType::Girasole), - [0x00, 0x31, 0x00] => Ok(WeaponType::HugeBattleFan), - [0x00, 0x32, 0x00] => Ok(WeaponType::TsumikiriJSword), - [0x00, 0x33, 0x00] => Ok(WeaponType::SealedJSword), - [0x00, 0x34, 0x00] => Ok(WeaponType::RedSword), - [0x00, 0x35, 0x00] => Ok(WeaponType::CrazyTune), - [0x00, 0x36, 0x00] => Ok(WeaponType::TwinChakram), - [0x00, 0x37, 0x00] => Ok(WeaponType::WokOfAkikosShop), - [0x00, 0x38, 0x00] => Ok(WeaponType::LavisBlade), - [0x00, 0x39, 0x00] => Ok(WeaponType::RedDagger), - [0x00, 0x3A, 0x00] => Ok(WeaponType::MadamsParasol), - [0x00, 0x3B, 0x00] => Ok(WeaponType::MadamsUmbrella), - [0x00, 0x3C, 0x00] => Ok(WeaponType::ImperialPick), - [0x00, 0x3D, 0x00] => Ok(WeaponType::Berdysh), - [0x00, 0x3E, 0x00] => Ok(WeaponType::RedPartisan), - [0x00, 0x3F, 0x00] => Ok(WeaponType::FlightCutter), - [0x00, 0x40, 0x00] => Ok(WeaponType::FlightFan), - [0x00, 0x41, 0x00] => Ok(WeaponType::RedSlicer), - [0x00, 0x42, 0x00] => Ok(WeaponType::HandgunGuld), - [0x00, 0x42, 0x01] => Ok(WeaponType::MasterRaven), - [0x00, 0x43, 0x00] => Ok(WeaponType::HandgunMilla), - [0x00, 0x43, 0x01] => Ok(WeaponType::LastSwan), - [0x00, 0x44, 0x00] => Ok(WeaponType::RedHandgun), - [0x00, 0x45, 0x00] => Ok(WeaponType::FrozenShooter), - [0x00, 0x45, 0x01] => Ok(WeaponType::SnowQueen), - [0x00, 0x46, 0x00] => Ok(WeaponType::AntiAndroidRifle), - [0x00, 0x47, 0x00] => Ok(WeaponType::RocketPunch), - [0x00, 0x48, 0x00] => Ok(WeaponType::SambaMaracas), - [0x00, 0x49, 0x00] => Ok(WeaponType::TwinPsychogun), - [0x00, 0x4A, 0x00] => Ok(WeaponType::DrillLauncher), - [0x00, 0x4B, 0x00] => Ok(WeaponType::GuldMilla), - [0x00, 0x4B, 0x01] => Ok(WeaponType::DualBird), - [0x00, 0x4C, 0x00] => Ok(WeaponType::RedMechgun), - [0x00, 0x4D, 0x00] => Ok(WeaponType::BelraCannon), - [0x00, 0x4E, 0x00] => Ok(WeaponType::PanzerFaust), - [0x00, 0x4E, 0x01] => Ok(WeaponType::IronFaust), - [0x00, 0x4F, 0x00] => Ok(WeaponType::SummitMoon), - [0x00, 0x50, 0x00] => Ok(WeaponType::Windmill), - [0x00, 0x51, 0x00] => Ok(WeaponType::EvilCurst), - [0x00, 0x52, 0x00] => Ok(WeaponType::FlowerCane), - [0x00, 0x53, 0x00] => Ok(WeaponType::HildebearsCane), - [0x00, 0x54, 0x00] => Ok(WeaponType::HildebluesCane), - [0x00, 0x55, 0x00] => Ok(WeaponType::RabbitWand), - [0x00, 0x56, 0x00] => Ok(WeaponType::PlantainLeaf), - [0x00, 0x56, 0x01] => Ok(WeaponType::Fatsia), - [0x00, 0x57, 0x00] => Ok(WeaponType::DemonicFork), - [0x00, 0x58, 0x00] => Ok(WeaponType::StrikerOfChao), - [0x00, 0x59, 0x00] => Ok(WeaponType::Broom), - [0x00, 0x5A, 0x00] => Ok(WeaponType::ProphetsOfMotav), - [0x00, 0x5B, 0x00] => Ok(WeaponType::TheSighOfAGod), - [0x00, 0x5C, 0x00] => Ok(WeaponType::TwinkleStar), - [0x00, 0x5D, 0x00] => Ok(WeaponType::PlantainFan), - [0x00, 0x5E, 0x00] => Ok(WeaponType::TwinBlaze), - [0x00, 0x5F, 0x00] => Ok(WeaponType::MarinasBag), - [0x00, 0x60, 0x00] => Ok(WeaponType::DragonsClaw), - [0x00, 0x61, 0x00] => Ok(WeaponType::PanthersClaw), - [0x00, 0x62, 0x00] => Ok(WeaponType::SRedsBlade), - [0x00, 0x63, 0x00] => Ok(WeaponType::PlantainHugeFan), - [0x00, 0x64, 0x00] => Ok(WeaponType::ChameleonScythe), - [0x00, 0x65, 0x00] => Ok(WeaponType::Yasminkov3000R), - [0x00, 0x66, 0x00] => Ok(WeaponType::AnoRifle), - [0x00, 0x67, 0x00] => Ok(WeaponType::BaranzLauncher), - [0x00, 0x68, 0x00] => Ok(WeaponType::BranchOfPakupaku), - [0x00, 0x69, 0x00] => Ok(WeaponType::HeartOfPoumn), - [0x00, 0x6A, 0x00] => Ok(WeaponType::Yasminkov2000H), - [0x00, 0x6B, 0x00] => Ok(WeaponType::Yasminkov7000V), - [0x00, 0x6C, 0x00] => Ok(WeaponType::Yasminkov9000M), - [0x00, 0x6D, 0x00] => Ok(WeaponType::MaserBeam), - [0x00, 0x6D, 0x01] => Ok(WeaponType::PowerMaser), - [0x00, 0x6E, 0x00] => Ok(WeaponType::GameMagazne), - [0x00, 0x6E, 0x01] => Ok(WeaponType::Login2), - [0x00, 0x6F, 0x00] => Ok(WeaponType::FlowerBouquet), - [0x00, 0x89, 0x00] => Ok(WeaponType::Musashi), - [0x00, 0x89, 0x01] => Ok(WeaponType::Yamato), - [0x00, 0x89, 0x02] => Ok(WeaponType::Asuka), - [0x00, 0x89, 0x03] => Ok(WeaponType::SangeYasha), - [0x00, 0x8A, 0x00] => Ok(WeaponType::Sange), - [0x00, 0x8A, 0x01] => Ok(WeaponType::Yasha), - [0x00, 0x8A, 0x02] => Ok(WeaponType::Kamui), - [0x00, 0x8B, 0x00] => Ok(WeaponType::PhotonLauncher), - [0x00, 0x8B, 0x01] => Ok(WeaponType::GuiltyLight), - [0x00, 0x8B, 0x02] => Ok(WeaponType::RedScorpio), - [0x00, 0x8B, 0x03] => Ok(WeaponType::PhononMaser), - [0x00, 0x8C, 0x00] => Ok(WeaponType::Talis), - [0x00, 0x8C, 0x01] => Ok(WeaponType::Mahu), - [0x00, 0x8C, 0x02] => Ok(WeaponType::Hitogata), - [0x00, 0x8C, 0x03] => Ok(WeaponType::DancingHitogata), - [0x00, 0x8C, 0x04] => Ok(WeaponType::Kunai), - [0x00, 0x8D, 0x00] => Ok(WeaponType::Nug2000Bazooka), - [0x00, 0x8E, 0x00] => Ok(WeaponType::SBerillsHands0), - [0x00, 0x8E, 0x01] => Ok(WeaponType::SBerillsHands1), - [0x00, 0x8F, 0x00] => Ok(WeaponType::FlowensSword3060), - [0x00, 0x8F, 0x01] => Ok(WeaponType::FlowensSword3064), - [0x00, 0x8F, 0x02] => Ok(WeaponType::FlowensSword3067), - [0x00, 0x8F, 0x03] => Ok(WeaponType::FlowensSword3073), - [0x00, 0x8F, 0x04] => Ok(WeaponType::FlowensSword3077), - [0x00, 0x8F, 0x05] => Ok(WeaponType::FlowensSword3082), - [0x00, 0x8F, 0x06] => Ok(WeaponType::FlowensSword3083), - [0x00, 0x8F, 0x07] => Ok(WeaponType::FlowensSword3084), - [0x00, 0x8F, 0x08] => Ok(WeaponType::FlowensSword3079), - [0x00, 0x90, 0x00] => Ok(WeaponType::DbsSaber3062), - [0x00, 0x90, 0x01] => Ok(WeaponType::DbsSaber3067), - [0x00, 0x90, 0x02] => Ok(WeaponType::DbsSaber3069Chris), - [0x00, 0x90, 0x03] => Ok(WeaponType::DbsSaber3064), - [0x00, 0x90, 0x04] => Ok(WeaponType::DbsSaber3069Torato), - [0x00, 0x90, 0x05] => Ok(WeaponType::DbsSaber3073), - [0x00, 0x90, 0x06] => Ok(WeaponType::DbsSaber3070), - [0x00, 0x90, 0x07] => Ok(WeaponType::DbsSaber3075), - [0x00, 0x90, 0x08] => Ok(WeaponType::DbsSaber3077), - [0x00, 0x91, 0x00] => Ok(WeaponType::GiGueBazooka), - [0x00, 0x92, 0x00] => Ok(WeaponType::Guardianna), - [0x00, 0x93, 0x00] => Ok(WeaponType::ViridiaCard), - [0x00, 0x93, 0x01] => Ok(WeaponType::GreenillCard), - [0x00, 0x93, 0x02] => Ok(WeaponType::SkylyCard), - [0x00, 0x93, 0x03] => Ok(WeaponType::BluefullCard), - [0x00, 0x93, 0x04] => Ok(WeaponType::PurplenumCard), - [0x00, 0x93, 0x05] => Ok(WeaponType::PinkalCard), - [0x00, 0x93, 0x06] => Ok(WeaponType::RedriaCard), - [0x00, 0x93, 0x07] => Ok(WeaponType::OranCard), - [0x00, 0x93, 0x08] => Ok(WeaponType::YellowbozeCard), - [0x00, 0x93, 0x09] => Ok(WeaponType::WhitillCard), - [0x00, 0x94, 0x00] => Ok(WeaponType::MorningGlory), - [0x00, 0x95, 0x00] => Ok(WeaponType::PartisanOfLightning), - [0x00, 0x96, 0x00] => Ok(WeaponType::GalWind), - [0x00, 0x97, 0x00] => Ok(WeaponType::Zanba), - [0x00, 0x98, 0x00] => Ok(WeaponType::RikasClaw), - [0x00, 0x99, 0x00] => Ok(WeaponType::AngelHarp), - [0x00, 0x9A, 0x00] => Ok(WeaponType::DemolitionComet), - [0x00, 0x9B, 0x00] => Ok(WeaponType::NeisClaw2), - [0x00, 0x9C, 0x00] => Ok(WeaponType::RainbowBaton), - [0x00, 0x9D, 0x00] => Ok(WeaponType::DarkFlow), - [0x00, 0x9E, 0x00] => Ok(WeaponType::DarkMeteor), - [0x00, 0x9F, 0x00] => Ok(WeaponType::DarkBridge), - [0x00, 0xA0, 0x00] => Ok(WeaponType::GAssassinsSabers), - [0x00, 0xA1, 0x00] => Ok(WeaponType::RappysFan), - [0x00, 0xA2, 0x00] => Ok(WeaponType::BoomasClaw), - [0x00, 0xA2, 0x01] => Ok(WeaponType::GoboomasClaw), - [0x00, 0xA2, 0x02] => Ok(WeaponType::GigoboomasClaw), - [0x00, 0xA3, 0x00] => Ok(WeaponType::RubyBullet), - [0x00, 0xA4, 0x00] => Ok(WeaponType::AmoreRose), - [0x00, 0xAA, 0x00] => Ok(WeaponType::SlicerOfFanatic), - [0x00, 0xAB, 0x00] => Ok(WeaponType::LameDArgent), - [0x00, 0xAC, 0x00] => Ok(WeaponType::Excalibur), - [0x00, 0xAD, 0x00] => Ok(WeaponType::RageDeFeu), - [0x00, 0xAD, 0x01] => Ok(WeaponType::RageDeFeu2), - [0x00, 0xAD, 0x02] => Ok(WeaponType::RageDeFeu3), - [0x00, 0xAD, 0x03] => Ok(WeaponType::RageDeFeu4), - [0x00, 0xAE, 0x00] => Ok(WeaponType::DaisyChain), - [0x00, 0xAF, 0x00] => Ok(WeaponType::OphelieSeize), - [0x00, 0xB0, 0x00] => Ok(WeaponType::MilleMarteaux), - [0x00, 0xB1, 0x00] => Ok(WeaponType::LeCogneur), - [0x00, 0xB2, 0x00] => Ok(WeaponType::CommanderBlade), - [0x00, 0xB3, 0x00] => Ok(WeaponType::Vivienne), - [0x00, 0xB4, 0x00] => Ok(WeaponType::Kusanagi), - [0x00, 0xB5, 0x00] => Ok(WeaponType::SacredDuster), - [0x00, 0xB6, 0x00] => Ok(WeaponType::Guren), - [0x00, 0xB7, 0x00] => Ok(WeaponType::Shouren), - [0x00, 0xB8, 0x00] => Ok(WeaponType::Jizai), - [0x00, 0xB9, 0x00] => Ok(WeaponType::Flamberge), - [0x00, 0xBA, 0x00] => Ok(WeaponType::Yunchang), - [0x00, 0xBB, 0x00] => Ok(WeaponType::SnakeSpire), - [0x00, 0xBC, 0x00] => Ok(WeaponType::FlapjackFlapper), - [0x00, 0xBD, 0x00] => Ok(WeaponType::Getsugasan), - [0x00, 0xBE, 0x00] => Ok(WeaponType::Maguwa), - [0x00, 0xBF, 0x00] => Ok(WeaponType::HeavenStriker), - [0x00, 0xC0, 0x00] => Ok(WeaponType::CannonRouge), - [0x00, 0xC1, 0x00] => Ok(WeaponType::MeteorRouge), - [0x00, 0xC2, 0x00] => Ok(WeaponType::Solferino), - [0x00, 0xC3, 0x00] => Ok(WeaponType::Clio), - [0x00, 0xC4, 0x00] => Ok(WeaponType::SirenGlassHammer), - [0x00, 0xC5, 0x00] => Ok(WeaponType::GlideDivine), - [0x00, 0xC6, 0x00] => Ok(WeaponType::Shichishito), - [0x00, 0xC7, 0x00] => Ok(WeaponType::Murasame), - [0x00, 0xC8, 0x00] => Ok(WeaponType::DaylightScar), - [0x00, 0xC9, 0x00] => Ok(WeaponType::Decalog), - [0x00, 0xCA, 0x00] => Ok(WeaponType::FifthAnnivBlade), - [0x00, 0xCB, 0x00] => Ok(WeaponType::TyrellsParasol), - [0x00, 0xCC, 0x00] => Ok(WeaponType::AkikosCleaver), - [0x00, 0xCD, 0x00] => Ok(WeaponType::Tanegashima), - [0x00, 0xCE, 0x00] => Ok(WeaponType::TreeClippers), - [0x00, 0xCF, 0x00] => Ok(WeaponType::NiceShot), - [0x00, 0xD0, 0x00] => Ok(WeaponType::Unknown3), - [0x00, 0xD1, 0x00] => Ok(WeaponType::Unknown4), - [0x00, 0xD2, 0x00] => Ok(WeaponType::AnoBazooka), - [0x00, 0xD3, 0x00] => Ok(WeaponType::Synthesizer), - [0x00, 0xD4, 0x00] => Ok(WeaponType::BambooSpear), - [0x00, 0xD5, 0x00] => Ok(WeaponType::KaneiTsuho), - [0x00, 0xD6, 0x00] => Ok(WeaponType::Jitte), - [0x00, 0xD7, 0x00] => Ok(WeaponType::ButterflyNet), - [0x00, 0xD8, 0x00] => Ok(WeaponType::Syringe), - [0x00, 0xD9, 0x00] => Ok(WeaponType::Battledore), - [0x00, 0xDA, 0x00] => Ok(WeaponType::Racket), - [0x00, 0xDB, 0x00] => Ok(WeaponType::Hammer), - [0x00, 0xDC, 0x00] => Ok(WeaponType::GreatBouquet), - [0x00, 0xDD, 0x00] => Ok(WeaponType::TypesaSaber), - [0x00, 0xDE, 0x00] => Ok(WeaponType::TypeslSaber), - [0x00, 0xDE, 0x01] => Ok(WeaponType::TypeslSlicer), - [0x00, 0xDE, 0x02] => Ok(WeaponType::TypeslClaw), - [0x00, 0xDE, 0x03] => Ok(WeaponType::TypeslKatana), - [0x00, 0xDF, 0x00] => Ok(WeaponType::TypejsSaber), - [0x00, 0xDF, 0x01] => Ok(WeaponType::TypejsSlicer), - [0x00, 0xDF, 0x02] => Ok(WeaponType::TypejsJSword), - [0x00, 0xE0, 0x00] => Ok(WeaponType::TypeswSword), - [0x00, 0xE0, 0x01] => Ok(WeaponType::TypeswSlicer), - [0x00, 0xE0, 0x02] => Ok(WeaponType::TypeswJSword), - [0x00, 0xE1, 0x00] => Ok(WeaponType::TyperoSword), - [0x00, 0xE1, 0x01] => Ok(WeaponType::TyperoHalbert), - [0x00, 0xE1, 0x02] => Ok(WeaponType::TyperoRod), - [0x00, 0xE2, 0x00] => Ok(WeaponType::TypeblBlade), - [0x00, 0xE3, 0x00] => Ok(WeaponType::TypeknBlade), - [0x00, 0xE3, 0x01] => Ok(WeaponType::TypeknClaw), - [0x00, 0xE4, 0x00] => Ok(WeaponType::TypehaHalbert), - [0x00, 0xE4, 0x01] => Ok(WeaponType::TypehaRod), - [0x00, 0xE5, 0x00] => Ok(WeaponType::TypedsDSaber), - [0x00, 0xE5, 0x01] => Ok(WeaponType::TypedsRod), - [0x00, 0xE5, 0x02] => Ok(WeaponType::Typeds), - [0x00, 0xE6, 0x00] => Ok(WeaponType::TypeclClaw), - [0x00, 0xE7, 0x00] => Ok(WeaponType::TypessSw), - [0x00, 0xE8, 0x00] => Ok(WeaponType::TypeguHand), - [0x00, 0xE8, 0x01] => Ok(WeaponType::TypeguMechgun), - [0x00, 0xE9, 0x00] => Ok(WeaponType::TyperiRifle), - [0x00, 0xEA, 0x00] => Ok(WeaponType::TypemeMechgun), - [0x00, 0xEB, 0x00] => Ok(WeaponType::TypeshShot), - [0x00, 0xEC, 0x00] => Ok(WeaponType::TypewaWand), - _ => Err(ItemParseError::InvalidWeaponType), - } - } -} #[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)] @@ -1457,206 +38,52 @@ pub enum WeaponModifier { }, } -#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] -pub struct Weapon { - pub weapon: WeaponType, - pub special: Option, - pub grind: u8, - pub attrs: [Option; 3], - pub tekked: bool, -} - - -impl Weapon { - pub fn new(wep: WeaponType) -> Weapon { - Weapon { - weapon: wep, - special: None, - grind: 0, - attrs: [None; 3], - tekked: true, - } - } - - pub fn apply_modifier(&mut self, modifier: &WeaponModifier) { - match modifier { - WeaponModifier::Tekked{special, percent, grind} => { - match special { - TekSpecialModifier::Plus => { - self.special = self.special.map(|special| { - special.rank_up() - }); - }, - TekSpecialModifier::Minus => { - self.special = self.special.map(|special| { - special.rank_down() - }); - }, - TekSpecialModifier::Neutral => { - }, - } - for i in 0..3 { - self.attrs[i] = self.attrs[i].map(|mut attr| { - match percent { - TekPercentModifier::PlusPlus => { - attr.value += 10; - }, - TekPercentModifier::Plus => { - attr.value += 5; - }, - TekPercentModifier::MinusMinus => { - attr.value -= 10; - }, - TekPercentModifier::Minus => { - attr.value -= 5; - }, - TekPercentModifier::Neutral => { - } - } - attr +pub fn apply_modifier(weapon: &mut Weapon, modifier: &WeaponModifier) { + match modifier { + WeaponModifier::Tekked{special, percent, grind} => { + match special { + TekSpecialModifier::Plus => { + weapon.special = weapon.special.map(|special| { + special.rank_up() }); - } - self.grind = std::cmp::max(self.grind as i32 + grind, 0) as u8; - self.tekked = true; - }, - WeaponModifier::AddGrind {amount, ..} => { - self.grind += *amount as u8; - }, - WeaponModifier::AddPercents {..} => { - // TODO - } - } - } - - pub fn as_bytes(&self) -> [u8; 16] { - let mut result = [0u8; 16]; - result[0..3].copy_from_slice(&self.weapon.value()); - result[3] = self.grind; - result[4] = self.special.map(|s| s.value()).unwrap_or(0); - - if !self.tekked { - result[4] += 0x80 - }; - - result[6..8].copy_from_slice(&self.attrs[0].map(|s| s.value()).unwrap_or([0,0])); - result[8..10].copy_from_slice(&self.attrs[1].map(|s| s.value()).unwrap_or([0,0])); - result[10..12].copy_from_slice(&self.attrs[2].map(|s| s.value()).unwrap_or([0,0])); - - result - } - - // TODO: error handling - pub fn from_bytes(data: [u8; 16]) -> Result { - let wep = WeaponType::parse_type([data[0], data[1], data[2]]); - if let Ok(weapon) = wep { - let mut special = None; - let mut tekked = true; - let grind = data[3]; - - if data[4] >= 0x81 && data[4] <= 0xA8 { - special = WeaponSpecial::from(data[4] - 0x80); - tekked = false; - } - else if data[4] >= 0x01 && data[4] <= 0x28 { - special = WeaponSpecial::from(data[4]); - tekked = true; + }, + TekSpecialModifier::Minus => { + weapon.special = weapon.special.map(|special| { + special.rank_down() + }); + }, + TekSpecialModifier::Neutral => { + }, } - // else { - // return Err(ItemParseError::InvalidSpecial) - // } - - let mut attrs = [ - None, - None, - None - ]; - for i in 0..3 { - if data[2 * (3 + i)] >= 1 && data[2 * (3 + i)] <= 5 { - attrs[i] = Some(WeaponAttribute{ - attr: Attribute::from(data[2 * (3 + i)]).unwrap(), - value: data[2 * (3 + i) + 1] as i8, - }); - } else { - attrs[i] = None; - // return Err(ItemParseError::InvalidAttribute) - } + weapon.attrs[i] = weapon.attrs[i].map(|mut attr| { + match percent { + TekPercentModifier::PlusPlus => { + attr.value += 10; + }, + TekPercentModifier::Plus => { + attr.value += 5; + }, + TekPercentModifier::MinusMinus => { + attr.value -= 10; + }, + TekPercentModifier::Minus => { + attr.value -= 5; + }, + TekPercentModifier::Neutral => { + } + } + attr + }); } - - Ok(Weapon { - weapon, - special, - grind, - attrs, - tekked, - }) + weapon.grind = std::cmp::max(weapon.grind as i32 + grind, 0) as u8; + weapon.tekked = true; + }, + WeaponModifier::AddGrind {amount, ..} => { + weapon.grind += *amount as u8; + }, + WeaponModifier::AddPercents {..} => { + // TODO } - else { - Err(ItemParseError::InvalidWeaponBytes) // TODO: error handling if wrong bytes are given - } - } - - // TODO: invert this? ie: handgun, saber, dagger etc. => false, _ => true? - pub fn is_rare_item(self) -> bool { - !matches!( - self.weapon, - WeaponType::Saber - | WeaponType::Brand - | WeaponType::Buster - | WeaponType::Pallasch - | WeaponType::Gladius - | WeaponType::Sword - | WeaponType::Gigush - | WeaponType::Breaker - | WeaponType::Claymore - | WeaponType::Calibur - | WeaponType::Dagger - | WeaponType::Knife - | WeaponType::Blade - | WeaponType::Edge - | WeaponType::Ripper - | WeaponType::Partisan - | WeaponType::Halbert - | WeaponType::Glaive - | WeaponType::Berdys - | WeaponType::Gungnir - | WeaponType::Slicer - | WeaponType::Spinner - | WeaponType::Cutter - | WeaponType::Sawcer - | WeaponType::Diska - | WeaponType::Handgun - | WeaponType::Autogun - | WeaponType::Lockgun - | WeaponType::Railgun - | WeaponType::Raygun - | WeaponType::Rifle - | WeaponType::Sniper - | WeaponType::Blaster - | WeaponType::Beam - | WeaponType::Laser - | WeaponType::Mechgun - | WeaponType::Assault - | WeaponType::Repeater - | WeaponType::Gatling - | WeaponType::Vulcan - | WeaponType::Shot - | WeaponType::Spread - | WeaponType::Cannon - | WeaponType::Launcher - | WeaponType::Arms - | WeaponType::Cane - | WeaponType::Stick - | WeaponType::Mace - | WeaponType::Club - | WeaponType::Rod - | WeaponType::Pole - | WeaponType::Pillar - | WeaponType::Striker - | WeaponType::Wand - | WeaponType::Staff - | WeaponType::Baton - | WeaponType::Scepter - ) } } diff --git a/src/items/src/actions.rs b/src/items/src/actions.rs index 0b55d6d..e1b9e8a 100644 --- a/src/items/src/actions.rs +++ b/src/items/src/actions.rs @@ -13,6 +13,7 @@ use entity::gateway::{EntityGateway, EntityGatewayTransaction}; use entity::item::{ItemDetail, NewItemEntity, TradeId, ItemModifier}; use entity::item::tool::Tool; use entity::room::RoomEntityId; +use entity::item::weapon::apply_modifier; use maps::area::MapArea; use crate::state::{ItemStateProxy, ItemStateError, AddItemResult, StackedItemDetail, IndividualItemDetail}; use crate::bank::{BankItem, BankItemDetail}; @@ -1112,7 +1113,7 @@ where Box::pin(async move { match (&mut inventory_item.item, modifier) { (InventoryItemDetail::Individual(IndividualItemDetail{entity_id, item: ItemDetail::Weapon(ref mut weapon), ..}), ItemModifier::WeaponModifier(modifier)) => { - weapon.apply_modifier(&modifier); + apply_modifier(weapon, &modifier); transaction.gateway().add_weapon_modifier(entity_id, &modifier).await?; }, _ => return Err(ItemStateError::InvalidModifier.into()) diff --git a/src/items/src/apply_item.rs b/src/items/src/apply_item.rs index 0f74627..6a55852 100644 --- a/src/items/src/apply_item.rs +++ b/src/items/src/apply_item.rs @@ -10,7 +10,7 @@ use entity::item::mag::{MagCell, MagCellError}; use entity::item::tool::{Tool, ToolType}; use entity::item::tech::TechniqueDisk; use entity::item::{ItemDetail, ItemEntityId}; -use entity::item::weapon::WeaponModifier; +use entity::item::weapon::{WeaponModifier, apply_modifier}; use crate::state::ItemStateProxy; use crate::inventory::InventoryItemDetail; @@ -259,7 +259,7 @@ where let mut inventory = item_state.inventory(&character.id).await?; let (weapon_entity_id, weapon) = inventory.equipped_weapon_mut() .ok_or(ApplyItemError::ItemNotEquipped)?; - weapon.apply_modifier(&modifier); + apply_modifier(weapon, &modifier); entity_gateway.add_weapon_modifier(&weapon_entity_id, &modifier).await?; item_state.set_inventory(inventory).await; diff --git a/src/items/src/bank.rs b/src/items/src/bank.rs index e68700a..8982c2a 100644 --- a/src/items/src/bank.rs +++ b/src/items/src/bank.rs @@ -1,4 +1,5 @@ use std::cmp::Ordering; +use libpso::item::ItemBytes; use libpso::character::character; use crate::ClientItemId; use entity::item::{Meseta, ItemEntityId, ItemDetail, ItemEntity, BankEntity, BankItemEntity}; diff --git a/src/items/src/inventory.rs b/src/items/src/inventory.rs index d8c0da9..a1282cf 100644 --- a/src/items/src/inventory.rs +++ b/src/items/src/inventory.rs @@ -8,7 +8,7 @@ use async_std::sync::{Arc, Mutex}; use entity::character::CharacterEntityId; use entity::item::tool::ToolType; use entity::item::mag::Mag; -use entity::item::weapon::Weapon; +use libpso::item::weapon::Weapon; use shops::{ShopItem, ArmorShopItem, ToolShopItem, WeaponShopItem}; use crate::state::ItemStateError; use crate::state::{IndividualItemDetail, StackedItemDetail, AddItemResult}; diff --git a/src/items/src/state.rs b/src/items/src/state.rs index ac17f0f..580a198 100644 --- a/src/items/src/state.rs +++ b/src/items/src/state.rs @@ -4,11 +4,12 @@ use async_std::sync::{Arc, RwLock, Mutex}; use futures::stream::{FuturesOrdered, StreamExt}; use anyhow::Context; +use libpso::item::ItemBytes; use entity::gateway::{EntityGateway, GatewayError}; use entity::character::{CharacterEntity, CharacterEntityId}; use entity::item::{ItemEntityId, ItemDetail, ItemEntity, InventoryItemEntity, BankItemEntity, BankIdentifier}; use entity::item::tool::Tool; -use entity::item::weapon::Weapon; +use libpso::item::weapon::Weapon; use entity::item::mag::Mag; use drops::ItemDrop; use crate::ClientItemId; diff --git a/src/login_server/src/character.rs b/src/login_server/src/character.rs index 30cf4af..a1a2d6b 100644 --- a/src/login_server/src/character.rs +++ b/src/login_server/src/character.rs @@ -25,7 +25,7 @@ use libpso::util::{utf8_to_array, utf8_to_utf16_array}; use entity::gateway::{EntityGateway, GatewayError}; use entity::account::{UserAccountId, UserAccountEntity, NewUserSettingsEntity, USERFLAG_NEWCHAR, USERFLAG_DRESSINGROOM}; use entity::item::{NewItemEntity, ItemDetail, ItemNote, InventoryItemEntity, InventoryEntity, BankEntity, BankIdentifier, EquippedEntity, Meseta}; -use entity::item::weapon::Weapon; +use libpso::item::weapon::{Weapon, WeaponType}; use entity::item::armor::Armor; use entity::item::tech::Technique; use entity::item::tool::Tool; @@ -216,9 +216,9 @@ async fn new_character(entity_gateway: &mut EG, user: entity_gateway.set_bank_meseta(&character.id, &BankIdentifier::Character, Meseta(0)).await?; let new_weapon = match character.char_class { - CharacterClass::HUmar | CharacterClass::HUnewearl | CharacterClass::HUcast | CharacterClass::HUcaseal => item::weapon::WeaponType::Saber, - CharacterClass::RAmar | CharacterClass::RAmarl | CharacterClass::RAcast | CharacterClass::RAcaseal => item::weapon::WeaponType::Handgun, - CharacterClass::FOmar | CharacterClass::FOmarl | CharacterClass::FOnewm | CharacterClass::FOnewearl => item::weapon::WeaponType::Cane, + CharacterClass::HUmar | CharacterClass::HUnewearl | CharacterClass::HUcast | CharacterClass::HUcaseal => WeaponType::Saber, + CharacterClass::RAmar | CharacterClass::RAmarl | CharacterClass::RAcast | CharacterClass::RAcaseal => WeaponType::Handgun, + CharacterClass::FOmar | CharacterClass::FOmarl | CharacterClass::FOnewm | CharacterClass::FOnewearl => WeaponType::Cane, }; diff --git a/src/pktbuilder/src/message.rs b/src/pktbuilder/src/message.rs index cf843df..d9262dc 100644 --- a/src/pktbuilder/src/message.rs +++ b/src/pktbuilder/src/message.rs @@ -1,5 +1,7 @@ use libpso::packet::messages::*; use libpso::packet::ship::*; +use libpso::item::weapon; +use libpso::item::ItemBytes; use entity::item; use stats::leveltable::CharacterStats; //use crate::ship::ship::{ShipError}; @@ -215,7 +217,7 @@ pub fn shop_list(shop_type: u8, items: &[I]) -> ShopList { } } -pub fn tek_preview(id: ClientItemId, weapon: &item::weapon::Weapon) -> TekPreview { +pub fn tek_preview(id: ClientItemId, weapon: &weapon::Weapon) -> TekPreview { let bytes = weapon.as_bytes(); TekPreview { client: 0x79, diff --git a/src/ship_server/src/direct_message.rs b/src/ship_server/src/direct_message.rs index 74e68e2..8968a3d 100644 --- a/src/ship_server/src/direct_message.rs +++ b/src/ship_server/src/direct_message.rs @@ -482,7 +482,7 @@ where .as_weapon() .ok_or_else(|| ItemStateError::WrongItemType(ClientItemId(tek_request.item_id)))?; - weapon.apply_modifier(&item::weapon::WeaponModifier::Tekked { + item::weapon::apply_modifier(&mut weapon, &item::weapon::WeaponModifier::Tekked { special: special_mod, percent: percent_mod, grind: grind_mod, diff --git a/src/shops/src/weapon.rs b/src/shops/src/weapon.rs index 3522645..255118d 100644 --- a/src/shops/src/weapon.rs +++ b/src/shops/src/weapon.rs @@ -11,7 +11,7 @@ use rand::seq::{SliceRandom, IteratorRandom}; use libpso::character::SectionID; use maps::room::Difficulty; use entity::item::ItemDetail; -use entity::item::weapon::{Weapon, WeaponType, WeaponSpecial, Attribute, WeaponAttribute}; +use libpso::item::weapon::{Weapon, WeaponType, WeaponSpecial, Attribute, WeaponAttribute}; use crate::ShopItem; use stats::items::WEAPON_STATS; diff --git a/src/stats/src/items.rs b/src/stats/src/items.rs index 13d0855..d76aa83 100644 --- a/src/stats/src/items.rs +++ b/src/stats/src/items.rs @@ -4,7 +4,7 @@ use serde::{Serialize, Deserialize}; use std::fs::File; use std::io::Read; -use entity::item::weapon::WeaponType; +use libpso::item::weapon::WeaponType; use entity::item::armor::ArmorType; use entity::item::shield::ShieldType; use entity::item::unit::UnitType; diff --git a/tests/common.rs b/tests/common.rs index c8836ca..33e0a1f 100644 --- a/tests/common.rs +++ b/tests/common.rs @@ -17,6 +17,7 @@ use drops::{DropTable, ItemDropType}; use shops::{ItemShops, WeaponShopItem, ToolShopItem, ArmorShopItem}; use entity::item; +use libpso::item::weapon; use libpso::packet::ship::*; use libpso::packet::login::{Login, Session}; @@ -160,16 +161,16 @@ pub async fn join_room(ship: &mut ShipServerState pub struct WeaponBuilder { - weapon: item::weapon::WeaponType, + weapon: weapon::WeaponType, grind: u8, - special: Option, - attributes: [Option; 3], + special: Option, + attributes: [Option; 3], tekked: bool, } impl WeaponBuilder { - fn new(weapon: item::weapon::WeaponType) -> WeaponBuilder { + fn new(weapon: weapon::WeaponType) -> WeaponBuilder { WeaponBuilder { weapon, grind: 0, @@ -186,19 +187,19 @@ impl WeaponBuilder { } } - pub fn special(self, special: item::weapon::WeaponSpecial) -> WeaponBuilder { + pub fn special(self, special: weapon::WeaponSpecial) -> WeaponBuilder { WeaponBuilder { special: Some(special), ..self } } - pub fn attr(mut self, attr: item::weapon::Attribute, value: i8) -> WeaponBuilder { + pub fn attr(mut self, attr: weapon::Attribute, value: i8) -> WeaponBuilder { self.attributes .iter_mut() .find(|k| k.is_none()) .map(|empty_attr| { - *empty_attr = Some(item::weapon::WeaponAttribute { + *empty_attr = Some(weapon::WeaponAttribute { attr, value, }) @@ -217,7 +218,7 @@ impl WeaponBuilder { pub fn as_new(self) -> item::NewItemEntity { item::NewItemEntity { item: item::ItemDetail::Weapon( - item::weapon::Weapon { + weapon::Weapon { weapon: self.weapon, grind: self.grind, special: self.special, @@ -411,7 +412,7 @@ impl TechBuilder { pub struct ItemBuilder; impl ItemBuilder { - pub fn weapon(weapon: item::weapon::WeaponType) -> WeaponBuilder { + pub fn weapon(weapon: weapon::WeaponType) -> WeaponBuilder { WeaponBuilder::new(weapon) } diff --git a/tests/test_bank.rs b/tests/test_bank.rs index 7f825af..1183f35 100644 --- a/tests/test_bank.rs +++ b/tests/test_bank.rs @@ -2,6 +2,7 @@ use std::collections::BTreeSet; use networking::serverstate::{ClientId, ServerState}; use entity::gateway::{EntityGateway, InMemoryGateway}; use entity::item; +use libpso::item::weapon; use ship_server::{RecvShipPacket, SendShipPacket}; use shops::StandardItemShops; @@ -20,7 +21,7 @@ async fn test_bank_items_sent_in_character_login() { let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a").await; let item = entity_gateway.create_item( - ItemBuilder::weapon(item::weapon::WeaponType::Vulcan) + ItemBuilder::weapon(weapon::WeaponType::Vulcan) .as_new() ).await.unwrap(); @@ -47,7 +48,7 @@ async fn test_request_bank_items() { let mut bank = Vec::new(); for _ in 0..3 { bank.push(entity_gateway.create_item( - ItemBuilder::weapon(item::weapon::WeaponType::Vulcan) + ItemBuilder::weapon(weapon::WeaponType::Vulcan) .as_new() ).await.unwrap()); } @@ -120,7 +121,7 @@ async fn test_request_bank_items_sorted() { let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a").await; let item1 = entity_gateway.create_item( - ItemBuilder::weapon(item::weapon::WeaponType::Vulcan) + ItemBuilder::weapon(weapon::WeaponType::Vulcan) .as_new() ).await.unwrap(); let monomate = entity_gateway.create_item( @@ -128,7 +129,7 @@ async fn test_request_bank_items_sorted() { .as_new() ).await.unwrap(); let item2 = entity_gateway.create_item( - ItemBuilder::weapon(item::weapon::WeaponType::Calibur) + ItemBuilder::weapon(weapon::WeaponType::Calibur) .as_new() ).await.unwrap(); @@ -164,11 +165,11 @@ async fn test_deposit_individual_item() { let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a").await; let item0 = entity_gateway.create_item( - ItemBuilder::weapon(item::weapon::WeaponType::Saber) + ItemBuilder::weapon(weapon::WeaponType::Saber) .as_new() ).await.unwrap(); let item1 = entity_gateway.create_item( - ItemBuilder::weapon(item::weapon::WeaponType::Handgun) + ItemBuilder::weapon(weapon::WeaponType::Handgun) .as_new() ).await.unwrap(); @@ -468,14 +469,14 @@ async fn test_deposit_individual_item_in_full_bank() { let mut inventory = Vec::new(); inventory.push(entity_gateway.create_item( - ItemBuilder::weapon(item::weapon::WeaponType::Vulcan) + ItemBuilder::weapon(weapon::WeaponType::Vulcan) .as_new() ).await.unwrap()); let mut bank = Vec::new(); for _ in 0..200usize { bank.push(entity_gateway.create_item( - ItemBuilder::weapon(item::weapon::WeaponType::Vulcan) + ItemBuilder::weapon(weapon::WeaponType::Vulcan) .as_new() ).await.unwrap()); } @@ -533,7 +534,7 @@ async fn test_deposit_stacked_item_in_full_bank() { let mut full_bank = Vec::new(); for _ in 0..200usize { full_bank.push(entity_gateway.create_item( - ItemBuilder::weapon(item::weapon::WeaponType::Vulcan) + ItemBuilder::weapon(weapon::WeaponType::Vulcan) .as_new() ).await.unwrap()); } @@ -600,7 +601,7 @@ async fn test_deposit_stacked_item_in_full_bank_with_partial_stack() { let mut almost_full_bank: Vec = Vec::new(); for _ in 0..199usize { almost_full_bank.push(entity_gateway.create_item( - ItemBuilder::weapon(item::weapon::WeaponType::Vulcan) + ItemBuilder::weapon(weapon::WeaponType::Vulcan) .as_new() ).await.unwrap().into()); } @@ -758,7 +759,7 @@ async fn test_withdraw_individual_item() { let mut bank = Vec::new(); bank.push(entity_gateway.create_item( - ItemBuilder::weapon(item::weapon::WeaponType::Saber) + ItemBuilder::weapon(weapon::WeaponType::Saber) .as_new() ).await.unwrap()); @@ -1049,14 +1050,14 @@ async fn test_withdraw_individual_item_in_full_inventory() { let mut bank = Vec::new(); bank.push(entity_gateway.create_item( - ItemBuilder::weapon(item::weapon::WeaponType::Vulcan) + ItemBuilder::weapon(weapon::WeaponType::Vulcan) .as_new() ).await.unwrap()); let mut inventory = Vec::new(); for _ in 0..30usize { inventory.push(entity_gateway.create_item( - ItemBuilder::weapon(item::weapon::WeaponType::Vulcan) + ItemBuilder::weapon(weapon::WeaponType::Vulcan) .as_new() ).await.unwrap()); } @@ -1110,7 +1111,7 @@ async fn test_withdraw_stacked_item_in_full_inventory() { let mut inventory = Vec::new(); for _ in 0..30usize { inventory.push(entity_gateway.create_item( - ItemBuilder::weapon(item::weapon::WeaponType::Vulcan) + ItemBuilder::weapon(weapon::WeaponType::Vulcan) .as_new() ).await.unwrap()); } @@ -1171,7 +1172,7 @@ async fn test_withdraw_stacked_item_in_full_inventory_with_partial_stack() { let mut items = Vec::new(); for _i in 0..29usize { items.push(entity_gateway.create_item( - ItemBuilder::weapon(item::weapon::WeaponType::Vulcan) + ItemBuilder::weapon(weapon::WeaponType::Vulcan) .as_new() ).await.unwrap().into()); } @@ -1389,12 +1390,12 @@ async fn test_deposit_items_into_shared_banks() { let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await; - let item0 = entity_gateway.create_item(ItemBuilder::weapon(item::weapon::WeaponType::Saber).as_new()).await.unwrap(); - let item1 = entity_gateway.create_item(ItemBuilder::weapon(item::weapon::WeaponType::Buster).as_new()).await.unwrap(); - let item2 = entity_gateway.create_item(ItemBuilder::weapon(item::weapon::WeaponType::Rifle).as_new()).await.unwrap(); - let item3 = entity_gateway.create_item(ItemBuilder::weapon(item::weapon::WeaponType::Handgun).as_new()).await.unwrap(); - let item4 = entity_gateway.create_item(ItemBuilder::weapon(item::weapon::WeaponType::Autogun).as_new()).await.unwrap(); - let item5 = entity_gateway.create_item(ItemBuilder::weapon(item::weapon::WeaponType::Calibur).as_new()).await.unwrap(); + let item0 = entity_gateway.create_item(ItemBuilder::weapon(weapon::WeaponType::Saber).as_new()).await.unwrap(); + let item1 = entity_gateway.create_item(ItemBuilder::weapon(weapon::WeaponType::Buster).as_new()).await.unwrap(); + let item2 = entity_gateway.create_item(ItemBuilder::weapon(weapon::WeaponType::Rifle).as_new()).await.unwrap(); + let item3 = entity_gateway.create_item(ItemBuilder::weapon(weapon::WeaponType::Handgun).as_new()).await.unwrap(); + let item4 = entity_gateway.create_item(ItemBuilder::weapon(weapon::WeaponType::Autogun).as_new()).await.unwrap(); + let item5 = entity_gateway.create_item(ItemBuilder::weapon(weapon::WeaponType::Calibur).as_new()).await.unwrap(); entity_gateway.set_character_inventory(&char1.id, &item::InventoryEntity::new(vec![item0, item1, item2, item3, item4, item5])).await.unwrap(); @@ -1586,12 +1587,12 @@ async fn test_withdraw_items_from_shared_banks() { let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await; - let item0 = entity_gateway.create_item(ItemBuilder::weapon(item::weapon::WeaponType::Saber).as_new()).await.unwrap(); - let item1 = entity_gateway.create_item(ItemBuilder::weapon(item::weapon::WeaponType::Buster).as_new()).await.unwrap(); - let item2 = entity_gateway.create_item(ItemBuilder::weapon(item::weapon::WeaponType::Rifle).as_new()).await.unwrap(); - let item3 = entity_gateway.create_item(ItemBuilder::weapon(item::weapon::WeaponType::Handgun).as_new()).await.unwrap(); - let item4 = entity_gateway.create_item(ItemBuilder::weapon(item::weapon::WeaponType::Autogun).as_new()).await.unwrap(); - let item5 = entity_gateway.create_item(ItemBuilder::weapon(item::weapon::WeaponType::Calibur).as_new()).await.unwrap(); + let item0 = entity_gateway.create_item(ItemBuilder::weapon(weapon::WeaponType::Saber).as_new()).await.unwrap(); + let item1 = entity_gateway.create_item(ItemBuilder::weapon(weapon::WeaponType::Buster).as_new()).await.unwrap(); + let item2 = entity_gateway.create_item(ItemBuilder::weapon(weapon::WeaponType::Rifle).as_new()).await.unwrap(); + let item3 = entity_gateway.create_item(ItemBuilder::weapon(weapon::WeaponType::Handgun).as_new()).await.unwrap(); + let item4 = entity_gateway.create_item(ItemBuilder::weapon(weapon::WeaponType::Autogun).as_new()).await.unwrap(); + let item5 = entity_gateway.create_item(ItemBuilder::weapon(weapon::WeaponType::Calibur).as_new()).await.unwrap(); entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(vec![item0, item1]), &item::BankIdentifier::Character).await.unwrap(); entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(vec![item2, item3]), &item::BankIdentifier::Shared(item::BankName("asdf".into()))).await.unwrap(); diff --git a/tests/test_item_drop.rs b/tests/test_item_drop.rs index 91f179b..29a5511 100644 --- a/tests/test_item_drop.rs +++ b/tests/test_item_drop.rs @@ -8,7 +8,7 @@ use maps::maps::Maps; use maps::area::MapArea; use maps::variant::{MapVariant, MapVariantMode}; use maps::enemy::MapEnemy; -use entity::item::weapon::WeaponType; +use libpso::item::weapon::WeaponType; use libpso::packet::ship::*; use libpso::packet::messages::*; diff --git a/tests/test_item_id.rs b/tests/test_item_id.rs index 3302806..06c38ec 100644 --- a/tests/test_item_id.rs +++ b/tests/test_item_id.rs @@ -1,6 +1,7 @@ use networking::serverstate::{ClientId, ServerState}; use entity::gateway::{EntityGateway, InMemoryGateway}; use entity::item; +use libpso::item::weapon; use ship_server::RecvShipPacket; use libpso::packet::ship::*; @@ -134,7 +135,7 @@ async fn test_using_some_monomates_after_a_convoluted_series_of_leaves_and_joins p3_items.push( item::InventoryItemEntity::Individual( entity_gateway.create_item( - ItemBuilder::weapon(item::weapon::WeaponType::Saber) + ItemBuilder::weapon(weapon::WeaponType::Saber) .as_new() ).await.unwrap() )); diff --git a/tests/test_item_pickup.rs b/tests/test_item_pickup.rs index ccef78a..7ec7987 100644 --- a/tests/test_item_pickup.rs +++ b/tests/test_item_pickup.rs @@ -1,6 +1,7 @@ use networking::serverstate::{ClientId, ServerState}; use entity::gateway::{EntityGateway, InMemoryGateway}; use entity::item; +use libpso::item::weapon; use ship_server::RecvShipPacket; use libpso::packet::ship::*; @@ -19,7 +20,7 @@ async fn test_pick_up_individual_item() { let mut p1_inv = Vec::new(); p1_inv.push(entity_gateway.create_item( - ItemBuilder::weapon(item::weapon::WeaponType::Handgun) + ItemBuilder::weapon(weapon::WeaponType::Handgun) .as_new() ).await.unwrap()); @@ -200,7 +201,7 @@ async fn test_pick_up_meseta_when_inventory_full() { let mut p1_items = Vec::new(); for _ in 0..30usize { p1_items.push(entity_gateway.create_item( - ItemBuilder::weapon(item::weapon::WeaponType::Saber) + ItemBuilder::weapon(weapon::WeaponType::Saber) .as_new() ).await.unwrap()); } @@ -263,7 +264,7 @@ async fn test_pick_up_partial_stacked_item_when_inventory_is_otherwise_full() { let mut p1_inv = Vec::new(); for _slot in 0..29usize { p1_inv.push(entity_gateway.create_item( - ItemBuilder::weapon(item::weapon::WeaponType::Saber) + ItemBuilder::weapon(weapon::WeaponType::Saber) .as_new() ).await.unwrap().into()); } @@ -328,14 +329,14 @@ async fn test_can_not_pick_up_item_when_inventory_full() { let mut p1_inv = Vec::new(); for _slot in 0..30usize { p1_inv.push(entity_gateway.create_item( - ItemBuilder::weapon(item::weapon::WeaponType::Saber) + ItemBuilder::weapon(weapon::WeaponType::Saber) .as_new() ).await.unwrap()); } let mut p2_inv = Vec::new(); p2_inv.push(entity_gateway.create_item( - ItemBuilder::weapon(item::weapon::WeaponType::Handgun) + ItemBuilder::weapon(weapon::WeaponType::Handgun) .as_new() ).await.unwrap()); diff --git a/tests/test_item_use.rs b/tests/test_item_use.rs index 274a344..7bdaa04 100644 --- a/tests/test_item_use.rs +++ b/tests/test_item_use.rs @@ -1,6 +1,7 @@ use networking::serverstate::{ClientId, ServerState}; use entity::gateway::{EntityGateway, InMemoryGateway}; use entity::item; +use libpso::item::weapon; use ship_server::RecvShipPacket; use entity::character::TechLevel; @@ -326,7 +327,7 @@ async fn test_use_monogrinder() { let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await; let saber = entity_gateway.create_item( - ItemBuilder::weapon(item::weapon::WeaponType::Saber) + ItemBuilder::weapon(weapon::WeaponType::Saber) .as_new() ).await.unwrap(); @@ -369,7 +370,7 @@ async fn test_use_monogrinder() { let inventory_items = entity_gateway.get_character_inventory(&char1.id).await.unwrap(); assert_eq!(inventory_items.items.len(), 2); - assert!(matches!(inventory_items.items[0], item::InventoryItemEntity::Individual(item::ItemEntity{ item: item::ItemDetail::Weapon(item::weapon::Weapon {grind: 2, ..}), ..}))); + assert!(matches!(inventory_items.items[0], item::InventoryItemEntity::Individual(item::ItemEntity{ item: item::ItemDetail::Weapon(weapon::Weapon {grind: 2, ..}), ..}))); } diff --git a/tests/test_shops.rs b/tests/test_shops.rs index 59540b7..400587d 100644 --- a/tests/test_shops.rs +++ b/tests/test_shops.rs @@ -1,6 +1,7 @@ use networking::serverstate::{ClientId, ServerState}; use entity::gateway::{EntityGateway, InMemoryGateway}; use entity::item; +use libpso::item::weapon; use ship_server::{RecvShipPacket, SendShipPacket}; use maps::room::Difficulty; use items::state::ItemStateError; @@ -265,12 +266,12 @@ async fn test_player_sells_3_attr_weapon_to_shop() { let mut p1_inv = Vec::new(); p1_inv.push(entity_gateway.create_item( - ItemBuilder::weapon(item::weapon::WeaponType::Vulcan) + ItemBuilder::weapon(weapon::WeaponType::Vulcan) .grind(5) - .special(item::weapon::WeaponSpecial::Charge) - .attr(item::weapon::Attribute::Hit, 100) - .attr(item::weapon::Attribute::Dark, 100) - .attr(item::weapon::Attribute::Native, 100) + .special(weapon::WeaponSpecial::Charge) + .attr(weapon::Attribute::Hit, 100) + .attr(weapon::Attribute::Dark, 100) + .attr(weapon::Attribute::Native, 100) .as_new() ).await.unwrap()); @@ -613,13 +614,13 @@ async fn test_player_sells_untekked_weapon() { let mut p1_inv = Vec::new(); p1_inv.push(entity_gateway.create_item( - ItemBuilder::weapon(item::weapon::WeaponType::Vulcan) + ItemBuilder::weapon(weapon::WeaponType::Vulcan) .untekked() .grind(5) - .special(item::weapon::WeaponSpecial::Charge) - .attr(item::weapon::Attribute::Hit, 100) - .attr(item::weapon::Attribute::Dark, 100) - .attr(item::weapon::Attribute::Native, 100) + .special(weapon::WeaponSpecial::Charge) + .attr(weapon::Attribute::Hit, 100) + .attr(weapon::Attribute::Dark, 100) + .attr(weapon::Attribute::Native, 100) .as_new() ).await.unwrap()); @@ -651,11 +652,11 @@ async fn test_player_sells_rare_item() { let mut p1_inv = Vec::new(); p1_inv.push(entity_gateway.create_item( - ItemBuilder::weapon(item::weapon::WeaponType::DarkFlow) + ItemBuilder::weapon(weapon::WeaponType::DarkFlow) .grind(5) - .attr(item::weapon::Attribute::Hit, 100) - .attr(item::weapon::Attribute::Dark, 100) - .attr(item::weapon::Attribute::Native, 100) + .attr(weapon::Attribute::Hit, 100) + .attr(weapon::Attribute::Dark, 100) + .attr(weapon::Attribute::Native, 100) .as_new() ).await.unwrap()); diff --git a/tests/test_trade.rs b/tests/test_trade.rs index 8266892..54de386 100644 --- a/tests/test_trade.rs +++ b/tests/test_trade.rs @@ -2,6 +2,7 @@ use std::convert::TryInto; use networking::serverstate::{ClientId, ServerState}; use entity::gateway::{EntityGateway, InMemoryGateway}; use entity::item; +use libpso::item::weapon; use ship_server::{ShipServerState, RecvShipPacket, SendShipPacket}; use entity::item::{Meseta, ItemEntity, InventoryItemEntity}; use ship_server::trade::TradeError; @@ -118,7 +119,7 @@ async fn test_trade_one_individual_item() { let mut p1_inv = Vec::new(); p1_inv.push(entity_gateway.create_item( - ItemBuilder::weapon(item::weapon::WeaponType::Handgun) + ItemBuilder::weapon(weapon::WeaponType::Handgun) .as_new() ).await.unwrap()); @@ -209,7 +210,7 @@ async fn test_trade_player2_to_player1() { let mut p2_inv = Vec::new(); p2_inv.push(entity_gateway.create_item( - ItemBuilder::weapon(item::weapon::WeaponType::Handgun) + ItemBuilder::weapon(weapon::WeaponType::Handgun) .as_new() ).await.unwrap()); @@ -300,7 +301,7 @@ async fn test_reverse_trade_ack_order() { let mut p1_inv = Vec::new(); p1_inv.push(entity_gateway.create_item( - ItemBuilder::weapon(item::weapon::WeaponType::Handgun) + ItemBuilder::weapon(weapon::WeaponType::Handgun) .as_new() ).await.unwrap()); @@ -590,12 +591,12 @@ async fn test_trade_individual_both() { let p1_inv = vec![ entity_gateway.create_item( - ItemBuilder::weapon(item::weapon::WeaponType::Saber) + ItemBuilder::weapon(weapon::WeaponType::Saber) .as_new() ).await.unwrap()]; let p2_inv = vec![ entity_gateway.create_item( - ItemBuilder::weapon(item::weapon::WeaponType::Handgun) + ItemBuilder::weapon(weapon::WeaponType::Handgun) .as_new() ).await.unwrap()]; @@ -722,10 +723,10 @@ async fn test_trade_individual_both() { let p1_items = entity_gateway.get_character_inventory(&char1.id).await.unwrap(); assert_eq!(p1_items.items.len(), 1); - assert!(matches!(p1_items.items[0].with_individual(|i| i.clone()).unwrap(), item::ItemEntity{item: item::ItemDetail::Weapon(item::weapon::Weapon {weapon: item::weapon::WeaponType::Handgun, ..}), ..})); + assert!(matches!(p1_items.items[0].with_individual(|i| i.clone()).unwrap(), item::ItemEntity{item: item::ItemDetail::Weapon(weapon::Weapon {weapon: weapon::WeaponType::Handgun, ..}), ..})); let p2_items = entity_gateway.get_character_inventory(&char2.id).await.unwrap(); assert_eq!(p2_items.items.len(), 1); - assert!(matches!(p2_items.items[0].with_individual(|i| i.clone()).unwrap(), item::ItemEntity{item: item::ItemDetail::Weapon(item::weapon::Weapon {weapon: item::weapon::WeaponType::Saber, ..}), ..})); + assert!(matches!(p2_items.items[0].with_individual(|i| i.clone()).unwrap(), item::ItemEntity{item: item::ItemDetail::Weapon(weapon::Weapon {weapon: weapon::WeaponType::Saber, ..}), ..})); } #[async_std::test] @@ -1355,7 +1356,7 @@ async fn test_trade_individual_for_stacked() { let p1_inv = vec![ entity_gateway.create_item( - ItemBuilder::weapon(item::weapon::WeaponType::Saber) + ItemBuilder::weapon(weapon::WeaponType::Saber) .as_new() ).await.unwrap()]; @@ -1499,7 +1500,7 @@ async fn test_trade_individual_for_stacked() { assert!(matches!(p1_items.items[0].with_stacked(|i| i.clone()).unwrap()[0], item::ItemEntity{item: item::ItemDetail::Tool(item::tool::Tool {tool: item::tool::ToolType::Monomate, ..}), ..})); let p2_items = entity_gateway.get_character_inventory(&char2.id).await.unwrap(); assert_eq!(p2_items.items.len(), 1); - assert!(matches!(p2_items.items[0].with_individual(|i| i.clone()).unwrap(), item::ItemEntity{item: item::ItemDetail::Weapon(item::weapon::Weapon {weapon: item::weapon::WeaponType::Saber, ..}), ..})); + assert!(matches!(p2_items.items[0].with_individual(|i| i.clone()).unwrap(), item::ItemEntity{item: item::ItemDetail::Weapon(weapon::Weapon {weapon: weapon::WeaponType::Saber, ..}), ..})); } #[async_std::test] @@ -1511,21 +1512,21 @@ async fn test_trade_multiple_individual() { let p1_inv = vec![ entity_gateway.create_item( - ItemBuilder::weapon(item::weapon::WeaponType::Saber) + ItemBuilder::weapon(weapon::WeaponType::Saber) .as_new() ).await.unwrap(), entity_gateway.create_item( - ItemBuilder::weapon(item::weapon::WeaponType::Buster) + ItemBuilder::weapon(weapon::WeaponType::Buster) .as_new() ).await.unwrap(), ]; let p2_inv = vec![ entity_gateway.create_item( - ItemBuilder::weapon(item::weapon::WeaponType::Handgun) + ItemBuilder::weapon(weapon::WeaponType::Handgun) .as_new() ).await.unwrap(), entity_gateway.create_item( - ItemBuilder::weapon(item::weapon::WeaponType::Autogun) + ItemBuilder::weapon(weapon::WeaponType::Autogun) .as_new() ).await.unwrap(), ]; @@ -1717,12 +1718,12 @@ async fn test_trade_multiple_individual() { let p1_items = entity_gateway.get_character_inventory(&char1.id).await.unwrap(); assert_eq!(p1_items.items.len(), 2); - assert!(matches!(p1_items.items[0].with_individual(|i| i.clone()).unwrap(), item::ItemEntity{item: item::ItemDetail::Weapon(item::weapon::Weapon {weapon: item::weapon::WeaponType::Handgun, ..}), ..})); - assert!(matches!(p1_items.items[1].with_individual(|i| i.clone()).unwrap(), item::ItemEntity{item: item::ItemDetail::Weapon(item::weapon::Weapon {weapon: item::weapon::WeaponType::Autogun, ..}), ..})); + assert!(matches!(p1_items.items[0].with_individual(|i| i.clone()).unwrap(), item::ItemEntity{item: item::ItemDetail::Weapon(weapon::Weapon {weapon: weapon::WeaponType::Handgun, ..}), ..})); + assert!(matches!(p1_items.items[1].with_individual(|i| i.clone()).unwrap(), item::ItemEntity{item: item::ItemDetail::Weapon(weapon::Weapon {weapon: weapon::WeaponType::Autogun, ..}), ..})); let p2_items = entity_gateway.get_character_inventory(&char2.id).await.unwrap(); assert_eq!(p2_items.items.len(), 2); - assert!(matches!(p2_items.items[0].with_individual(|i| i.clone()).unwrap(), item::ItemEntity{item: item::ItemDetail::Weapon(item::weapon::Weapon {weapon: item::weapon::WeaponType::Saber, ..}), ..})); - assert!(matches!(p2_items.items[1].with_individual(|i| i.clone()).unwrap(), item::ItemEntity{item: item::ItemDetail::Weapon(item::weapon::Weapon {weapon: item::weapon::WeaponType::Buster, ..}), ..})); + assert!(matches!(p2_items.items[0].with_individual(|i| i.clone()).unwrap(), item::ItemEntity{item: item::ItemDetail::Weapon(weapon::Weapon {weapon: weapon::WeaponType::Saber, ..}), ..})); + assert!(matches!(p2_items.items[1].with_individual(|i| i.clone()).unwrap(), item::ItemEntity{item: item::ItemDetail::Weapon(weapon::Weapon {weapon: weapon::WeaponType::Buster, ..}), ..})); } @@ -1986,7 +1987,7 @@ async fn test_trade_not_enough_inventory_space_individual() { let mut entity_gateway = entity_gateway.clone(); async move { entity_gateway.create_item( - ItemBuilder::weapon(item::weapon::WeaponType::Handgun) + ItemBuilder::weapon(weapon::WeaponType::Handgun) .as_new() ).await }})) @@ -1999,7 +2000,7 @@ async fn test_trade_not_enough_inventory_space_individual() { let mut entity_gateway = entity_gateway.clone(); async move { entity_gateway.create_item( - ItemBuilder::weapon(item::weapon::WeaponType::Handgun) + ItemBuilder::weapon(weapon::WeaponType::Handgun) .as_new() ).await }})) @@ -2102,7 +2103,7 @@ async fn test_trade_not_enough_inventory_space_stacked() { let mut entity_gateway = entity_gateway.clone(); async move { entity_gateway.create_item( - ItemBuilder::weapon(item::weapon::WeaponType::Handgun) + ItemBuilder::weapon(weapon::WeaponType::Handgun) .as_new() ).await }})) @@ -2553,7 +2554,7 @@ async fn test_back_out_of_trade_last_minute() { let mut p1_inv = Vec::new(); p1_inv.push(entity_gateway.create_item( - ItemBuilder::weapon(item::weapon::WeaponType::Handgun) + ItemBuilder::weapon(weapon::WeaponType::Handgun) .as_new() ).await.unwrap()); @@ -2611,7 +2612,7 @@ async fn test_valid_trade_when_both_inventories_are_full() { let mut entity_gateway = entity_gateway.clone(); async move { entity_gateway.create_item( - ItemBuilder::weapon(item::weapon::WeaponType::Saber) + ItemBuilder::weapon(weapon::WeaponType::Saber) .as_new() ).await }})) @@ -2624,7 +2625,7 @@ async fn test_valid_trade_when_both_inventories_are_full() { let mut entity_gateway = entity_gateway.clone(); async move { entity_gateway.create_item( - ItemBuilder::weapon(item::weapon::WeaponType::Handgun) + ItemBuilder::weapon(weapon::WeaponType::Handgun) .as_new() ).await }})) @@ -2714,12 +2715,12 @@ async fn test_valid_trade_when_both_inventories_are_full() { let p1_items = entity_gateway.get_character_inventory(&char1.id).await.unwrap(); assert_eq!(p1_items.items.len(), 30); - assert_eq!(p1_items.items.iter().filter(|i| matches!(i.individual().unwrap().item, item::ItemDetail::Weapon(item::weapon::Weapon { weapon: item::weapon::WeaponType::Saber, ..}, ..))).count(), 28); - assert_eq!(p1_items.items.iter().filter(|i| matches!(i.individual().unwrap().item, item::ItemDetail::Weapon(item::weapon::Weapon { weapon: item::weapon::WeaponType::Handgun, ..}, ..))).count(), 2); + assert_eq!(p1_items.items.iter().filter(|i| matches!(i.individual().unwrap().item, item::ItemDetail::Weapon(weapon::Weapon { weapon: weapon::WeaponType::Saber, ..}, ..))).count(), 28); + assert_eq!(p1_items.items.iter().filter(|i| matches!(i.individual().unwrap().item, item::ItemDetail::Weapon(weapon::Weapon { weapon: weapon::WeaponType::Handgun, ..}, ..))).count(), 2); let p2_items = entity_gateway.get_character_inventory(&char2.id).await.unwrap(); assert_eq!(p2_items.items.len(), 30); - assert_eq!(p2_items.items.iter().filter(|i| matches!(i.individual().unwrap().item, item::ItemDetail::Weapon(item::weapon::Weapon { weapon: item::weapon::WeaponType::Saber, ..}, ..))).count(), 2); - assert_eq!(p2_items.items.iter().filter(|i| matches!(i.individual().unwrap().item, item::ItemDetail::Weapon(item::weapon::Weapon { weapon: item::weapon::WeaponType::Handgun, ..}, ..))).count(), 28); + assert_eq!(p2_items.items.iter().filter(|i| matches!(i.individual().unwrap().item, item::ItemDetail::Weapon(weapon::Weapon { weapon: weapon::WeaponType::Saber, ..}, ..))).count(), 2); + assert_eq!(p2_items.items.iter().filter(|i| matches!(i.individual().unwrap().item, item::ItemDetail::Weapon(weapon::Weapon { weapon: weapon::WeaponType::Handgun, ..}, ..))).count(), 28); } #[async_std::test] @@ -2733,7 +2734,7 @@ async fn test_invalid_trade_when_both_inventories_are_full() { let mut entity_gateway = entity_gateway.clone(); async move { entity_gateway.create_item( - ItemBuilder::weapon(item::weapon::WeaponType::Saber) + ItemBuilder::weapon(weapon::WeaponType::Saber) .as_new() ).await }})) @@ -2746,7 +2747,7 @@ async fn test_invalid_trade_when_both_inventories_are_full() { let mut entity_gateway = entity_gateway.clone(); async move { entity_gateway.create_item( - ItemBuilder::weapon(item::weapon::WeaponType::Handgun) + ItemBuilder::weapon(weapon::WeaponType::Handgun) .as_new() ).await }})) @@ -2847,10 +2848,10 @@ async fn test_invalid_trade_when_both_inventories_are_full() { let p1_items = entity_gateway.get_character_inventory(&char1.id).await.unwrap(); assert_eq!(p1_items.items.len(), 30); - assert_eq!(p1_items.items.iter().filter(|i| matches!(i.individual().unwrap().item, item::ItemDetail::Weapon(item::weapon::Weapon { weapon: item::weapon::WeaponType::Saber, ..}, ..))).count(), 30); + assert_eq!(p1_items.items.iter().filter(|i| matches!(i.individual().unwrap().item, item::ItemDetail::Weapon(weapon::Weapon { weapon: weapon::WeaponType::Saber, ..}, ..))).count(), 30); let p2_items = entity_gateway.get_character_inventory(&char2.id).await.unwrap(); assert_eq!(p2_items.items.len(), 30); - assert_eq!(p2_items.items.iter().filter(|i| matches!(i.individual().unwrap().item, item::ItemDetail::Weapon(item::weapon::Weapon { weapon: item::weapon::WeaponType::Handgun, ..}, ..))).count(), 30); + assert_eq!(p2_items.items.iter().filter(|i| matches!(i.individual().unwrap().item, item::ItemDetail::Weapon(weapon::Weapon { weapon: weapon::WeaponType::Handgun, ..}, ..))).count(), 30); } @@ -2932,7 +2933,7 @@ async fn test_add_then_remove_individual_item() { let mut p1_inv = Vec::new(); for _ in 0..2 { p1_inv.push(entity_gateway.create_item( - ItemBuilder::weapon(item::weapon::WeaponType::Handgun) + ItemBuilder::weapon(weapon::WeaponType::Handgun) .as_new() ).await.unwrap()); } @@ -3357,7 +3358,7 @@ async fn test_items_to_trade_data_does_not_match() { let mut p1_inv = Vec::new(); p1_inv.push(entity_gateway.create_item( - ItemBuilder::weapon(item::weapon::WeaponType::Handgun) + ItemBuilder::weapon(weapon::WeaponType::Handgun) .as_new() ).await.unwrap()); @@ -3394,8 +3395,8 @@ async fn test_items_to_trade_data_does_not_match() { ItemEntity { id: p1_items.items[0].with_individual(|i| i.id).unwrap(), item: item::ItemDetail::Weapon( - item::weapon::Weapon { - weapon: item::weapon::WeaponType::Handgun, + weapon::Weapon { + weapon: weapon::WeaponType::Handgun, grind: 2, special: None, attrs: [None, None, None], @@ -3430,7 +3431,7 @@ async fn test_items_to_trade_id_does_not_match() { let mut p1_inv = Vec::new(); p1_inv.push(entity_gateway.create_item( - ItemBuilder::weapon(item::weapon::WeaponType::Handgun) + ItemBuilder::weapon(weapon::WeaponType::Handgun) .as_new() ).await.unwrap()); @@ -3627,15 +3628,15 @@ async fn test_items_to_trade_count_less_than() { let p1_inv = vec![ entity_gateway.create_item( - ItemBuilder::weapon(item::weapon::WeaponType::Saber) + ItemBuilder::weapon(weapon::WeaponType::Saber) .as_new() ).await.unwrap(), entity_gateway.create_item( - ItemBuilder::weapon(item::weapon::WeaponType::Brand) + ItemBuilder::weapon(weapon::WeaponType::Brand) .as_new() ).await.unwrap(), entity_gateway.create_item( - ItemBuilder::weapon(item::weapon::WeaponType::Buster) + ItemBuilder::weapon(weapon::WeaponType::Buster) .as_new() ).await.unwrap(), ]; @@ -3705,15 +3706,15 @@ async fn test_items_to_trade_count_greater_than() { let p1_inv = vec![ entity_gateway.create_item( - ItemBuilder::weapon(item::weapon::WeaponType::Saber) + ItemBuilder::weapon(weapon::WeaponType::Saber) .as_new() ).await.unwrap(), entity_gateway.create_item( - ItemBuilder::weapon(item::weapon::WeaponType::Brand) + ItemBuilder::weapon(weapon::WeaponType::Brand) .as_new() ).await.unwrap(), entity_gateway.create_item( - ItemBuilder::weapon(item::weapon::WeaponType::Buster) + ItemBuilder::weapon(weapon::WeaponType::Buster) .as_new() ).await.unwrap(), ]; @@ -3787,15 +3788,15 @@ async fn test_items_to_trade_count_mismatch_with_meseta() { let p1_inv = vec![ entity_gateway.create_item( - ItemBuilder::weapon(item::weapon::WeaponType::Saber) + ItemBuilder::weapon(weapon::WeaponType::Saber) .as_new() ).await.unwrap(), entity_gateway.create_item( - ItemBuilder::weapon(item::weapon::WeaponType::Brand) + ItemBuilder::weapon(weapon::WeaponType::Brand) .as_new() ).await.unwrap(), entity_gateway.create_item( - ItemBuilder::weapon(item::weapon::WeaponType::Buster) + ItemBuilder::weapon(weapon::WeaponType::Buster) .as_new() ).await.unwrap(), ]; @@ -3863,7 +3864,7 @@ async fn test_dropping_item_after_trade() { let mut p1_inv = Vec::new(); p1_inv.push(entity_gateway.create_item( - ItemBuilder::weapon(item::weapon::WeaponType::Handgun) + ItemBuilder::weapon(weapon::WeaponType::Handgun) .as_new() ).await.unwrap());