2020-09-05 22:06:39 -06:00
|
|
|
use thiserror::Error;
|
2020-09-05 21:10:12 -06:00
|
|
|
use crate::entity::gateway::EntityGateway;
|
|
|
|
use crate::entity::character::CharacterEntity;
|
|
|
|
use crate::entity::item::ItemDetail;
|
|
|
|
use crate::entity::item::tool::ToolType;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-09-05 22:06:39 -06:00
|
|
|
#[derive(Error, Debug)]
|
|
|
|
#[error("")]
|
|
|
|
pub enum UseItemError {
|
|
|
|
NoCharacter,
|
|
|
|
}
|
2020-09-05 21:10:12 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//pub fn use_tool()
|
|
|
|
|
|
|
|
pub async fn power_material<EG: EntityGateway>(entity_gateway: &mut EG, character: &mut CharacterEntity) {
|
|
|
|
character.materials.power += 1;
|
|
|
|
entity_gateway.save_character(character).await;
|
|
|
|
}
|
|
|
|
|
|
|
|
pub async fn mind_material<EG: EntityGateway>(entity_gateway: &mut EG, character: &mut CharacterEntity) {
|
|
|
|
character.materials.mind += 1;
|
|
|
|
entity_gateway.save_character(character).await;
|
|
|
|
}
|
|
|
|
|
|
|
|
pub async fn evade_material<EG: EntityGateway>(entity_gateway: &mut EG, character: &mut CharacterEntity) {
|
|
|
|
character.materials.evade += 1;
|
|
|
|
entity_gateway.save_character(character).await;
|
|
|
|
}
|
|
|
|
|
|
|
|
pub async fn def_material<EG: EntityGateway>(entity_gateway: &mut EG, character: &mut CharacterEntity) {
|
|
|
|
character.materials.def += 1;
|
|
|
|
entity_gateway.save_character(character).await;
|
|
|
|
}
|
|
|
|
|
|
|
|
pub async fn luck_material<EG: EntityGateway>(entity_gateway: &mut EG, character: &mut CharacterEntity) {
|
|
|
|
character.materials.luck += 1;
|
|
|
|
entity_gateway.save_character(character).await;
|
|
|
|
}
|
|
|
|
|
|
|
|
pub async fn hp_material<EG: EntityGateway>(entity_gateway: &mut EG, character: &mut CharacterEntity) {
|
|
|
|
character.materials.hp += 1;
|
|
|
|
entity_gateway.save_character(character).await;
|
|
|
|
}
|
|
|
|
|
|
|
|
pub async fn tp_material<EG: EntityGateway>(entity_gateway: &mut EG, character: &mut CharacterEntity) {
|
|
|
|
character.materials.tp += 1;
|
|
|
|
entity_gateway.save_character(character).await;
|
|
|
|
}
|