Skip to content

Commit

Permalink
Only display break tie if another player has the same score as the cu…
Browse files Browse the repository at this point in the history
…rrent player (#106)
  • Loading branch information
gareththegeek authored Sep 27, 2022
1 parent bf79b1e commit ff914ba
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions client/src/components/nameDie/NameDie.tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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 <></>
}
Expand Down Expand Up @@ -53,7 +57,7 @@ export const NameDie = ({ contestant }: NameDieProps) => {
{isCurrentPlayerRolling && (
<Placeholder className="animate-pulse anim w-full md:w-auto">Rolling Name Die...</Placeholder>
)}
{isCurrentPlayer && !rolling && (
{isCurrentPlayer && !rolling && isTied && (
<Button
className="w-full md:w-auto"
onClick={() => {
Expand Down
2 changes: 1 addition & 1 deletion client/src/slices/contestSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export const updateAsync = createAsyncThunk(
dispatch(contestant.setContestAsync(value))
dispatch(strife.setContestAsync(value))
dispatch(update(value))
console.log('wargs21')

setTimeout(() => {
window.scrollTo({
top: 0,
Expand Down

0 comments on commit ff914ba

Please sign in to comment.