From 304fcff75c561115d2816f8bb9c1074b70a204ee Mon Sep 17 00:00:00 2001 From: alex Date: Wed, 10 Jul 2019 16:29:44 +0100 Subject: fixes #5 --- wat/db.go | 4 ++++ wat/game.go | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/wat/db.go b/wat/db.go index 672d65d..aa86f1c 100644 --- a/wat/db.go +++ b/wat/db.go @@ -128,6 +128,10 @@ func (w *WatDb) TopLost() []Player { return w.GetTopColumn("coins_lost") } +func (w *WatDb) Bankruptest() []Player { + return w.GetTopColumn("bankrupcy") +} + func (w *WatDb) TopTen() []Player { var user = make([]Player, 10) w.db.Where("nick != 'watt'").Limit(10).Order("coins desc").Find(&user) diff --git a/wat/game.go b/wat/game.go index 452534f..6f19dc3 100644 --- a/wat/game.go +++ b/wat/game.go @@ -60,6 +60,7 @@ func NewWatGame(bot *WatBot, db *WatDb) *WatGame { "healthiest", "losers", "richest", + "bankruptest", } return &g } @@ -86,6 +87,8 @@ func (g *WatGame) Msg(m *irc.Message, player *Player, fields []string) { reply = fmt.Sprintf("%s losers: %s", currency, g.TopLost()) case "richest": reply = fmt.Sprintf("%s holders: %s", currency, g.TopTen()) + case "bankruptest": + reply = fmt.Sprintf("most indebited: %s", g.Bankrupest()) case "source": reply = "https://git.circuitco.de/self/watbot" } @@ -588,6 +591,15 @@ func (g *WatGame) TopLost() string { return ret } +func (g *WatGame) Bankrupest() string { + players := g.db.Bankruptest() + ret := "" + for _, p := range players { + ret += fmt.Sprintf("%s (%d) ", CleanNick(p.Nick), p.Bankrupcy) + } + return ret +} + func (g *WatGame) TopTen() string { players := g.db.TopTen() ret := "" -- cgit v1.2.3