Browse Source

moved weapon logic to libpso

move_stuff_to_libpso
jake 1 year ago
parent
commit
04180d1d86
  1. 2
      Cargo.toml
  2. 68
      src/bin/main.rs
  3. 2
      src/drops/src/generic_weapon.rs
  4. 3
      src/drops/src/lib.rs
  5. 2
      src/drops/src/rare_drop_table.rs
  6. 2
      src/entity/src/gateway/inmemory.rs
  7. 4
      src/entity/src/gateway/postgres/models.rs
  8. 2
      src/entity/src/gateway/postgres/postgres.rs
  9. 4
      src/entity/src/item/esweapon.rs
  10. 6
      src/entity/src/item/mod.rs
  11. 1661
      src/entity/src/item/weapon.rs
  12. 3
      src/items/src/actions.rs
  13. 4
      src/items/src/apply_item.rs
  14. 1
      src/items/src/bank.rs
  15. 2
      src/items/src/inventory.rs
  16. 3
      src/items/src/state.rs
  17. 8
      src/login_server/src/character.rs
  18. 4
      src/pktbuilder/src/message.rs
  19. 2
      src/ship_server/src/direct_message.rs
  20. 2
      src/shops/src/weapon.rs
  21. 2
      src/stats/src/items.rs
  22. 19
      tests/common.rs
  23. 55
      tests/test_bank.rs
  24. 2
      tests/test_item_drop.rs
  25. 3
      tests/test_item_id.rs
  26. 11
      tests/test_item_pickup.rs
  27. 5
      tests/test_item_use.rs
  28. 29
      tests/test_shops.rs
  29. 93
      tests/test_trade.rs

2
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"

68
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,
}
),

2
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};

3
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 {

2
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};

2
src/entity/src/gateway/inmemory.rs

@ -271,7 +271,7 @@ fn apply_modifiers(items: &BTreeMap<ItemEntityId, ItemEntity>,
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)

4
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<PgWeapon> for weapon::Weapon {
#[derive(Debug, sqlx::FromRow)]
pub struct PgWeaponModifier {
pub weapon: i32,
pub modifier: sqlx::types::Json<weapon::WeaponModifier>,
pub modifier: sqlx::types::Json<WeaponModifier>,
}
#[derive(Debug, Serialize, Deserialize)]

2
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;

4
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,

6
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),

1661
src/entity/src/item/weapon.rs
File diff suppressed because it is too large
View File

3
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())

4
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;

1
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};

2
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};

3
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;

8
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<EG: EntityGateway + Clone>(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,
};

4
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<I: ShopItem>(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,

2
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,

2
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;

2
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;

19
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<EG: EntityGateway + Clone>(ship: &mut ShipServerState<EG>
pub struct WeaponBuilder {
weapon: item::weapon::WeaponType,
weapon: weapon::WeaponType,
grind: u8,
special: Option<item::weapon::WeaponSpecial>,
attributes: [Option<item::weapon::WeaponAttribute>; 3],
special: Option<weapon::WeaponSpecial>,
attributes: [Option<weapon::WeaponAttribute>; 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)
}

55
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<item::BankItemEntity> = 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();

2
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::*;

3
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()
));

11
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());

5
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, ..}), ..})));
}

29
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());

93
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());

Loading…
Cancel
Save