This commit is contained in:
alex 2019-07-10 16:29:44 +01:00
parent e1eddb1b11
commit 304fcff75c
2 changed files with 16 additions and 0 deletions

View File

@ -128,6 +128,10 @@ func (w *WatDb) TopLost() []Player {
return w.GetTopColumn("coins_lost") return w.GetTopColumn("coins_lost")
} }
func (w *WatDb) Bankruptest() []Player {
return w.GetTopColumn("bankrupcy")
}
func (w *WatDb) TopTen() []Player { func (w *WatDb) TopTen() []Player {
var user = make([]Player, 10) var user = make([]Player, 10)
w.db.Where("nick != 'watt'").Limit(10).Order("coins desc").Find(&user) w.db.Where("nick != 'watt'").Limit(10).Order("coins desc").Find(&user)

View File

@ -60,6 +60,7 @@ func NewWatGame(bot *WatBot, db *WatDb) *WatGame {
"healthiest", "healthiest",
"losers", "losers",
"richest", "richest",
"bankruptest",
} }
return &g 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()) reply = fmt.Sprintf("%s losers: %s", currency, g.TopLost())
case "richest": case "richest":
reply = fmt.Sprintf("%s holders: %s", currency, g.TopTen()) reply = fmt.Sprintf("%s holders: %s", currency, g.TopTen())
case "bankruptest":
reply = fmt.Sprintf("most indebited: %s", g.Bankrupest())
case "source": case "source":
reply = "https://git.circuitco.de/self/watbot" reply = "https://git.circuitco.de/self/watbot"
} }
@ -588,6 +591,15 @@ func (g *WatGame) TopLost() string {
return ret 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 { func (g *WatGame) TopTen() string {
players := g.db.TopTen() players := g.db.TopTen()
ret := "" ret := ""