Files
imposter/game/game.js
2025-12-05 21:29:26 +01:00

32 lines
885 B
JavaScript

const parts = window.location.pathname.split("/").filter(Boolean);
const sessionId = parts[0] ?? null;
const username = parts[1] ?? null;
async function getState() {
const res = await fetch(`/api/${sessionId}/${username}/state`);
const state = await res.json();
}
async function show_user() {
const res = await fetch(`/api/user/${sessionId}`);
const users = await res.json();
const allUsers = users.map((u) => u.state);
if (allUsers.every((v) => v === 0)) {
async function createImposter() {
const res = await fetch(`/api/${sessionId}/${username}/createImposter`);
}
}
}
async function getImposter() {
const res = await fetch(`/api/${sessionId}/${username}/getImposter`);
const stateObj = await res.json();
state = stateObj.state;
if (state == 1) {
console.log("du bist imposter");
} else {
console.log("du bist kein imposter");
}
}