dkforest

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

commit 6e911280413d35265853c8976283754530421e54
parent 5df9f0a32ba085dfd14c8c253fea749442201590
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Tue, 12 Dec 2023 17:27:27 -0500

cleanup

Diffstat:
Mpkg/database/tablePokerTables.go | 6++++++
Mpkg/web/handlers/poker/poker.go | 7++-----
2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/pkg/database/tablePokerTables.go b/pkg/database/tablePokerTables.go @@ -43,6 +43,12 @@ func (a *PokerTableAccount) DoSave(db *DkfDB) { } } +func (a *PokerTableAccount) RefundBetAndSave(db *DkfDB) { + a.Amount += a.AmountBet + a.AmountBet = 0 + a.DoSave(db) +} + func (d *DkfDB) GetPositivePokerTableAccounts() (out []PokerTableAccount, err error) { err = d.db.Preload("PokerTable").Find(&out, "amount > 0 OR amount_bet > 0").Error return diff --git a/pkg/web/handlers/poker/poker.go b/pkg/web/handlers/poker/poker.go @@ -916,9 +916,7 @@ END: tx := db.Begin() for _, p := range g.Ongoing.Players { account, _ := tx.GetPokerTableAccount(p.UserID, g.PokerTableID) - account.Amount += account.AmountBet - account.AmountBet = 0 - account.DoSave(tx) + account.RefundBetAndSave(tx) } tx.Commit() } @@ -1192,9 +1190,8 @@ func Refund(db *database.DkfDB) { tx := db.Begin() for _, account := range accounts { if user, err := tx.GetUserByID(account.UserID); err == nil { - account.Amount += account.AmountBet if account.PokerTable.IsTest { - user.ChipsTest += int(account.Amount) + user.ChipsTest += int(account.Amount + account.AmountBet) } account.Amount = 0 account.AmountBet = 0