From 62144ce8a1b71cdaeac5bc946d1e735299729b16 Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 28 Jun 2019 18:54:32 +0100 Subject: fixes #7 --- wat/db.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'wat/db.go') diff --git a/wat/db.go b/wat/db.go index fb677d8..672d65d 100644 --- a/wat/db.go +++ b/wat/db.go @@ -111,15 +111,21 @@ func (w *WatDb) Act(player *Player, actionType ActionType) { } func (w *WatDb) Strongest() []Player { + return w.GetTopColumn("anarchy") +} + +func (w *WatDb) GetTopColumn(tipe string) []Player { var user = make([]Player, 10) - w.db.Limit(10).Order("anarchy desc").Find(&user) + w.db.Limit(10).Order(tipe + " desc").Find(&user) return user } +func (w *WatDb) Healthiest() []Player { + return w.GetTopColumn("health") +} + func (w *WatDb) TopLost() []Player { - var user = make([]Player, 10) - w.db.Limit(10).Order("coins_lost desc").Find(&user) - return user + return w.GetTopColumn("coins_lost") } func (w *WatDb) TopTen() []Player { -- cgit v1.2.3