rBD IS WORKING!!!! at least for now!
This commit is contained in:
parent
3ad30b476a
commit
8e1cfbcb6f
31 changed files with 374 additions and 81 deletions
|
@ -1,18 +1,17 @@
|
|||
import { goto } from '$app/navigation';
|
||||
import { createGame } from './InsertGameInDB.js';
|
||||
import { questions } from './GameCreateData.svelte.js';
|
||||
import { createGame } from "./InsertGameInDB.js";
|
||||
import { questions } from "./GameCreateData.svelte.js";
|
||||
|
||||
export async function startGame() {
|
||||
if (questions.v.some((q) => q.name === '')) return alert('Please fill all questions');
|
||||
if (questions.v.some((q) => q.answers.some((a) => a === ''))) return alert('Fill all options');
|
||||
if (questions.v.some((q) => q.name === "")) return alert("Please fill all questions");
|
||||
if (questions.v.some((q) => q.answers.some((a) => a === ""))) return alert("Fill all options");
|
||||
if (questions.v.some((q) => q.correctAnswer === undefined))
|
||||
return alert('Select correct answers');
|
||||
return alert("Select correct answers");
|
||||
|
||||
const gamePin = Math.floor(Math.random() * 1000000)
|
||||
.toString()
|
||||
.padStart(6, '0');
|
||||
.padStart(6, "0");
|
||||
|
||||
createGame(questions.v, gamePin);
|
||||
await createGame(questions.v, gamePin);
|
||||
|
||||
goto('/host/' + gamePin);
|
||||
window.location.href = "/host/" + gamePin;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue