Skip to content

Commit

Permalink
Merge branch 'main' into stop-stopwatch-run
Browse files Browse the repository at this point in the history
  • Loading branch information
marvin-wtt committed Apr 7, 2024
2 parents 22558de + 3122b58 commit 1b8b720
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/components/questions/buzzer/BuzzerScoreboardButtons.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ const props = defineProps<{
controller: IController;
}>();
const emit = defineEmits<{
(e: 'update', correct: boolean | undefined, points: number | undefined): void;
}>();
const audioCorrect = new Audio('sounds/answer-correct.mp3');
const audioWrong = new Audio('sounds/answer-wrong.mp3');
Expand All @@ -54,6 +58,7 @@ const onAnswerChange = (answer: boolean) => {
if (answerCorrect.value === answer) {
answerCorrect.value = undefined;
updateScoreboard(points * -1);
emit('update', undefined, undefined);
return;
}
Expand All @@ -67,6 +72,7 @@ const onAnswerChange = (answer: boolean) => {
answerCorrect.value = answer;
updateScoreboard(points);
emit('update', answer, points);
playAudio(answer);
};
Expand Down
18 changes: 18 additions & 0 deletions src/pages/questions/BuzzerQuestionPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<count-down
v-if="buzzerSettings.answerTime > 0"
v-model="gameState.time"
:paused="gameState.correct !== undefined"
:beep="soundsEnabled"
:beep-start-time="buzzerSettings.countDownBeepStartAt"
:style="countDownStyle"
Expand Down Expand Up @@ -80,6 +81,7 @@
<buzzer-scoreboard-buttons
v-if="showScoreboardActions"
:controller="gameState.controller"
@update="onScored"
/>

<div class="q-pt-md">
Expand Down Expand Up @@ -299,6 +301,22 @@ const listener = (event: ButtonEvent) => {
event.controller.setLight(true);
};
const onScored = (correct: boolean | undefined, points: number | undefined) => {
if (gameState.value.name !== 'answering') {
return;
}
gameState.value = {
game: 'buzzer',
name: 'answering',
time: gameState.value.time,
controller: gameState.value.controller,
disabledControllerIds: gameState.value.disabledControllerIds,
correct,
points,
};
};
const continueQuestion = () => {
if (gameState.value.name !== 'answering') {
return;
Expand Down

0 comments on commit 1b8b720

Please sign in to comment.