fix player_after bugs
authorGeoffrey Allott <geoffrey@allott.email>
Wed, 14 Jun 2023 10:54:27 +0000 (11:54 +0100)
committerGeoffrey Allott <geoffrey@allott.email>
Wed, 14 Jun 2023 10:54:27 +0000 (11:54 +0100)
site/modules/cribbage.js
site/modules/game.js

index 8cf308731ae1439f2343cfff33c38bc882531946..ac71cdac3169e17309041239c5c1000395735554 100644 (file)
@@ -266,7 +266,7 @@ export class Cribbage extends GameWithChat {
                 if (this.count === 31) {
                     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);
+                this.active = this.player_after(user_action.username, username => !this.passed.has(username) && this.hands.has(username) && this.hands.get(username).length > 0);
                 this.redraw_cards();
                 this.redraw_players();
                 break;
@@ -275,7 +275,7 @@ export class Cribbage extends GameWithChat {
                 if (this.passed.size === this.hands.size) {
                     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);
+                this.active = this.player_after(user_action.username, username => !this.passed.has(username) && this.hands.has(username) && this.hands.get(username).length > 0);
                 this.redraw_cards();
                 this.redraw_players();
                 break;
index 33564d0b42a717cd95887733e9b1232e1cae52d9..c00049838cbef26ef409b95682b4d134d77ddb29 100644 (file)
@@ -45,7 +45,7 @@ export class Game {
             }
         }
         if (player_after_seat === null) for (const [username, seat] of this.seats) {
-            if (is_playing(username) && player_after_seat === null || seat < player_after_seat) {
+            if (is_playing(username) && (player_after_seat === null || seat < player_after_seat)) {
                 player_after = username;
                 player_after_seat = seat;
             }