commit 5748258b976f798061e777424e1e17218d5fd0aa
parent 876b0722e4fa10c4612f7065b1097714a3564d55
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Tue, 12 Dec 2023 06:06:47 -0500
add error msg
Diffstat:
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/cmd/dkf/migrations/147.sql b/cmd/dkf/migrations/147.sql
@@ -11,6 +11,11 @@ CREATE INDEX poker_tables_slug_idx ON poker_tables (slug);
CREATE INDEX poker_tables_is_test_idx ON poker_tables (is_test);
INSERT INTO poker_tables (slug, name, min_buy_in, max_buy_in, min_bet, is_test) VALUES ('test', 'test', 1000, 2000, 20, 1);
+INSERT INTO poker_tables (slug, name, min_buy_in, max_buy_in, min_bet, is_test) VALUES ('test1', 'test1', 1000, 2000, 20, 1);
+INSERT INTO poker_tables (slug, name, min_buy_in, max_buy_in, min_bet, is_test) VALUES ('test2', 'test2', 1000, 2000, 20, 1);
+INSERT INTO poker_tables (slug, name, min_buy_in, max_buy_in, min_bet, is_test) VALUES ('test3', 'test3', 1000, 2000, 20, 1);
+INSERT INTO poker_tables (slug, name, min_buy_in, max_buy_in, min_bet, is_test) VALUES ('test4', 'test4', 1000, 2000, 20, 1);
+INSERT INTO poker_tables (slug, name, min_buy_in, max_buy_in, min_bet, is_test) VALUES ('test5', 'test5', 1000, 2000, 20, 1);
CREATE TABLE IF NOT EXISTS poker_table_accounts (
id INTEGER NOT NULL PRIMARY KEY,
diff --git a/pkg/web/handlers/poker/poker.go b/pkg/web/handlers/poker/poker.go
@@ -1237,6 +1237,7 @@ func PokerSitHandler(c echo.Context) error {
return c.HTML(http.StatusOK, html)
}
roomTopic := "room_" + roomID
+ roomUserTopic := "room_" + roomID + "_" + authUser.Username.String()
roomLogsTopic := "room_" + roomID + "_logs"
g := PokerInstance.GetGame(roomID)
if g == nil {
@@ -1253,7 +1254,9 @@ func PokerSitHandler(c echo.Context) error {
if tableAccount.PokerTable.IsTest {
userChips = int64(authUser.ChipsTest)
}
- if userChips+tableAccount.Amount < pokerTable.MinBuyIn {
+ totalChips := userChips + tableAccount.Amount
+ if totalChips < pokerTable.MinBuyIn {
+ PokerPubSub.Pub(roomUserTopic, ErrorMsgEvent{Message: fmt.Sprintf("Not enough chips to sit; have: %d; needs: %d", totalChips, pokerTable.MinBuyIn)})
return c.HTML(http.StatusOK, html)
}
needed := pokerTable.MinBuyIn - tableAccount.Amount