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]
|
#[double]
|
||||||
use crate::db::DBTrans;
|
use crate::db::DBTrans;
|
||||||
use crate::{
|
use crate::{
|
||||||
language::{self, indefinite_article},
|
language::{self, indefinite_article, join_words},
|
||||||
message_handler::{
|
message_handler::{
|
||||||
user_commands::{user_error, UResult, UserError, VerbContext},
|
user_commands::{user_error, UResult, UserError, VerbContext},
|
||||||
ListenerSession,
|
ListenerSession,
|
||||||
@ -20,6 +20,7 @@ use crate::{
|
|||||||
task::{Task, TaskDetails, TaskMeta},
|
task::{Task, TaskDetails, TaskMeta},
|
||||||
},
|
},
|
||||||
regular_tasks::{TaskHandler, TaskRunContext},
|
regular_tasks::{TaskHandler, TaskRunContext},
|
||||||
|
services::skills::calculate_total_stats_skills_for_user,
|
||||||
static_content::journals::award_journal_if_needed,
|
static_content::journals::award_journal_if_needed,
|
||||||
DResult,
|
DResult,
|
||||||
};
|
};
|
||||||
@ -762,12 +763,12 @@ async fn apply_conversation_buff(trans: &DBTrans, to_player: &mut Item) -> DResu
|
|||||||
});
|
});
|
||||||
to_player.temporary_buffs.push(Buff {
|
to_player.temporary_buffs.push(Buff {
|
||||||
description: "Sharing knowledge improved you (for a while)".to_owned(),
|
description: "Sharing knowledge improved you (for a while)".to_owned(),
|
||||||
code: "sharing".to_owned(),
|
code: "sharIng".to_owned(),
|
||||||
cause: BuffCause::WaitingTask {
|
cause: BuffCause::WaitingTask {
|
||||||
task_type: "ExpireBuff".to_owned(),
|
task_type: "ExpireBuff".to_owned(),
|
||||||
task_code: exp_task_code.clone(),
|
task_code: exp_task_code.clone(),
|
||||||
},
|
},
|
||||||
impacts: buffs,
|
impacts: buffs.clone(),
|
||||||
});
|
});
|
||||||
trans
|
trans
|
||||||
.upsert_task(&Task {
|
.upsert_task(&Task {
|
||||||
@ -783,6 +784,40 @@ async fn apply_conversation_buff(trans: &DBTrans, to_player: &mut Item) -> DResu
|
|||||||
})
|
})
|
||||||
.await?;
|
.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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user