diff --git a/blastmud_game/src/message_handler/user_commands/use_cmd.rs b/blastmud_game/src/message_handler/user_commands/use_cmd.rs index 7e7a312..ff636b6 100644 --- a/blastmud_game/src/message_handler/user_commands/use_cmd.rs +++ b/blastmud_game/src/message_handler/user_commands/use_cmd.rs @@ -25,6 +25,7 @@ use crate::{ broadcast_to_room, skills::skill_check_and_grind, effect::run_effects, + check_consent, }, language, }; @@ -164,6 +165,14 @@ impl QueueCommandHandler for QueueHandler { None => user_error("You can't use that!".to_owned())?, Some(d) => d }; + if let Some(consent_type) = use_data.needs_consent_check.as_ref() { + if !check_consent(ctx.trans, "use", consent_type, &player_item, &target).await? { + user_error(format!("{} doesn't allow {} from you", + &target.display_for_sentence(!ctx.session_dat.less_explicit_mode, + 1, true), + consent_type.to_str()))? + } + } if let Some(charge_data) = item.possession_type.as_ref() .and_then(|poss_type| possession_data().get(&poss_type)) .and_then(|poss_data| poss_data.charge_data.as_ref()) { diff --git a/blastmud_game/src/services.rs b/blastmud_game/src/services.rs index dccf0ab..0d04864 100644 --- a/blastmud_game/src/services.rs +++ b/blastmud_game/src/services.rs @@ -74,6 +74,10 @@ pub async fn check_consent(trans: &DBTrans, action: &str, }); } + if target.item_code == by.item_code { + return Ok(true) + } + trans.delete_expired_user_consent().await?; if let Some(consent) = trans.find_user_consent_by_parties_type( &target.item_code, &by.item_code, consent_type).await? { diff --git a/blastmud_game/src/static_content/possession_type/trauma_kit.rs b/blastmud_game/src/static_content/possession_type/trauma_kit.rs index c7c18b3..0981d4a 100644 --- a/blastmud_game/src/static_content/possession_type/trauma_kit.rs +++ b/blastmud_game/src/static_content/possession_type/trauma_kit.rs @@ -1,5 +1,8 @@ use super::{PossessionData, UseData, UseEffect, ChargeData}; -use crate::models::item::SkillType; +use crate::models::{ + item::SkillType, + consent::ConsentType, +}; use super::PossessionType::*; @@ -216,6 +219,7 @@ pub fn medium_data() -> PossessionData { } else { None }), + needs_consent_check: Some(ConsentType::Medicine), ..Default::default() }), becomes_on_spent: Some(EmptyMedicalBox),