Stand up during certain commands
This commit is contained in:
parent
94fc4656f8
commit
8336c5be9b
@ -5,6 +5,7 @@ use super::{
|
||||
},
|
||||
get_player_item_or_fail, look,
|
||||
open::{attempt_open_immediate, is_door_in_direction, DoorSituation},
|
||||
stand::stand_if_needed,
|
||||
user_error, UResult, UserError, UserVerb, UserVerbRef, VerbContext,
|
||||
};
|
||||
#[double]
|
||||
@ -669,6 +670,7 @@ impl QueueCommandHandler for QueueHandler {
|
||||
};
|
||||
// Solely to eliminate completely invalid moves before propagating.
|
||||
move_to_where(&use_location, direction, ctx).await?;
|
||||
stand_if_needed(&ctx.trans, &mut ctx.item).await?;
|
||||
propagate_move_to_followers(&ctx.trans, &mut ctx.item, &direction, &source).await?;
|
||||
Ok(time::Duration::from_secs(1))
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ use crate::{
|
||||
regular_tasks::queued_command::{
|
||||
queue_command_and_save, QueueCommand, QueueCommandHandler, QueuedCommandContext,
|
||||
},
|
||||
services::comms::broadcast_to_room,
|
||||
services::{comms::broadcast_to_room, urges::recalculate_urge_growth},
|
||||
};
|
||||
use async_trait::async_trait;
|
||||
use std::time;
|
||||
@ -156,6 +156,7 @@ impl QueueCommandHandler for QueueHandler {
|
||||
.await?;
|
||||
|
||||
ctx.item.action_type = LocationActionType::Reclining(item.map(|it| it.refstr()));
|
||||
recalculate_urge_growth(&ctx.trans, &mut ctx.item).await?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ use crate::{
|
||||
regular_tasks::queued_command::{
|
||||
queue_command_and_save, QueueCommand, QueueCommandHandler, QueuedCommandContext,
|
||||
},
|
||||
services::comms::broadcast_to_room,
|
||||
services::{comms::broadcast_to_room, urges::recalculate_urge_growth},
|
||||
};
|
||||
use async_trait::async_trait;
|
||||
use std::time;
|
||||
@ -148,6 +148,7 @@ impl QueueCommandHandler for QueueHandler {
|
||||
.await?;
|
||||
|
||||
ctx.item.action_type = LocationActionType::Sitting(item.map(|it| it.refstr()));
|
||||
recalculate_urge_growth(&ctx.trans, &mut ctx.item).await?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,31 @@
|
||||
use super::{get_player_item_or_fail, user_error, UResult, UserVerb, UserVerbRef, VerbContext};
|
||||
#[double]
|
||||
use crate::db::DBTrans;
|
||||
use crate::{
|
||||
models::item::LocationActionType,
|
||||
models::item::{Item, LocationActionType},
|
||||
regular_tasks::queued_command::{
|
||||
queue_command_and_save, QueueCommand, QueueCommandHandler, QueuedCommandContext,
|
||||
},
|
||||
services::comms::broadcast_to_room,
|
||||
services::{comms::broadcast_to_room, urges::recalculate_urge_growth},
|
||||
};
|
||||
use async_trait::async_trait;
|
||||
use mockall_double::double;
|
||||
use std::time;
|
||||
|
||||
pub async fn stand_if_needed(trans: &DBTrans, who: &mut Item) -> UResult<()> {
|
||||
match who.action_type {
|
||||
LocationActionType::Sitting { .. } | LocationActionType::Reclining { .. } => {}
|
||||
_ => return Ok(()),
|
||||
}
|
||||
let msg_exp = format!("{} stands up.\n", &who.display_for_sentence(true, 1, true),);
|
||||
let msg_nonexp = format!("{} stands up.\n", &who.display_for_sentence(false, 1, true),);
|
||||
broadcast_to_room(trans, &who.location, None, &msg_exp, Some(&msg_nonexp)).await?;
|
||||
|
||||
who.action_type = LocationActionType::Normal;
|
||||
recalculate_urge_growth(trans, who).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub struct QueueHandler;
|
||||
#[async_trait]
|
||||
impl QueueCommandHandler for QueueHandler {
|
||||
@ -44,24 +61,7 @@ impl QueueCommandHandler for QueueHandler {
|
||||
LocationActionType::Sitting { .. } | LocationActionType::Reclining { .. } => {}
|
||||
_ => user_error("You're already standing.".to_owned())?,
|
||||
}
|
||||
let msg_exp = format!(
|
||||
"{} stands up.\n",
|
||||
&ctx.item.display_for_sentence(true, 1, true),
|
||||
);
|
||||
let msg_nonexp = format!(
|
||||
"{} stands up.\n",
|
||||
&ctx.item.display_for_sentence(false, 1, true),
|
||||
);
|
||||
broadcast_to_room(
|
||||
ctx.trans,
|
||||
&ctx.item.location,
|
||||
None,
|
||||
&msg_exp,
|
||||
Some(&msg_nonexp),
|
||||
)
|
||||
.await?;
|
||||
|
||||
ctx.item.action_type = LocationActionType::Normal;
|
||||
stand_if_needed(&ctx.trans, &mut ctx.item).await?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,8 @@
|
||||
use crate::db::DBTrans;
|
||||
use crate::{
|
||||
message_handler::user_commands::{
|
||||
follow::cancel_follow_by_leader, user_error, CommandHandlingError, UResult,
|
||||
follow::cancel_follow_by_leader, stand::stand_if_needed, user_error, CommandHandlingError,
|
||||
UResult,
|
||||
},
|
||||
models::{
|
||||
item::{DeathData, Item, ItemFlag, LocationActionType, SkillType, Subattack},
|
||||
@ -670,14 +671,7 @@ pub async fn start_attack_mut(
|
||||
let mut verb: String = "attacks".to_string();
|
||||
match by_whom.action_type {
|
||||
LocationActionType::Sitting { .. } | LocationActionType::Reclining { .. } => {
|
||||
msg_exp.push_str(&format!(ansi!("{} stands up.\n"), &by_whom.display));
|
||||
msg_nonexp.push_str(&format!(
|
||||
ansi!("{} stands up.\n"),
|
||||
by_whom
|
||||
.display_less_explicit
|
||||
.as_ref()
|
||||
.unwrap_or(&by_whom.display)
|
||||
));
|
||||
stand_if_needed(trans, by_whom).await?;
|
||||
}
|
||||
LocationActionType::Attacking(_) => {
|
||||
match by_whom
|
||||
|
Loading…
Reference in New Issue
Block a user