Browse Source

itembuilder to clean up item creation in tests

pull/130/head
jake 1 year ago
parent
commit
1bd88fdaaf
  1. 43
      tests/common.rs

43
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<EG: EntityGateway + Clone>(ship: &mut ShipServerState<EG>
})).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,
}
}
}
Loading…
Cancel
Save