disable fold action and change "call" to "check" when chips_to_call is 0
authorGeoffrey Allott <geoffrey@allott.email>
Sat, 6 Mar 2021 08:23:36 +0000 (08:23 +0000)
committerGeoffrey Allott <geoffrey@allott.email>
Sat, 6 Mar 2021 13:32:12 +0000 (13:32 +0000)
site/modules/poker.js

index 08fda651dd5f3c8977b6a8a15f339ecdcacda888..860647001fe4e5879e706e0f75e5ace8d5396401 100644 (file)
@@ -83,8 +83,8 @@ export class TexasHoldEm {
         this.svg.append(this.call_control);
 
         const call_control_label = document.createElementNS(svgns, "text");
-        const call_control_text = document.createTextNode("Call");
-        call_control_label.append(call_control_text);
+        this.call_control_text = document.createTextNode("Call");
+        call_control_label.append(this.call_control_text);
         call_control_label.setAttribute("x", "385");
         call_control_label.setAttribute("y", "470");
         call_control_label.classList.add("call-control-label");
@@ -124,8 +124,9 @@ export class TexasHoldEm {
     }
 
     redraw_players() {
-        this.fold_control.classList.toggle("active", this.active === this.username);
+        this.fold_control.classList.toggle("active", this.active === this.username && this.chips_to_call() > 0);
         this.call_control.classList.toggle("active", this.active === this.username);
+        this.call_control_text.textContent = this.active === this.username && this.chips_to_call() == 0 ? "Check" : "Call";
         this.bet_control.classList.toggle("active", this.active === this.username);
         for (const [username, [user, stack, active, bet]] of this.user_icons) {
             if (!this.seats.has(username)) {