im fucking awesome
This commit is contained in:
parent
a21ed0fc81
commit
38c20f09d5
2
bot.go
2
bot.go
@ -49,7 +49,7 @@ var dict = map[string]string{
|
|||||||
|
|
||||||
var argmap = map[string]int{
|
var argmap = map[string]int{
|
||||||
".set": 4,
|
".set": 4,
|
||||||
".print": 2,
|
".print": 3,
|
||||||
".vote": 1,
|
".vote": 1,
|
||||||
".d": 1,
|
".d": 1,
|
||||||
".mode": 1,
|
".mode": 1,
|
||||||
|
219
character.go
219
character.go
@ -8,48 +8,40 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Character struct {
|
type Character struct {
|
||||||
irc string
|
Equipment struct {
|
||||||
personal PersonalData
|
Armour []interface{} `json:"armour"`
|
||||||
equipment EquipmentData
|
Items []interface{} `json:"items"`
|
||||||
stats StatData
|
Missiles []interface{} `json:"missiles"`
|
||||||
wealth WealthData
|
Weapons []interface{} `json:"weapons"`
|
||||||
}
|
} `json:"equipment"`
|
||||||
|
Irc string `json:"irc"`
|
||||||
type PersonalData struct {
|
Personal struct {
|
||||||
name string
|
Ac int `json:"ac"`
|
||||||
lvl int
|
Age int `json:"age"`
|
||||||
race string
|
Alignment string `json:"alignment"`
|
||||||
xp int
|
Classes []string `json:"classes"`
|
||||||
height int
|
Height int `json:"height"`
|
||||||
alignment string
|
Hp int `json:"hp"`
|
||||||
classes []string
|
Lvl int `json:"lvl"`
|
||||||
weight int
|
Name string `json:"name"`
|
||||||
sex string
|
Race string `json:"race"`
|
||||||
hp int
|
Sex string `json:"sex"`
|
||||||
ac int
|
Weight int `json:"weight"`
|
||||||
age int
|
Xp int `json:"xp"`
|
||||||
}
|
} `json:"personal"`
|
||||||
|
Stats struct {
|
||||||
type EquipmentData struct {
|
Cha int `json:"cha"`
|
||||||
armour []string
|
Con int `json:"con"`
|
||||||
weapons []string
|
Dex int `json:"dex"`
|
||||||
items []string
|
Intl int `json:"intl"`
|
||||||
missiles []string
|
Str int `json:"str"`
|
||||||
}
|
Wis int `json:"wis"`
|
||||||
|
} `json:"stats"`
|
||||||
type StatData struct {
|
Wealth struct {
|
||||||
con int
|
Coins int `json:"coins"`
|
||||||
str int
|
Gems []interface{} `json:"gems"`
|
||||||
intl int
|
Other []interface{} `json:"other"`
|
||||||
cha int
|
} `json:"wealth"`
|
||||||
wis int
|
|
||||||
dex int
|
|
||||||
}
|
|
||||||
|
|
||||||
type WealthData struct {
|
|
||||||
coins int
|
|
||||||
other []string
|
|
||||||
gems []string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var charmap map[string]Character
|
var charmap map[string]Character
|
||||||
@ -57,7 +49,7 @@ var charmap map[string]Character
|
|||||||
func accessChar(set bool, nick string, cat string, item string, val string) string {
|
func accessChar(set bool, nick string, cat string, item string, val string) string {
|
||||||
var pdata, edata, sdata, wdata bool
|
var pdata, edata, sdata, wdata bool
|
||||||
|
|
||||||
switch (cat) {
|
switch cat {
|
||||||
case "personal":
|
case "personal":
|
||||||
pdata = true
|
pdata = true
|
||||||
break
|
break
|
||||||
@ -70,37 +62,34 @@ func accessChar(set bool, nick string, cat string, item string, val string) stri
|
|||||||
case "wealth":
|
case "wealth":
|
||||||
wdata = true
|
wdata = true
|
||||||
break
|
break
|
||||||
case "nil":
|
|
||||||
return charmap[nick].irc // can't be anything else but
|
|
||||||
break
|
|
||||||
default:
|
default:
|
||||||
return "invalid category"
|
return "invalid category"
|
||||||
}
|
}
|
||||||
|
|
||||||
if pdata {
|
if pdata {
|
||||||
switch (item) {
|
switch item {
|
||||||
case "name":
|
case "name":
|
||||||
return charmap[nick].personal.name
|
return charmap[nick].Personal.Name
|
||||||
break
|
break
|
||||||
case "lvl":
|
case "lvl":
|
||||||
return strconv.Itoa(charmap[nick].personal.lvl)
|
return strconv.Itoa(charmap[nick].Personal.Lvl)
|
||||||
break
|
break
|
||||||
case "race":
|
case "race":
|
||||||
return charmap[nick].personal.race
|
return charmap[nick].Personal.Race
|
||||||
break
|
break
|
||||||
case "xp":
|
case "xp":
|
||||||
return strconv.Itoa(charmap[nick].personal.xp)
|
return strconv.Itoa(charmap[nick].Personal.Xp)
|
||||||
break
|
break
|
||||||
case "height":
|
case "height":
|
||||||
return strconv.Itoa(charmap[nick].personal.height)
|
return strconv.Itoa(charmap[nick].Personal.Height)
|
||||||
break
|
break
|
||||||
case "alignment":
|
case "alignment":
|
||||||
return charmap[nick].personal.alignment
|
return charmap[nick].Personal.Alignment
|
||||||
break
|
break
|
||||||
case "classes":
|
case "classes":
|
||||||
var classes string
|
var classes string
|
||||||
for _, j := range charmap[nick].personal.classes {
|
for _, j := range charmap[nick].Personal.Classes {
|
||||||
if len(charmap[nick].personal.classes) > 0 {
|
if len(charmap[nick].Personal.Classes) > 0 {
|
||||||
if len(classes) > 0 {
|
if len(classes) > 0 {
|
||||||
classes = classes + ", " + j
|
classes = classes + ", " + j
|
||||||
} else {
|
} 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
|
break
|
||||||
case "weight":
|
case "weight":
|
||||||
return strconv.Itoa(charmap[nick].personal.weight)
|
return strconv.Itoa(charmap[nick].Personal.Weight)
|
||||||
break
|
break
|
||||||
case "sex":
|
case "sex":
|
||||||
return charmap[nick].personal.sex
|
return charmap[nick].Personal.Sex
|
||||||
break
|
break
|
||||||
case "hp":
|
case "hp":
|
||||||
return strconv.Itoa(charmap[nick].personal.hp)
|
return strconv.Itoa(charmap[nick].Personal.Hp)
|
||||||
break
|
break
|
||||||
case "ac":
|
case "ac":
|
||||||
return strconv.Itoa(charmap[nick].personal.ac)
|
return strconv.Itoa(charmap[nick].Personal.Ac)
|
||||||
break
|
break
|
||||||
case "age":
|
case "age":
|
||||||
return strconv.Itoa(charmap[nick].personal.age)
|
return strconv.Itoa(charmap[nick].Personal.Age)
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
return "invalid item"
|
return "invalid item"
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
} else if edata {
|
} else if edata {
|
||||||
switch (item) {
|
switch item {
|
||||||
case "armour":
|
case "armour":
|
||||||
var armour string
|
var armour string
|
||||||
for _, j := range charmap[nick].equipment.armour {
|
for _, j := range charmap[nick].Equipment.Armour {
|
||||||
if len(charmap[nick].equipment.armour) > 0 {
|
value, _ := j.(string)
|
||||||
|
if len(charmap[nick].Equipment.Armour) > 0 {
|
||||||
if len(armour) > 0 {
|
if len(armour) > 0 {
|
||||||
armour = armour + ", " + j
|
armour = armour + ", " + value
|
||||||
} else {
|
} else {
|
||||||
armour = j
|
armour = value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if len(armour) > 0 {
|
||||||
|
return armour
|
||||||
|
}
|
||||||
|
return "you've got no armour, m80"
|
||||||
break
|
break
|
||||||
case "weapons":
|
case "weapons":
|
||||||
var weapons string
|
var weapons string
|
||||||
for _, j := range charmap[nick].equipment.weapons {
|
for _, j := range charmap[nick].Equipment.Weapons {
|
||||||
if len(charmap[nick].equipment.weapons) > 0 {
|
value, _ := j.(string)
|
||||||
|
if len(charmap[nick].Equipment.Weapons) > 0 {
|
||||||
if len(weapons) > 0 {
|
if len(weapons) > 0 {
|
||||||
weapons = weapons + ", " + j
|
weapons = weapons + ", " + value
|
||||||
} else {
|
} else {
|
||||||
weapons = j
|
weapons = value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if len(weapons) > 0 {
|
||||||
|
return weapons
|
||||||
|
}
|
||||||
|
return "you've got no weapons, m80"
|
||||||
break
|
break
|
||||||
case "items":
|
case "items":
|
||||||
var items string
|
var items string
|
||||||
for _, j := range charmap[nick].equipment.items {
|
for _, j := range charmap[nick].Equipment.Items {
|
||||||
if len(charmap[nick].equipment.items) > 0 {
|
value, _ := j.(string)
|
||||||
|
if len(charmap[nick].Equipment.Items) > 0 {
|
||||||
if len(items) > 0 {
|
if len(items) > 0 {
|
||||||
items = items + ", " + j
|
items = items + ", " + value
|
||||||
} else {
|
} else {
|
||||||
items = j
|
items = value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if len(items) > 0 {
|
||||||
|
return items
|
||||||
|
}
|
||||||
|
return "you've got no items, m80"
|
||||||
break
|
break
|
||||||
case "missiles":
|
case "missiles":
|
||||||
var missiles string
|
var missiles string
|
||||||
for _, j := range charmap[nick].equipment.missiles {
|
for _, j := range charmap[nick].Equipment.Missiles {
|
||||||
if len(charmap[nick].equipment.missiles) > 0 {
|
value, _ := j.(string)
|
||||||
|
if len(charmap[nick].Equipment.Missiles) > 0 {
|
||||||
if len(missiles) > 0 {
|
if len(missiles) > 0 {
|
||||||
missiles = missiles + ", " + j
|
missiles = missiles + ", " + value
|
||||||
} else {
|
} else {
|
||||||
missiles = j
|
missiles = value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if len(missiles) > 0 {
|
||||||
|
return missiles
|
||||||
|
}
|
||||||
|
return "you've got no missiles, m80"
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
return "invalid item"
|
return "invalid item"
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
} else if sdata {
|
} else if sdata {
|
||||||
switch (item) {
|
switch item {
|
||||||
case "con":
|
case "con":
|
||||||
return strconv.Itoa(charmap[nick].stats.con)
|
return strconv.Itoa(charmap[nick].Stats.Con)
|
||||||
break
|
break
|
||||||
case "str":
|
case "str":
|
||||||
return strconv.Itoa(charmap[nick].stats.str)
|
return strconv.Itoa(charmap[nick].Stats.Str)
|
||||||
break
|
break
|
||||||
case "intl":
|
case "intl":
|
||||||
return strconv.Itoa(charmap[nick].stats.intl)
|
return strconv.Itoa(charmap[nick].Stats.Intl)
|
||||||
break
|
break
|
||||||
case "cha":
|
case "cha":
|
||||||
return strconv.Itoa(charmap[nick].stats.cha)
|
return strconv.Itoa(charmap[nick].Stats.Cha)
|
||||||
break
|
break
|
||||||
case "wis":
|
case "wis":
|
||||||
return strconv.Itoa(charmap[nick].stats.wis)
|
return strconv.Itoa(charmap[nick].Stats.Wis)
|
||||||
break
|
break
|
||||||
case "dex":
|
case "dex":
|
||||||
return strconv.Itoa(charmap[nick].stats.dex)
|
return strconv.Itoa(charmap[nick].Stats.Dex)
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
return "invalid item"
|
return "invalid item"
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
} else if wdata {
|
} else if wdata {
|
||||||
switch (item) {
|
switch item {
|
||||||
case "coins":
|
case "coins":
|
||||||
return strconv.Itoa(charmap[nick].wealth.coins)
|
return strconv.Itoa(charmap[nick].Wealth.Coins)
|
||||||
break
|
break
|
||||||
case "other":
|
case "other":
|
||||||
var other string
|
var other string
|
||||||
for _, j := range charmap[nick].wealth.other {
|
for _, j := range charmap[nick].Wealth.Other {
|
||||||
if len(charmap[nick].wealth.other) > 0 {
|
value, _ := j.(string)
|
||||||
|
if len(charmap[nick].Wealth.Other) > 0 {
|
||||||
if len(other) > 0 {
|
if len(other) > 0 {
|
||||||
other = other + ", " + j
|
other = other + ", " + value
|
||||||
} else {
|
} else {
|
||||||
other = j
|
other = value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if len(other) > 0 {
|
||||||
|
return other
|
||||||
|
}
|
||||||
|
return "you've got no other items, m80"
|
||||||
break
|
break
|
||||||
case "gems":
|
case "gems":
|
||||||
var gems string
|
var gems string
|
||||||
for _, j := range charmap[nick].wealth.gems {
|
for _, j := range charmap[nick].Wealth.Gems {
|
||||||
if len(charmap[nick].wealth.gems) > 0 {
|
value, _ := j.(string)
|
||||||
|
if len(charmap[nick].Wealth.Gems) > 0 {
|
||||||
if len(gems) > 0 {
|
if len(gems) > 0 {
|
||||||
gems = gems + ", " + j
|
gems = gems + ", " + value
|
||||||
} else {
|
} else {
|
||||||
gems = j
|
gems = value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if len(gems) > 0 {
|
||||||
|
return gems
|
||||||
|
}
|
||||||
|
return "you've got no gems, m80"
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -250,10 +273,14 @@ func importChar(nick string) bool {
|
|||||||
|
|
||||||
var char Character
|
var char Character
|
||||||
|
|
||||||
json.Unmarshal(file, char)
|
err = json.Unmarshal([]byte(file), &char)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
charmap = map[string]Character{
|
charmap = map[string]Character{
|
||||||
char.irc: char,
|
nick: char,
|
||||||
}
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
Loading…
Reference in New Issue
Block a user