formatting changes from goimport

added a link to source, healing
parse ints through one function and return helpful errors that can be used as return values
added more error checking
improved some output
made some more joke methods
lazily added more if conditions for people i'm sick of
This commit is contained in:
alex 2018-11-08 10:40:08 +00:00
parent ecb988a3d9
commit 237d91de16
3 changed files with 185 additions and 102 deletions

View File

@ -1,21 +1,22 @@
package wat package wat
import ( import (
"github.com/go-irc/irc"
"crypto/tls" "crypto/tls"
"fmt" "fmt"
"strings" "strings"
"github.com/go-irc/irc"
) )
type WatBot struct { type WatBot struct {
client *irc.Client client *irc.Client
conn *tls.Conn conn *tls.Conn
game *WatGame game *WatGame
Db *WatDb Db *WatDb
Nick string Nick string
} }
var allowedChannels = []string { var allowedChannels = []string{
"##wat", "##wat",
"##test", "##test",
"##sweden", "##sweden",
@ -23,7 +24,7 @@ var allowedChannels = []string {
} }
func NewWatBot(config *irc.ClientConfig, serverConn *tls.Conn) *WatBot { func NewWatBot(config *irc.ClientConfig, serverConn *tls.Conn) *WatBot {
wat := WatBot{conn:serverConn, Nick:config.Nick} wat := WatBot{conn: serverConn, Nick: config.Nick}
wat.Db = NewWatDb() wat.Db = NewWatDb()
wat.game = NewWatGame(&wat, wat.Db) wat.game = NewWatGame(&wat, wat.Db)
config.Handler = irc.HandlerFunc(wat.HandleIrcMsg) config.Handler = irc.HandlerFunc(wat.HandleIrcMsg)
@ -32,7 +33,7 @@ func NewWatBot(config *irc.ClientConfig, serverConn *tls.Conn) *WatBot {
} }
func CleanNick(nick string) string { func CleanNick(nick string) string {
return string(nick[0])+"\u200c"+nick[1:] return string(nick[0]) + "\u200c" + nick[1:]
} }
func (w *WatBot) HandleIrcMsg(c *irc.Client, m *irc.Message) { func (w *WatBot) HandleIrcMsg(c *irc.Client, m *irc.Message) {
@ -60,7 +61,7 @@ func (w *WatBot) AllowedChannel(c string) bool {
func (w *WatBot) Msg(m *irc.Message) { func (w *WatBot) Msg(m *irc.Message) {
// bail out if you're not yves, if you're not tripsit or if you're not in an allowed channel // bail out if you're not yves, if you're not tripsit or if you're not in an allowed channel
// but if you're an admin you can do whatever // but if you're an admin you can do whatever
if m.Prefix.Host == "tripsit/user/Yves" || !strings.Contains(m.Prefix.Host, "tripsit") || (!w.AllowedChannel(m.Params[0]) && !w.Admin(m)) { if m.Prefix.Host == "tripsit/user/creatonez" || m.Prefix.Host == "tripsit/user/Yves" || !strings.Contains(m.Prefix.Host, "tripsit") || (!w.AllowedChannel(m.Params[0]) && !w.Admin(m)) {
return return
} }
@ -70,7 +71,7 @@ func (w *WatBot) Msg(m *irc.Message) {
} }
// fieldsfunc allows you to obtain rune separated fields/args // fieldsfunc allows you to obtain rune separated fields/args
args := strings.FieldsFunc(m.Params[1], func(c rune) bool {return c == ' '}) args := strings.FieldsFunc(m.Params[1], func(c rune) bool { return c == ' ' })
if len(args) == 0 { if len(args) == 0 {
return return
@ -135,6 +136,6 @@ func (w *WatBot) reply(s *irc.Message, r string) {
func (w *WatBot) write(cmd string, params ...string) { func (w *WatBot) write(cmd string, params ...string) {
w.client.WriteMessage(&irc.Message{ w.client.WriteMessage(&irc.Message{
Command: cmd, Command: cmd,
Params: params, Params: params,
}) })
} }

View File

@ -2,23 +2,24 @@ package wat
import ( import (
"time" "time"
"github.com/jinzhu/gorm" "github.com/jinzhu/gorm"
_"github.com/jinzhu/gorm/dialects/sqlite" _ "github.com/jinzhu/gorm/dialects/sqlite"
) )
import "fmt" import "fmt"
type Player struct { type Player struct {
gorm.Model gorm.Model
Nick string Nick string
Host string Host string
Watting int64 Watting int64
Anarchy int64 Anarchy int64
Trickery int64 Trickery int64
Coins int64 `gorm:"default:'100'"` Coins int64 `gorm:"default:'100'"`
Health int64 Health int64
LastMined int64 LastMined int64
LastRested int64 LastRested int64
CoinsLost int64 CoinsLost int64
} }
func (p *Player) LoseCoins(coins int64) { func (p *Player) LoseCoins(coins int64) {
@ -32,9 +33,9 @@ func (p *Player) Conscious() bool {
func (p *Player) Level(xp int64) int64 { func (p *Player) Level(xp int64) int64 {
if xp < 100 { if xp < 100 {
return xp/10 return xp / 10
} else if xp < 900 { } else if xp < 900 {
return 10 + (xp/100) return 10 + (xp / 100)
} else { } else {
return 99 return 99
} }
@ -42,21 +43,21 @@ func (p *Player) Level(xp int64) int64 {
type Ledger struct { type Ledger struct {
PlayerId uint `gorm:"primary_key"` PlayerId uint `gorm:"primary_key"`
Time int64 Time int64
Balance int64 Balance int64
Log string Log string
} }
type Item struct { type Item struct {
PlayerId uint PlayerId uint
Name string `gorm:"primary_key"` Name string `gorm:"primary_key"`
Price int64 Price int64
} }
type PlayerItem struct { type PlayerItem struct {
PlayerId uint PlayerId uint
ItemId int ItemId int
Count int Count int
} }
type WatDb struct { type WatDb struct {
@ -89,8 +90,11 @@ func (w *WatDb) User(nick, host string, create bool) Player {
return player return player
} }
func (w *WatDb) Update(upd interface{}) { func (w *WatDb) Update(upd ...interface{}) {
w.db.Save(upd) for _, u := range upd {
fmt.Printf("Updating %+v\n", u)
w.db.Save(u)
}
} }
func (w *WatDb) TopTen() []Player { func (w *WatDb) TopTen() []Player {

View File

@ -1,38 +1,43 @@
package wat package wat
import ( import (
"fmt"
"time"
"strings"
"strconv"
"crypto/rand" "crypto/rand"
"fmt"
"math/big" "math/big"
"strconv"
"strings"
"time"
"github.com/go-irc/irc" "github.com/go-irc/irc"
) )
type WatGame struct { type WatGame struct {
bot *WatBot bot *WatBot
db *WatDb db *WatDb
me Player me Player
commands map[string](func(*Player,[]string)(string)) commands map[string](func(*Player, []string) string)
lifeCommands map[string](func(*Player, []string)(string)) lifeCommands map[string](func(*Player, []string) string)
} }
func NewWatGame(bot *WatBot, db *WatDb) *WatGame { func NewWatGame(bot *WatBot, db *WatDb) *WatGame {
g := WatGame{bot, db, Player{}, nil, nil} g := WatGame{bot, db, Player{}, nil, nil}
g.me = g.db.User(bot.Nick, "tripsit/user/"+bot.Nick, true) g.me = g.db.User(bot.Nick, "tripsit/user/"+bot.Nick, true)
g.commands = map[string](func(*Player,[]string)(string)) { g.commands = map[string](func(*Player, []string) string){
"wat": g.megaWat, "wat": g.megaWat,
"watch": g.Watch, "watch": g.Watch,
"coins": g.Balance, "coins": g.Balance,
"send": g.Send, "send": g.Send,
"rest": g.Rest, "rest": g.Rest,
"leech": g.Leech, "leech": g.Leech,
"roll": g.Roll, "roll": g.Roll,
"dice": g.Dice, "flip": g.Roll,
"mine": g.Mine, "dice": g.Dice,
"mine": g.Mine,
"riot": g.Riot,
"bench": g.Bench,
} }
g.lifeCommands = map[string](func(*Player, []string)(string)) { g.lifeCommands = map[string](func(*Player, []string) string){
"heal": g.Heal,
"steal": g.Steal, "steal": g.Steal,
"frame": g.Frame, "frame": g.Frame,
"punch": g.Punch, "punch": g.Punch,
@ -45,7 +50,8 @@ var currency = "watcoin"
var currencys = "watcoins" var currencys = "watcoins"
var unconscious = "wat, your hands fumble and fail you. try resting, weakling." var unconscious = "wat, your hands fumble and fail you. try resting, weakling."
var helpText = fmt.Sprintf("coins <nick>, watch <nick>, topten, mine, send <nick> <%s>, roll <%s>, steal <nick> <%s>, frame <nick> <%s>, punch <nick>", currency, currency, currency, currency) var helpText = fmt.Sprintf("coins <nick>, watch <nick>, topten, mine, send <nick> <%s>, roll <%s>, steal <nick> <%s>, frame <nick> <%s>, punch <nick>", currency, currency, currency, currency)
var rules = "A new account is created with 5 hours time credit. Mining exchanges time credit for %s: 1-10h: 1 p/h; >10h: 10 p/h; >1 day: 50 p/h; >1 month: 1000 p/h."
//var rules = "A new account is created with 5 hours time credit. Mining exchanges time credit for %s: 1-10h: 1 p/h; >10h: 10 p/h; >1 day: 50 p/h; >1 month: 1000 p/h."
// missing // missing
// invent, create, give inventory // invent, create, give inventory
@ -57,12 +63,14 @@ func (g *WatGame) Msg(m *irc.Message, player *Player, fields []string) {
} else { } else {
// one liners // one liners
switch strings.ToLower(fields[0]) { switch strings.ToLower(fields[0]) {
case "rules":
reply = rules
case "help": case "help":
reply = helpText reply = helpText
case "topten": case "topten":
reply = fmt.Sprintf("%s holders: %s", currency, g.TopTen()) reply = fmt.Sprintf("%s holders: %s", currency, g.TopTen())
case "source":
reply = "https://git.circuitco.de/self/watbot"
case "butt":
reply = "I LOVE BUTTS"
} }
} }
if g.lifeCommands[fields[0]] != nil { if g.lifeCommands[fields[0]] != nil {
@ -80,6 +88,37 @@ func (g *WatGame) RandInt(max int64) int64 {
return i.Int64() return i.Int64()
} }
func (g *WatGame) Heal(player *Player, fields []string) string {
multiplier := int64(5)
if len(fields) < 3 {
return "#heal <player> <coins> - sacrifice your money to me, peasant! i might heal someone!"
}
target, e := g.GetTarget("", fields[1])
if e != "" {
return e
}
amount, err := g.Int(fields[2])
if err != nil {
return err.Error()
}
if amount > player.Coins {
return "u poor lol"
}
if amount < multiplier {
return fmt.Sprintf("too cheap lol at least %d", multiplier)
}
target.Health += amount / multiplier
player.Coins -= amount
if target.Nick == player.Nick {
target.Coins -= amount
g.db.Update(target)
} else {
g.db.Update(target, player)
}
fmtStr := "%s throws %d on the dirt. %s picks it up and waves their hand across %s, healing them. %s now has %d health."
return fmt.Sprintf(fmtStr, player.Nick, amount, g.bot.Nick, target.Nick, target.Nick, target.Health)
}
func (g *WatGame) Dice(player *Player, fields []string) string { func (g *WatGame) Dice(player *Player, fields []string) string {
roll := int64(6) roll := int64(6)
if len(fields) > 1 { if len(fields) > 1 {
@ -88,18 +127,26 @@ func (g *WatGame) Dice(player *Player, fields []string) string {
roll = i roll = i
} }
} }
answer := g.RandInt(roll)+1 answer := g.RandInt(roll) + 1
return fmt.Sprintf("1d%d - %d", roll, answer) return fmt.Sprintf("1d%d - %d", roll, answer)
} }
type PositiveError struct {} type PositiveError struct{}
func (e PositiveError) Error() string {return ""} type ParseIntError struct {
original string
}
func (e PositiveError) Error() string { return "i don't do negative numbers lol" }
func (e ParseIntError) Error() string { return fmt.Sprintf("wat kinda number is %s", e.original) }
func (g *WatGame) Int(str string) (int64, error) { func (g *WatGame) Int(str string) (int64, error) {
i, e := strconv.ParseInt(str, 10, 64) i, e := strconv.ParseInt(str, 10, 64)
if i < 0 { if i < 0 {
return 0, PositiveError{} return 0, PositiveError{}
} }
if e != nil {
e = ParseIntError{}
}
return i, e return i, e
} }
@ -109,12 +156,12 @@ func (g *WatGame) Roll(player *Player, fields []string) string {
} }
amount, e := g.Int(fields[1]) amount, e := g.Int(fields[1])
if e != nil { if e != nil {
return "wat kinda number is that" return e.Error()
} }
if amount > player.Coins { if amount > player.Coins {
return "wat? brokeass" return "wat? brokeass"
} }
n := g.RandInt(100)+1 n := g.RandInt(100) + 1
ret := fmt.Sprintf("%s rolls a 1d100... %d! ", player.Nick, n) ret := fmt.Sprintf("%s rolls a 1d100... %d! ", player.Nick, n)
if n < 50 { if n < 50 {
player.Coins += amount player.Coins += amount
@ -137,8 +184,11 @@ func (g *WatGame) Punch(player *Player, fields []string) string {
if err != "" { if err != "" {
return err return err
} }
chance := g.RandInt(6)+1 if !target.Conscious() {
dmg := g.RandInt(6)+1 return "wat? you're punching someone who is already unconscious. u crazy?"
}
chance := g.RandInt(6) + 1
dmg := g.RandInt(6) + 1
ret := fmt.Sprintf("%s rolls a d6... %s ", player.Nick, player.Nick) ret := fmt.Sprintf("%s rolls a d6... %s ", player.Nick, player.Nick)
if chance > 3 { if chance > 3 {
dmg += player.Level(player.Anarchy) dmg += player.Level(player.Anarchy)
@ -164,8 +214,8 @@ func (g *WatGame) Frame(player *Player, fields []string) string {
return fmt.Sprintf("frame <nick> <%s> - d6 roll. Sneaky? You force the target to pay me. Clumsy? You pay a fine to the target and myself.", currency) return fmt.Sprintf("frame <nick> <%s> - d6 roll. Sneaky? You force the target to pay me. Clumsy? You pay a fine to the target and myself.", currency)
} }
amount, e := g.Int(fields[2]) amount, e := g.Int(fields[2])
if amount <= 0 || e != nil { if e != nil {
return "wat kinda number is "+fields[2]+"?" return e.Error()
} }
if player.Coins < amount { if player.Coins < amount {
return "wat? you too poor for that." return "wat? you too poor for that."
@ -177,21 +227,20 @@ func (g *WatGame) Frame(player *Player, fields []string) string {
if target.Coins < amount { if target.Coins < amount {
return fmt.Sprintf("wat? %s is too poor for this.", target.Nick) return fmt.Sprintf("wat? %s is too poor for this.", target.Nick)
} }
n := g.RandInt(6)+1 n := g.RandInt(6) + 1
ret := fmt.Sprintf("%s rolls a d6 to frame %s with %d %s: It's a %d! (<3 wins). ", player.Nick, target.Nick, amount, currency, n) ret := fmt.Sprintf("%s rolls a d6 to frame %s with %d %s: It's a %d! (<3 wins). ", player.Nick, target.Nick, amount, currency, n)
if n < 3 { if n < 3 {
ret += fmt.Sprintf("You frame %s for a minor crime. They pay me %d.", target.Nick, amount) ret += fmt.Sprintf("You frame %s for a minor crime. They pay me %d.", target.Nick, amount)
player.Anarchy += 1 player.Anarchy += 1
target.Coins -= amount target.Coins -= amount
} else { } else {
ret += fmt.Sprintf("You were caught and pay them %d. %s gets the rest.", (amount/2), g.bot.Nick) ret += fmt.Sprintf("You were caught and pay them %d. %s gets the rest.", (amount / 2), g.bot.Nick)
player.LoseCoins(amount) player.LoseCoins(amount)
target.Coins += amount/2 target.Coins += amount / 2
g.me.Coins += amount/2 g.me.Coins += amount / 2
g.db.Update(g.me) g.db.Update(g.me)
} }
g.db.Update(player) g.db.Update(player, target)
g.db.Update(target)
return ret return ret
} }
@ -200,11 +249,11 @@ func (g *WatGame) Steal(player *Player, fields []string) string {
return fmt.Sprintf("steal <nick> <%s> - d6 roll. If you fail, you pay double the %s to %s", currency, currency, g.bot.Nick) return fmt.Sprintf("steal <nick> <%s> - d6 roll. If you fail, you pay double the %s to %s", currency, currency, g.bot.Nick)
} }
amount, e := g.Int(fields[2]) amount, e := g.Int(fields[2])
if amount <= 0 || e != nil { if e != nil {
return "wat kinda number is "+fields[2]+"?" return e.Error()
} }
if player.Coins < amount*2 { if player.Coins < amount*2 {
return "wat? You'd go bankrupt if they steal back..." return "wat? you need double your theft or you'd go bankrupt if they steal back..."
} }
target, err := g.GetTarget(player.Nick, fields[1]) target, err := g.GetTarget(player.Nick, fields[1])
if target == nil { if target == nil {
@ -213,7 +262,7 @@ func (g *WatGame) Steal(player *Player, fields []string) string {
if target.Coins < amount { if target.Coins < amount {
return fmt.Sprintf("wat? %s is poor and doesn't have that much to steal. (%d %s)", target.Nick, target.Coins, currency) return fmt.Sprintf("wat? %s is poor and doesn't have that much to steal. (%d %s)", target.Nick, target.Coins, currency)
} }
n := g.RandInt(6)+1 n := g.RandInt(6) + 1
ret := fmt.Sprintf("%s is trying to steal %d %s from %s... ", player.Nick, amount, currency, target.Nick) ret := fmt.Sprintf("%s is trying to steal %d %s from %s... ", player.Nick, amount, currency, target.Nick)
if n < 3 { if n < 3 {
ret += "You did it! Sneaky bastard!" ret += "You did it! Sneaky bastard!"
@ -222,9 +271,9 @@ func (g *WatGame) Steal(player *Player, fields []string) string {
target.Coins -= amount target.Coins -= amount
g.db.Update(target) g.db.Update(target)
} else { } else {
ret += fmt.Sprintf("You were caught and I took %d %s from your pocket.", (amount*2), currency) ret += fmt.Sprintf("You were caught and I took %d %s from your pocket.", (amount * 2), currency)
player.LoseCoins(amount*2) player.LoseCoins(amount * 2)
g.me.Coins += amount*2 g.me.Coins += amount * 2
g.db.Update(g.me) g.db.Update(g.me)
} }
g.db.Update(player) g.db.Update(player)
@ -258,17 +307,16 @@ func (g *WatGame) Leech(player *Player, fields []string) string {
if err != "" { if err != "" {
return err return err
} }
r := g.RandInt(10)+1 r := g.RandInt(10) + 1
reply := fmt.Sprintf("You muster your wealth and feed it to %s. ", g.bot.Nick) reply := fmt.Sprintf("You muster your wealth and feed it to %s. ", g.bot.Nick)
hpDown := amount/divisor hpDown := amount / divisor
player.Coins -= amount player.Coins -= amount
if r < 5 { if r < 5 {
target.Health -= hpDown target.Health -= hpDown
player.Health += hpDown player.Health += hpDown
player.Anarchy += 1 player.Anarchy += 1
reply += fmt.Sprintf("The deal is done, you took %d HP from %s. They now have %d HP, you have %d.", hpDown, target.Nick, target.Health, player.Health) reply += fmt.Sprintf("The deal is done, you took %d HP from %s. They now have %d HP, you have %d.", hpDown, target.Nick, target.Health, player.Health)
g.db.Update(target) g.db.Update(target, player)
g.db.Update(player)
} else { } else {
reply += "The gods do not smile upon you this waturday. Your money vanishes and nothing happens." reply += "The gods do not smile upon you this waturday. Your money vanishes and nothing happens."
} }
@ -287,7 +335,7 @@ func (g *WatGame) Rest(player *Player, fields []string) string {
} else if delta < minRest { } else if delta < minRest {
ret = fmt.Sprintf("wat were you thinking, sleeping at a time like this (%d until next rest)", minRest-delta) ret = fmt.Sprintf("wat were you thinking, sleeping at a time like this (%d until next rest)", minRest-delta)
} else { } else {
value := g.RandInt(10)+1 value := g.RandInt(10) + 1
ret = fmt.Sprintf("wat a nap - have back a random amount of hitpoints (this time it's %d)", value) ret = fmt.Sprintf("wat a nap - have back a random amount of hitpoints (this time it's %d)", value)
player.LastRested = time.Now().Unix() player.LastRested = time.Now().Unix()
player.Health += value player.Health += value
@ -296,6 +344,42 @@ func (g *WatGame) Rest(player *Player, fields []string) string {
return ret return ret
} }
func (g *WatGame) Bench(player *Player, fields []string) string {
weight := g.RandInt(370) + 50
reps := g.RandInt(10)
value := int64(0)
reply := fmt.Sprintf("%s benches %dwatts for %d reps, ", player.Nick, weight, reps)
if weight < 150 {
reply += "do u even lift bro?"
return reply
} else if weight < 250 {
value = 1
} else if weight < 420 {
value = 2
} else if weight == 420 {
value = 10
reply += "four twenty blaze it bro! "
}
player.Anarchy += value
g.db.Update(player)
reply += fmt.Sprintf("ur %d stronger lol", value)
return reply
}
func (g *WatGame) Riot(player *Player, fields []string) string {
r := g.RandInt(100)
reply := ""
if r > 30 {
player.Anarchy += 10
reply = fmt.Sprintf("You have successfully smashed the state! The brogeoise have been toppled. You're now a little more anarchistic (lv %d / exp %d)", player.Anarchy, player.Level(player.Anarchy))
} else {
player.Health -= 3
reply = fmt.Sprintf("The proletariat have been hunted down by the secret police and had their faces smashed in! Your rebellion fails and you lose 3HP.")
}
g.db.Update(player)
return reply
}
func (g *WatGame) QuestStart(player *Player, fields []string) string { func (g *WatGame) QuestStart(player *Player, fields []string) string {
// Begin a quest with some people. It will involve multiple dice rolls. // Begin a quest with some people. It will involve multiple dice rolls.
return "" return ""
@ -305,9 +389,9 @@ func (g *WatGame) Send(player *Player, fields []string) string {
if len(fields) < 3 { if len(fields) < 3 {
return fmt.Sprintf("You forgot somethin'. send <nick> <%s>", currency) return fmt.Sprintf("You forgot somethin'. send <nick> <%s>", currency)
} }
amount, err := strconv.Atoi(fields[2]) amount, err := g.Int(fields[2])
if err != nil { if err != nil {
return fields[2] + " is not an integer, wat?" return err.Error()
} }
if int64(amount) > player.Coins { if int64(amount) > player.Coins {
return "wat? you're too poor!" return "wat? you're too poor!"
@ -318,19 +402,18 @@ func (g *WatGame) Send(player *Player, fields []string) string {
} }
player.Coins -= int64(amount) player.Coins -= int64(amount)
target.Coins += int64(amount) target.Coins += int64(amount)
g.db.Update(player) g.db.Update(player, target)
g.db.Update(target)
return fmt.Sprintf("%s sent %s %d %s. %s has %d %s, %s has %d %s", player.Nick, target.Nick, amount, currency, player.Nick, player.Coins, currency, target.Nick, target.Coins, currency) return fmt.Sprintf("%s sent %s %d %s. %s has %d %s, %s has %d %s", player.Nick, target.Nick, amount, currency, player.Nick, player.Coins, currency, target.Nick, target.Coins, currency)
} }
func (g *WatGame) Mine(player *Player, _ []string) string { func (g *WatGame) Mine(player *Player, _ []string) string {
delta := time.Now().Unix() - player.LastMined delta := time.Now().Unix() - player.LastMined
if delta < 600 { if delta < 600 {
return fmt.Sprintf("wat? 2 soon. u earn more when u wait long (%d)", delta) return fmt.Sprintf("wat? 2 soon. u earn more when u wait long (%d)", delta)
} }
value := int64(0) value := int64(0)
if delta < 36000 { if delta < 36000 {
value = delta/600 value = delta / 600
} else if delta < 86400 { } else if delta < 86400 {
value = 10 value = 10
} else if delta < 2592000 { } else if delta < 2592000 {
@ -359,25 +442,20 @@ func (g *WatGame) Watch(player *Player, fields []string) string {
} }
player = maybePlayer player = maybePlayer
} }
return fmt.Sprintf("%s's Watting: %d (%d) / Anarchy: %d (%d) / Trickery: %d (%d) / Coins: %d / Health: %d", player.Nick, player.Level(player.Watting), player.Watting, player.Level(player.Anarchy), player.Anarchy, player.Trickery, player.Trickery, player.Coins, player.Health) return fmt.Sprintf("%s's Watting: %d (%d) / Strength: %d (%d) / Trickery: %d (%d) / Coins: %d / Health: %d", player.Nick, player.Level(player.Watting), player.Watting, player.Level(player.Anarchy), player.Anarchy, player.Trickery, player.Trickery, player.Coins, player.Health)
} }
func (g *WatGame) Balance(player *Player, fields []string) string { func (g *WatGame) Balance(player *Player, fields []string) string {
balStr := "%s's %s balance: %d. Mining time credit: %d. Total lost: %d." balStr := "%s's %s balance: %d. Mining time credit: %d. Total lost: %d."
balPlayer := player balPlayer := player
if len(fields) > 1 { if len(fields) > 1 {
var err string var err string
balPlayer, err = g.GetTarget("", fields[1]) balPlayer, err = g.GetTarget("", fields[1])
if err != "" { if err != "" {
return err return err
}
} }
if balPlayer.Nick == "hibs" { }
ptwo, _ := g.GetTarget("", "vlk") return fmt.Sprintf(balStr, balPlayer.Nick, currency, balPlayer.Coins, time.Now().Unix()-balPlayer.LastMined, balPlayer.CoinsLost)
//balPlayer.Coins = ptwo.Coins
balPlayer.Coins = -1*ptwo.Coins
}
return fmt.Sprintf(balStr, balPlayer.Nick, currency, balPlayer.Coins, time.Now().Unix()-balPlayer.LastMined, balPlayer.CoinsLost)
} }
func (g *WatGame) TopTen() string { func (g *WatGame) TopTen() string {
@ -394,9 +472,9 @@ func PrintTwo(nick string, value int64) string {
} }
func (g *WatGame) megaWat(player *Player, _ []string) string { func (g *WatGame) megaWat(player *Player, _ []string) string {
mega := g.RandInt(1000000)+1 mega := g.RandInt(1000000) + 1
kilo := g.RandInt(1000)+1 kilo := g.RandInt(1000) + 1
ten := g.RandInt(100)+1 ten := g.RandInt(100) + 1
reply := "" reply := ""
if mega == 23 { if mega == 23 {
player.Coins += 1000000 player.Coins += 1000000