actually this makes more sense
This commit is contained in:
parent
23bc39b5bf
commit
ebdd4b28de
@ -5,7 +5,7 @@ use crate::entity::gateway::EntityGateway;
|
|||||||
use crate::entity::character::{CharacterEntity, CharacterEntityId};
|
use crate::entity::character::{CharacterEntity, CharacterEntityId};
|
||||||
use crate::entity::item::{ItemDetail, ItemLocation, BankName};
|
use crate::entity::item::{ItemDetail, ItemLocation, BankName};
|
||||||
use crate::entity::item::{Meseta, NewItemEntity};
|
use crate::entity::item::{Meseta, NewItemEntity};
|
||||||
use crate::entity::item::tool::Tool;
|
use crate::entity::item::tool::{Tool, ToolType};
|
||||||
use crate::ship::map::MapArea;
|
use crate::ship::map::MapArea;
|
||||||
use crate::ship::ship::ItemDropLocation;
|
use crate::ship::ship::ItemDropLocation;
|
||||||
use crate::ship::drops::{ItemDrop, ItemDropType};
|
use crate::ship::drops::{ItemDrop, ItemDropType};
|
||||||
@ -14,6 +14,7 @@ use crate::ship::location::{AreaClient, RoomId};
|
|||||||
use crate::ship::items::bank::*;
|
use crate::ship::items::bank::*;
|
||||||
use crate::ship::items::floor::*;
|
use crate::ship::items::floor::*;
|
||||||
use crate::ship::items::inventory::*;
|
use crate::ship::items::inventory::*;
|
||||||
|
use crate::ship::items::use_tool;
|
||||||
|
|
||||||
|
|
||||||
pub enum TriggerCreateItem {
|
pub enum TriggerCreateItem {
|
||||||
@ -636,4 +637,45 @@ impl ItemManager {
|
|||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
pub async fn use_item<EG: EntityGateway>(&mut self,
|
||||||
|
used_item: ItemDetail,
|
||||||
|
entity_gateway: &mut EG,
|
||||||
|
character: &mut CharacterEntity) -> Result<(), ItemManagerError> {
|
||||||
|
match used_item {
|
||||||
|
ItemDetail::Weapon(_w) => {
|
||||||
|
// something like when items are used to combine/transform them?
|
||||||
|
//_ => {}
|
||||||
|
},
|
||||||
|
ItemDetail::Tool(t) => {
|
||||||
|
match t.tool {
|
||||||
|
ToolType::PowerMaterial => {
|
||||||
|
use_tool::power_material(entity_gateway, character).await;
|
||||||
|
},
|
||||||
|
ToolType::MindMaterial => {
|
||||||
|
use_tool::mind_material(entity_gateway, character).await;
|
||||||
|
},
|
||||||
|
ToolType::EvadeMaterial => {
|
||||||
|
use_tool::evade_material(entity_gateway, character).await;
|
||||||
|
},
|
||||||
|
ToolType::DefMaterial => {
|
||||||
|
use_tool::def_material(entity_gateway, character).await;
|
||||||
|
},
|
||||||
|
ToolType::LuckMaterial => {
|
||||||
|
use_tool::luck_material(entity_gateway, character).await;
|
||||||
|
},
|
||||||
|
ToolType::HpMaterial => {
|
||||||
|
use_tool::hp_material(entity_gateway, character).await;
|
||||||
|
},
|
||||||
|
ToolType::TpMaterial => {
|
||||||
|
use_tool::tp_material(entity_gateway, character).await;
|
||||||
|
},
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
use thiserror::Error;
|
||||||
use crate::entity::gateway::EntityGateway;
|
use crate::entity::gateway::EntityGateway;
|
||||||
use crate::entity::character::CharacterEntity;
|
use crate::entity::character::CharacterEntity;
|
||||||
use crate::entity::item::ItemDetail;
|
use crate::entity::item::ItemDetail;
|
||||||
@ -7,7 +8,11 @@ use crate::entity::item::tool::ToolType;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#[derive(Error, Debug)]
|
||||||
|
#[error("")]
|
||||||
|
pub enum UseItemError {
|
||||||
|
NoCharacter,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,7 +10,6 @@ use crate::ship::location::{ClientLocation, ClientLocationError};
|
|||||||
use crate::ship::map::{MapArea};
|
use crate::ship::map::{MapArea};
|
||||||
use crate::ship::items::{ItemManager, ClientItemId};
|
use crate::ship::items::{ItemManager, ClientItemId};
|
||||||
use crate::ship::packet::builder;
|
use crate::ship::packet::builder;
|
||||||
use crate::ship::items::use_tool;
|
|
||||||
|
|
||||||
pub async fn request_exp<EG: EntityGateway>(id: ClientId,
|
pub async fn request_exp<EG: EntityGateway>(id: ClientId,
|
||||||
request_exp: &RequestExp,
|
request_exp: &RequestExp,
|
||||||
@ -264,43 +263,9 @@ where
|
|||||||
EG: EntityGateway
|
EG: EntityGateway
|
||||||
{
|
{
|
||||||
let client = clients.get_mut(&id).ok_or(ShipError::ClientNotFound(id))?;
|
let client = clients.get_mut(&id).ok_or(ShipError::ClientNotFound(id))?;
|
||||||
|
|
||||||
let item_used_type = item_manager.player_consumes_tool(entity_gateway, &client.character, ClientItemId(player_use_tool.item_id), 1).await?;
|
let item_used_type = item_manager.player_consumes_tool(entity_gateway, &client.character, ClientItemId(player_use_tool.item_id), 1).await?;
|
||||||
|
|
||||||
match item_used_type {
|
item_manager.use_item(item_used_type, entity_gateway, &mut client.character).await?;
|
||||||
ItemDetail::Weapon(_w) => {
|
|
||||||
// something like when items are used to combine/transform them?
|
|
||||||
//_ => {}
|
|
||||||
},
|
|
||||||
ItemDetail::Tool(t) => {
|
|
||||||
match t.tool {
|
|
||||||
ToolType::PowerMaterial => {
|
|
||||||
use_tool::power_material(entity_gateway, &mut client.character).await;
|
|
||||||
},
|
|
||||||
ToolType::MindMaterial => {
|
|
||||||
use_tool::mind_material(entity_gateway, &mut client.character).await;
|
|
||||||
},
|
|
||||||
ToolType::EvadeMaterial => {
|
|
||||||
use_tool::evade_material(entity_gateway, &mut client.character).await;
|
|
||||||
},
|
|
||||||
ToolType::DefMaterial => {
|
|
||||||
use_tool::def_material(entity_gateway, &mut client.character).await;
|
|
||||||
},
|
|
||||||
ToolType::LuckMaterial => {
|
|
||||||
use_tool::luck_material(entity_gateway, &mut client.character).await;
|
|
||||||
},
|
|
||||||
ToolType::HpMaterial => {
|
|
||||||
use_tool::hp_material(entity_gateway, &mut client.character).await;
|
|
||||||
},
|
|
||||||
ToolType::TpMaterial => {
|
|
||||||
use_tool::tp_material(entity_gateway, &mut client.character).await;
|
|
||||||
},
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(Box::new(None.into_iter()))
|
Ok(Box::new(None.into_iter()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user