int64 -> uint64 for coins, disable noisy logging, turned off wattery (it was quickly abused), made anarchy less likely to win and time limited

This commit is contained in:
alex 2018-12-03 23:21:11 +00:00
parent 88d612e041
commit ca91956e27
3 changed files with 15 additions and 20 deletions

View File

@ -121,7 +121,7 @@ func (w *WatBot) say(dest, msg string) {
if len(msg) == 0 { if len(msg) == 0 {
return return
} }
fmt.Printf("MSG %s: %s\n", dest, msg) //fmt.Printf("MSG %s: %s\n", dest, msg)
w.write("PRIVMSG", dest, msg) w.write("PRIVMSG", dest, msg)
} }

View File

@ -20,6 +20,7 @@ type Player struct {
LastMined int64 LastMined int64
LastRested int64 LastRested int64
CoinsLost uint64 CoinsLost uint64
Bankrupcy int64 // how many times someone has been bankrupt
} }
type Action struct { type Action struct {
@ -78,7 +79,7 @@ func (w *WatDb) User(nick, host string, create bool) Player {
func (w *WatDb) Update(upd ...interface{}) { func (w *WatDb) Update(upd ...interface{}) {
for _, u := range upd { for _, u := range upd {
fmt.Printf("Updating %+v\n", u) //fmt.Printf("Updating %+v\n", u)
w.db.Save(u) w.db.Save(u)
} }
} }

View File

@ -27,7 +27,7 @@ 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,
@ -45,7 +45,6 @@ func NewWatGame(bot *WatBot, db *WatDb) *WatGame {
"steal": g.Steal, "steal": g.Steal,
"frame": g.Frame, "frame": g.Frame,
"punch": g.Punch, "punch": g.Punch,
"quest": g.QuestStart,
} }
return &g return &g
} }
@ -66,8 +65,6 @@ func (g *WatGame) Msg(m *irc.Message, player *Player, fields []string) {
reply = fmt.Sprintf("%s holders: %s", currency, g.TopTen()) reply = fmt.Sprintf("%s holders: %s", currency, g.TopTen())
case "source": case "source":
reply = "https://git.circuitco.de/self/watbot" reply = "https://git.circuitco.de/self/watbot"
case "butt":
reply = "I LOVE BUTTS"
} }
} }
if g.lifeCommands[command] != nil { if g.lifeCommands[command] != nil {
@ -176,16 +173,19 @@ func (g *WatGame) Roll(player *Player, fields []string) string {
if amount > player.Coins { if amount > player.Coins {
return "wat? brokeass" return "wat? brokeass"
} }
n := g.RandInt(100) + 1 n := int64(g.RandInt(100)) + 1
ret := fmt.Sprintf("%s rolls a 1d100... %d! ", player.Nick, n) ret := fmt.Sprintf("%s rolls the 100 sided die... %d! ", player.Nick, n)
if player.Nick == "vlk" {
n -= 5
}
if n < 50 { if n < 50 {
player.Coins += amount player.Coins += amount
ret += fmt.Sprintf("You win! total: %d %s", player.Coins, currency) ret += fmt.Sprintf("You win! ◕ ◡ ◕ total: %d %s", player.Coins, currency)
} else { } else {
player.LoseCoins(amount) player.LoseCoins(amount)
g.me.Coins += amount g.me.Coins += amount
g.db.Update(g.me) g.db.Update(g.me)
ret += fmt.Sprintf("You lose! %d %s left...", player.Coins, currency) ret += fmt.Sprintf("You lose! ≧ヮ≦ %d %s left...", player.Coins, currency)
} }
g.db.Update(player) g.db.Update(player)
return ret return ret
@ -377,7 +377,6 @@ func (g *WatGame) Bench(player *Player, fields []string) string {
if !g.CanAct(player, Action_Lift, minTime) { if !g.CanAct(player, Action_Lift, minTime) {
return "you're tired. no more lifting for now." return "you're tired. no more lifting for now."
} }
return "ok"
weight := g.RandInt(370) + 50 weight := g.RandInt(370) + 50
reps := g.RandInt(10) reps := g.RandInt(10)
value := int64(0) value := int64(0)
@ -406,9 +405,9 @@ func (g *WatGame) Riot(player *Player, fields []string) string {
} }
r := g.RandInt(100) r := g.RandInt(100)
reply := "" reply := ""
if r > 30 { if r > 40 {
player.Anarchy += 10 player.Anarchy += 3
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)) reply = fmt.Sprintf("%s has successfully smashed the state! The brogeoise have been toppled. You feel stronger...", player.Nick)
} else { } else {
player.Health -= 3 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.") 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.")
@ -418,11 +417,6 @@ func (g *WatGame) Riot(player *Player, fields []string) string {
return reply return reply
} }
func (g *WatGame) QuestStart(player *Player, fields []string) string {
// Begin a quest with some people. It will involve multiple dice rolls.
return ""
}
func (g *WatGame) Send(player *Player, fields []string) string { 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)
@ -481,7 +475,7 @@ func (g *WatGame) Watch(player *Player, fields []string) string {
} }
player = maybePlayer player = maybePlayer
} }
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) return fmt.Sprintf("%s's Strength: %d (%d) / Trickery: %d (%d) / Coins: %d / Health: %d", player.Nick, 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 {