im fucking awesome

This commit is contained in:
Elliott Pardee 2015-06-09 07:02:15 -04:00
parent a21ed0fc81
commit 38c20f09d5
2 changed files with 143 additions and 116 deletions

2
bot.go
View File

@ -49,7 +49,7 @@ var dict = map[string]string{
var argmap = map[string]int{
".set": 4,
".print": 2,
".print": 3,
".vote": 1,
".d": 1,
".mode": 1,

View File

@ -8,48 +8,40 @@ import (
)
type Character struct {
irc string
personal PersonalData
equipment EquipmentData
stats StatData
wealth WealthData
}
type PersonalData struct {
name string
lvl int
race string
xp int
height int
alignment string
classes []string
weight int
sex string
hp int
ac int
age int
}
type EquipmentData struct {
armour []string
weapons []string
items []string
missiles []string
}
type StatData struct {
con int
str int
intl int
cha int
wis int
dex int
}
type WealthData struct {
coins int
other []string
gems []string
Equipment struct {
Armour []interface{} `json:"armour"`
Items []interface{} `json:"items"`
Missiles []interface{} `json:"missiles"`
Weapons []interface{} `json:"weapons"`
} `json:"equipment"`
Irc string `json:"irc"`
Personal struct {
Ac int `json:"ac"`
Age int `json:"age"`
Alignment string `json:"alignment"`
Classes []string `json:"classes"`
Height int `json:"height"`
Hp int `json:"hp"`
Lvl int `json:"lvl"`
Name string `json:"name"`
Race string `json:"race"`
Sex string `json:"sex"`
Weight int `json:"weight"`
Xp int `json:"xp"`
} `json:"personal"`
Stats struct {
Cha int `json:"cha"`
Con int `json:"con"`
Dex int `json:"dex"`
Intl int `json:"intl"`
Str int `json:"str"`
Wis int `json:"wis"`
} `json:"stats"`
Wealth struct {
Coins int `json:"coins"`
Gems []interface{} `json:"gems"`
Other []interface{} `json:"other"`
} `json:"wealth"`
}
var charmap map[string]Character
@ -57,50 +49,47 @@ var charmap map[string]Character
func accessChar(set bool, nick string, cat string, item string, val string) string {
var pdata, edata, sdata, wdata bool
switch (cat) {
case "personal":
pdata = true
break
case "equipment":
edata = true
break
case "stats":
sdata = true
break
case "wealth":
wdata = true
break
case "nil":
return charmap[nick].irc // can't be anything else but
break
default:
return "invalid category"
switch cat {
case "personal":
pdata = true
break
case "equipment":
edata = true
break
case "stats":
sdata = true
break
case "wealth":
wdata = true
break
default:
return "invalid category"
}
if pdata {
switch (item) {
switch item {
case "name":
return charmap[nick].personal.name
return charmap[nick].Personal.Name
break
case "lvl":
return strconv.Itoa(charmap[nick].personal.lvl)
return strconv.Itoa(charmap[nick].Personal.Lvl)
break
case "race":
return charmap[nick].personal.race
return charmap[nick].Personal.Race
break
case "xp":
return strconv.Itoa(charmap[nick].personal.xp)
return strconv.Itoa(charmap[nick].Personal.Xp)
break
case "height":
return strconv.Itoa(charmap[nick].personal.height)
return strconv.Itoa(charmap[nick].Personal.Height)
break
case "alignment":
return charmap[nick].personal.alignment
return charmap[nick].Personal.Alignment
break
case "classes":
var classes string
for _, j := range charmap[nick].personal.classes {
if len(charmap[nick].personal.classes) > 0 {
for _, j := range charmap[nick].Personal.Classes {
if len(charmap[nick].Personal.Classes) > 0 {
if len(classes) > 0 {
classes = classes + ", " + j
} else {
@ -108,132 +97,166 @@ func accessChar(set bool, nick string, cat string, item string, val string) stri
}
}
}
if len(classes) > 0 {
return classes
}
return "you've got no classes, m80"
break
case "weight":
return strconv.Itoa(charmap[nick].personal.weight)
return strconv.Itoa(charmap[nick].Personal.Weight)
break
case "sex":
return charmap[nick].personal.sex
return charmap[nick].Personal.Sex
break
case "hp":
return strconv.Itoa(charmap[nick].personal.hp)
return strconv.Itoa(charmap[nick].Personal.Hp)
break
case "ac":
return strconv.Itoa(charmap[nick].personal.ac)
return strconv.Itoa(charmap[nick].Personal.Ac)
break
case "age":
return strconv.Itoa(charmap[nick].personal.age)
return strconv.Itoa(charmap[nick].Personal.Age)
break
default:
return "invalid item"
break
}
} else if edata {
switch (item) {
switch item {
case "armour":
var armour string
for _, j := range charmap[nick].equipment.armour {
if len(charmap[nick].equipment.armour) > 0 {
for _, j := range charmap[nick].Equipment.Armour {
value, _ := j.(string)
if len(charmap[nick].Equipment.Armour) > 0 {
if len(armour) > 0 {
armour = armour + ", " + j
armour = armour + ", " + value
} else {
armour = j
armour = value
}
}
}
if len(armour) > 0 {
return armour
}
return "you've got no armour, m80"
break
case "weapons":
var weapons string
for _, j := range charmap[nick].equipment.weapons {
if len(charmap[nick].equipment.weapons) > 0 {
for _, j := range charmap[nick].Equipment.Weapons {
value, _ := j.(string)
if len(charmap[nick].Equipment.Weapons) > 0 {
if len(weapons) > 0 {
weapons = weapons + ", " + j
weapons = weapons + ", " + value
} else {
weapons = j
weapons = value
}
}
}
if len(weapons) > 0 {
return weapons
}
return "you've got no weapons, m80"
break
case "items":
var items string
for _, j := range charmap[nick].equipment.items {
if len(charmap[nick].equipment.items) > 0 {
for _, j := range charmap[nick].Equipment.Items {
value, _ := j.(string)
if len(charmap[nick].Equipment.Items) > 0 {
if len(items) > 0 {
items = items + ", " + j
items = items + ", " + value
} else {
items = j
items = value
}
}
}
if len(items) > 0 {
return items
}
return "you've got no items, m80"
break
case "missiles":
var missiles string
for _, j := range charmap[nick].equipment.missiles {
if len(charmap[nick].equipment.missiles) > 0 {
for _, j := range charmap[nick].Equipment.Missiles {
value, _ := j.(string)
if len(charmap[nick].Equipment.Missiles) > 0 {
if len(missiles) > 0 {
missiles = missiles + ", " + j
missiles = missiles + ", " + value
} else {
missiles = j
missiles = value
}
}
}
if len(missiles) > 0 {
return missiles
}
return "you've got no missiles, m80"
break
default:
return "invalid item"
break
}
} else if sdata {
switch (item) {
switch item {
case "con":
return strconv.Itoa(charmap[nick].stats.con)
return strconv.Itoa(charmap[nick].Stats.Con)
break
case "str":
return strconv.Itoa(charmap[nick].stats.str)
return strconv.Itoa(charmap[nick].Stats.Str)
break
case "intl":
return strconv.Itoa(charmap[nick].stats.intl)
return strconv.Itoa(charmap[nick].Stats.Intl)
break
case "cha":
return strconv.Itoa(charmap[nick].stats.cha)
return strconv.Itoa(charmap[nick].Stats.Cha)
break
case "wis":
return strconv.Itoa(charmap[nick].stats.wis)
return strconv.Itoa(charmap[nick].Stats.Wis)
break
case "dex":
return strconv.Itoa(charmap[nick].stats.dex)
return strconv.Itoa(charmap[nick].Stats.Dex)
break
default:
return "invalid item"
break
}
} else if wdata {
switch (item) {
switch item {
case "coins":
return strconv.Itoa(charmap[nick].wealth.coins)
return strconv.Itoa(charmap[nick].Wealth.Coins)
break
case "other":
var other string
for _, j := range charmap[nick].wealth.other {
if len(charmap[nick].wealth.other) > 0 {
for _, j := range charmap[nick].Wealth.Other {
value, _ := j.(string)
if len(charmap[nick].Wealth.Other) > 0 {
if len(other) > 0 {
other = other + ", " + j
other = other + ", " + value
} else {
other = j
other = value
}
}
}
if len(other) > 0 {
return other
}
return "you've got no other items, m80"
break
case "gems":
var gems string
for _, j := range charmap[nick].wealth.gems {
if len(charmap[nick].wealth.gems) > 0 {
for _, j := range charmap[nick].Wealth.Gems {
value, _ := j.(string)
if len(charmap[nick].Wealth.Gems) > 0 {
if len(gems) > 0 {
gems = gems + ", " + j
gems = gems + ", " + value
} else {
gems = j
gems = value
}
}
}
if len(gems) > 0 {
return gems
}
return "you've got no gems, m80"
break
}
}
@ -250,10 +273,14 @@ func importChar(nick string) bool {
var char Character
json.Unmarshal(file, char)
err = json.Unmarshal([]byte(file), &char)
if err != nil {
panic(err)
}
charmap = map[string]Character{
char.irc: char,
nick: char,
}
return true