2021-02-07 21:39:21 +00:00
|
|
|
use super::{Command, Execution, ExecutionResult};
|
2020-10-31 13:19:38 +00:00
|
|
|
use crate::context::Context;
|
2021-03-18 20:54:49 +00:00
|
|
|
use crate::cthulhu::dice::{
|
|
|
|
advancement_roll, regular_roll, AdvancementRoll, AdvancementRollWithContext, DiceRoll,
|
|
|
|
DiceRollWithContext,
|
|
|
|
};
|
2020-10-31 13:19:38 +00:00
|
|
|
use async_trait::async_trait;
|
|
|
|
|
|
|
|
pub struct CthRoll(pub DiceRoll);
|
|
|
|
|
|
|
|
#[async_trait]
|
|
|
|
impl Command for CthRoll {
|
|
|
|
fn name(&self) -> &'static str {
|
2021-03-18 20:54:49 +00:00
|
|
|
"roll percentile dice"
|
2020-10-31 13:19:38 +00:00
|
|
|
}
|
|
|
|
|
2021-05-21 15:32:08 +00:00
|
|
|
fn is_secure(&self) -> bool {
|
|
|
|
false
|
|
|
|
}
|
|
|
|
|
2021-02-07 21:39:21 +00:00
|
|
|
async fn execute(&self, ctx: &Context<'_>) -> ExecutionResult {
|
2020-11-04 20:09:39 +00:00
|
|
|
let roll_with_ctx = DiceRollWithContext(&self.0, ctx);
|
2021-01-30 14:17:34 +00:00
|
|
|
let executed_roll = regular_roll(&roll_with_ctx).await?;
|
|
|
|
|
|
|
|
let html = format!(
|
2021-05-13 21:29:44 +00:00
|
|
|
"<strong>Roll:</strong> {}</p><p><strong>Result</strong>: {}",
|
2021-01-30 14:17:34 +00:00
|
|
|
executed_roll, executed_roll.roll
|
|
|
|
);
|
|
|
|
|
2021-02-07 21:39:21 +00:00
|
|
|
Execution::success(html)
|
2020-10-31 13:19:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub struct CthAdvanceRoll(pub AdvancementRoll);
|
2020-10-31 14:03:18 +00:00
|
|
|
|
|
|
|
#[async_trait]
|
|
|
|
impl Command for CthAdvanceRoll {
|
|
|
|
fn name(&self) -> &'static str {
|
2021-03-18 20:54:49 +00:00
|
|
|
"roll skill advancement dice"
|
2020-10-31 14:03:18 +00:00
|
|
|
}
|
|
|
|
|
2021-05-21 15:32:08 +00:00
|
|
|
fn is_secure(&self) -> bool {
|
|
|
|
false
|
|
|
|
}
|
|
|
|
|
2021-03-18 20:54:49 +00:00
|
|
|
async fn execute(&self, ctx: &Context<'_>) -> ExecutionResult {
|
|
|
|
let roll_with_ctx = AdvancementRollWithContext(&self.0, ctx);
|
|
|
|
let executed_roll = advancement_roll(&roll_with_ctx).await?;
|
2020-10-31 14:03:18 +00:00
|
|
|
let html = format!(
|
2021-05-13 21:29:44 +00:00
|
|
|
"<strong>Roll:</strong> {}</p><p><strong>Result</strong>: {}",
|
2021-03-18 20:54:49 +00:00
|
|
|
executed_roll, executed_roll.roll
|
2020-10-31 14:03:18 +00:00
|
|
|
);
|
|
|
|
|
2021-02-07 21:39:21 +00:00
|
|
|
Execution::success(html)
|
2020-10-31 14:03:18 +00:00
|
|
|
}
|
|
|
|
}
|