moved weapon logic to libpso
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
f1e1fd72af
commit
04180d1d86
@ -42,7 +42,7 @@ patch_server = { path = "./src/patch_server" }
|
|||||||
login_server = { path = "./src/login_server" }
|
login_server = { path = "./src/login_server" }
|
||||||
ship_server = { path = "./src/ship_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"] }
|
async-std = { version = "1.9.0", features = ["unstable", "attributes"] }
|
||||||
futures = "0.3.5"
|
futures = "0.3.5"
|
||||||
|
@ -7,6 +7,8 @@ use login_server::character::CharacterServerState;
|
|||||||
use patch_server::{PatchServerState, generate_patch_tree, load_config, load_motd};
|
use patch_server::{PatchServerState, generate_patch_tree, load_config, load_motd};
|
||||||
use ship_server::ShipServerStateBuilder;
|
use ship_server::ShipServerStateBuilder;
|
||||||
|
|
||||||
|
use libpso::item::weapon::{Weapon, WeaponType, WeaponSpecial, WeaponAttribute, Attribute};
|
||||||
|
|
||||||
use maps::Holiday;
|
use maps::Holiday;
|
||||||
use entity::gateway::{EntityGateway, InMemoryGateway};
|
use entity::gateway::{EntityGateway, InMemoryGateway};
|
||||||
use entity::account::{NewUserAccountEntity, NewUserSettingsEntity};
|
use entity::account::{NewUserAccountEntity, NewUserSettingsEntity};
|
||||||
@ -81,8 +83,8 @@ fn main() {
|
|||||||
entity_gateway.create_item(
|
entity_gateway.create_item(
|
||||||
item::NewItemEntity {
|
item::NewItemEntity {
|
||||||
item: item::ItemDetail::Weapon(
|
item: item::ItemDetail::Weapon(
|
||||||
item::weapon::Weapon {
|
Weapon {
|
||||||
weapon: item::weapon::WeaponType::Vulcan,
|
weapon: WeaponType::Vulcan,
|
||||||
grind: 0,
|
grind: 0,
|
||||||
special: None,
|
special: None,
|
||||||
attrs: [None, None, None],
|
attrs: [None, None, None],
|
||||||
@ -106,12 +108,12 @@ fn main() {
|
|||||||
let item0 = entity_gateway.create_item(
|
let item0 = entity_gateway.create_item(
|
||||||
NewItemEntity {
|
NewItemEntity {
|
||||||
item: ItemDetail::Weapon(
|
item: ItemDetail::Weapon(
|
||||||
item::weapon::Weapon {
|
Weapon {
|
||||||
weapon: item::weapon::WeaponType::Raygun,
|
weapon: WeaponType::Raygun,
|
||||||
grind: 5,
|
grind: 5,
|
||||||
special: Some(item::weapon::WeaponSpecial::Hell),
|
special: Some(WeaponSpecial::Hell),
|
||||||
attrs: [Some(item::weapon::WeaponAttribute{attr: item::weapon::Attribute::Hit, value: 40}),
|
attrs: [Some(WeaponAttribute{attr: Attribute::Hit, value: 40}),
|
||||||
Some(item::weapon::WeaponAttribute{attr: item::weapon::Attribute::Dark, value: 30}),
|
Some(WeaponAttribute{attr: Attribute::Dark, value: 30}),
|
||||||
None,],
|
None,],
|
||||||
tekked: false,
|
tekked: false,
|
||||||
}
|
}
|
||||||
@ -120,12 +122,12 @@ fn main() {
|
|||||||
let item1 = entity_gateway.create_item(
|
let item1 = entity_gateway.create_item(
|
||||||
NewItemEntity {
|
NewItemEntity {
|
||||||
item: ItemDetail::Weapon(
|
item: ItemDetail::Weapon(
|
||||||
item::weapon::Weapon {
|
Weapon {
|
||||||
weapon: item::weapon::WeaponType::Handgun,
|
weapon: WeaponType::Handgun,
|
||||||
grind: 5,
|
grind: 5,
|
||||||
special: Some(item::weapon::WeaponSpecial::Charge),
|
special: Some(WeaponSpecial::Charge),
|
||||||
attrs: [Some(item::weapon::WeaponAttribute{attr: item::weapon::Attribute::Hit, value: 40}),
|
attrs: [Some(WeaponAttribute{attr: Attribute::Hit, value: 40}),
|
||||||
Some(item::weapon::WeaponAttribute{attr: item::weapon::Attribute::Dark, value: 30}),
|
Some(WeaponAttribute{attr: Attribute::Dark, value: 30}),
|
||||||
None,],
|
None,],
|
||||||
tekked: true,
|
tekked: true,
|
||||||
}
|
}
|
||||||
@ -134,12 +136,12 @@ fn main() {
|
|||||||
let item2_w = entity_gateway.create_item(
|
let item2_w = entity_gateway.create_item(
|
||||||
NewItemEntity {
|
NewItemEntity {
|
||||||
item: ItemDetail::Weapon(
|
item: ItemDetail::Weapon(
|
||||||
item::weapon::Weapon {
|
Weapon {
|
||||||
weapon: item::weapon::WeaponType::Vjaya,
|
weapon: WeaponType::Vjaya,
|
||||||
grind: 5,
|
grind: 5,
|
||||||
special: Some(item::weapon::WeaponSpecial::Charge),
|
special: Some(WeaponSpecial::Charge),
|
||||||
attrs: [Some(item::weapon::WeaponAttribute{attr: item::weapon::Attribute::Hit, value: 40}),
|
attrs: [Some(WeaponAttribute{attr: Attribute::Hit, value: 40}),
|
||||||
Some(item::weapon::WeaponAttribute{attr: item::weapon::Attribute::Dark, value: 100}),
|
Some(WeaponAttribute{attr: Attribute::Dark, value: 100}),
|
||||||
None,],
|
None,],
|
||||||
tekked: true,
|
tekked: true,
|
||||||
}
|
}
|
||||||
@ -148,12 +150,12 @@ fn main() {
|
|||||||
let item3 = entity_gateway.create_item(
|
let item3 = entity_gateway.create_item(
|
||||||
NewItemEntity {
|
NewItemEntity {
|
||||||
item: ItemDetail::Weapon(
|
item: ItemDetail::Weapon(
|
||||||
item::weapon::Weapon {
|
Weapon {
|
||||||
weapon: item::weapon::WeaponType::Vulcan,
|
weapon: WeaponType::Vulcan,
|
||||||
grind: 5,
|
grind: 5,
|
||||||
special: Some(item::weapon::WeaponSpecial::Charge),
|
special: Some(WeaponSpecial::Charge),
|
||||||
attrs: [Some(item::weapon::WeaponAttribute{attr: item::weapon::Attribute::Hit, value: 100}),
|
attrs: [Some(WeaponAttribute{attr: Attribute::Hit, value: 100}),
|
||||||
Some(item::weapon::WeaponAttribute{attr: item::weapon::Attribute::Dark, value: 100}),
|
Some(WeaponAttribute{attr: Attribute::Dark, value: 100}),
|
||||||
None,],
|
None,],
|
||||||
tekked: true,
|
tekked: true,
|
||||||
}
|
}
|
||||||
@ -162,13 +164,13 @@ fn main() {
|
|||||||
let item4 = entity_gateway.create_item(
|
let item4 = entity_gateway.create_item(
|
||||||
NewItemEntity {
|
NewItemEntity {
|
||||||
item: ItemDetail::Weapon(
|
item: ItemDetail::Weapon(
|
||||||
item::weapon::Weapon {
|
Weapon {
|
||||||
weapon: item::weapon::WeaponType::DarkFlow,
|
weapon: WeaponType::DarkFlow,
|
||||||
grind: 0,
|
grind: 0,
|
||||||
special: None,
|
special: None,
|
||||||
attrs: [Some(item::weapon::WeaponAttribute{attr: item::weapon::Attribute::Hit, value: 100}),
|
attrs: [Some(WeaponAttribute{attr: Attribute::Hit, value: 100}),
|
||||||
Some(item::weapon::WeaponAttribute{attr: item::weapon::Attribute::Dark, value: 100}),
|
Some(WeaponAttribute{attr: Attribute::Dark, value: 100}),
|
||||||
Some(item::weapon::WeaponAttribute{attr: item::weapon::Attribute::Native, value: 100}),],
|
Some(WeaponAttribute{attr: Attribute::Native, value: 100}),],
|
||||||
tekked: true,
|
tekked: true,
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
@ -289,13 +291,13 @@ fn main() {
|
|||||||
let item14 = entity_gateway.create_item(
|
let item14 = entity_gateway.create_item(
|
||||||
NewItemEntity {
|
NewItemEntity {
|
||||||
item: ItemDetail::Weapon(
|
item: ItemDetail::Weapon(
|
||||||
item::weapon::Weapon {
|
Weapon {
|
||||||
weapon: item::weapon::WeaponType::Vulcan,
|
weapon: WeaponType::Vulcan,
|
||||||
grind: 5,
|
grind: 5,
|
||||||
special: Some(item::weapon::WeaponSpecial::Charge),
|
special: Some(WeaponSpecial::Charge),
|
||||||
attrs: [Some(item::weapon::WeaponAttribute{attr: item::weapon::Attribute::Hit, value: 100}),
|
attrs: [Some(WeaponAttribute{attr: Attribute::Hit, value: 100}),
|
||||||
Some(item::weapon::WeaponAttribute{attr: item::weapon::Attribute::Dark, value: 100}),
|
Some(WeaponAttribute{attr: Attribute::Dark, value: 100}),
|
||||||
Some(item::weapon::WeaponAttribute{attr: item::weapon::Attribute::Native, value: 100}),],
|
Some(WeaponAttribute{attr: Attribute::Native, value: 100}),],
|
||||||
tekked: true,
|
tekked: true,
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
|
@ -5,7 +5,7 @@ use rand::distributions::{WeightedIndex, Distribution};
|
|||||||
use rand::seq::SliceRandom;
|
use rand::seq::SliceRandom;
|
||||||
|
|
||||||
use libpso::character::SectionID;
|
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::room::{Difficulty, Episode};
|
||||||
use maps::area::MapArea;
|
use maps::area::MapArea;
|
||||||
use crate::{ItemDropType, load_data_file};
|
use crate::{ItemDropType, load_data_file};
|
||||||
|
@ -33,7 +33,8 @@ use crate::tool_table::ToolTable;
|
|||||||
use crate::rare_drop_table::RareDropTable;
|
use crate::rare_drop_table::RareDropTable;
|
||||||
use crate::box_drop_table::BoxDropTable;
|
use crate::box_drop_table::BoxDropTable;
|
||||||
use maps::object::MapObject;
|
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 {
|
fn data_file_path(episode: Episode, difficulty: Difficulty, section_id: SectionID, filename: &str) -> PathBuf {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
use serde::{Serialize, Deserialize};
|
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::armor::{Armor, ArmorType};
|
||||||
use entity::item::shield::{Shield, ShieldType};
|
use entity::item::shield::{Shield, ShieldType};
|
||||||
use entity::item::unit::{Unit, UnitType};
|
use entity::item::unit::{Unit, UnitType};
|
||||||
|
@ -271,7 +271,7 @@ fn apply_modifiers(items: &BTreeMap<ItemEntityId, ItemEntity>,
|
|||||||
ItemDetail::Weapon(mut weapon) => {
|
ItemDetail::Weapon(mut weapon) => {
|
||||||
if let Some(weapon_modifiers) = weapon_modifiers.get(&item.id) {
|
if let Some(weapon_modifiers) = weapon_modifiers.get(&item.id) {
|
||||||
for weapon_modifier in weapon_modifiers.iter() {
|
for weapon_modifier in weapon_modifiers.iter() {
|
||||||
weapon.apply_modifier(weapon_modifier);
|
weapon::apply_modifier(&mut weapon, weapon_modifier);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ItemDetail::Weapon(weapon)
|
ItemDetail::Weapon(weapon)
|
||||||
|
@ -8,6 +8,8 @@ use crate::account::*;
|
|||||||
use crate::character::*;
|
use crate::character::*;
|
||||||
use libpso::character::{CharacterClass, SectionID};
|
use libpso::character::{CharacterClass, SectionID};
|
||||||
use crate::item::*;
|
use crate::item::*;
|
||||||
|
use crate::item::weapon::WeaponModifier;
|
||||||
|
use libpso::item::weapon;
|
||||||
use crate::room::*;
|
use crate::room::*;
|
||||||
use maps::area::MapArea;
|
use maps::area::MapArea;
|
||||||
use maps::room::{Episode, Difficulty};
|
use maps::room::{Episode, Difficulty};
|
||||||
@ -327,7 +329,7 @@ impl From<PgWeapon> for weapon::Weapon {
|
|||||||
#[derive(Debug, sqlx::FromRow)]
|
#[derive(Debug, sqlx::FromRow)]
|
||||||
pub struct PgWeaponModifier {
|
pub struct PgWeaponModifier {
|
||||||
pub weapon: i32,
|
pub weapon: i32,
|
||||||
pub modifier: sqlx::types::Json<weapon::WeaponModifier>,
|
pub modifier: sqlx::types::Json<WeaponModifier>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
|
@ -92,7 +92,7 @@ async fn apply_item_modifications(conn: &mut sqlx::PgConnection, item: ItemEntit
|
|||||||
|
|
||||||
weapon_modifiers.for_each(|modifier| async move {
|
weapon_modifiers.for_each(|modifier| async move {
|
||||||
if let Ok(modifier) = modifier {
|
if let Ok(modifier) = modifier {
|
||||||
weapon.apply_modifier(&modifier.modifier);
|
weapon::apply_modifier(&mut weapon, &modifier.modifier);
|
||||||
}
|
}
|
||||||
}).await;
|
}).await;
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ pub enum ItemParseError {
|
|||||||
InvalidESWeaponName,
|
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 {
|
pub enum ESWeaponType {
|
||||||
Saber = 0,
|
Saber = 0,
|
||||||
Sword,
|
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 {
|
pub enum ESWeaponSpecial {
|
||||||
Jellen = 1,
|
Jellen = 1,
|
||||||
Zalure,
|
Zalure,
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
#![allow(dead_code)]
|
|
||||||
pub mod weapon;
|
pub mod weapon;
|
||||||
pub mod armor;
|
pub mod armor;
|
||||||
pub mod shield;
|
pub mod shield;
|
||||||
@ -13,6 +12,7 @@ use crate::character::CharacterEntityId;
|
|||||||
use crate::room::RoomEntityId;
|
use crate::room::RoomEntityId;
|
||||||
use maps::area::MapArea;
|
use maps::area::MapArea;
|
||||||
use maps::monster::MonsterType;
|
use maps::monster::MonsterType;
|
||||||
|
use libpso::item::ItemBytes;
|
||||||
//use crate::ship::drops::ItemDropType;
|
//use crate::ship::drops::ItemDropType;
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Copy, Clone, Debug, Hash, PartialOrd, Ord, Serialize, Deserialize)]
|
#[derive(PartialEq, Eq, Copy, Clone, Debug, Hash, PartialOrd, Ord, Serialize, Deserialize)]
|
||||||
@ -108,7 +108,7 @@ impl Meseta {
|
|||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||||
pub enum ItemType {
|
pub enum ItemType {
|
||||||
Weapon(weapon::WeaponType),
|
Weapon(libpso::item::weapon::WeaponType),
|
||||||
Armor(armor::ArmorType),
|
Armor(armor::ArmorType),
|
||||||
Shield(shield::ShieldType),
|
Shield(shield::ShieldType),
|
||||||
Unit(unit::UnitType),
|
Unit(unit::UnitType),
|
||||||
@ -125,7 +125,7 @@ pub enum ItemParseError {
|
|||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
pub enum ItemDetail {
|
pub enum ItemDetail {
|
||||||
Weapon(weapon::Weapon),
|
Weapon(libpso::item::weapon::Weapon),
|
||||||
Armor(armor::Armor),
|
Armor(armor::Armor),
|
||||||
Shield(shield::Shield),
|
Shield(shield::Shield),
|
||||||
Unit(unit::Unit),
|
Unit(unit::Unit),
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -13,6 +13,7 @@ use entity::gateway::{EntityGateway, EntityGatewayTransaction};
|
|||||||
use entity::item::{ItemDetail, NewItemEntity, TradeId, ItemModifier};
|
use entity::item::{ItemDetail, NewItemEntity, TradeId, ItemModifier};
|
||||||
use entity::item::tool::Tool;
|
use entity::item::tool::Tool;
|
||||||
use entity::room::RoomEntityId;
|
use entity::room::RoomEntityId;
|
||||||
|
use entity::item::weapon::apply_modifier;
|
||||||
use maps::area::MapArea;
|
use maps::area::MapArea;
|
||||||
use crate::state::{ItemStateProxy, ItemStateError, AddItemResult, StackedItemDetail, IndividualItemDetail};
|
use crate::state::{ItemStateProxy, ItemStateError, AddItemResult, StackedItemDetail, IndividualItemDetail};
|
||||||
use crate::bank::{BankItem, BankItemDetail};
|
use crate::bank::{BankItem, BankItemDetail};
|
||||||
@ -1112,7 +1113,7 @@ where
|
|||||||
Box::pin(async move {
|
Box::pin(async move {
|
||||||
match (&mut inventory_item.item, modifier) {
|
match (&mut inventory_item.item, modifier) {
|
||||||
(InventoryItemDetail::Individual(IndividualItemDetail{entity_id, item: ItemDetail::Weapon(ref mut weapon), ..}), ItemModifier::WeaponModifier(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?;
|
transaction.gateway().add_weapon_modifier(entity_id, &modifier).await?;
|
||||||
},
|
},
|
||||||
_ => return Err(ItemStateError::InvalidModifier.into())
|
_ => return Err(ItemStateError::InvalidModifier.into())
|
||||||
|
@ -10,7 +10,7 @@ use entity::item::mag::{MagCell, MagCellError};
|
|||||||
use entity::item::tool::{Tool, ToolType};
|
use entity::item::tool::{Tool, ToolType};
|
||||||
use entity::item::tech::TechniqueDisk;
|
use entity::item::tech::TechniqueDisk;
|
||||||
use entity::item::{ItemDetail, ItemEntityId};
|
use entity::item::{ItemDetail, ItemEntityId};
|
||||||
use entity::item::weapon::WeaponModifier;
|
use entity::item::weapon::{WeaponModifier, apply_modifier};
|
||||||
use crate::state::ItemStateProxy;
|
use crate::state::ItemStateProxy;
|
||||||
use crate::inventory::InventoryItemDetail;
|
use crate::inventory::InventoryItemDetail;
|
||||||
|
|
||||||
@ -259,7 +259,7 @@ where
|
|||||||
let mut inventory = item_state.inventory(&character.id).await?;
|
let mut inventory = item_state.inventory(&character.id).await?;
|
||||||
let (weapon_entity_id, weapon) = inventory.equipped_weapon_mut()
|
let (weapon_entity_id, weapon) = inventory.equipped_weapon_mut()
|
||||||
.ok_or(ApplyItemError::ItemNotEquipped)?;
|
.ok_or(ApplyItemError::ItemNotEquipped)?;
|
||||||
weapon.apply_modifier(&modifier);
|
apply_modifier(weapon, &modifier);
|
||||||
entity_gateway.add_weapon_modifier(&weapon_entity_id, &modifier).await?;
|
entity_gateway.add_weapon_modifier(&weapon_entity_id, &modifier).await?;
|
||||||
item_state.set_inventory(inventory).await;
|
item_state.set_inventory(inventory).await;
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
use std::cmp::Ordering;
|
use std::cmp::Ordering;
|
||||||
|
use libpso::item::ItemBytes;
|
||||||
use libpso::character::character;
|
use libpso::character::character;
|
||||||
use crate::ClientItemId;
|
use crate::ClientItemId;
|
||||||
use entity::item::{Meseta, ItemEntityId, ItemDetail, ItemEntity, BankEntity, BankItemEntity};
|
use entity::item::{Meseta, ItemEntityId, ItemDetail, ItemEntity, BankEntity, BankItemEntity};
|
||||||
|
@ -8,7 +8,7 @@ use async_std::sync::{Arc, Mutex};
|
|||||||
use entity::character::CharacterEntityId;
|
use entity::character::CharacterEntityId;
|
||||||
use entity::item::tool::ToolType;
|
use entity::item::tool::ToolType;
|
||||||
use entity::item::mag::Mag;
|
use entity::item::mag::Mag;
|
||||||
use entity::item::weapon::Weapon;
|
use libpso::item::weapon::Weapon;
|
||||||
use shops::{ShopItem, ArmorShopItem, ToolShopItem, WeaponShopItem};
|
use shops::{ShopItem, ArmorShopItem, ToolShopItem, WeaponShopItem};
|
||||||
use crate::state::ItemStateError;
|
use crate::state::ItemStateError;
|
||||||
use crate::state::{IndividualItemDetail, StackedItemDetail, AddItemResult};
|
use crate::state::{IndividualItemDetail, StackedItemDetail, AddItemResult};
|
||||||
|
@ -4,11 +4,12 @@ use async_std::sync::{Arc, RwLock, Mutex};
|
|||||||
use futures::stream::{FuturesOrdered, StreamExt};
|
use futures::stream::{FuturesOrdered, StreamExt};
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
|
|
||||||
|
use libpso::item::ItemBytes;
|
||||||
use entity::gateway::{EntityGateway, GatewayError};
|
use entity::gateway::{EntityGateway, GatewayError};
|
||||||
use entity::character::{CharacterEntity, CharacterEntityId};
|
use entity::character::{CharacterEntity, CharacterEntityId};
|
||||||
use entity::item::{ItemEntityId, ItemDetail, ItemEntity, InventoryItemEntity, BankItemEntity, BankIdentifier};
|
use entity::item::{ItemEntityId, ItemDetail, ItemEntity, InventoryItemEntity, BankItemEntity, BankIdentifier};
|
||||||
use entity::item::tool::Tool;
|
use entity::item::tool::Tool;
|
||||||
use entity::item::weapon::Weapon;
|
use libpso::item::weapon::Weapon;
|
||||||
use entity::item::mag::Mag;
|
use entity::item::mag::Mag;
|
||||||
use drops::ItemDrop;
|
use drops::ItemDrop;
|
||||||
use crate::ClientItemId;
|
use crate::ClientItemId;
|
||||||
|
@ -25,7 +25,7 @@ use libpso::util::{utf8_to_array, utf8_to_utf16_array};
|
|||||||
use entity::gateway::{EntityGateway, GatewayError};
|
use entity::gateway::{EntityGateway, GatewayError};
|
||||||
use entity::account::{UserAccountId, UserAccountEntity, NewUserSettingsEntity, USERFLAG_NEWCHAR, USERFLAG_DRESSINGROOM};
|
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::{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::armor::Armor;
|
||||||
use entity::item::tech::Technique;
|
use entity::item::tech::Technique;
|
||||||
use entity::item::tool::Tool;
|
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?;
|
entity_gateway.set_bank_meseta(&character.id, &BankIdentifier::Character, Meseta(0)).await?;
|
||||||
|
|
||||||
let new_weapon = match character.char_class {
|
let new_weapon = match character.char_class {
|
||||||
CharacterClass::HUmar | CharacterClass::HUnewearl | CharacterClass::HUcast | CharacterClass::HUcaseal => item::weapon::WeaponType::Saber,
|
CharacterClass::HUmar | CharacterClass::HUnewearl | CharacterClass::HUcast | CharacterClass::HUcaseal => WeaponType::Saber,
|
||||||
CharacterClass::RAmar | CharacterClass::RAmarl | CharacterClass::RAcast | CharacterClass::RAcaseal => item::weapon::WeaponType::Handgun,
|
CharacterClass::RAmar | CharacterClass::RAmarl | CharacterClass::RAcast | CharacterClass::RAcaseal => WeaponType::Handgun,
|
||||||
CharacterClass::FOmar | CharacterClass::FOmarl | CharacterClass::FOnewm | CharacterClass::FOnewearl => item::weapon::WeaponType::Cane,
|
CharacterClass::FOmar | CharacterClass::FOmarl | CharacterClass::FOnewm | CharacterClass::FOnewearl => WeaponType::Cane,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
use libpso::packet::messages::*;
|
use libpso::packet::messages::*;
|
||||||
use libpso::packet::ship::*;
|
use libpso::packet::ship::*;
|
||||||
|
use libpso::item::weapon;
|
||||||
|
use libpso::item::ItemBytes;
|
||||||
use entity::item;
|
use entity::item;
|
||||||
use stats::leveltable::CharacterStats;
|
use stats::leveltable::CharacterStats;
|
||||||
//use crate::ship::ship::{ShipError};
|
//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();
|
let bytes = weapon.as_bytes();
|
||||||
TekPreview {
|
TekPreview {
|
||||||
client: 0x79,
|
client: 0x79,
|
||||||
|
@ -482,7 +482,7 @@ where
|
|||||||
.as_weapon()
|
.as_weapon()
|
||||||
.ok_or_else(|| ItemStateError::WrongItemType(ClientItemId(tek_request.item_id)))?;
|
.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,
|
special: special_mod,
|
||||||
percent: percent_mod,
|
percent: percent_mod,
|
||||||
grind: grind_mod,
|
grind: grind_mod,
|
||||||
|
@ -11,7 +11,7 @@ use rand::seq::{SliceRandom, IteratorRandom};
|
|||||||
use libpso::character::SectionID;
|
use libpso::character::SectionID;
|
||||||
use maps::room::Difficulty;
|
use maps::room::Difficulty;
|
||||||
use entity::item::ItemDetail;
|
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 crate::ShopItem;
|
||||||
use stats::items::WEAPON_STATS;
|
use stats::items::WEAPON_STATS;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ use serde::{Serialize, Deserialize};
|
|||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
|
|
||||||
use entity::item::weapon::WeaponType;
|
use libpso::item::weapon::WeaponType;
|
||||||
use entity::item::armor::ArmorType;
|
use entity::item::armor::ArmorType;
|
||||||
use entity::item::shield::ShieldType;
|
use entity::item::shield::ShieldType;
|
||||||
use entity::item::unit::UnitType;
|
use entity::item::unit::UnitType;
|
||||||
|
@ -17,6 +17,7 @@ use drops::{DropTable, ItemDropType};
|
|||||||
use shops::{ItemShops, WeaponShopItem, ToolShopItem, ArmorShopItem};
|
use shops::{ItemShops, WeaponShopItem, ToolShopItem, ArmorShopItem};
|
||||||
|
|
||||||
use entity::item;
|
use entity::item;
|
||||||
|
use libpso::item::weapon;
|
||||||
|
|
||||||
use libpso::packet::ship::*;
|
use libpso::packet::ship::*;
|
||||||
use libpso::packet::login::{Login, Session};
|
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 {
|
pub struct WeaponBuilder {
|
||||||
weapon: item::weapon::WeaponType,
|
weapon: weapon::WeaponType,
|
||||||
grind: u8,
|
grind: u8,
|
||||||
special: Option<item::weapon::WeaponSpecial>,
|
special: Option<weapon::WeaponSpecial>,
|
||||||
attributes: [Option<item::weapon::WeaponAttribute>; 3],
|
attributes: [Option<weapon::WeaponAttribute>; 3],
|
||||||
tekked: bool,
|
tekked: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl WeaponBuilder {
|
impl WeaponBuilder {
|
||||||
fn new(weapon: item::weapon::WeaponType) -> WeaponBuilder {
|
fn new(weapon: weapon::WeaponType) -> WeaponBuilder {
|
||||||
WeaponBuilder {
|
WeaponBuilder {
|
||||||
weapon,
|
weapon,
|
||||||
grind: 0,
|
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 {
|
WeaponBuilder {
|
||||||
special: Some(special),
|
special: Some(special),
|
||||||
..self
|
..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
|
self.attributes
|
||||||
.iter_mut()
|
.iter_mut()
|
||||||
.find(|k| k.is_none())
|
.find(|k| k.is_none())
|
||||||
.map(|empty_attr| {
|
.map(|empty_attr| {
|
||||||
*empty_attr = Some(item::weapon::WeaponAttribute {
|
*empty_attr = Some(weapon::WeaponAttribute {
|
||||||
attr,
|
attr,
|
||||||
value,
|
value,
|
||||||
})
|
})
|
||||||
@ -217,7 +218,7 @@ impl WeaponBuilder {
|
|||||||
pub fn as_new(self) -> item::NewItemEntity {
|
pub fn as_new(self) -> item::NewItemEntity {
|
||||||
item::NewItemEntity {
|
item::NewItemEntity {
|
||||||
item: item::ItemDetail::Weapon(
|
item: item::ItemDetail::Weapon(
|
||||||
item::weapon::Weapon {
|
weapon::Weapon {
|
||||||
weapon: self.weapon,
|
weapon: self.weapon,
|
||||||
grind: self.grind,
|
grind: self.grind,
|
||||||
special: self.special,
|
special: self.special,
|
||||||
@ -411,7 +412,7 @@ impl TechBuilder {
|
|||||||
pub struct ItemBuilder;
|
pub struct ItemBuilder;
|
||||||
|
|
||||||
impl ItemBuilder {
|
impl ItemBuilder {
|
||||||
pub fn weapon(weapon: item::weapon::WeaponType) -> WeaponBuilder {
|
pub fn weapon(weapon: weapon::WeaponType) -> WeaponBuilder {
|
||||||
WeaponBuilder::new(weapon)
|
WeaponBuilder::new(weapon)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ use std::collections::BTreeSet;
|
|||||||
use networking::serverstate::{ClientId, ServerState};
|
use networking::serverstate::{ClientId, ServerState};
|
||||||
use entity::gateway::{EntityGateway, InMemoryGateway};
|
use entity::gateway::{EntityGateway, InMemoryGateway};
|
||||||
use entity::item;
|
use entity::item;
|
||||||
|
use libpso::item::weapon;
|
||||||
use ship_server::{RecvShipPacket, SendShipPacket};
|
use ship_server::{RecvShipPacket, SendShipPacket};
|
||||||
use shops::StandardItemShops;
|
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 (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
|
||||||
|
|
||||||
let item = entity_gateway.create_item(
|
let item = entity_gateway.create_item(
|
||||||
ItemBuilder::weapon(item::weapon::WeaponType::Vulcan)
|
ItemBuilder::weapon(weapon::WeaponType::Vulcan)
|
||||||
.as_new()
|
.as_new()
|
||||||
).await.unwrap();
|
).await.unwrap();
|
||||||
|
|
||||||
@ -47,7 +48,7 @@ async fn test_request_bank_items() {
|
|||||||
let mut bank = Vec::new();
|
let mut bank = Vec::new();
|
||||||
for _ in 0..3 {
|
for _ in 0..3 {
|
||||||
bank.push(entity_gateway.create_item(
|
bank.push(entity_gateway.create_item(
|
||||||
ItemBuilder::weapon(item::weapon::WeaponType::Vulcan)
|
ItemBuilder::weapon(weapon::WeaponType::Vulcan)
|
||||||
.as_new()
|
.as_new()
|
||||||
).await.unwrap());
|
).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 (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
|
||||||
|
|
||||||
let item1 = entity_gateway.create_item(
|
let item1 = entity_gateway.create_item(
|
||||||
ItemBuilder::weapon(item::weapon::WeaponType::Vulcan)
|
ItemBuilder::weapon(weapon::WeaponType::Vulcan)
|
||||||
.as_new()
|
.as_new()
|
||||||
).await.unwrap();
|
).await.unwrap();
|
||||||
let monomate = entity_gateway.create_item(
|
let monomate = entity_gateway.create_item(
|
||||||
@ -128,7 +129,7 @@ async fn test_request_bank_items_sorted() {
|
|||||||
.as_new()
|
.as_new()
|
||||||
).await.unwrap();
|
).await.unwrap();
|
||||||
let item2 = entity_gateway.create_item(
|
let item2 = entity_gateway.create_item(
|
||||||
ItemBuilder::weapon(item::weapon::WeaponType::Calibur)
|
ItemBuilder::weapon(weapon::WeaponType::Calibur)
|
||||||
.as_new()
|
.as_new()
|
||||||
).await.unwrap();
|
).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 (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
|
||||||
|
|
||||||
let item0 = entity_gateway.create_item(
|
let item0 = entity_gateway.create_item(
|
||||||
ItemBuilder::weapon(item::weapon::WeaponType::Saber)
|
ItemBuilder::weapon(weapon::WeaponType::Saber)
|
||||||
.as_new()
|
.as_new()
|
||||||
).await.unwrap();
|
).await.unwrap();
|
||||||
let item1 = entity_gateway.create_item(
|
let item1 = entity_gateway.create_item(
|
||||||
ItemBuilder::weapon(item::weapon::WeaponType::Handgun)
|
ItemBuilder::weapon(weapon::WeaponType::Handgun)
|
||||||
.as_new()
|
.as_new()
|
||||||
).await.unwrap();
|
).await.unwrap();
|
||||||
|
|
||||||
@ -468,14 +469,14 @@ async fn test_deposit_individual_item_in_full_bank() {
|
|||||||
|
|
||||||
let mut inventory = Vec::new();
|
let mut inventory = Vec::new();
|
||||||
inventory.push(entity_gateway.create_item(
|
inventory.push(entity_gateway.create_item(
|
||||||
ItemBuilder::weapon(item::weapon::WeaponType::Vulcan)
|
ItemBuilder::weapon(weapon::WeaponType::Vulcan)
|
||||||
.as_new()
|
.as_new()
|
||||||
).await.unwrap());
|
).await.unwrap());
|
||||||
|
|
||||||
let mut bank = Vec::new();
|
let mut bank = Vec::new();
|
||||||
for _ in 0..200usize {
|
for _ in 0..200usize {
|
||||||
bank.push(entity_gateway.create_item(
|
bank.push(entity_gateway.create_item(
|
||||||
ItemBuilder::weapon(item::weapon::WeaponType::Vulcan)
|
ItemBuilder::weapon(weapon::WeaponType::Vulcan)
|
||||||
.as_new()
|
.as_new()
|
||||||
).await.unwrap());
|
).await.unwrap());
|
||||||
}
|
}
|
||||||
@ -533,7 +534,7 @@ async fn test_deposit_stacked_item_in_full_bank() {
|
|||||||
let mut full_bank = Vec::new();
|
let mut full_bank = Vec::new();
|
||||||
for _ in 0..200usize {
|
for _ in 0..200usize {
|
||||||
full_bank.push(entity_gateway.create_item(
|
full_bank.push(entity_gateway.create_item(
|
||||||
ItemBuilder::weapon(item::weapon::WeaponType::Vulcan)
|
ItemBuilder::weapon(weapon::WeaponType::Vulcan)
|
||||||
.as_new()
|
.as_new()
|
||||||
).await.unwrap());
|
).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();
|
let mut almost_full_bank: Vec<item::BankItemEntity> = Vec::new();
|
||||||
for _ in 0..199usize {
|
for _ in 0..199usize {
|
||||||
almost_full_bank.push(entity_gateway.create_item(
|
almost_full_bank.push(entity_gateway.create_item(
|
||||||
ItemBuilder::weapon(item::weapon::WeaponType::Vulcan)
|
ItemBuilder::weapon(weapon::WeaponType::Vulcan)
|
||||||
.as_new()
|
.as_new()
|
||||||
).await.unwrap().into());
|
).await.unwrap().into());
|
||||||
}
|
}
|
||||||
@ -758,7 +759,7 @@ async fn test_withdraw_individual_item() {
|
|||||||
|
|
||||||
let mut bank = Vec::new();
|
let mut bank = Vec::new();
|
||||||
bank.push(entity_gateway.create_item(
|
bank.push(entity_gateway.create_item(
|
||||||
ItemBuilder::weapon(item::weapon::WeaponType::Saber)
|
ItemBuilder::weapon(weapon::WeaponType::Saber)
|
||||||
.as_new()
|
.as_new()
|
||||||
).await.unwrap());
|
).await.unwrap());
|
||||||
|
|
||||||
@ -1049,14 +1050,14 @@ async fn test_withdraw_individual_item_in_full_inventory() {
|
|||||||
|
|
||||||
let mut bank = Vec::new();
|
let mut bank = Vec::new();
|
||||||
bank.push(entity_gateway.create_item(
|
bank.push(entity_gateway.create_item(
|
||||||
ItemBuilder::weapon(item::weapon::WeaponType::Vulcan)
|
ItemBuilder::weapon(weapon::WeaponType::Vulcan)
|
||||||
.as_new()
|
.as_new()
|
||||||
).await.unwrap());
|
).await.unwrap());
|
||||||
|
|
||||||
let mut inventory = Vec::new();
|
let mut inventory = Vec::new();
|
||||||
for _ in 0..30usize {
|
for _ in 0..30usize {
|
||||||
inventory.push(entity_gateway.create_item(
|
inventory.push(entity_gateway.create_item(
|
||||||
ItemBuilder::weapon(item::weapon::WeaponType::Vulcan)
|
ItemBuilder::weapon(weapon::WeaponType::Vulcan)
|
||||||
.as_new()
|
.as_new()
|
||||||
).await.unwrap());
|
).await.unwrap());
|
||||||
}
|
}
|
||||||
@ -1110,7 +1111,7 @@ async fn test_withdraw_stacked_item_in_full_inventory() {
|
|||||||
let mut inventory = Vec::new();
|
let mut inventory = Vec::new();
|
||||||
for _ in 0..30usize {
|
for _ in 0..30usize {
|
||||||
inventory.push(entity_gateway.create_item(
|
inventory.push(entity_gateway.create_item(
|
||||||
ItemBuilder::weapon(item::weapon::WeaponType::Vulcan)
|
ItemBuilder::weapon(weapon::WeaponType::Vulcan)
|
||||||
.as_new()
|
.as_new()
|
||||||
).await.unwrap());
|
).await.unwrap());
|
||||||
}
|
}
|
||||||
@ -1171,7 +1172,7 @@ async fn test_withdraw_stacked_item_in_full_inventory_with_partial_stack() {
|
|||||||
let mut items = Vec::new();
|
let mut items = Vec::new();
|
||||||
for _i in 0..29usize {
|
for _i in 0..29usize {
|
||||||
items.push(entity_gateway.create_item(
|
items.push(entity_gateway.create_item(
|
||||||
ItemBuilder::weapon(item::weapon::WeaponType::Vulcan)
|
ItemBuilder::weapon(weapon::WeaponType::Vulcan)
|
||||||
.as_new()
|
.as_new()
|
||||||
).await.unwrap().into());
|
).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 (_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 item0 = entity_gateway.create_item(ItemBuilder::weapon(weapon::WeaponType::Saber).as_new()).await.unwrap();
|
||||||
let item1 = entity_gateway.create_item(ItemBuilder::weapon(item::weapon::WeaponType::Buster).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(item::weapon::WeaponType::Rifle).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(item::weapon::WeaponType::Handgun).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(item::weapon::WeaponType::Autogun).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(item::weapon::WeaponType::Calibur).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();
|
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 (_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 item0 = entity_gateway.create_item(ItemBuilder::weapon(weapon::WeaponType::Saber).as_new()).await.unwrap();
|
||||||
let item1 = entity_gateway.create_item(ItemBuilder::weapon(item::weapon::WeaponType::Buster).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(item::weapon::WeaponType::Rifle).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(item::weapon::WeaponType::Handgun).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(item::weapon::WeaponType::Autogun).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(item::weapon::WeaponType::Calibur).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![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();
|
entity_gateway.set_character_bank(&char1.id, &item::BankEntity::new(vec![item2, item3]), &item::BankIdentifier::Shared(item::BankName("asdf".into()))).await.unwrap();
|
||||||
|
@ -8,7 +8,7 @@ use maps::maps::Maps;
|
|||||||
use maps::area::MapArea;
|
use maps::area::MapArea;
|
||||||
use maps::variant::{MapVariant, MapVariantMode};
|
use maps::variant::{MapVariant, MapVariantMode};
|
||||||
use maps::enemy::MapEnemy;
|
use maps::enemy::MapEnemy;
|
||||||
use entity::item::weapon::WeaponType;
|
use libpso::item::weapon::WeaponType;
|
||||||
|
|
||||||
use libpso::packet::ship::*;
|
use libpso::packet::ship::*;
|
||||||
use libpso::packet::messages::*;
|
use libpso::packet::messages::*;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
use networking::serverstate::{ClientId, ServerState};
|
use networking::serverstate::{ClientId, ServerState};
|
||||||
use entity::gateway::{EntityGateway, InMemoryGateway};
|
use entity::gateway::{EntityGateway, InMemoryGateway};
|
||||||
use entity::item;
|
use entity::item;
|
||||||
|
use libpso::item::weapon;
|
||||||
use ship_server::RecvShipPacket;
|
use ship_server::RecvShipPacket;
|
||||||
|
|
||||||
use libpso::packet::ship::*;
|
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(
|
p3_items.push(
|
||||||
item::InventoryItemEntity::Individual(
|
item::InventoryItemEntity::Individual(
|
||||||
entity_gateway.create_item(
|
entity_gateway.create_item(
|
||||||
ItemBuilder::weapon(item::weapon::WeaponType::Saber)
|
ItemBuilder::weapon(weapon::WeaponType::Saber)
|
||||||
.as_new()
|
.as_new()
|
||||||
).await.unwrap()
|
).await.unwrap()
|
||||||
));
|
));
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
use networking::serverstate::{ClientId, ServerState};
|
use networking::serverstate::{ClientId, ServerState};
|
||||||
use entity::gateway::{EntityGateway, InMemoryGateway};
|
use entity::gateway::{EntityGateway, InMemoryGateway};
|
||||||
use entity::item;
|
use entity::item;
|
||||||
|
use libpso::item::weapon;
|
||||||
use ship_server::RecvShipPacket;
|
use ship_server::RecvShipPacket;
|
||||||
|
|
||||||
use libpso::packet::ship::*;
|
use libpso::packet::ship::*;
|
||||||
@ -19,7 +20,7 @@ async fn test_pick_up_individual_item() {
|
|||||||
|
|
||||||
let mut p1_inv = Vec::new();
|
let mut p1_inv = Vec::new();
|
||||||
p1_inv.push(entity_gateway.create_item(
|
p1_inv.push(entity_gateway.create_item(
|
||||||
ItemBuilder::weapon(item::weapon::WeaponType::Handgun)
|
ItemBuilder::weapon(weapon::WeaponType::Handgun)
|
||||||
.as_new()
|
.as_new()
|
||||||
).await.unwrap());
|
).await.unwrap());
|
||||||
|
|
||||||
@ -200,7 +201,7 @@ async fn test_pick_up_meseta_when_inventory_full() {
|
|||||||
let mut p1_items = Vec::new();
|
let mut p1_items = Vec::new();
|
||||||
for _ in 0..30usize {
|
for _ in 0..30usize {
|
||||||
p1_items.push(entity_gateway.create_item(
|
p1_items.push(entity_gateway.create_item(
|
||||||
ItemBuilder::weapon(item::weapon::WeaponType::Saber)
|
ItemBuilder::weapon(weapon::WeaponType::Saber)
|
||||||
.as_new()
|
.as_new()
|
||||||
).await.unwrap());
|
).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();
|
let mut p1_inv = Vec::new();
|
||||||
for _slot in 0..29usize {
|
for _slot in 0..29usize {
|
||||||
p1_inv.push(entity_gateway.create_item(
|
p1_inv.push(entity_gateway.create_item(
|
||||||
ItemBuilder::weapon(item::weapon::WeaponType::Saber)
|
ItemBuilder::weapon(weapon::WeaponType::Saber)
|
||||||
.as_new()
|
.as_new()
|
||||||
).await.unwrap().into());
|
).await.unwrap().into());
|
||||||
}
|
}
|
||||||
@ -328,14 +329,14 @@ async fn test_can_not_pick_up_item_when_inventory_full() {
|
|||||||
let mut p1_inv = Vec::new();
|
let mut p1_inv = Vec::new();
|
||||||
for _slot in 0..30usize {
|
for _slot in 0..30usize {
|
||||||
p1_inv.push(entity_gateway.create_item(
|
p1_inv.push(entity_gateway.create_item(
|
||||||
ItemBuilder::weapon(item::weapon::WeaponType::Saber)
|
ItemBuilder::weapon(weapon::WeaponType::Saber)
|
||||||
.as_new()
|
.as_new()
|
||||||
).await.unwrap());
|
).await.unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut p2_inv = Vec::new();
|
let mut p2_inv = Vec::new();
|
||||||
p2_inv.push(entity_gateway.create_item(
|
p2_inv.push(entity_gateway.create_item(
|
||||||
ItemBuilder::weapon(item::weapon::WeaponType::Handgun)
|
ItemBuilder::weapon(weapon::WeaponType::Handgun)
|
||||||
.as_new()
|
.as_new()
|
||||||
).await.unwrap());
|
).await.unwrap());
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
use networking::serverstate::{ClientId, ServerState};
|
use networking::serverstate::{ClientId, ServerState};
|
||||||
use entity::gateway::{EntityGateway, InMemoryGateway};
|
use entity::gateway::{EntityGateway, InMemoryGateway};
|
||||||
use entity::item;
|
use entity::item;
|
||||||
|
use libpso::item::weapon;
|
||||||
use ship_server::RecvShipPacket;
|
use ship_server::RecvShipPacket;
|
||||||
use entity::character::TechLevel;
|
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 (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
|
||||||
|
|
||||||
let saber = entity_gateway.create_item(
|
let saber = entity_gateway.create_item(
|
||||||
ItemBuilder::weapon(item::weapon::WeaponType::Saber)
|
ItemBuilder::weapon(weapon::WeaponType::Saber)
|
||||||
.as_new()
|
.as_new()
|
||||||
).await.unwrap();
|
).await.unwrap();
|
||||||
|
|
||||||
@ -369,7 +370,7 @@ async fn test_use_monogrinder() {
|
|||||||
let inventory_items = entity_gateway.get_character_inventory(&char1.id).await.unwrap();
|
let inventory_items = entity_gateway.get_character_inventory(&char1.id).await.unwrap();
|
||||||
assert_eq!(inventory_items.items.len(), 2);
|
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, ..}), ..})));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
use networking::serverstate::{ClientId, ServerState};
|
use networking::serverstate::{ClientId, ServerState};
|
||||||
use entity::gateway::{EntityGateway, InMemoryGateway};
|
use entity::gateway::{EntityGateway, InMemoryGateway};
|
||||||
use entity::item;
|
use entity::item;
|
||||||
|
use libpso::item::weapon;
|
||||||
use ship_server::{RecvShipPacket, SendShipPacket};
|
use ship_server::{RecvShipPacket, SendShipPacket};
|
||||||
use maps::room::Difficulty;
|
use maps::room::Difficulty;
|
||||||
use items::state::ItemStateError;
|
use items::state::ItemStateError;
|
||||||
@ -265,12 +266,12 @@ async fn test_player_sells_3_attr_weapon_to_shop() {
|
|||||||
let mut p1_inv = Vec::new();
|
let mut p1_inv = Vec::new();
|
||||||
|
|
||||||
p1_inv.push(entity_gateway.create_item(
|
p1_inv.push(entity_gateway.create_item(
|
||||||
ItemBuilder::weapon(item::weapon::WeaponType::Vulcan)
|
ItemBuilder::weapon(weapon::WeaponType::Vulcan)
|
||||||
.grind(5)
|
.grind(5)
|
||||||
.special(item::weapon::WeaponSpecial::Charge)
|
.special(weapon::WeaponSpecial::Charge)
|
||||||
.attr(item::weapon::Attribute::Hit, 100)
|
.attr(weapon::Attribute::Hit, 100)
|
||||||
.attr(item::weapon::Attribute::Dark, 100)
|
.attr(weapon::Attribute::Dark, 100)
|
||||||
.attr(item::weapon::Attribute::Native, 100)
|
.attr(weapon::Attribute::Native, 100)
|
||||||
.as_new()
|
.as_new()
|
||||||
).await.unwrap());
|
).await.unwrap());
|
||||||
|
|
||||||
@ -613,13 +614,13 @@ async fn test_player_sells_untekked_weapon() {
|
|||||||
let mut p1_inv = Vec::new();
|
let mut p1_inv = Vec::new();
|
||||||
|
|
||||||
p1_inv.push(entity_gateway.create_item(
|
p1_inv.push(entity_gateway.create_item(
|
||||||
ItemBuilder::weapon(item::weapon::WeaponType::Vulcan)
|
ItemBuilder::weapon(weapon::WeaponType::Vulcan)
|
||||||
.untekked()
|
.untekked()
|
||||||
.grind(5)
|
.grind(5)
|
||||||
.special(item::weapon::WeaponSpecial::Charge)
|
.special(weapon::WeaponSpecial::Charge)
|
||||||
.attr(item::weapon::Attribute::Hit, 100)
|
.attr(weapon::Attribute::Hit, 100)
|
||||||
.attr(item::weapon::Attribute::Dark, 100)
|
.attr(weapon::Attribute::Dark, 100)
|
||||||
.attr(item::weapon::Attribute::Native, 100)
|
.attr(weapon::Attribute::Native, 100)
|
||||||
.as_new()
|
.as_new()
|
||||||
).await.unwrap());
|
).await.unwrap());
|
||||||
|
|
||||||
@ -651,11 +652,11 @@ async fn test_player_sells_rare_item() {
|
|||||||
let mut p1_inv = Vec::new();
|
let mut p1_inv = Vec::new();
|
||||||
|
|
||||||
p1_inv.push(entity_gateway.create_item(
|
p1_inv.push(entity_gateway.create_item(
|
||||||
ItemBuilder::weapon(item::weapon::WeaponType::DarkFlow)
|
ItemBuilder::weapon(weapon::WeaponType::DarkFlow)
|
||||||
.grind(5)
|
.grind(5)
|
||||||
.attr(item::weapon::Attribute::Hit, 100)
|
.attr(weapon::Attribute::Hit, 100)
|
||||||
.attr(item::weapon::Attribute::Dark, 100)
|
.attr(weapon::Attribute::Dark, 100)
|
||||||
.attr(item::weapon::Attribute::Native, 100)
|
.attr(weapon::Attribute::Native, 100)
|
||||||
.as_new()
|
.as_new()
|
||||||
).await.unwrap());
|
).await.unwrap());
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ use std::convert::TryInto;
|
|||||||
use networking::serverstate::{ClientId, ServerState};
|
use networking::serverstate::{ClientId, ServerState};
|
||||||
use entity::gateway::{EntityGateway, InMemoryGateway};
|
use entity::gateway::{EntityGateway, InMemoryGateway};
|
||||||
use entity::item;
|
use entity::item;
|
||||||
|
use libpso::item::weapon;
|
||||||
use ship_server::{ShipServerState, RecvShipPacket, SendShipPacket};
|
use ship_server::{ShipServerState, RecvShipPacket, SendShipPacket};
|
||||||
use entity::item::{Meseta, ItemEntity, InventoryItemEntity};
|
use entity::item::{Meseta, ItemEntity, InventoryItemEntity};
|
||||||
use ship_server::trade::TradeError;
|
use ship_server::trade::TradeError;
|
||||||
@ -118,7 +119,7 @@ async fn test_trade_one_individual_item() {
|
|||||||
|
|
||||||
let mut p1_inv = Vec::new();
|
let mut p1_inv = Vec::new();
|
||||||
p1_inv.push(entity_gateway.create_item(
|
p1_inv.push(entity_gateway.create_item(
|
||||||
ItemBuilder::weapon(item::weapon::WeaponType::Handgun)
|
ItemBuilder::weapon(weapon::WeaponType::Handgun)
|
||||||
.as_new()
|
.as_new()
|
||||||
).await.unwrap());
|
).await.unwrap());
|
||||||
|
|
||||||
@ -209,7 +210,7 @@ async fn test_trade_player2_to_player1() {
|
|||||||
|
|
||||||
let mut p2_inv = Vec::new();
|
let mut p2_inv = Vec::new();
|
||||||
p2_inv.push(entity_gateway.create_item(
|
p2_inv.push(entity_gateway.create_item(
|
||||||
ItemBuilder::weapon(item::weapon::WeaponType::Handgun)
|
ItemBuilder::weapon(weapon::WeaponType::Handgun)
|
||||||
.as_new()
|
.as_new()
|
||||||
).await.unwrap());
|
).await.unwrap());
|
||||||
|
|
||||||
@ -300,7 +301,7 @@ async fn test_reverse_trade_ack_order() {
|
|||||||
|
|
||||||
let mut p1_inv = Vec::new();
|
let mut p1_inv = Vec::new();
|
||||||
p1_inv.push(entity_gateway.create_item(
|
p1_inv.push(entity_gateway.create_item(
|
||||||
ItemBuilder::weapon(item::weapon::WeaponType::Handgun)
|
ItemBuilder::weapon(weapon::WeaponType::Handgun)
|
||||||
.as_new()
|
.as_new()
|
||||||
).await.unwrap());
|
).await.unwrap());
|
||||||
|
|
||||||
@ -590,12 +591,12 @@ async fn test_trade_individual_both() {
|
|||||||
|
|
||||||
let p1_inv = vec![
|
let p1_inv = vec![
|
||||||
entity_gateway.create_item(
|
entity_gateway.create_item(
|
||||||
ItemBuilder::weapon(item::weapon::WeaponType::Saber)
|
ItemBuilder::weapon(weapon::WeaponType::Saber)
|
||||||
.as_new()
|
.as_new()
|
||||||
).await.unwrap()];
|
).await.unwrap()];
|
||||||
let p2_inv = vec![
|
let p2_inv = vec![
|
||||||
entity_gateway.create_item(
|
entity_gateway.create_item(
|
||||||
ItemBuilder::weapon(item::weapon::WeaponType::Handgun)
|
ItemBuilder::weapon(weapon::WeaponType::Handgun)
|
||||||
.as_new()
|
.as_new()
|
||||||
).await.unwrap()];
|
).await.unwrap()];
|
||||||
|
|
||||||
@ -722,10 +723,10 @@ async fn test_trade_individual_both() {
|
|||||||
|
|
||||||
let p1_items = entity_gateway.get_character_inventory(&char1.id).await.unwrap();
|
let p1_items = entity_gateway.get_character_inventory(&char1.id).await.unwrap();
|
||||||
assert_eq!(p1_items.items.len(), 1);
|
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();
|
let p2_items = entity_gateway.get_character_inventory(&char2.id).await.unwrap();
|
||||||
assert_eq!(p2_items.items.len(), 1);
|
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]
|
#[async_std::test]
|
||||||
@ -1355,7 +1356,7 @@ async fn test_trade_individual_for_stacked() {
|
|||||||
|
|
||||||
let p1_inv = vec![
|
let p1_inv = vec![
|
||||||
entity_gateway.create_item(
|
entity_gateway.create_item(
|
||||||
ItemBuilder::weapon(item::weapon::WeaponType::Saber)
|
ItemBuilder::weapon(weapon::WeaponType::Saber)
|
||||||
.as_new()
|
.as_new()
|
||||||
).await.unwrap()];
|
).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, ..}), ..}));
|
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();
|
let p2_items = entity_gateway.get_character_inventory(&char2.id).await.unwrap();
|
||||||
assert_eq!(p2_items.items.len(), 1);
|
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]
|
#[async_std::test]
|
||||||
@ -1511,21 +1512,21 @@ async fn test_trade_multiple_individual() {
|
|||||||
|
|
||||||
let p1_inv = vec![
|
let p1_inv = vec![
|
||||||
entity_gateway.create_item(
|
entity_gateway.create_item(
|
||||||
ItemBuilder::weapon(item::weapon::WeaponType::Saber)
|
ItemBuilder::weapon(weapon::WeaponType::Saber)
|
||||||
.as_new()
|
.as_new()
|
||||||
).await.unwrap(),
|
).await.unwrap(),
|
||||||
entity_gateway.create_item(
|
entity_gateway.create_item(
|
||||||
ItemBuilder::weapon(item::weapon::WeaponType::Buster)
|
ItemBuilder::weapon(weapon::WeaponType::Buster)
|
||||||
.as_new()
|
.as_new()
|
||||||
).await.unwrap(),
|
).await.unwrap(),
|
||||||
];
|
];
|
||||||
let p2_inv = vec![
|
let p2_inv = vec![
|
||||||
entity_gateway.create_item(
|
entity_gateway.create_item(
|
||||||
ItemBuilder::weapon(item::weapon::WeaponType::Handgun)
|
ItemBuilder::weapon(weapon::WeaponType::Handgun)
|
||||||
.as_new()
|
.as_new()
|
||||||
).await.unwrap(),
|
).await.unwrap(),
|
||||||
entity_gateway.create_item(
|
entity_gateway.create_item(
|
||||||
ItemBuilder::weapon(item::weapon::WeaponType::Autogun)
|
ItemBuilder::weapon(weapon::WeaponType::Autogun)
|
||||||
.as_new()
|
.as_new()
|
||||||
).await.unwrap(),
|
).await.unwrap(),
|
||||||
];
|
];
|
||||||
@ -1717,12 +1718,12 @@ async fn test_trade_multiple_individual() {
|
|||||||
|
|
||||||
let p1_items = entity_gateway.get_character_inventory(&char1.id).await.unwrap();
|
let p1_items = entity_gateway.get_character_inventory(&char1.id).await.unwrap();
|
||||||
assert_eq!(p1_items.items.len(), 2);
|
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[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(item::weapon::Weapon {weapon: item::weapon::WeaponType::Autogun, ..}), ..}));
|
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();
|
let p2_items = entity_gateway.get_character_inventory(&char2.id).await.unwrap();
|
||||||
assert_eq!(p2_items.items.len(), 2);
|
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[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(item::weapon::Weapon {weapon: item::weapon::WeaponType::Buster, ..}), ..}));
|
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();
|
let mut entity_gateway = entity_gateway.clone();
|
||||||
async move {
|
async move {
|
||||||
entity_gateway.create_item(
|
entity_gateway.create_item(
|
||||||
ItemBuilder::weapon(item::weapon::WeaponType::Handgun)
|
ItemBuilder::weapon(weapon::WeaponType::Handgun)
|
||||||
.as_new()
|
.as_new()
|
||||||
).await
|
).await
|
||||||
}}))
|
}}))
|
||||||
@ -1999,7 +2000,7 @@ async fn test_trade_not_enough_inventory_space_individual() {
|
|||||||
let mut entity_gateway = entity_gateway.clone();
|
let mut entity_gateway = entity_gateway.clone();
|
||||||
async move {
|
async move {
|
||||||
entity_gateway.create_item(
|
entity_gateway.create_item(
|
||||||
ItemBuilder::weapon(item::weapon::WeaponType::Handgun)
|
ItemBuilder::weapon(weapon::WeaponType::Handgun)
|
||||||
.as_new()
|
.as_new()
|
||||||
).await
|
).await
|
||||||
}}))
|
}}))
|
||||||
@ -2102,7 +2103,7 @@ async fn test_trade_not_enough_inventory_space_stacked() {
|
|||||||
let mut entity_gateway = entity_gateway.clone();
|
let mut entity_gateway = entity_gateway.clone();
|
||||||
async move {
|
async move {
|
||||||
entity_gateway.create_item(
|
entity_gateway.create_item(
|
||||||
ItemBuilder::weapon(item::weapon::WeaponType::Handgun)
|
ItemBuilder::weapon(weapon::WeaponType::Handgun)
|
||||||
.as_new()
|
.as_new()
|
||||||
).await
|
).await
|
||||||
}}))
|
}}))
|
||||||
@ -2553,7 +2554,7 @@ async fn test_back_out_of_trade_last_minute() {
|
|||||||
|
|
||||||
let mut p1_inv = Vec::new();
|
let mut p1_inv = Vec::new();
|
||||||
p1_inv.push(entity_gateway.create_item(
|
p1_inv.push(entity_gateway.create_item(
|
||||||
ItemBuilder::weapon(item::weapon::WeaponType::Handgun)
|
ItemBuilder::weapon(weapon::WeaponType::Handgun)
|
||||||
.as_new()
|
.as_new()
|
||||||
).await.unwrap());
|
).await.unwrap());
|
||||||
|
|
||||||
@ -2611,7 +2612,7 @@ async fn test_valid_trade_when_both_inventories_are_full() {
|
|||||||
let mut entity_gateway = entity_gateway.clone();
|
let mut entity_gateway = entity_gateway.clone();
|
||||||
async move {
|
async move {
|
||||||
entity_gateway.create_item(
|
entity_gateway.create_item(
|
||||||
ItemBuilder::weapon(item::weapon::WeaponType::Saber)
|
ItemBuilder::weapon(weapon::WeaponType::Saber)
|
||||||
.as_new()
|
.as_new()
|
||||||
).await
|
).await
|
||||||
}}))
|
}}))
|
||||||
@ -2624,7 +2625,7 @@ async fn test_valid_trade_when_both_inventories_are_full() {
|
|||||||
let mut entity_gateway = entity_gateway.clone();
|
let mut entity_gateway = entity_gateway.clone();
|
||||||
async move {
|
async move {
|
||||||
entity_gateway.create_item(
|
entity_gateway.create_item(
|
||||||
ItemBuilder::weapon(item::weapon::WeaponType::Handgun)
|
ItemBuilder::weapon(weapon::WeaponType::Handgun)
|
||||||
.as_new()
|
.as_new()
|
||||||
).await
|
).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();
|
let p1_items = entity_gateway.get_character_inventory(&char1.id).await.unwrap();
|
||||||
assert_eq!(p1_items.items.len(), 30);
|
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(weapon::Weapon { weapon: 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::Handgun, ..}, ..))).count(), 2);
|
||||||
let p2_items = entity_gateway.get_character_inventory(&char2.id).await.unwrap();
|
let p2_items = entity_gateway.get_character_inventory(&char2.id).await.unwrap();
|
||||||
assert_eq!(p2_items.items.len(), 30);
|
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(weapon::Weapon { weapon: 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::Handgun, ..}, ..))).count(), 28);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_std::test]
|
#[async_std::test]
|
||||||
@ -2733,7 +2734,7 @@ async fn test_invalid_trade_when_both_inventories_are_full() {
|
|||||||
let mut entity_gateway = entity_gateway.clone();
|
let mut entity_gateway = entity_gateway.clone();
|
||||||
async move {
|
async move {
|
||||||
entity_gateway.create_item(
|
entity_gateway.create_item(
|
||||||
ItemBuilder::weapon(item::weapon::WeaponType::Saber)
|
ItemBuilder::weapon(weapon::WeaponType::Saber)
|
||||||
.as_new()
|
.as_new()
|
||||||
).await
|
).await
|
||||||
}}))
|
}}))
|
||||||
@ -2746,7 +2747,7 @@ async fn test_invalid_trade_when_both_inventories_are_full() {
|
|||||||
let mut entity_gateway = entity_gateway.clone();
|
let mut entity_gateway = entity_gateway.clone();
|
||||||
async move {
|
async move {
|
||||||
entity_gateway.create_item(
|
entity_gateway.create_item(
|
||||||
ItemBuilder::weapon(item::weapon::WeaponType::Handgun)
|
ItemBuilder::weapon(weapon::WeaponType::Handgun)
|
||||||
.as_new()
|
.as_new()
|
||||||
).await
|
).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();
|
let p1_items = entity_gateway.get_character_inventory(&char1.id).await.unwrap();
|
||||||
assert_eq!(p1_items.items.len(), 30);
|
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();
|
let p2_items = entity_gateway.get_character_inventory(&char2.id).await.unwrap();
|
||||||
assert_eq!(p2_items.items.len(), 30);
|
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();
|
let mut p1_inv = Vec::new();
|
||||||
for _ in 0..2 {
|
for _ in 0..2 {
|
||||||
p1_inv.push(entity_gateway.create_item(
|
p1_inv.push(entity_gateway.create_item(
|
||||||
ItemBuilder::weapon(item::weapon::WeaponType::Handgun)
|
ItemBuilder::weapon(weapon::WeaponType::Handgun)
|
||||||
.as_new()
|
.as_new()
|
||||||
).await.unwrap());
|
).await.unwrap());
|
||||||
}
|
}
|
||||||
@ -3357,7 +3358,7 @@ async fn test_items_to_trade_data_does_not_match() {
|
|||||||
|
|
||||||
let mut p1_inv = Vec::new();
|
let mut p1_inv = Vec::new();
|
||||||
p1_inv.push(entity_gateway.create_item(
|
p1_inv.push(entity_gateway.create_item(
|
||||||
ItemBuilder::weapon(item::weapon::WeaponType::Handgun)
|
ItemBuilder::weapon(weapon::WeaponType::Handgun)
|
||||||
.as_new()
|
.as_new()
|
||||||
).await.unwrap());
|
).await.unwrap());
|
||||||
|
|
||||||
@ -3394,8 +3395,8 @@ async fn test_items_to_trade_data_does_not_match() {
|
|||||||
ItemEntity {
|
ItemEntity {
|
||||||
id: p1_items.items[0].with_individual(|i| i.id).unwrap(),
|
id: p1_items.items[0].with_individual(|i| i.id).unwrap(),
|
||||||
item: item::ItemDetail::Weapon(
|
item: item::ItemDetail::Weapon(
|
||||||
item::weapon::Weapon {
|
weapon::Weapon {
|
||||||
weapon: item::weapon::WeaponType::Handgun,
|
weapon: weapon::WeaponType::Handgun,
|
||||||
grind: 2,
|
grind: 2,
|
||||||
special: None,
|
special: None,
|
||||||
attrs: [None, None, 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();
|
let mut p1_inv = Vec::new();
|
||||||
p1_inv.push(entity_gateway.create_item(
|
p1_inv.push(entity_gateway.create_item(
|
||||||
ItemBuilder::weapon(item::weapon::WeaponType::Handgun)
|
ItemBuilder::weapon(weapon::WeaponType::Handgun)
|
||||||
.as_new()
|
.as_new()
|
||||||
).await.unwrap());
|
).await.unwrap());
|
||||||
|
|
||||||
@ -3627,15 +3628,15 @@ async fn test_items_to_trade_count_less_than() {
|
|||||||
|
|
||||||
let p1_inv = vec![
|
let p1_inv = vec![
|
||||||
entity_gateway.create_item(
|
entity_gateway.create_item(
|
||||||
ItemBuilder::weapon(item::weapon::WeaponType::Saber)
|
ItemBuilder::weapon(weapon::WeaponType::Saber)
|
||||||
.as_new()
|
.as_new()
|
||||||
).await.unwrap(),
|
).await.unwrap(),
|
||||||
entity_gateway.create_item(
|
entity_gateway.create_item(
|
||||||
ItemBuilder::weapon(item::weapon::WeaponType::Brand)
|
ItemBuilder::weapon(weapon::WeaponType::Brand)
|
||||||
.as_new()
|
.as_new()
|
||||||
).await.unwrap(),
|
).await.unwrap(),
|
||||||
entity_gateway.create_item(
|
entity_gateway.create_item(
|
||||||
ItemBuilder::weapon(item::weapon::WeaponType::Buster)
|
ItemBuilder::weapon(weapon::WeaponType::Buster)
|
||||||
.as_new()
|
.as_new()
|
||||||
).await.unwrap(),
|
).await.unwrap(),
|
||||||
];
|
];
|
||||||
@ -3705,15 +3706,15 @@ async fn test_items_to_trade_count_greater_than() {
|
|||||||
|
|
||||||
let p1_inv = vec![
|
let p1_inv = vec![
|
||||||
entity_gateway.create_item(
|
entity_gateway.create_item(
|
||||||
ItemBuilder::weapon(item::weapon::WeaponType::Saber)
|
ItemBuilder::weapon(weapon::WeaponType::Saber)
|
||||||
.as_new()
|
.as_new()
|
||||||
).await.unwrap(),
|
).await.unwrap(),
|
||||||
entity_gateway.create_item(
|
entity_gateway.create_item(
|
||||||
ItemBuilder::weapon(item::weapon::WeaponType::Brand)
|
ItemBuilder::weapon(weapon::WeaponType::Brand)
|
||||||
.as_new()
|
.as_new()
|
||||||
).await.unwrap(),
|
).await.unwrap(),
|
||||||
entity_gateway.create_item(
|
entity_gateway.create_item(
|
||||||
ItemBuilder::weapon(item::weapon::WeaponType::Buster)
|
ItemBuilder::weapon(weapon::WeaponType::Buster)
|
||||||
.as_new()
|
.as_new()
|
||||||
).await.unwrap(),
|
).await.unwrap(),
|
||||||
];
|
];
|
||||||
@ -3787,15 +3788,15 @@ async fn test_items_to_trade_count_mismatch_with_meseta() {
|
|||||||
|
|
||||||
let p1_inv = vec![
|
let p1_inv = vec![
|
||||||
entity_gateway.create_item(
|
entity_gateway.create_item(
|
||||||
ItemBuilder::weapon(item::weapon::WeaponType::Saber)
|
ItemBuilder::weapon(weapon::WeaponType::Saber)
|
||||||
.as_new()
|
.as_new()
|
||||||
).await.unwrap(),
|
).await.unwrap(),
|
||||||
entity_gateway.create_item(
|
entity_gateway.create_item(
|
||||||
ItemBuilder::weapon(item::weapon::WeaponType::Brand)
|
ItemBuilder::weapon(weapon::WeaponType::Brand)
|
||||||
.as_new()
|
.as_new()
|
||||||
).await.unwrap(),
|
).await.unwrap(),
|
||||||
entity_gateway.create_item(
|
entity_gateway.create_item(
|
||||||
ItemBuilder::weapon(item::weapon::WeaponType::Buster)
|
ItemBuilder::weapon(weapon::WeaponType::Buster)
|
||||||
.as_new()
|
.as_new()
|
||||||
).await.unwrap(),
|
).await.unwrap(),
|
||||||
];
|
];
|
||||||
@ -3863,7 +3864,7 @@ async fn test_dropping_item_after_trade() {
|
|||||||
|
|
||||||
let mut p1_inv = Vec::new();
|
let mut p1_inv = Vec::new();
|
||||||
p1_inv.push(entity_gateway.create_item(
|
p1_inv.push(entity_gateway.create_item(
|
||||||
ItemBuilder::weapon(item::weapon::WeaponType::Handgun)
|
ItemBuilder::weapon(weapon::WeaponType::Handgun)
|
||||||
.as_new()
|
.as_new()
|
||||||
).await.unwrap());
|
).await.unwrap());
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user