From b9e69136d3790236c6586c4b467607a0ef4d8194 Mon Sep 17 00:00:00 2001 From: uncaught Date: Tue, 23 Jun 2020 18:49:24 +0200 Subject: [PATCH] Fix detection of solo player if he would be the dealer himself (fixes #15) --- .../src/store/Games/DetectLastGameAndForcedSolo.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/client/src/store/Games/DetectLastGameAndForcedSolo.ts b/client/src/store/Games/DetectLastGameAndForcedSolo.ts index 886b9ed..9b24f6b 100644 --- a/client/src/store/Games/DetectLastGameAndForcedSolo.ts +++ b/client/src/store/Games/DetectLastGameAndForcedSolo.ts @@ -30,12 +30,18 @@ export function detectLastGameAndForcedSolo( //Find the players that are still present and still need their solo: const open = playersWithStats.filter(({player, dutySoloPlayed}) => !dutySoloPlayed && activePlayers.includes(player)); - if (open.length < remainingRegularGames) { + const openIndexes = open.map(({player}) => activePlayers.indexOf(player)); + const countIndexesAfterDealer = openIndexes.filter((idx) => idx > nextDealerIndex).length; + + if (open.length < remainingRegularGames + + //Make sure the player does not have to deal when he is supposed to have his forced solo: + && (activePlayers.length < 5 || countIndexesAfterDealer !== 1 || remainingRegularGames > 2) + && (activePlayers.length < 6 || countIndexesAfterDealer !== 2 || remainingRegularGames > 3) + ) { return; } - const openIndexes = open.map(({player}) => activePlayers.indexOf(player)); - gameData.gameType = 'forcedSolo'; gameData.re.members = []; gameData.contra.members = [];