dkforest

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

commit c756e0528bf74694fcd1b4921e1e6b4ef733abef
parent 6b554654bccba3bf30b5ab2c02f09035468ab905
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Sun, 17 Dec 2023 01:35:29 -0500

fix db sync

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

diff --git a/pkg/database/tablePokerTables.go b/pkg/database/tablePokerTables.go @@ -108,6 +108,12 @@ func (d *DkfDB) PokerTableAccountRefundBet(userID UserID, pokerTableID int64) (e return } +func (d *DkfDB) PokerTableAccountRefundPartialBet(userID UserID, pokerTableID int64, diff 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 = ?`, + diff, diff, userID, pokerTableID).Error + return +} + func (d *DkfDB) PokerTableAccountGain(userID UserID, pokerTableID int64, gain PokerChip) (err error) { err = d.db.Exec(`UPDATE poker_table_accounts SET amount = amount + ?, amount_bet = 0 WHERE user_id = ? AND poker_table_id = ?`, gain, userID, pokerTableID).Error diff --git a/pkg/web/handlers/poker/poker.go b/pkg/web/handlers/poker/poker.go @@ -821,6 +821,7 @@ RoundIsSettled: firstPlayer := newArray[0] secondPlayer := newArray[1] diff := firstPlayer.Bet - secondPlayer.Bet + _ = db.PokerTableAccountRefundPartialBet(firstPlayer.UserID, g.PokerTableID, diff) firstPlayer.Bet -= diff firstPlayer.Cash += diff } @@ -828,6 +829,7 @@ RoundIsSettled: // Transfer players bets into the main pot for _, p := range g.Ongoing.Players { mainPot += p.Bet + _ = db.PokerTableAccountResetAmountBet(p.UserID, g.PokerTableID) p.Bet = 0 }