From 1bd88fdaaff79cadea120395f5246810795ce4ef Mon Sep 17 00:00:00 2001 From: jake Date: Mon, 6 Feb 2023 18:07:13 -0700 Subject: [PATCH] itembuilder to clean up item creation in tests --- tests/common.rs | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/tests/common.rs b/tests/common.rs index a8f6929..e9dccd0 100644 --- a/tests/common.rs +++ b/tests/common.rs @@ -8,6 +8,8 @@ use elseware::entity::item::{Meseta, BankName, BankIdentifier}; use elseware::ship::ship::{ShipServerState, RecvShipPacket}; use elseware::ship::room::Difficulty; +use elseware::entity::item; + use libpso::packet::ship::*; use libpso::packet::login::{Login, Session}; use libpso::{utf8_to_array, utf8_to_utf16_array}; @@ -92,3 +94,44 @@ pub async fn join_room(ship: &mut ShipServerState })).await.unwrap(); ship.handle(id, RecvShipPacket::DoneBursting(DoneBursting {})).await.unwrap(); } + + + +pub struct WeaponBuilder { + weapon: item::weapon::WeaponType, + grind: u8, +} + +impl WeaponBuilder { + pub fn grind(self, grind: u8) -> WeaponBuilder { + WeaponBuilder { + grind, + ..self + } + } + + pub fn as_new(self) -> item::NewItemEntity { + item::NewItemEntity { + item: item::ItemDetail::Weapon( + item::weapon::Weapon { + weapon: self.weapon, + grind: self.grind, + special: None, + attrs: [None, None, None], + tekked: true, + } + ) + } + } +} + +pub struct ItemBuilder; + +impl ItemBuilder { + pub fn weapon(weapon: item::weapon::WeaponType) -> WeaponBuilder { + WeaponBuilder { + weapon, + grind: 0, + } + } +}