made the loby working using the newer rDB and makeing everything to bbe better manageable by using folders and more components!
This commit is contained in:
parent
2b9b5c3b39
commit
d3e0f3406e
37 changed files with 417 additions and 159 deletions
25
src/routes/play/[gamePin]/logic/startGame.js
Normal file
25
src/routes/play/[gamePin]/logic/startGame.js
Normal file
|
@ -0,0 +1,25 @@
|
|||
import { supabase } from "$lib/supabase.js";
|
||||
import { LobbyConnection } from "./UpdatePlayersList.js";
|
||||
import { questions, Status, CurrentQuestion, currentQuestion } from "./HostsData.svelte.js";
|
||||
|
||||
export async function startGame(gamePin) {
|
||||
await supabase.removeChannel(LobbyConnection);
|
||||
|
||||
Status.v = "started";
|
||||
|
||||
const { data } = await supabase
|
||||
.from("questions")
|
||||
.select("*")
|
||||
.eq("gameid", Number(gamePin))
|
||||
.order("id", { ascending: true });
|
||||
questions.v = data;
|
||||
|
||||
CurrentQuestion.v = 0;
|
||||
|
||||
await supabase
|
||||
.from("games")
|
||||
.update({ status: `question-${currentQuestion.v}` })
|
||||
.eq("gamepin", gamePin);
|
||||
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue