handle NewBlinds messages in chat; hide dealer chip when there is no dealer; fix...
authorGeoffrey Allott <geoffrey@allott.email>
Sat, 27 May 2023 14:01:19 +0000 (15:01 +0100)
committerGeoffrey Allott <geoffrey@allott.email>
Sat, 27 May 2023 14:01:19 +0000 (15:01 +0100)
site/modules/chatroom.js
site/modules/poker.js

index c9f729934584d9c5cfea8dfbad985754e78bec36..b2b17a1ff5c17b497336d8ebd8dd8c5d65768855 100644 (file)
@@ -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));
index 4002d09fbf8089c50f33cab70a73129c28f55cc5..b2e57616b48182ae3f5750fdb37e21fc8e5fac29 100644 (file)
@@ -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);