Moving logs to the log folder, starting die()
This commit is contained in:
parent
e8ca00b454
commit
2e60a72417
30
bot.go
30
bot.go
@ -6,6 +6,8 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
"math/rand"
|
||||||
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Bot struct {
|
type Bot struct {
|
||||||
@ -26,7 +28,7 @@ var (
|
|||||||
charmap = make(map[string]map[string]map[string]string)
|
charmap = make(map[string]map[string]map[string]string)
|
||||||
monsmap = make(map[string]string)
|
monsmap = make(map[string]string)
|
||||||
|
|
||||||
filename = "log_" + time.Now().Local().Format("20060102") + "_" + time.Now().Local().Format("150405") + ".txt"
|
filename = "log/log_" + time.Now().Local().Format("20060102") + "_" + time.Now().Local().Format("150405") + ".txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
var dict = map[string]string{
|
var dict = map[string]string{
|
||||||
@ -48,6 +50,7 @@ var dict = map[string]string{
|
|||||||
var argmap = map[string]int{
|
var argmap = map[string]int{
|
||||||
".set": 4,
|
".set": 4,
|
||||||
".print": 3,
|
".print": 3,
|
||||||
|
".die": 2,
|
||||||
".mode": 1,
|
".mode": 1,
|
||||||
".rmmode": 1,
|
".rmmode": 1,
|
||||||
".dm": 1,
|
".dm": 1,
|
||||||
@ -65,6 +68,25 @@ func fillCharmap(nick string, cat string, item string, val string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func die(side int, amount int) {
|
||||||
|
// TODO: Works, just not correctly.
|
||||||
|
var numbers = make([]int, amount + 1)
|
||||||
|
var tmpnum = make([]int, amount)
|
||||||
|
|
||||||
|
for i := 0; i < amount; i++ {
|
||||||
|
r1 := rand.NewSource(0)
|
||||||
|
r2 := rand.New(r1)
|
||||||
|
number := r2.Intn(side)
|
||||||
|
numbers[i] = number
|
||||||
|
|
||||||
|
if amount > i {
|
||||||
|
tmpnum[i] = numbers[i + 1] + number
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println(tmpnum[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Create functions related to character import/export.
|
// TODO: Create functions related to character import/export.
|
||||||
|
|
||||||
func (b *Bot) Command(nick string, msg string) {
|
func (b *Bot) Command(nick string, msg string) {
|
||||||
@ -114,6 +136,12 @@ func (b *Bot) Command(nick string, msg string) {
|
|||||||
}
|
}
|
||||||
break
|
break
|
||||||
|
|
||||||
|
case ".die":
|
||||||
|
arg1, _ := strconv.Atoi(args[0])
|
||||||
|
arg2, _ := strconv.Atoi(args[1])
|
||||||
|
die(arg1, arg2)
|
||||||
|
break
|
||||||
|
|
||||||
case ".mode":
|
case ".mode":
|
||||||
if stringInSlice(args[0], rulemod) {
|
if stringInSlice(args[0], rulemod) {
|
||||||
b.Say(args[0] + " is already set to true")
|
b.Say(args[0] + " is already set to true")
|
||||||
|
Loading…
Reference in New Issue
Block a user