made the filestructure better and migrated the game creation from the old type of db to the newer relational db type!

This commit is contained in:
RezHackXYZ 2025-05-15 06:27:40 +05:30
parent 9ac813c699
commit 736059646d
No known key found for this signature in database
28 changed files with 343 additions and 736 deletions

View file

@ -0,0 +1,17 @@
import { goto } from '$app/navigation';
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.correctAnswer === undefined)) return alert('Select correct answers');
const gamePin = Math.floor(Math.random() * 1000000)
.toString()
.padStart(6, '0');
createGame($state.snapshot(questions), gamePin);
goto('/host/' + gamePin);
}