Rename some variables for consistency.

Fixes #50.
This commit is contained in:
projectmoon 2020-12-17 20:59:29 +00:00
parent 23cf9e6ba4
commit f355fad06b
1 changed files with 8 additions and 5 deletions

View File

@ -156,15 +156,18 @@ pub struct DicePoolRoll {
rolls: Vec<i32>, rolls: Vec<i32>,
} }
/// 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 { fn fmt_rolls(pool: &DicePoolRoll) -> String {
let max_displayed_rolls = 15;
let rolls = pool.rolls(); let rolls = pool.rolls();
if rolls.len() > max_displayed_rolls { if rolls.len() > MAX_DISPLAYED_ROLLS {
let first_ten = rolls.iter().take(max_displayed_rolls).join(", "); let shown_amount = rolls.iter().take(MAX_DISPLAYED_ROLLS).join(", ");
format!( format!(
"{}, and {} more", "{}, and {} more",
first_ten, shown_amount,
rolls.len() - max_displayed_rolls rolls.len() - MAX_DISPLAYED_ROLLS
) )
} else { } else {
rolls.iter().join(", ") rolls.iter().join(", ")