summaryrefslogtreecommitdiffstats
path: root/wat/db.go
diff options
context:
space:
mode:
authoralex2019-06-28 18:54:32 +0100
committeralex2019-06-28 18:54:32 +0100
commit62144ce8a1b71cdaeac5bc946d1e735299729b16 (patch)
tree0cbd8118b743b5b26c351d6c070a3c910a066d72 /wat/db.go
parent3b9233307acfc32414ec982cca2cf72471ac4d50 (diff)
downloadwatbot-62144ce8a1b71cdaeac5bc946d1e735299729b16.tar.gz
watbot-62144ce8a1b71cdaeac5bc946d1e735299729b16.tar.bz2
watbot-62144ce8a1b71cdaeac5bc946d1e735299729b16.zip
fixes #7
Diffstat (limited to 'wat/db.go')
-rw-r--r--wat/db.go14
1 files changed, 10 insertions, 4 deletions
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 {