From cdf3df7cfd9970f8d3b7c152f3214a46e35f09c0 Mon Sep 17 00:00:00 2001 From: Geoffrey Allott Date: Sat, 27 May 2023 15:01:19 +0100 Subject: [PATCH] handle NewBlinds messages in chat; hide dealer chip when there is no dealer; fix some but not all issues with buttons being active at incorrect times --- site/modules/chatroom.js | 5 +++++ site/modules/poker.js | 10 +++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/site/modules/chatroom.js b/site/modules/chatroom.js index c9f7299..b2b17a1 100644 --- a/site/modules/chatroom.js +++ b/site/modules/chatroom.js @@ -67,6 +67,11 @@ export class Chatroom { this.chat.append(this.info_element(user_action.username, "Posts blind of " + user_action.action.chips)); } break; + case "NewBlinds": + this.chat.append(this.info_element(user_action.username, "Blinds Up: " + + "Level " + user_action.action.level + + ": " + user_action.action.small_blind + "/" + user_action.action.big_blind)); + break; case "Bet": const text = user_action.action.chips === 0 ? "Checks" : "Bets " + user_action.action.chips; this.chat.append(this.info_element(user_action.username, text)); diff --git a/site/modules/poker.js b/site/modules/poker.js index 4002d09..b2e5761 100644 --- a/site/modules/poker.js +++ b/site/modules/poker.js @@ -153,7 +153,7 @@ export class TexasHoldEm { this.pot_size_text = document.createTextNode(""); pot_size.append(this.pot_size_text); - this.dealer_chip = create_svg_element(this.svg, "ellipse", ["dealer-chip"], [["cx", "250"], ["cy", "250"], ["rx", "10"], ["ry", "5"]]); + this.dealer_chip = create_svg_element(this.svg, "ellipse", ["dealer-chip"], [["cx", "250"], ["cy", "250"], ["rx", "10"], ["ry", "5"], ["visibility", "hidden"]]); const defs = create_svg_element(this.svg, "defs", [], []); const dealer_chip_gradient = create_svg_element(defs, "radialGradient", [], [["id", "dealer-chip-gradient"]]); const stop1 = create_svg_element(dealer_chip_gradient, "stop", [], [["offset", "0%"], ["stop-color", "red"]]); @@ -241,6 +241,9 @@ export class TexasHoldEm { const y = 245 + 52 * Math.cos(angle); this.dealer_chip.setAttribute("cx", x); this.dealer_chip.setAttribute("cy", y); + this.dealer_chip.setAttribute("visibility", "visible"); + } else { + this.dealer_chip.setAttribute("visibility", "hidden"); } for (const [username, [user, stack, active, bet]] of this.user_icons) { if (!this.seats.has(username)) { @@ -502,6 +505,8 @@ export class TexasHoldEm { this.redraw_cards(); break; case "RevealCard": + this.active = null; + this.bet_controls.redraw(); if (!this.user_has_card(user_action.username, user_action.action.card)) { for (const card of this.hands.get(user_action.username)) { if (card.card === null) { @@ -538,7 +543,9 @@ export class TexasHoldEm { this.set_info_text(user_action.username + " wins " + user_action.action.chips + " chips" + (user_action.action.hand === null ? "" : " with\n" + user_action.action.hand)); + this.active = null; this.redraw_players(); + break; case "EndDeal": this.active = this.player_after(user_action.username, username => true); this.redraw_players(); @@ -555,6 +562,7 @@ export class TexasHoldEm { this.svg.removeChild(card.image); } } + this.pot = 0; this.hands.clear(); this.redraw_players(); new CongratulateWinner(this.svg, user_action.username); -- 2.34.1