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:
parent
9ac813c699
commit
736059646d
28 changed files with 343 additions and 736 deletions
17
src/routes/create/logic/StartGame.js
Normal file
17
src/routes/create/logic/StartGame.js
Normal 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);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue