check only nonempty hands to see if all players have passed
authorGeoffrey Allott <geoffrey@allott.email>
Wed, 14 Jun 2023 18:48:02 +0000 (19:48 +0100)
committerGeoffrey Allott <geoffrey@allott.email>
Wed, 14 Jun 2023 18:48:02 +0000 (19:48 +0100)
site/modules/cribbage.js

index ac71cdac3169e17309041239c5c1000395735554..0b873195cda9f207205b5f5e8ada0a5c43ca8e93 100644 (file)
@@ -272,7 +272,7 @@ export class Cribbage extends GameWithChat {
                 break;
             case "Pass":
                 this.passed.add(user_action.username);
-                if (this.passed.size === this.hands.size) {
+                if (this.passed.size === [...this.hands.values()].filter(hand => hand.length > 0).length) {
                     this.clear_pegging();
                 }
                 this.active = this.player_after(user_action.username, username => !this.passed.has(username) && this.hands.has(username) && this.hands.get(username).length > 0);