random formatting and ordering changes
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
b6cc50360a
commit
c8b9564009
@ -93,11 +93,11 @@ pub trait EntityGateway: Send + Sync + Clone {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
async fn add_shield_modifier(&mut self, _item_id: &ItemEntityId, _modifier: shield::ShieldModifier) -> Result<(), GatewayError> {
|
||||
async fn add_unit_modifier(&mut self, _item_id: &ItemEntityId, _modifier: unit::UnitModifier) -> Result<(), GatewayError> {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
async fn add_unit_modifier(&mut self, _item_id: &ItemEntityId, _modifier: unit::UnitModifier) -> Result<(), GatewayError> {
|
||||
async fn add_shield_modifier(&mut self, _item_id: &ItemEntityId, _modifier: shield::ShieldModifier) -> Result<(), GatewayError> {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
|
@ -17,12 +17,12 @@ pub struct InMemoryGateway {
|
||||
inventories: Arc<Mutex<BTreeMap<CharacterEntityId, InventoryEntity>>>,
|
||||
banks: Arc<Mutex<BTreeMap<CharacterEntityId, BankEntity>>>,
|
||||
equips: Arc<Mutex<BTreeMap<CharacterEntityId, EquippedEntity>>>,
|
||||
mag_modifiers: Arc<Mutex<BTreeMap<ItemEntityId, Vec<mag::MagModifier>>>>,
|
||||
weapon_modifiers: Arc<Mutex<BTreeMap<ItemEntityId, Vec<weapon::WeaponModifier>>>>,
|
||||
esweapon_modifiers: Arc<Mutex<BTreeMap<ItemEntityId, Vec<esweapon::ESWeaponModifier>>>>,
|
||||
armor_modifiers: Arc<Mutex<BTreeMap<ItemEntityId, Vec<armor::ArmorModifier>>>>,
|
||||
shield_modifiers: Arc<Mutex<BTreeMap<ItemEntityId, Vec<shield::ShieldModifier>>>>,
|
||||
unit_modifiers: Arc<Mutex<BTreeMap<ItemEntityId, Vec<unit::UnitModifier>>>>,
|
||||
shield_modifiers: Arc<Mutex<BTreeMap<ItemEntityId, Vec<shield::ShieldModifier>>>>,
|
||||
mag_modifiers: Arc<Mutex<BTreeMap<ItemEntityId, Vec<mag::MagModifier>>>>,
|
||||
tech_modifiers: Arc<Mutex<BTreeMap<ItemEntityId, Vec<tech::TechModifier>>>>,
|
||||
tool_modifiers: Arc<Mutex<BTreeMap<ItemEntityId, Vec<tool::ToolModifier>>>>,
|
||||
}
|
||||
@ -37,12 +37,12 @@ impl InMemoryGateway {
|
||||
inventories: Arc::new(Mutex::new(BTreeMap::new())),
|
||||
banks: Arc::new(Mutex::new(BTreeMap::new())),
|
||||
equips: Arc::new(Mutex::new(BTreeMap::new())),
|
||||
mag_modifiers: Arc::new(Mutex::new(BTreeMap::new())),
|
||||
weapon_modifiers: Arc::new(Mutex::new(BTreeMap::new())),
|
||||
esweapon_modifiers: Arc::new(Mutex::new(BTreeMap::new())),
|
||||
armor_modifiers: Arc::new(Mutex::new(BTreeMap::new())),
|
||||
shield_modifiers: Arc::new(Mutex::new(BTreeMap::new())),
|
||||
unit_modifiers: Arc::new(Mutex::new(BTreeMap::new())),
|
||||
shield_modifiers: Arc::new(Mutex::new(BTreeMap::new())),
|
||||
mag_modifiers: Arc::new(Mutex::new(BTreeMap::new())),
|
||||
tech_modifiers: Arc::new(Mutex::new(BTreeMap::new())),
|
||||
tool_modifiers: Arc::new(Mutex::new(BTreeMap::new())),
|
||||
}
|
||||
@ -80,14 +80,6 @@ impl InMemoryGateway {
|
||||
}
|
||||
ItemDetail::Armor(armor)
|
||||
},
|
||||
ItemDetail::Shield(mut shield) => {
|
||||
if let Some(shield_modifiers) = self.shield_modifiers.lock().unwrap().get(&item.id) {
|
||||
for shield_modifier in shield_modifiers.iter() {
|
||||
shield.apply_modifier(&shield_modifier);
|
||||
}
|
||||
}
|
||||
ItemDetail::Shield(shield)
|
||||
},
|
||||
ItemDetail::Unit(mut unit) => {
|
||||
if let Some(unit_modifiers) = self.unit_modifiers.lock().unwrap().get(&item.id) {
|
||||
for unit_modifier in unit_modifiers.iter() {
|
||||
@ -96,21 +88,13 @@ impl InMemoryGateway {
|
||||
}
|
||||
ItemDetail::Unit(unit)
|
||||
},
|
||||
ItemDetail::TechniqueDisk(mut tech) => {
|
||||
if let Some(tech_modifiers) = self.tech_modifiers.lock().unwrap().get(&item.id) {
|
||||
for tech_modifier in tech_modifiers.iter() {
|
||||
tech.apply_modifier(&tech_modifier);
|
||||
ItemDetail::Shield(mut shield) => {
|
||||
if let Some(shield_modifiers) = self.shield_modifiers.lock().unwrap().get(&item.id) {
|
||||
for shield_modifier in shield_modifiers.iter() {
|
||||
shield.apply_modifier(&shield_modifier);
|
||||
}
|
||||
}
|
||||
ItemDetail::TechniqueDisk(tech)
|
||||
},
|
||||
ItemDetail::Tool(mut tool) => {
|
||||
if let Some(tool_modifiers) = self.tool_modifiers.lock().unwrap().get(&item.id) {
|
||||
for tool_modifier in tool_modifiers.iter() {
|
||||
tool.apply_modifier(&tool_modifier);
|
||||
}
|
||||
}
|
||||
ItemDetail::Tool(tool)
|
||||
ItemDetail::Shield(shield)
|
||||
},
|
||||
ItemDetail::Mag(mag) => {
|
||||
let mut mag = {
|
||||
@ -148,9 +132,22 @@ impl InMemoryGateway {
|
||||
}
|
||||
ItemDetail::Mag(mag)
|
||||
},
|
||||
// _ => {
|
||||
// item.item
|
||||
// }
|
||||
ItemDetail::TechniqueDisk(mut tech) => {
|
||||
if let Some(tech_modifiers) = self.tech_modifiers.lock().unwrap().get(&item.id) {
|
||||
for tech_modifier in tech_modifiers.iter() {
|
||||
tech.apply_modifier(&tech_modifier);
|
||||
}
|
||||
}
|
||||
ItemDetail::TechniqueDisk(tech)
|
||||
},
|
||||
ItemDetail::Tool(mut tool) => {
|
||||
if let Some(tool_modifiers) = self.tool_modifiers.lock().unwrap().get(&item.id) {
|
||||
for tool_modifier in tool_modifiers.iter() {
|
||||
tool.apply_modifier(&tool_modifier);
|
||||
}
|
||||
}
|
||||
ItemDetail::Tool(tool)
|
||||
},
|
||||
};
|
||||
item
|
||||
})
|
||||
@ -354,16 +351,16 @@ impl EntityGateway for InMemoryGateway {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn add_shield_modifier(&mut self, item_id: &ItemEntityId, modifier: shield::ShieldModifier) -> Result<(), GatewayError> {
|
||||
self.shield_modifiers.lock().unwrap()
|
||||
async fn add_unit_modifier(&mut self, item_id: &ItemEntityId, modifier: unit::UnitModifier) -> Result<(), GatewayError> {
|
||||
self.unit_modifiers.lock().unwrap()
|
||||
.entry(*item_id)
|
||||
.or_insert(Vec::new())
|
||||
.push(modifier);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn add_unit_modifier(&mut self, item_id: &ItemEntityId, modifier: unit::UnitModifier) -> Result<(), GatewayError> {
|
||||
self.unit_modifiers.lock().unwrap()
|
||||
async fn add_shield_modifier(&mut self, item_id: &ItemEntityId, modifier: shield::ShieldModifier) -> Result<(), GatewayError> {
|
||||
self.shield_modifiers.lock().unwrap()
|
||||
.entry(*item_id)
|
||||
.or_insert(Vec::new())
|
||||
.push(modifier);
|
||||
|
@ -93,20 +93,32 @@ create table weapon_modifier (
|
||||
created_at timestamptz default current_timestamp not null
|
||||
);
|
||||
|
||||
create table esweapon_modifier (
|
||||
esweapon integer references item (id) not null,
|
||||
modifier jsonb not null,
|
||||
created_at timestamptz default current_timestamp not null
|
||||
);
|
||||
|
||||
create table armor_modifier (
|
||||
armor integer references item (id) not null,
|
||||
modifier jsonb not null,
|
||||
created_at timestamptz default current_timestamp not null
|
||||
);
|
||||
|
||||
create table unit_modifier (
|
||||
unit integer references item (id) not null,
|
||||
modifier jsonb not null,
|
||||
created_at timestamptz default current_timestamp not null
|
||||
);
|
||||
|
||||
create table shield_modifier (
|
||||
shield integer references item (id) not null,
|
||||
modifier jsonb not null,
|
||||
created_at timestamptz default current_timestamp not null
|
||||
);
|
||||
|
||||
create table unit_modifier (
|
||||
unit integer references item (id) not null,
|
||||
create table mag_modifier (
|
||||
mag integer references item (id) not null,
|
||||
modifier jsonb not null,
|
||||
created_at timestamptz default current_timestamp not null
|
||||
);
|
||||
@ -122,15 +134,3 @@ create table tool_modifier (
|
||||
modifier jsonb not null,
|
||||
created_at timestamptz default current_timestamp not null
|
||||
);
|
||||
|
||||
create table esweapon_modifier (
|
||||
esweapon integer references item (id) not null,
|
||||
modifier jsonb not null,
|
||||
created_at timestamptz default current_timestamp not null
|
||||
);
|
||||
|
||||
create table mag_modifier (
|
||||
mag integer references item (id) not null,
|
||||
modifier jsonb not null,
|
||||
created_at timestamptz default current_timestamp not null
|
||||
);
|
||||
|
@ -178,7 +178,6 @@ impl From<SectionID> for PgSectionId {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[derive(Debug, sqlx::FromRow)]
|
||||
pub struct PgCharacter {
|
||||
pub id: i32,
|
||||
@ -277,8 +276,6 @@ impl Into<CharacterEntity> for PgCharacter {
|
||||
pub struct PgGuildCard {
|
||||
}
|
||||
|
||||
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct PgWeapon {
|
||||
weapon: weapon::WeaponType,
|
||||
@ -329,6 +326,45 @@ pub struct PgWeaponModifier {
|
||||
pub modifier: sqlx::types::Json<weapon::WeaponModifier>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct PgESWeapon {
|
||||
esweapon: esweapon::ESWeaponType,
|
||||
special: Option<esweapon::ESWeaponSpecial>,
|
||||
name: String,
|
||||
grind: u8,
|
||||
wrapping: Option<WrappingPaper>,
|
||||
}
|
||||
|
||||
impl From<esweapon::ESWeapon> for PgESWeapon {
|
||||
fn from(other: esweapon::ESWeapon) -> PgESWeapon {
|
||||
PgESWeapon {
|
||||
esweapon: other.esweapon,
|
||||
special: other.special,
|
||||
name: other.name,
|
||||
grind: other.grind,
|
||||
wrapping: other.wrapping,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<esweapon::ESWeapon> for PgESWeapon {
|
||||
fn into(self) -> esweapon::ESWeapon {
|
||||
esweapon::ESWeapon {
|
||||
esweapon: self.esweapon,
|
||||
special: self.special,
|
||||
name: self.name,
|
||||
grind: self.grind,
|
||||
wrapping: self.wrapping,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, sqlx::FromRow)]
|
||||
pub struct PgESWeaponModifier {
|
||||
pub esweapon: i32,
|
||||
pub modifier: sqlx::types::Json<esweapon::ESWeaponModifier>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct PgArmor {
|
||||
armor: armor::ArmorType,
|
||||
@ -368,6 +404,39 @@ pub struct PgArmorModifier {
|
||||
pub modifier: sqlx::types::Json<armor::ArmorModifier>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct PgUnit {
|
||||
unit: unit::UnitType,
|
||||
modifier: Option<unit::UnitModifier>,
|
||||
wrapping: Option<WrappingPaper>,
|
||||
}
|
||||
|
||||
impl From<unit::Unit> for PgUnit {
|
||||
fn from(other: unit::Unit) -> PgUnit {
|
||||
PgUnit {
|
||||
unit: other.unit,
|
||||
modifier: other.modifier,
|
||||
wrapping: other.wrapping,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<unit::Unit> for PgUnit {
|
||||
fn into(self) -> unit::Unit {
|
||||
unit::Unit {
|
||||
unit: self.unit,
|
||||
modifier: self.modifier,
|
||||
wrapping: self.wrapping,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, sqlx::FromRow)]
|
||||
pub struct PgUnitModifier {
|
||||
pub unit: i32,
|
||||
pub modifier: sqlx::types::Json<unit::UnitModifier>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct PgShield {
|
||||
shield: shield::ShieldType,
|
||||
@ -405,68 +474,34 @@ pub struct PgShieldModifier {
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct PgUnit {
|
||||
unit: unit::UnitType,
|
||||
modifier: Option<unit::UnitModifier>,
|
||||
pub struct PgMag {
|
||||
mag: mag::MagType,
|
||||
synchro: u8,
|
||||
color: u8,
|
||||
wrapping: Option<WrappingPaper>,
|
||||
}
|
||||
|
||||
impl From<unit::Unit> for PgUnit {
|
||||
fn from(other: unit::Unit) -> PgUnit {
|
||||
PgUnit {
|
||||
unit: other.unit,
|
||||
modifier: other.modifier,
|
||||
impl From<mag::Mag> for PgMag {
|
||||
fn from(other: mag::Mag) -> PgMag {
|
||||
PgMag {
|
||||
mag: other.mag,
|
||||
synchro: other.synchro,
|
||||
color: other.color,
|
||||
wrapping: other.wrapping,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<unit::Unit> for PgUnit {
|
||||
fn into(self) -> unit::Unit {
|
||||
unit::Unit {
|
||||
unit: self.unit,
|
||||
modifier: self.modifier,
|
||||
wrapping: self.wrapping,
|
||||
}
|
||||
impl Into<mag::Mag> for PgMag {
|
||||
fn into(self) -> mag::Mag {
|
||||
let mut mag = mag::Mag::baby_mag(self.color as u16);
|
||||
mag.mag = self.mag;
|
||||
mag.synchro = self.synchro;
|
||||
mag.wrapping = self.wrapping;
|
||||
mag
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, sqlx::FromRow)]
|
||||
pub struct PgUnitModifier {
|
||||
pub unit: i32,
|
||||
pub modifier: sqlx::types::Json<unit::UnitModifier>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct PgTool {
|
||||
pub tool: tool::ToolType,
|
||||
wrapping: Option<WrappingPaper>,
|
||||
}
|
||||
|
||||
impl From<tool::Tool> for PgTool {
|
||||
fn from(other: tool::Tool) -> PgTool {
|
||||
PgTool {
|
||||
tool: other.tool,
|
||||
wrapping: other.wrapping,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<tool::Tool> for PgTool {
|
||||
fn into(self) -> tool::Tool {
|
||||
tool::Tool {
|
||||
tool: self.tool,
|
||||
wrapping: self.wrapping,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, sqlx::FromRow)]
|
||||
pub struct PgToolModifier {
|
||||
pub tool: i32,
|
||||
pub modifier: sqlx::types::Json<tool::ToolModifier>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct PgTechDisk {
|
||||
tech: tech::Technique,
|
||||
@ -501,110 +536,58 @@ pub struct PgTechModifier {
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct PgMag {
|
||||
mag: mag::MagType,
|
||||
synchro: u8,
|
||||
color: u8,
|
||||
pub struct PgTool {
|
||||
pub tool: tool::ToolType,
|
||||
wrapping: Option<WrappingPaper>,
|
||||
}
|
||||
|
||||
impl From<mag::Mag> for PgMag {
|
||||
fn from(other: mag::Mag) -> PgMag {
|
||||
PgMag {
|
||||
mag: other.mag,
|
||||
synchro: other.synchro,
|
||||
color: other.color,
|
||||
impl From<tool::Tool> for PgTool {
|
||||
fn from(other: tool::Tool) -> PgTool {
|
||||
PgTool {
|
||||
tool: other.tool,
|
||||
wrapping: other.wrapping,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<mag::Mag> for PgMag {
|
||||
fn into(self) -> mag::Mag {
|
||||
/*mag::Mag {
|
||||
mag: self.mag,
|
||||
synchro: self.synchro,
|
||||
color: self.color,
|
||||
def: 500,
|
||||
pow: 0,
|
||||
dex: 0,
|
||||
mnd: 0,
|
||||
iq: 0,
|
||||
photon_blast: [None; 3],
|
||||
class: CharacterClass::HUmar,
|
||||
id: SectionID::Viridia,
|
||||
}*/
|
||||
let mut mag = mag::Mag::baby_mag(self.color as u16);
|
||||
mag.mag = self.mag;
|
||||
mag.synchro = self.synchro;
|
||||
mag.wrapping = self.wrapping;
|
||||
mag
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct PgESWeapon {
|
||||
esweapon: esweapon::ESWeaponType,
|
||||
special: Option<esweapon::ESWeaponSpecial>,
|
||||
name: String,
|
||||
grind: u8,
|
||||
wrapping: Option<WrappingPaper>,
|
||||
}
|
||||
|
||||
impl From<esweapon::ESWeapon> for PgESWeapon {
|
||||
fn from(other: esweapon::ESWeapon) -> PgESWeapon {
|
||||
PgESWeapon {
|
||||
esweapon: other.esweapon,
|
||||
special: other.special,
|
||||
name: other.name,
|
||||
grind: other.grind,
|
||||
wrapping: other.wrapping,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<esweapon::ESWeapon> for PgESWeapon {
|
||||
fn into(self) -> esweapon::ESWeapon {
|
||||
esweapon::ESWeapon {
|
||||
esweapon: self.esweapon,
|
||||
special: self.special,
|
||||
name: self.name,
|
||||
grind: self.grind,
|
||||
impl Into<tool::Tool> for PgTool {
|
||||
fn into(self) -> tool::Tool {
|
||||
tool::Tool {
|
||||
tool: self.tool,
|
||||
wrapping: self.wrapping,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, sqlx::FromRow)]
|
||||
pub struct PgESWeaponModifier {
|
||||
pub esweapon: i32,
|
||||
pub modifier: sqlx::types::Json<esweapon::ESWeaponModifier>,
|
||||
pub struct PgToolModifier {
|
||||
pub tool: i32,
|
||||
pub modifier: sqlx::types::Json<tool::ToolModifier>,
|
||||
}
|
||||
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub enum PgItemDetail {
|
||||
Weapon(PgWeapon),
|
||||
Armor(PgArmor),
|
||||
Shield(PgShield),
|
||||
Unit(PgUnit),
|
||||
Tool(PgTool),
|
||||
TechDisk(PgTechDisk),
|
||||
Mag(PgMag),
|
||||
ESWeapon(PgESWeapon),
|
||||
Armor(PgArmor),
|
||||
Unit(PgUnit),
|
||||
Shield(PgShield),
|
||||
Mag(PgMag),
|
||||
TechDisk(PgTechDisk),
|
||||
Tool(PgTool),
|
||||
}
|
||||
|
||||
impl From<ItemDetail> for PgItemDetail {
|
||||
fn from(other: ItemDetail) -> PgItemDetail {
|
||||
match other {
|
||||
ItemDetail::Weapon(weapon) => PgItemDetail::Weapon(weapon.into()),
|
||||
ItemDetail::Armor(armor) => PgItemDetail::Armor(armor.into()),
|
||||
ItemDetail::Shield(shield) => PgItemDetail::Shield(shield.into()),
|
||||
ItemDetail::Unit(unit) => PgItemDetail::Unit(unit.into()),
|
||||
ItemDetail::Tool(tool) => PgItemDetail::Tool(tool.into()),
|
||||
ItemDetail::TechniqueDisk(tech_disk) => PgItemDetail::TechDisk(tech_disk.into()),
|
||||
ItemDetail::Mag(mag) => PgItemDetail::Mag(mag.into()),
|
||||
ItemDetail::ESWeapon(esweapon) => PgItemDetail::ESWeapon(esweapon.into()),
|
||||
ItemDetail::Armor(armor) => PgItemDetail::Armor(armor.into()),
|
||||
ItemDetail::Unit(unit) => PgItemDetail::Unit(unit.into()),
|
||||
ItemDetail::Shield(shield) => PgItemDetail::Shield(shield.into()),
|
||||
ItemDetail::Mag(mag) => PgItemDetail::Mag(mag.into()),
|
||||
ItemDetail::TechniqueDisk(tech_disk) => PgItemDetail::TechDisk(tech_disk.into()),
|
||||
ItemDetail::Tool(tool) => PgItemDetail::Tool(tool.into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -613,13 +596,13 @@ impl Into<ItemDetail> for PgItemDetail {
|
||||
fn into(self) -> ItemDetail {
|
||||
match self {
|
||||
PgItemDetail::Weapon(weapon) => ItemDetail::Weapon(weapon.into()),
|
||||
PgItemDetail::Armor(armor) => ItemDetail::Armor(armor.into()),
|
||||
PgItemDetail::Shield(shield) => ItemDetail::Shield(shield.into()),
|
||||
PgItemDetail::Unit(unit) => ItemDetail::Unit(unit.into()),
|
||||
PgItemDetail::Tool(tool) => ItemDetail::Tool(tool.into()),
|
||||
PgItemDetail::TechDisk(tech_disk) => ItemDetail::TechniqueDisk(tech_disk.into()),
|
||||
PgItemDetail::Mag(mag) => ItemDetail::Mag(mag.into()),
|
||||
PgItemDetail::ESWeapon(esweapon) => ItemDetail::ESWeapon(esweapon.into()),
|
||||
PgItemDetail::Armor(armor) => ItemDetail::Armor(armor.into()),
|
||||
PgItemDetail::Unit(unit) => ItemDetail::Unit(unit.into()),
|
||||
PgItemDetail::Shield(shield) => ItemDetail::Shield(shield.into()),
|
||||
PgItemDetail::Mag(mag) => ItemDetail::Mag(mag.into()),
|
||||
PgItemDetail::TechDisk(tech_disk) => ItemDetail::TechniqueDisk(tech_disk.into()),
|
||||
PgItemDetail::Tool(tool) => ItemDetail::Tool(tool.into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -630,7 +613,6 @@ pub struct PgItem {
|
||||
pub item: sqlx::types::Json<PgItemDetail>,
|
||||
}
|
||||
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub enum PgItemLocationDetail {
|
||||
Inventory {
|
||||
@ -688,7 +670,6 @@ impl Into<ItemLocation> for PgItemLocationDetail {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[derive(Debug, sqlx::FromRow)]
|
||||
pub struct PgItemLocation {
|
||||
//pub id: i32,
|
||||
@ -696,7 +677,6 @@ pub struct PgItemLocation {
|
||||
created_at: chrono::DateTime<chrono::Utc>,
|
||||
}
|
||||
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub enum PgMagModifierDetail {
|
||||
FeedMag(i32),
|
||||
@ -740,7 +720,6 @@ pub struct PgMagModifier {
|
||||
created_at: chrono::DateTime<chrono::Utc>,
|
||||
}
|
||||
|
||||
|
||||
#[derive(Debug, sqlx::FromRow)]
|
||||
pub struct PgItemEntity {
|
||||
pub id: i32,
|
||||
@ -764,7 +743,6 @@ impl Into<ItemEntity> for PgItemWithLocation {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[derive(Debug, sqlx::FromRow)]
|
||||
pub struct PgMagModifierWithParameters {
|
||||
pub mag: i32,
|
||||
@ -773,7 +751,6 @@ pub struct PgMagModifierWithParameters {
|
||||
pub cell: Option<sqlx::types::Json<PgTool>>,
|
||||
}
|
||||
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum PgInventoryItemEntity {
|
||||
@ -799,11 +776,11 @@ pub struct PgEquipped {
|
||||
pchar: i32,
|
||||
weapon: Option<i32>,
|
||||
armor: Option<i32>,
|
||||
shield: Option<i32>,
|
||||
unit0: Option<i32>,
|
||||
unit1: Option<i32>,
|
||||
unit2: Option<i32>,
|
||||
unit3: Option<i32>,
|
||||
shield: Option<i32>,
|
||||
mag: Option<i32>,
|
||||
}
|
||||
|
||||
@ -812,12 +789,12 @@ impl Into<EquippedEntity> for PgEquipped {
|
||||
EquippedEntity {
|
||||
weapon: self.weapon.map(|i| ItemEntityId(i as u32)),
|
||||
armor: self.armor.map(|i| ItemEntityId(i as u32)),
|
||||
shield: self.shield.map(|i| ItemEntityId(i as u32)),
|
||||
unit: [self.unit0.map(|i| ItemEntityId(i as u32)),
|
||||
self.unit1.map(|i| ItemEntityId(i as u32)),
|
||||
self.unit2.map(|i| ItemEntityId(i as u32)),
|
||||
self.unit3.map(|i| ItemEntityId(i as u32)),
|
||||
self.unit1.map(|i| ItemEntityId(i as u32)),
|
||||
self.unit2.map(|i| ItemEntityId(i as u32)),
|
||||
self.unit3.map(|i| ItemEntityId(i as u32)),
|
||||
],
|
||||
shield: self.shield.map(|i| ItemEntityId(i as u32)),
|
||||
mag: self.mag.map(|i| ItemEntityId(i as u32)),
|
||||
}
|
||||
}
|
||||
@ -829,13 +806,12 @@ impl From<(CharacterEntityId, EquippedEntity)> for PgEquipped {
|
||||
pchar: char_equips.0.0 as i32,
|
||||
weapon: char_equips.1.weapon.map(|i| i.0 as i32),
|
||||
armor: char_equips.1.armor.map(|i| i.0 as i32),
|
||||
shield: char_equips.1.shield.map(|i| i.0 as i32),
|
||||
unit0: char_equips.1.unit[0].map(|i| i.0 as i32),
|
||||
unit1: char_equips.1.unit[1].map(|i| i.0 as i32),
|
||||
unit2: char_equips.1.unit[2].map(|i| i.0 as i32),
|
||||
unit3: char_equips.1.unit[3].map(|i| i.0 as i32),
|
||||
shield: char_equips.1.shield.map(|i| i.0 as i32),
|
||||
mag: char_equips.1.mag.map(|i| i.0 as i32),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -82,6 +82,57 @@ impl PostgresGateway {
|
||||
|
||||
ItemDetail::ESWeapon(esweapon)
|
||||
},
|
||||
ItemDetail::Armor(mut armor) => {
|
||||
let q = r#"select armor, modifier
|
||||
from armor_modifier
|
||||
where armor = $1
|
||||
order by created_at"#;
|
||||
let armor_modifiers = sqlx::query_as::<_, PgArmorModifier>(q)
|
||||
.bind(id.0 as i32)
|
||||
.fetch(&self.pool);
|
||||
|
||||
armor_modifiers.for_each(|modifier| {
|
||||
if let Ok(modifier) = modifier {
|
||||
armor.apply_modifier(&modifier.modifier);
|
||||
}
|
||||
}).await;
|
||||
|
||||
ItemDetail::Armor(armor)
|
||||
},
|
||||
ItemDetail::Unit(mut unit) => {
|
||||
let q = r#"select unit, modifier
|
||||
from unit_modifier
|
||||
where unit = $1
|
||||
order by created_at"#;
|
||||
let unit_modifiers = sqlx::query_as::<_, PgUnitModifier>(q)
|
||||
.bind(id.0 as i32)
|
||||
.fetch(&self.pool);
|
||||
|
||||
unit_modifiers.for_each(|modifier| {
|
||||
if let Ok(modifier) = modifier {
|
||||
unit.apply_modifier(&modifier.modifier);
|
||||
}
|
||||
}).await;
|
||||
|
||||
ItemDetail::Unit(unit)
|
||||
},
|
||||
ItemDetail::Shield(mut shield) => {
|
||||
let q = r#"select shield, modifier
|
||||
from shield_modifier
|
||||
where shield = $1
|
||||
order by created_at"#;
|
||||
let shield_modifiers = sqlx::query_as::<_, PgShieldModifier>(q)
|
||||
.bind(id.0 as i32)
|
||||
.fetch(&self.pool);
|
||||
|
||||
shield_modifiers.for_each(|modifier| {
|
||||
if let Ok(modifier) = modifier {
|
||||
shield.apply_modifier(&modifier.modifier);
|
||||
}
|
||||
}).await;
|
||||
|
||||
ItemDetail::Shield(shield)
|
||||
},
|
||||
ItemDetail::Mag(mut mag) => {
|
||||
let q = r#"select mag, modifier, item.item -> 'Tool' as feed, item2.item -> 'Tool' as cell
|
||||
from mag_modifier
|
||||
@ -115,57 +166,6 @@ impl PostgresGateway {
|
||||
|
||||
ItemDetail::Mag(mag)
|
||||
},
|
||||
ItemDetail::Armor(mut armor) => {
|
||||
let q = r#"select armor, modifier
|
||||
from armor_modifier
|
||||
where armor = $1
|
||||
order by created_at"#;
|
||||
let armor_modifiers = sqlx::query_as::<_, PgArmorModifier>(q)
|
||||
.bind(id.0 as i32)
|
||||
.fetch(&self.pool);
|
||||
|
||||
armor_modifiers.for_each(|modifier| {
|
||||
if let Ok(modifier) = modifier {
|
||||
armor.apply_modifier(&modifier.modifier);
|
||||
}
|
||||
}).await;
|
||||
|
||||
ItemDetail::Armor(armor)
|
||||
},
|
||||
ItemDetail::Shield(mut shield) => {
|
||||
let q = r#"select shield, modifier
|
||||
from shield_modifier
|
||||
where shield = $1
|
||||
order by created_at"#;
|
||||
let shield_modifiers = sqlx::query_as::<_, PgShieldModifier>(q)
|
||||
.bind(id.0 as i32)
|
||||
.fetch(&self.pool);
|
||||
|
||||
shield_modifiers.for_each(|modifier| {
|
||||
if let Ok(modifier) = modifier {
|
||||
shield.apply_modifier(&modifier.modifier);
|
||||
}
|
||||
}).await;
|
||||
|
||||
ItemDetail::Shield(shield)
|
||||
},
|
||||
ItemDetail::Unit(mut unit) => {
|
||||
let q = r#"select unit, modifier
|
||||
from unit_modifier
|
||||
where unit = $1
|
||||
order by created_at"#;
|
||||
let unit_modifiers = sqlx::query_as::<_, PgUnitModifier>(q)
|
||||
.bind(id.0 as i32)
|
||||
.fetch(&self.pool);
|
||||
|
||||
unit_modifiers.for_each(|modifier| {
|
||||
if let Ok(modifier) = modifier {
|
||||
unit.apply_modifier(&modifier.modifier);
|
||||
}
|
||||
}).await;
|
||||
|
||||
ItemDetail::Unit(unit)
|
||||
},
|
||||
item @ _ => item
|
||||
};
|
||||
|
||||
@ -502,16 +502,16 @@ impl EntityGateway for PostgresGateway {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn add_shield_modifier(&mut self, item_id: &ItemEntityId, modifier: shield::ShieldModifier) -> Result<(), GatewayError> {
|
||||
sqlx::query("insert into shield_modifier (shield, modifier) values ($1, $2);")
|
||||
async fn add_unit_modifier(&mut self, item_id: &ItemEntityId, modifier: unit::UnitModifier) -> Result<(), GatewayError> {
|
||||
sqlx::query("insert into unit_modifier (unit, modifier) values ($1, $2);")
|
||||
.bind(item_id.0)
|
||||
.bind(sqlx::types::Json(modifier))
|
||||
.execute(&self.pool).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn add_unit_modifier(&mut self, item_id: &ItemEntityId, modifier: unit::UnitModifier) -> Result<(), GatewayError> {
|
||||
sqlx::query("insert into unit_modifier (unit, modifier) values ($1, $2);")
|
||||
async fn add_shield_modifier(&mut self, item_id: &ItemEntityId, modifier: shield::ShieldModifier) -> Result<(), GatewayError> {
|
||||
sqlx::query("insert into shield_modifier (shield, modifier) values ($1, $2);")
|
||||
.bind(item_id.0)
|
||||
.bind(sqlx::types::Json(modifier))
|
||||
.execute(&self.pool).await?;
|
||||
@ -707,16 +707,16 @@ impl EntityGateway for PostgresGateway {
|
||||
}
|
||||
|
||||
async fn set_character_equips(&mut self, char_id: &CharacterEntityId, equips: &EquippedEntity) -> Result<(), GatewayError> {
|
||||
sqlx::query(r#"insert into equipped (pchar, weapon, armor, shield, unit0, unit1, unit2, unit3, mag) values ($1, $2, $3, $4, $5, $6, $7, $8, $9)
|
||||
sqlx::query(r#"insert into equipped (pchar, weapon, armor, unit0, unit1, unit2, unit3, shield, mag) values ($1, $2, $3, $4, $5, $6, $7, $8, $9)
|
||||
on conflict (pchar) do update set weapon=$2, armor=$3, shield=$4, unit0=$5, unit1=$6, unit2=$7, unit3=$8, mag=$9"#)
|
||||
.bind(char_id.0)
|
||||
.bind(equips.weapon.map(|i| i.0 as i32))
|
||||
.bind(equips.armor.map(|i| i.0 as i32))
|
||||
.bind(equips.shield.map(|i| i.0 as i32))
|
||||
.bind(equips.unit[0].map(|i| i.0 as i32))
|
||||
.bind(equips.unit[1].map(|i| i.0 as i32))
|
||||
.bind(equips.unit[2].map(|i| i.0 as i32))
|
||||
.bind(equips.unit[3].map(|i| i.0 as i32))
|
||||
.bind(equips.shield.map(|i| i.0 as i32))
|
||||
.bind(equips.mag.map(|i| i.0 as i32))
|
||||
.execute(&self.pool)
|
||||
.await?;
|
||||
|
@ -288,7 +288,6 @@ impl ArmorType {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub enum ArmorModifier {
|
||||
AddSlot {
|
||||
@ -298,7 +297,6 @@ pub enum ArmorModifier {
|
||||
UnwrapPresent,
|
||||
}
|
||||
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
|
||||
pub struct Armor {
|
||||
pub armor: ArmorType,
|
||||
|
@ -337,6 +337,4 @@ mod test {
|
||||
let bytes = testweapon.as_bytes();
|
||||
assert_eq!(bytes, [0x00, 0xA7, 0x0B, 0x69, 0x00, 0x00, 0x83, 0x35, 0x9D, 0x2F, 0xA0, 0x00, 0x00, 0x00, 0x00, 0x00]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -56,8 +56,6 @@ lazy_static::lazy_static! {
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub enum ItemParseError {
|
||||
InvalidMagType,
|
||||
@ -548,7 +546,6 @@ pub struct Mag {
|
||||
pub wrapping: Option<WrappingPaper>,
|
||||
}
|
||||
|
||||
|
||||
impl Mag {
|
||||
pub fn baby_mag(skin: u16) -> Mag {
|
||||
Mag {
|
||||
@ -1216,4 +1213,3 @@ mod test {
|
||||
fn test_mag_does_not_level_down() {
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,6 @@ impl Meseta {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||
pub enum ItemType {
|
||||
Weapon(weapon::WeaponType),
|
||||
@ -279,7 +278,6 @@ impl InventoryEntity {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum BankItemEntity {
|
||||
Individual(ItemEntity),
|
||||
@ -314,7 +312,6 @@ impl BankItemEntity {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[derive(Clone, Debug, Default)]
|
||||
pub struct BankEntity {
|
||||
pub items: Vec<BankItemEntity>,
|
||||
|
@ -343,7 +343,6 @@ pub struct Unit {
|
||||
pub wrapping: Option<WrappingPaper>,
|
||||
}
|
||||
|
||||
|
||||
impl Unit {
|
||||
pub fn as_bytes(&self) -> [u8; 16] {
|
||||
let mut result = [0; 16];
|
||||
|
@ -44,7 +44,6 @@ impl WeaponAttribute {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Serialize, Deserialize, strum_macros::EnumIter)]
|
||||
pub enum WeaponSpecial {
|
||||
Draw = 1,
|
||||
@ -1420,7 +1419,6 @@ impl WeaponType {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub enum TekSpecialModifier {
|
||||
Plus,
|
||||
@ -1468,7 +1466,6 @@ pub struct Weapon {
|
||||
pub wrapping: Option<WrappingPaper>,
|
||||
}
|
||||
|
||||
|
||||
impl Weapon {
|
||||
pub fn new(wep: WeaponType) -> Weapon {
|
||||
Weapon {
|
||||
@ -1615,5 +1612,3 @@ impl Weapon {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -3,14 +3,14 @@ use thiserror::Error;
|
||||
use libpso::character::character;//::InventoryItem;
|
||||
use crate::entity::character::CharacterEntityId;
|
||||
use crate::entity::item::{ItemEntityId, ItemDetail, ItemEntity, ItemType, ItemLocation, InventoryEntity, InventoryItemEntity, EquippedEntity};
|
||||
use crate::entity::item::tool::Tool;
|
||||
use crate::entity::item::mag::Mag;
|
||||
use crate::entity::item::weapon::Weapon;
|
||||
use crate::entity::item::esweapon::ESWeapon;
|
||||
use crate::entity::item::armor::Armor; // TODO: cleanup uses
|
||||
use crate::entity::item::shield::Shield;
|
||||
use crate::entity::item::unit::Unit;
|
||||
use crate::entity::item::shield::Shield;
|
||||
use crate::entity::item::mag::Mag;
|
||||
use crate::entity::item::tech::TechniqueDisk;
|
||||
use crate::entity::item::tool::Tool;
|
||||
use crate::ship::items::{ClientItemId, BankItem, BankItemHandle};
|
||||
use crate::ship::items::floor::{IndividualFloorItem, StackedFloorItem};
|
||||
|
||||
@ -43,44 +43,44 @@ impl IndividualInventoryItem {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn mag_mut(&mut self) -> Option<&mut Mag> {
|
||||
match self.item {
|
||||
ItemDetail::Mag(ref mut mag) => Some(mag),
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
|
||||
pub fn weapon_mut(&mut self) -> Option<&mut Weapon> {
|
||||
match self.item {
|
||||
ItemDetail::Weapon(ref mut weapon) => Some(weapon),
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pub fn esweapon_mut(&mut self) -> Option<&mut ESWeapon> {
|
||||
match self.item {
|
||||
ItemDetail::ESWeapon(ref mut esweapon) => Some(esweapon),
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pub fn armor_mut(&mut self) -> Option<&mut Armor> {
|
||||
match self.item {
|
||||
ItemDetail::Armor(ref mut armor) => Some(armor),
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pub fn unit_mut(&mut self) -> Option<&mut Unit> {
|
||||
match self.item {
|
||||
ItemDetail::Unit(ref mut unit) => Some(unit),
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
|
||||
pub fn shield_mut(&mut self) -> Option<&mut Shield> {
|
||||
match self.item {
|
||||
ItemDetail::Shield(ref mut shield) => Some(shield),
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
|
||||
pub fn unit_mut(&mut self) -> Option<&mut Unit> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn mag_mut(&mut self) -> Option<&mut Mag> {
|
||||
match self.item {
|
||||
ItemDetail::Unit(ref mut unit) => Some(unit),
|
||||
ItemDetail::Mag(ref mut mag) => Some(mag),
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
@ -237,13 +237,13 @@ impl InventoryItem {
|
||||
InventoryItem::Individual(item) => {
|
||||
match &item.item {
|
||||
ItemDetail::Weapon(w) => w.as_bytes(),
|
||||
ItemDetail::Armor(a) => a.as_bytes(),
|
||||
ItemDetail::Shield(s) => s.as_bytes(),
|
||||
ItemDetail::Unit(u) => u.as_bytes(),
|
||||
ItemDetail::Tool(t) => t.as_individual_bytes(),
|
||||
ItemDetail::TechniqueDisk(d) => d.as_bytes(),
|
||||
ItemDetail::Mag(m) => m.as_bytes(),
|
||||
ItemDetail::ESWeapon(e) => e.as_bytes(),
|
||||
ItemDetail::Armor(a) => a.as_bytes(),
|
||||
ItemDetail::Unit(u) => u.as_bytes(),
|
||||
ItemDetail::Shield(s) => s.as_bytes(),
|
||||
ItemDetail::Mag(m) => m.as_bytes(),
|
||||
ItemDetail::TechniqueDisk(d) => d.as_bytes(),
|
||||
ItemDetail::Tool(t) => t.as_individual_bytes(),
|
||||
}
|
||||
},
|
||||
InventoryItem::Stacked(item) => {
|
||||
|
@ -502,7 +502,6 @@ impl ItemManager {
|
||||
let inventory = self.character_inventory.get_mut(&character.id).ok_or(ItemManagerError::NoCharacter(character.id))?;
|
||||
let used_item = inventory.get_item_handle_by_id(item_id).ok_or(ItemManagerError::NoSuchItemId(item_id))?;
|
||||
let consumed_item = used_item.consume(amount)?;
|
||||
println!("consumed some item");
|
||||
if let ItemDetail::TechniqueDisk(tech_disk) = consumed_item.item() {
|
||||
// TODO: validate tech level in packet is in bounds [1..30]
|
||||
character.techs.set_tech(tech_disk.tech, TechLevel(tech_disk.level as u8));
|
||||
@ -645,22 +644,30 @@ impl ItemManager {
|
||||
used_item.unwrap_present();
|
||||
} else {
|
||||
match used_item.item_type() {
|
||||
ItemType::Armor(_) => {
|
||||
let _actual_used_item = used_item.individual_mut().ok_or(ItemManagerError::CannotGetMutItem)?.armor_mut().ok_or(ItemManagerError::CannotGetMutItem)?;
|
||||
ItemType::Weapon(_) => {
|
||||
let _actual_used_item = used_item.individual_mut().ok_or(ItemManagerError::CannotGetMutItem)?.weapon_mut().ok_or(ItemManagerError::CannotGetMutItem)?;
|
||||
// combining / unsealing?
|
||||
},
|
||||
ItemType::ESWeapon(_) => { // TODO: wrap srank weapons
|
||||
let _actual_used_item = used_item.individual_mut().ok_or(ItemManagerError::CannotGetMutItem)?.esweapon_mut().ok_or(ItemManagerError::CannotGetMutItem)?;
|
||||
// combining / unsealing?
|
||||
},
|
||||
ItemType::Mag(_) => {
|
||||
let _actual_used_item = used_item.individual_mut().ok_or(ItemManagerError::CannotGetMutItem)?.mag_mut().ok_or(ItemManagerError::CannotGetMutItem)?;
|
||||
ItemType::Armor(_) => {
|
||||
let _actual_used_item = used_item.individual_mut().ok_or(ItemManagerError::CannotGetMutItem)?.armor_mut().ok_or(ItemManagerError::CannotGetMutItem)?;
|
||||
// combining / unsealing?
|
||||
},
|
||||
ItemType::Unit(_) => {
|
||||
let _actual_used_item = used_item.individual_mut().ok_or(ItemManagerError::CannotGetMutItem)?.unit_mut().ok_or(ItemManagerError::CannotGetMutItem)?;
|
||||
// combining / unsealing?
|
||||
},
|
||||
ItemType::Shield(_) => {
|
||||
let _actual_used_item = used_item.individual_mut().ok_or(ItemManagerError::CannotGetMutItem)?.shield_mut().ok_or(ItemManagerError::CannotGetMutItem)?;
|
||||
// combining / unsealing?
|
||||
},
|
||||
ItemType::Mag(_) => {
|
||||
let _actual_used_item = used_item.individual_mut().ok_or(ItemManagerError::CannotGetMutItem)?.mag_mut().ok_or(ItemManagerError::CannotGetMutItem)?;
|
||||
// combining / unsealing?
|
||||
},
|
||||
ItemType::TechniqueDisk(_) => {
|
||||
let _actual_used_item = used_item.individual_mut().ok_or(ItemManagerError::CannotGetMutItem)?.tech_mut().ok_or(ItemManagerError::CannotGetMutItem)?;
|
||||
// combining / unsealing?
|
||||
@ -769,14 +776,6 @@ impl ItemManager {
|
||||
_ => {},
|
||||
}
|
||||
},
|
||||
ItemType::Unit(_) => {
|
||||
let _actual_used_item = used_item.individual_mut().ok_or(ItemManagerError::CannotGetMutItem)?.unit_mut().ok_or(ItemManagerError::CannotGetMutItem)?;
|
||||
// combining / unsealing?
|
||||
},
|
||||
ItemType::Weapon(_) => {
|
||||
let _actual_used_item = used_item.individual_mut().ok_or(ItemManagerError::CannotGetMutItem)?.weapon_mut().ok_or(ItemManagerError::CannotGetMutItem)?;
|
||||
// combining / unsealing?
|
||||
},
|
||||
}
|
||||
}
|
||||
entity_gateway.set_character_inventory(&character.id, &inventory.as_inventory_entity(&character.id)).await?;
|
||||
|
@ -1,12 +1,9 @@
|
||||
// TODO: `pub(super) for most of these?`
|
||||
use std::io::{Read};
|
||||
|
||||
use byteorder::{LittleEndian, ReadBytesExt};
|
||||
use thiserror::Error;
|
||||
|
||||
use crate::ship::monster::MonsterType;
|
||||
use crate::ship::room::Episode;
|
||||
|
||||
use crate::ship::map::*;
|
||||
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
@ -62,7 +59,6 @@ impl RawMapEnemy {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[error("")]
|
||||
pub enum MapEnemyError {
|
||||
@ -70,7 +66,6 @@ pub enum MapEnemyError {
|
||||
MapAreaError(#[from] MapAreaError),
|
||||
}
|
||||
|
||||
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct MapEnemy {
|
||||
pub monster: MonsterType,
|
||||
@ -194,7 +189,6 @@ impl MapEnemy {
|
||||
_ => return Err(MapEnemyError::UnknownEnemyId(enemy.id))
|
||||
}
|
||||
},
|
||||
|
||||
MapArea::Tower => {
|
||||
match (enemy, episode) {
|
||||
(RawMapEnemy {id: 97, ..}, _) => MonsterType::DelLily,
|
||||
|
@ -27,7 +27,7 @@ async fn test_unwrap_weapon() {
|
||||
Some(item::weapon::WeaponAttribute{attr: item::weapon::Attribute::Hit, value: 30}),
|
||||
None],
|
||||
tekked: false,
|
||||
wrapping: Some(item::WrappingPaper::Red_Green),
|
||||
wrapping: Some(item::WrappingPaper::RedGreen),
|
||||
}),
|
||||
location: item::ItemLocation::Inventory{
|
||||
character_id: char1.id,
|
||||
@ -43,7 +43,7 @@ async fn test_unwrap_weapon() {
|
||||
let mut ship = Box::new(ShipServerState::builder()
|
||||
.gateway(entity_gateway.clone())
|
||||
.build());
|
||||
|
||||
|
||||
log_in_char(&mut ship, ClientId(1), "a1", "a").await;
|
||||
join_lobby(&mut ship, ClientId(1)).await;
|
||||
create_room(&mut ship, ClientId(1), "room", "").await;
|
||||
@ -79,7 +79,7 @@ async fn test_unwrap_armor() {
|
||||
dfp: 3u8,
|
||||
evp: 2u8,
|
||||
slots: 4u8,
|
||||
wrapping: Some(item::WrappingPaper::Red_Green), // 5
|
||||
wrapping: Some(item::WrappingPaper::RedGreen), // 5
|
||||
}),
|
||||
location: item::ItemLocation::Inventory{
|
||||
character_id: char1.id,
|
||||
@ -96,7 +96,7 @@ async fn test_unwrap_armor() {
|
||||
let mut ship = Box::new(ShipServerState::builder()
|
||||
.gateway(entity_gateway.clone())
|
||||
.build());
|
||||
|
||||
|
||||
log_in_char(&mut ship, ClientId(1), "a1", "a").await;
|
||||
join_lobby(&mut ship, ClientId(1)).await;
|
||||
create_room(&mut ship, ClientId(1), "room", "").await;
|
||||
@ -131,7 +131,7 @@ async fn test_unwrap_shield() {
|
||||
shield: item::shield::ShieldType::CoreShield,
|
||||
dfp: 2u8,
|
||||
evp: 3u8,
|
||||
wrapping: Some(item::WrappingPaper::Red_Green), // 5
|
||||
wrapping: Some(item::WrappingPaper::RedGreen), // 5
|
||||
}),
|
||||
location: item::ItemLocation::Inventory{
|
||||
character_id: char1.id,
|
||||
@ -147,7 +147,7 @@ async fn test_unwrap_shield() {
|
||||
let mut ship = Box::new(ShipServerState::builder()
|
||||
.gateway(entity_gateway.clone())
|
||||
.build());
|
||||
|
||||
|
||||
log_in_char(&mut ship, ClientId(1), "a1", "a").await;
|
||||
join_lobby(&mut ship, ClientId(1)).await;
|
||||
create_room(&mut ship, ClientId(1), "room", "").await;
|
||||
@ -181,7 +181,7 @@ async fn test_unwrap_unit() {
|
||||
item: item::ItemDetail::Unit(item::unit::Unit {
|
||||
unit: item::unit::UnitType::KnightPower,
|
||||
modifier: Some(item::unit::UnitModifier::MinusMinus),
|
||||
wrapping: Some(item::WrappingPaper::Red_Green), // 5
|
||||
wrapping: Some(item::WrappingPaper::RedGreen), // 5
|
||||
}),
|
||||
location: item::ItemLocation::Inventory{
|
||||
character_id: char1.id,
|
||||
@ -197,7 +197,7 @@ async fn test_unwrap_unit() {
|
||||
let mut ship = Box::new(ShipServerState::builder()
|
||||
.gateway(entity_gateway.clone())
|
||||
.build());
|
||||
|
||||
|
||||
log_in_char(&mut ship, ClientId(1), "a1", "a").await;
|
||||
join_lobby(&mut ship, ClientId(1)).await;
|
||||
create_room(&mut ship, ClientId(1), "room", "").await;
|
||||
@ -244,7 +244,7 @@ async fn test_unwrap_mag() {
|
||||
let mut ship = Box::new(ShipServerState::builder()
|
||||
.gateway(entity_gateway.clone())
|
||||
.build());
|
||||
|
||||
|
||||
log_in_char(&mut ship, ClientId(1), "a1", "a").await;
|
||||
join_lobby(&mut ship, ClientId(1)).await;
|
||||
create_room(&mut ship, ClientId(1), "room", "").await;
|
||||
|
Loading…
x
Reference in New Issue
Block a user