dkforest

A forum and chat platform (onion)
git clone https://git.dasho.dev/n0tr1v/dkforest.git
Log | Files | Refs | LICENSE

tablePokerCasino.go (723B)


      1 package database
      2 
      3 import "fmt"
      4 
      5 // PokerCasino table, should always be one row
      6 type PokerCasino struct {
      7 	ID            int64
      8 	Rake          PokerChip
      9 	HandsPlayed   int64
     10 	TotalRakeBack int64
     11 }
     12 
     13 func (PokerCasino) TableName() string { return "poker_casino" }
     14 
     15 func (d *DkfDB) GetPokerCasino() (out PokerCasino) {
     16 	if err := d.db.Model(PokerCasino{}).First(&out).Error; err != nil {
     17 		if err = d.db.Create(&out).Error; err != nil {
     18 			fmt.Println(err)
     19 		}
     20 	}
     21 	return
     22 }
     23 
     24 func (d *DkfDB) IncrPokerCasinoRake(rake, rakeBack PokerChip) (err error) {
     25 	err = d.db.Exec(`UPDATE poker_casino SET rake = rake + ?, total_rake_back = total_rake_back + ?, hands_played = hands_played + 1 WHERE id = 1`, rake, rakeBack).Error
     26 	return
     27 }