Added Image Questions
This commit is contained in:
@@ -3,11 +3,12 @@
|
||||
import { page } from "$app/state";
|
||||
import { error } from "@sveltejs/kit";
|
||||
import SimpleQuestionComponent from "$lib/SimpleQuestionComponent.svelte";
|
||||
import { isMultipleChoiceQuestion, isSimpleQuestion } from "$lib/games/games";
|
||||
import { isImageQuestion, isMultipleChoiceQuestion, isSimpleQuestion } from "$lib/games/games";
|
||||
import ws from "$lib/websocket.svelte";
|
||||
import { MessageType } from "$lib/MessageType";
|
||||
import { untrack } from "svelte";
|
||||
import MultipleChoiceQuestionComponent from "$lib/MultipleChoiceQuestionComponent.svelte";
|
||||
import ImageQuestionComponent from "$lib/ImageQuestionComponent.svelte";
|
||||
|
||||
console.log("wall:", page.params.wall);
|
||||
|
||||
@@ -60,6 +61,7 @@
|
||||
|
||||
let showAnswer = $state(false);
|
||||
let showQuestion = $state(false);
|
||||
let isBuzzed = $state(false);
|
||||
|
||||
$effect(() => {
|
||||
if (ws.messageNum <= 0) return;
|
||||
@@ -92,6 +94,18 @@
|
||||
showAnswer = false;
|
||||
});
|
||||
}
|
||||
if (json.type == MessageType.BUZZER_PRESSED) {
|
||||
ws.nextMessage();
|
||||
untrack(() => {
|
||||
isBuzzed = true;
|
||||
});
|
||||
}
|
||||
if (json.type == MessageType.BUZZER_RELEASED) {
|
||||
ws.nextMessage();
|
||||
untrack(() => {
|
||||
isBuzzed = false;
|
||||
});
|
||||
}
|
||||
} catch (e) {}
|
||||
});
|
||||
</script>
|
||||
@@ -110,6 +124,8 @@
|
||||
<SimpleQuestionComponent {question} {showAnswer} {showQuestion} />
|
||||
{:else if isMultipleChoiceQuestion(question)}
|
||||
<MultipleChoiceQuestionComponent {question} {showAnswer} {showQuestion} />
|
||||
{:else if isImageQuestion(question)}
|
||||
<ImageQuestionComponent {question} {showAnswer} {showQuestion} {isBuzzed} />
|
||||
{:else}
|
||||
<p>Type of question unknown</p>
|
||||
{/if}
|
||||
|
||||
Reference in New Issue
Block a user