Enforce consent check on use command.
This commit is contained in:
parent
b000f9830b
commit
3f6419e5f8
@ -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()) {
|
||||
|
@ -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? {
|
||||
|
@ -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),
|
||||
|
Loading…
Reference in New Issue
Block a user