dkforest

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

commit 4fe268ca6687990ea5e6a3a33a29e47d6d8e7aa8
parent 317c872a63bca8e96b5b6c2ae66fb6196cbd047b
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Fri, 15 Dec 2023 20:57:09 -0500

cleanup

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

diff --git a/pkg/database/tablePokerTables.go b/pkg/database/tablePokerTables.go @@ -86,3 +86,9 @@ func (d *DkfDB) GetPokerTableAccount(userID UserID, pokerTableID int64) (out Pok } return } + +func (d *DkfDB) PokerTableAccountBet(userID UserID, pokerTableID int64, bet PokerChip) (err error) { + err = d.db.Exec(`UPDATE poker_table_accounts SET amount = amount - ?, amount_bet = amount_bet + ? WHERE user_id = ? AND poker_table_id = ?`, + bet, bet, userID, pokerTableID).Error + return +} diff --git a/pkg/web/handlers/poker/poker.go b/pkg/web/handlers/poker/poker.go @@ -130,10 +130,7 @@ func (p *PokerPlayer) isAllIn() bool { } func (p *PokerPlayer) doBet(db *database.DkfDB, bet database.PokerChip, pokerTableID int64, roomTopic string) { - account, _ := db.GetPokerTableAccount(p.UserID, pokerTableID) - account.Amount -= bet - account.AmountBet += bet - account.DoSave(db) + _ = db.PokerTableAccountBet(p.UserID, pokerTableID, bet) p.RoundTotalBet += bet p.Bet += bet p.Cash -= bet