rolling dice is a bit cleaner

This commit is contained in:
Elliott Pardee 2015-02-10 09:24:36 -05:00
parent f02caacbb5
commit 267ad38fb1

10
bot.go
View File

@ -3,11 +3,11 @@ package main
import ( import (
"fmt" "fmt"
"github.com/thoj/go-ircevent" "github.com/thoj/go-ircevent"
"math/rand"
"os" "os"
"strconv"
"strings" "strings"
"time" "time"
"math/rand"
"strconv"
) )
type Bot struct { type Bot struct {
@ -51,7 +51,7 @@ var dict = map[string]string{
var argmap = map[string]int{ var argmap = map[string]int{
".set": 4, ".set": 4,
".print": 3, ".print": 3,
".roll": 1, ".d": 1,
".mode": 1, ".mode": 1,
".rmmode": 1, ".rmmode": 1,
".dm": 1, ".dm": 1,
@ -71,7 +71,7 @@ func fillCharmap(nick string, cat string, item string, val string) {
func roll(amount int, side int) int { func roll(amount int, side int) int {
var numbers = make([]int, amount) var numbers = make([]int, amount)
var finaln = 0; var finaln = 0
for i := 0; i < amount; i++ { for i := 0; i < amount; i++ {
number := rand.Intn(side) + 1 number := rand.Intn(side) + 1
@ -138,7 +138,7 @@ func (b *Bot) Command(nick string, msg string) {
} }
break break
case ".roll": case ".d":
amount, _ := strconv.Atoi(strings.Split(args[0], "d")[0]) amount, _ := strconv.Atoi(strings.Split(args[0], "d")[0])
side, _ := strconv.Atoi(strings.Split(args[0], "d")[1]) side, _ := strconv.Atoi(strings.Split(args[0], "d")[1])