From f355fad06b92e27a3699ae16da8f0018824c63ca Mon Sep 17 00:00:00 2001 From: projectmoon Date: Thu, 17 Dec 2020 20:59:29 +0000 Subject: [PATCH] Rename some variables for consistency. Fixes #50. --- src/cofd/dice.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/cofd/dice.rs b/src/cofd/dice.rs index 4e18e44..4b7608d 100644 --- a/src/cofd/dice.rs +++ b/src/cofd/dice.rs @@ -156,15 +156,18 @@ pub struct DicePoolRoll { rolls: Vec, } +/// Amount of dice to display before cutting off and showing "and X +/// more", so we don't spam the room with huge messages. +const MAX_DISPLAYED_ROLLS: usize = 15; + fn fmt_rolls(pool: &DicePoolRoll) -> String { - let max_displayed_rolls = 15; let rolls = pool.rolls(); - if rolls.len() > max_displayed_rolls { - let first_ten = rolls.iter().take(max_displayed_rolls).join(", "); + if rolls.len() > MAX_DISPLAYED_ROLLS { + let shown_amount = rolls.iter().take(MAX_DISPLAYED_ROLLS).join(", "); format!( "{}, and {} more", - first_ten, - rolls.len() - max_displayed_rolls + shown_amount, + rolls.len() - MAX_DISPLAYED_ROLLS ) } else { rolls.iter().join(", ")