Skip to content

Commit ff914ba

Browse files
Only display break tie if another player has the same score as the current player (#106)
1 parent bf79b1e commit ff914ba

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

client/src/components/nameDie/NameDie.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useState } from 'react'
22
import { useSelector } from 'react-redux'
33
import { Contestant } from '../../api/contestants'
4-
import { selectRollingNameDie } from '../../slices/contestantSlice'
4+
import { selectContestants, selectRollingNameDie } from '../../slices/contestantSlice'
55
import { selectPlayerId } from '../../slices/playerSlice'
66
import { Button } from '../Button'
77
import { FieldSet } from '../FieldSet'
@@ -18,11 +18,15 @@ export const NameDie = ({ contestant }: NameDieProps) => {
1818
const playerId = useSelector(selectPlayerId)
1919
const isCurrentPlayer = playerId === contestant.playerId
2020
const isCurrentPlayerRolling = isCurrentPlayer && rolling
21+
const isTied = Object.values(useSelector(selectContestants))
22+
.some(c => c.dicePool.score === contestant.dicePool.score && c.playerId !== contestant.playerId)
23+
console.log(Object.values(useSelector(selectContestants)))
24+
console.log(isTied)
2125

2226
const [showDiceSelector, setShowDiceSelector] = useState(false)
2327

2428
const nameDie = contestant.dicePool.nameDie
25-
29+
2630
if (!isCurrentPlayer) {
2731
return <></>
2832
}
@@ -53,7 +57,7 @@ export const NameDie = ({ contestant }: NameDieProps) => {
5357
{isCurrentPlayerRolling && (
5458
<Placeholder className="animate-pulse anim w-full md:w-auto">Rolling Name Die...</Placeholder>
5559
)}
56-
{isCurrentPlayer && !rolling && (
60+
{isCurrentPlayer && !rolling && isTied && (
5761
<Button
5862
className="w-full md:w-auto"
5963
onClick={() => {

client/src/slices/contestSlice.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export const updateAsync = createAsyncThunk(
119119
dispatch(contestant.setContestAsync(value))
120120
dispatch(strife.setContestAsync(value))
121121
dispatch(update(value))
122-
console.log('wargs21')
122+
123123
setTimeout(() => {
124124
window.scrollTo({
125125
top: 0,

0 commit comments

Comments
 (0)