Skip to content

Commit

Permalink
Fix duplicate issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladimir-Urik committed Apr 2, 2024
1 parent 9024230 commit 355a02e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions src/components/Game.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,16 @@ export function Game({ setGradient }: GameProps) {
truth = true
) => {
const texts = data[category][truth ? 'truth' : 'dare']
return texts[Math.floor(Math.random() * texts.length)]
if (texts.length === 1) {
return texts[0]
}

const randomText = texts[Math.floor(Math.random() * texts.length)]
while (randomText === text) {
return texts[Math.floor(Math.random() * texts.length)]
}

return randomText
}

const getRandomText = () => {
Expand All @@ -44,7 +53,7 @@ export function Game({ setGradient }: GameProps) {
audio.click.playbackRate = 1.5
audio.click.play()
const truth = Math.random() < 0.3
const group = Math.random() < 0.15
const group = Math.random() < 0.1

setTruth(truth)
if (group) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Guidelines.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const Guidelines = () => {
<span className={'font-bold'}>Šance na úkol:</span> 70%
</li>
<li>
<span className={'font-bold'}>Šance na skupinový úkol:</span> 15%
<span className={'font-bold'}>Šance na skupinový úkol:</span> 10%
</li>
</ul>
</div>
Expand Down

0 comments on commit 355a02e

Please sign in to comment.