From ff914ba86aeb5cff248974a7ee19c808f6226601 Mon Sep 17 00:00:00 2001 From: gareththegeek Date: Tue, 27 Sep 2022 14:01:06 +0100 Subject: [PATCH] Only display break tie if another player has the same score as the current player (#106) --- client/src/components/nameDie/NameDie.tsx | 10 +++++++--- client/src/slices/contestSlice.ts | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/client/src/components/nameDie/NameDie.tsx b/client/src/components/nameDie/NameDie.tsx index 82e9d51..4b29e68 100644 --- a/client/src/components/nameDie/NameDie.tsx +++ b/client/src/components/nameDie/NameDie.tsx @@ -1,7 +1,7 @@ import React, { useState } from 'react' import { useSelector } from 'react-redux' import { Contestant } from '../../api/contestants' -import { selectRollingNameDie } from '../../slices/contestantSlice' +import { selectContestants, selectRollingNameDie } from '../../slices/contestantSlice' import { selectPlayerId } from '../../slices/playerSlice' import { Button } from '../Button' import { FieldSet } from '../FieldSet' @@ -18,11 +18,15 @@ export const NameDie = ({ contestant }: NameDieProps) => { const playerId = useSelector(selectPlayerId) const isCurrentPlayer = playerId === contestant.playerId const isCurrentPlayerRolling = isCurrentPlayer && rolling + const isTied = Object.values(useSelector(selectContestants)) + .some(c => c.dicePool.score === contestant.dicePool.score && c.playerId !== contestant.playerId) + console.log(Object.values(useSelector(selectContestants))) + console.log(isTied) const [showDiceSelector, setShowDiceSelector] = useState(false) const nameDie = contestant.dicePool.nameDie - + if (!isCurrentPlayer) { return <> } @@ -53,7 +57,7 @@ export const NameDie = ({ contestant }: NameDieProps) => { {isCurrentPlayerRolling && ( Rolling Name Die... )} - {isCurrentPlayer && !rolling && ( + {isCurrentPlayer && !rolling && isTied && (