|
@ -8,9 +8,9 @@ use crate::entity::gateway::{EntityGateway, GatewayError}; |
|
|
use crate::entity::character::{CharacterEntity, TechLevel};
|
|
|
use crate::entity::character::{CharacterEntity, TechLevel};
|
|
|
use crate::entity::item::mag::{MagCell, MagCellError};
|
|
|
use crate::entity::item::mag::{MagCell, MagCellError};
|
|
|
use crate::entity::item::tool::{Tool, ToolType};
|
|
|
use crate::entity::item::tool::{Tool, ToolType};
|
|
|
use crate::entity::item::tech::{TechniqueDisk, Technique};
|
|
|
|
|
|
|
|
|
use crate::entity::item::tech::TechniqueDisk;
|
|
|
use crate::entity::item::{ItemDetail, ItemEntityId};
|
|
|
use crate::entity::item::{ItemDetail, ItemEntityId};
|
|
|
use crate::ship::items::state::{ItemStateProxy, ItemStateError};
|
|
|
|
|
|
|
|
|
use crate::ship::items::state::ItemStateProxy;
|
|
|
use crate::ship::items::inventory::{InventoryItem, InventoryItemDetail};
|
|
|
use crate::ship::items::inventory::{InventoryItem, InventoryItemDetail};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -26,10 +26,6 @@ pub enum ApplyItemError { |
|
|
InvalidTool,
|
|
|
InvalidTool,
|
|
|
#[error("gateway error {0}")]
|
|
|
#[error("gateway error {0}")]
|
|
|
GatewayError(#[from] GatewayError),
|
|
|
GatewayError(#[from] GatewayError),
|
|
|
|
|
|
|
|
|
//#[error("itemstate error {0}")]
|
|
|
|
|
|
//ItemStateError(Box<ItemStateError>),
|
|
|
|
|
|
|
|
|
|
|
|
#[error("magcell error {0}")]
|
|
|
#[error("magcell error {0}")]
|
|
|
MagCellError(#[from] MagCellError),
|
|
|
MagCellError(#[from] MagCellError),
|
|
|
}
|
|
|
}
|
|
@ -42,15 +38,6 @@ pub enum ApplyItemAction { |
|
|
//RemoveItem,
|
|
|
//RemoveItem,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
impl From<ItemStateError> for ApplyItemError {
|
|
|
|
|
|
fn from(other: ItemStateError) -> ApplyItemError {
|
|
|
|
|
|
ApplyItemError::ItemStateError(Box::new(other))
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async fn power_material<EG: EntityGateway + ?Sized>(entity_gateway: &mut EG, character: &mut CharacterEntity) -> Result<Vec<ApplyItemAction>, anyhow::Error> {
|
|
|
async fn power_material<EG: EntityGateway + ?Sized>(entity_gateway: &mut EG, character: &mut CharacterEntity) -> Result<Vec<ApplyItemAction>, anyhow::Error> {
|
|
|
character.materials.power += 1;
|
|
|
character.materials.power += 1;
|
|
|
entity_gateway.save_character(character).await?;
|
|
|
entity_gateway.save_character(character).await?;
|
|
@ -315,14 +302,14 @@ where |
|
|
// TODO: rest of these
|
|
|
// TODO: rest of these
|
|
|
_ => Err(anyhow::Error::from(ApplyItemError::InvalidTool))
|
|
|
_ => Err(anyhow::Error::from(ApplyItemError::InvalidTool))
|
|
|
.with_context(|| {
|
|
|
.with_context(|| {
|
|
|
format!("invalid tool {:?}", tool)
|
|
|
|
|
|
|
|
|
format!("invalid tool {tool:?}")
|
|
|
})
|
|
|
})
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
async fn apply_tech<'a, EG>(item_state: &mut ItemStateProxy,
|
|
|
|
|
|
|
|
|
async fn apply_tech<'a, EG>(_item_state: &mut ItemStateProxy,
|
|
|
entity_gateway: &mut EG,
|
|
|
entity_gateway: &mut EG,
|
|
|
character: &mut CharacterEntity,
|
|
|
character: &mut CharacterEntity,
|
|
|
_entity_id: ItemEntityId,
|
|
|
_entity_id: ItemEntityId,
|
|
@ -353,7 +340,7 @@ where |
|
|
ItemDetail::TechniqueDisk(tech) => apply_tech(item_state, entity_gateway, character, individual_item.entity_id, tech).await,
|
|
|
ItemDetail::TechniqueDisk(tech) => apply_tech(item_state, entity_gateway, character, individual_item.entity_id, tech).await,
|
|
|
_ => Err(anyhow::Error::from(ApplyItemError::InvalidItem))
|
|
|
_ => Err(anyhow::Error::from(ApplyItemError::InvalidItem))
|
|
|
.with_context(|| {
|
|
|
.with_context(|| {
|
|
|
format!("item {:?}", individual_item)
|
|
|
|
|
|
|
|
|
format!("item {individual_item:?}")
|
|
|
})
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
},
|
|
|