diff options
Diffstat (limited to 'wat/db.go')
-rw-r--r-- | wat/db.go | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -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) |