summaryrefslogtreecommitdiffstats
path: root/wat/db.go
diff options
context:
space:
mode:
authoralex2018-11-14 22:38:32 +0000
committeralex2018-11-14 22:38:32 +0000
commit5c24c985d30b8b2cb3451a68bcfc1dc43c2949a7 (patch)
treeba5a8e45959984afe19f7b720a4d85d6a63c74a3 /wat/db.go
parent237d91de163b1c20e6e5aaf49ee802dbde2397d6 (diff)
downloadwatbot-5c24c985d30b8b2cb3451a68bcfc1dc43c2949a7.tar.gz
watbot-5c24c985d30b8b2cb3451a68bcfc1dc43c2949a7.tar.bz2
watbot-5c24c985d30b8b2cb3451a68bcfc1dc43c2949a7.zip
changed coins to uint64 and started using uints all over the place
added toplost removed an ignore
Diffstat (limited to 'wat/db.go')
-rw-r--r--wat/db.go12
1 files changed, 9 insertions, 3 deletions
diff --git a/wat/db.go b/wat/db.go
index d04514d..f609597 100644
--- a/wat/db.go
+++ b/wat/db.go
@@ -15,14 +15,14 @@ type Player struct {
Watting int64
Anarchy int64
Trickery int64
- Coins int64 `gorm:"default:'100'"`
+ Coins uint64 `gorm:"default:'100'"`
Health int64
LastMined int64
LastRested int64
- CoinsLost int64
+ CoinsLost uint64
}
-func (p *Player) LoseCoins(coins int64) {
+func (p *Player) LoseCoins(coins uint64) {
p.Coins -= coins
p.CoinsLost += coins
}
@@ -97,6 +97,12 @@ func (w *WatDb) Update(upd ...interface{}) {
}
}
+func (w *WatDb) TopLost() []Player {
+ var user = make([]Player, 10)
+ w.db.Limit(10).Order("coins_lost desc").Find(&user)
+ return user
+}
+
func (w *WatDb) TopTen() []Player {
var user = make([]Player, 10)
w.db.Limit(10).Order("coins desc").Find(&user)