|
@ -10,6 +10,7 @@ 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;
|
|
|
use crate::entity::item::tech::TechniqueDisk;
|
|
|
use crate::entity::item::{ItemDetail, ItemEntityId};
|
|
|
use crate::entity::item::{ItemDetail, ItemEntityId};
|
|
|
|
|
|
use crate::entity::item::weapon::WeaponModifier;
|
|
|
use crate::ship::items::state::ItemStateProxy;
|
|
|
use crate::ship::items::state::ItemStateProxy;
|
|
|
use crate::ship::items::inventory::{InventoryItem, InventoryItemDetail};
|
|
|
use crate::ship::items::inventory::{InventoryItem, InventoryItemDetail};
|
|
|
|
|
|
|
|
@ -34,7 +35,7 @@ pub enum ApplyItemError { |
|
|
pub enum ApplyItemAction {
|
|
|
pub enum ApplyItemAction {
|
|
|
UpdateCharacter(Box<CharacterEntity>),
|
|
|
UpdateCharacter(Box<CharacterEntity>),
|
|
|
CreateItem(ItemDetail),
|
|
|
CreateItem(ItemDetail),
|
|
|
//TransformItem,
|
|
|
|
|
|
|
|
|
//TransformItem(ItemDetail),
|
|
|
//RemoveItem,
|
|
|
//RemoveItem,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
@ -241,6 +242,30 @@ fn jack_o_lantern() -> Result<Vec<ApplyItemAction>, anyhow::Error> |
|
|
Ok(vec![ApplyItemAction::CreateItem(ItemDetail::Tool(Tool {tool: mag_type}))])
|
|
|
Ok(vec![ApplyItemAction::CreateItem(ItemDetail::Tool(Tool {tool: mag_type}))])
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async fn weapon_grind<'a, EG>(item_state: &mut ItemStateProxy,
|
|
|
|
|
|
entity_gateway: &mut EG,
|
|
|
|
|
|
character: &mut CharacterEntity,
|
|
|
|
|
|
entity_id: ItemEntityId,
|
|
|
|
|
|
grind: u32,)
|
|
|
|
|
|
-> Result<Vec<ApplyItemAction>, anyhow::Error>
|
|
|
|
|
|
where
|
|
|
|
|
|
EG: EntityGateway + ?Sized,
|
|
|
|
|
|
{
|
|
|
|
|
|
let modifier = WeaponModifier::AddGrind {
|
|
|
|
|
|
amount: grind,
|
|
|
|
|
|
grinder: entity_id,
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
let mut inventory = item_state.inventory(&character.id).await?;
|
|
|
|
|
|
let (weapon_entity_id, weapon) = inventory.equipped_weapon_mut()
|
|
|
|
|
|
.ok_or(ApplyItemError::ItemNotEquipped)?;
|
|
|
|
|
|
weapon.apply_modifier(&modifier);
|
|
|
|
|
|
entity_gateway.add_weapon_modifier(&weapon_entity_id, &modifier).await?;
|
|
|
|
|
|
item_state.set_inventory(inventory).await;
|
|
|
|
|
|
|
|
|
|
|
|
Ok(Vec::new())
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
async fn apply_tool<'a, EG>(item_state: &mut ItemStateProxy,
|
|
|
async fn apply_tool<'a, EG>(item_state: &mut ItemStateProxy,
|
|
|
entity_gateway: &mut EG,
|
|
|
entity_gateway: &mut EG,
|
|
|
character: &mut CharacterEntity,
|
|
|
character: &mut CharacterEntity,
|
|
@ -271,6 +296,9 @@ where |
|
|
ToolType::Antidote => Ok(Vec::new()),
|
|
|
ToolType::Antidote => Ok(Vec::new()),
|
|
|
ToolType::Antiparalysis => Ok(Vec::new()),
|
|
|
ToolType::Antiparalysis => Ok(Vec::new()),
|
|
|
ToolType::TrapVision => Ok(Vec::new()),
|
|
|
ToolType::TrapVision => Ok(Vec::new()),
|
|
|
|
|
|
ToolType::Monogrinder => weapon_grind(item_state, entity_gateway, character, entity_id, 1).await,
|
|
|
|
|
|
ToolType::Digrinder => weapon_grind(item_state, entity_gateway, character, entity_id, 2).await,
|
|
|
|
|
|
ToolType::Trigrinder => weapon_grind(item_state, entity_gateway, character, entity_id, 3).await,
|
|
|
ToolType::HuntersReport => Ok(Vec::new()),
|
|
|
ToolType::HuntersReport => Ok(Vec::new()),
|
|
|
ToolType::CellOfMag502
|
|
|
ToolType::CellOfMag502
|
|
|
| ToolType::CellOfMag213
|
|
|
| ToolType::CellOfMag213
|
|
|