From 22ea83c42ad0e5c6aeed520adc007dc35bf9f339 Mon Sep 17 00:00:00 2001 From: Vaclav Lunak Date: Sat, 18 Nov 2023 13:07:45 +0100 Subject: [PATCH] fix dice rolling calculation --- dice.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dice.go b/dice.go index 0a7f7c2..3ae8840 100644 --- a/dice.go +++ b/dice.go @@ -20,11 +20,11 @@ type Roll struct { func (d Roll) calculate() string { if d.sides == 0 { - return fmt.Sprintf("1 %d-sided die: %d", d.number, rand.Intn(d.number-1)+1) + return fmt.Sprintf("1 %d-sided die: %d", d.number, rand.Intn(d.number)+1) } var result int for i := 1; i <= d.number; i++ { - result += rand.Intn(d.sides-1) + 1 + result += rand.Intn(d.sides) + 1 } if d.operand != 0 {