Recalculate total stats based off sharing, and inform user of impact
This commit is contained in:
parent
fbfc33857d
commit
bf3860dd11
@ -4,7 +4,7 @@ use std::sync::Arc;
|
||||
#[double]
|
||||
use crate::db::DBTrans;
|
||||
use crate::{
|
||||
language::{self, indefinite_article},
|
||||
language::{self, indefinite_article, join_words},
|
||||
message_handler::{
|
||||
user_commands::{user_error, UResult, UserError, VerbContext},
|
||||
ListenerSession,
|
||||
@ -20,6 +20,7 @@ use crate::{
|
||||
task::{Task, TaskDetails, TaskMeta},
|
||||
},
|
||||
regular_tasks::{TaskHandler, TaskRunContext},
|
||||
services::skills::calculate_total_stats_skills_for_user,
|
||||
static_content::journals::award_journal_if_needed,
|
||||
DResult,
|
||||
};
|
||||
@ -762,12 +763,12 @@ async fn apply_conversation_buff(trans: &DBTrans, to_player: &mut Item) -> DResu
|
||||
});
|
||||
to_player.temporary_buffs.push(Buff {
|
||||
description: "Sharing knowledge improved you (for a while)".to_owned(),
|
||||
code: "sharing".to_owned(),
|
||||
code: "sharIng".to_owned(),
|
||||
cause: BuffCause::WaitingTask {
|
||||
task_type: "ExpireBuff".to_owned(),
|
||||
task_code: exp_task_code.clone(),
|
||||
},
|
||||
impacts: buffs,
|
||||
impacts: buffs.clone(),
|
||||
});
|
||||
trans
|
||||
.upsert_task(&Task {
|
||||
@ -783,6 +784,40 @@ async fn apply_conversation_buff(trans: &DBTrans, to_player: &mut Item) -> DResu
|
||||
})
|
||||
.await?;
|
||||
|
||||
if to_player.item_type == "player" {
|
||||
if let Some(user) = trans.find_by_username(&to_player.item_code).await? {
|
||||
calculate_total_stats_skills_for_user(to_player, &user);
|
||||
}
|
||||
|
||||
if let Some((sess, _)) = trans.find_session_for_player(&to_player.item_code).await? {
|
||||
let impacts_vec = buffs
|
||||
.iter()
|
||||
.filter_map(|b| match b {
|
||||
BuffImpact::ChangeStat { stat, magnitude } => {
|
||||
Some(format!("{} is increased by {}", stat.display(), magnitude))
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
.collect::<Vec<String>>();
|
||||
let impact = join_words(
|
||||
&impacts_vec
|
||||
.iter()
|
||||
.map(|b| b.as_str())
|
||||
.collect::<Vec<&str>>(),
|
||||
);
|
||||
|
||||
trans
|
||||
.queue_for_session(
|
||||
&sess,
|
||||
Some(&format!(ansi!(
|
||||
"<green>You feel sharing knowledge improved you [for the next 10 minutes, {}]<reset>\n"),
|
||||
impact
|
||||
)),
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user