From cc9c3994643c234362bc2cb1b63c2f2cd50a2d7d Mon Sep 17 00:00:00 2001 From: Jean Date: Sun, 19 Jul 2026 19:52:44 +0000 Subject: [PATCH] Don't print unreconcilable addends for a truncated dice listing --- modules/diceserv/src/roll.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/modules/diceserv/src/roll.rs b/modules/diceserv/src/roll.rs index eb0929e..86c6180 100644 --- a/modules/diceserv/src/roll.rs +++ b/modules/diceserv/src/roll.rs @@ -60,11 +60,15 @@ pub fn handle(me: &str, from: &Sender, rest: &[&str], ctx: &mut ServiceCtx, exte // "2d6: 4+5=9" for the extended output. fn render_roll(r: &expr::Roll) -> String { if r.values.len() == 1 { - format!("{}: {}", r.spec, r.total) - } else { - let each = r.values.iter().map(u64::to_string).collect::>().join("+"); - format!("{}: {}={}", r.spec, each, r.total) + return format!("{}: {}", r.spec, r.total); } + // For a huge roll the kept face list is capped, so the addends wouldn't sum to + // the true total — show the total alone rather than a listing that doesn't add up. + if r.values.iter().copied().sum::() != r.total { + return format!("{}: {} (first {} dice)", r.spec, r.total, r.values.len()); + } + let each = r.values.iter().map(u64::to_string).collect::>().join("+"); + format!("{}: {}={}", r.spec, each, r.total) } // ROLL rounds to a whole number; CALC keeps up to four decimals, trimmed.