Skip to content

Commit

Permalink
make die roles independently random fixed #57
Browse files Browse the repository at this point in the history
  • Loading branch information
slugalisk committed Oct 24, 2023
1 parent e816289 commit e294d84
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -558,10 +558,14 @@ func (b *bot) roll(m dggchat.Message, s *dggchat.Session) {
}
}

if math.MaxInt64/count <= sides {
if math.MaxInt64/count <= sides || count > 100 {
return
}

res := rand.Int63n(int64((sides-1)*count)) + int64(count)
b.sendMessageDedupe(fmt.Sprintf("%s rolled %d", m.Sender.Nick, res), s)
var sum int64
for i := uint64(0); i < count; i++ {
sum += rand.Int63n(int64(sides)) + 1
}

b.sendMessageDedupe(fmt.Sprintf("%s rolled %d", m.Sender.Nick, sum), s)
}

0 comments on commit e294d84

Please sign in to comment.