diff --git a/src/screens/Game.tsx b/src/screens/Game.tsx index a0bf113..b976231 100644 --- a/src/screens/Game.tsx +++ b/src/screens/Game.tsx @@ -10,10 +10,9 @@ import '../static/styles/home.css'; import { useParams } from 'react-router-dom'; import useGame from '../hooks/useGame'; import QuestionsService from '../services/questions.service'; -import wrongAnswerSound from '../static/x.mp3'; import wrongAnswerPng from '../static/x.png'; import { truncateQuestion } from '../helpers/truncate-question'; -import { useSounds } from '../hooks/useSounds.hook'; +import { WRONG_ANSWER_TIME } from '../utils/contants'; const Game = () => { const [currentQuestion, setCurrentQuestion] = useState(); @@ -37,15 +36,11 @@ const Game = () => { if (game?.wrongAnswer === 0) { return; } - const audio = new Audio(wrongAnswerSound); - const { play, stop } = useSounds(audio); - play(audio); setWrongAnswers(Math.min(3, game.wrongAnswer)); setTimeout(() => { setWrongAnswers(0); - stop(audio); - }, 2000); + }, WRONG_ANSWER_TIME); }, [game?.wrongAnswer]); useEffect(() => { diff --git a/src/shared/GameRound/GameRoundAdmin.tsx b/src/shared/GameRound/GameRoundAdmin.tsx index 2fe0248..8591ac2 100644 --- a/src/shared/GameRound/GameRoundAdmin.tsx +++ b/src/shared/GameRound/GameRoundAdmin.tsx @@ -20,6 +20,8 @@ import { NormalGame } from '../../types/game'; import { useSounds } from '../../hooks/useSounds.hook'; import round_start from '../../static/round_start.mp3'; import correct_answer from '../../static/correct_answer.mp3'; +import wrongAnswerSound from '../../static/x.mp3'; +import { WRONG_ANSWER_TIME } from '../../utils/contants'; const GameRoundAdmin = (props: any) => { const [questions, setQuestions] = useState([]); @@ -101,6 +103,9 @@ const GameRoundAdmin = (props: any) => { }; const setAllWrong = () => { + if (counterWrongAnswers != 3){ + playSound(wrongAnswerSound, WRONG_ANSWER_TIME); + } GamesService.update(selectedGame, { ...game, wrongAnswer: 3 @@ -380,12 +385,20 @@ const GameRoundAdmin = (props: any) => {

Wrong answers

-