From c432390984aa7bee1fa787e24d57a37c05865d16 Mon Sep 17 00:00:00 2001 From: adrian Date: Mon, 15 Dec 2025 20:45:41 +0100 Subject: [PATCH] bug fixes --- backend.js | 2 +- game/game.js | 18 ++++++------------ imposter.db | Bin 28672 -> 28672 bytes index.html | 13 +++++++------ session/style.css | 3 ++- style.css | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 62 insertions(+), 20 deletions(-) diff --git a/backend.js b/backend.js index 293b95c..f188200 100644 --- a/backend.js +++ b/backend.js @@ -145,7 +145,7 @@ app.get("/api/reset/:sessionId", (req, res) => { const { sessionId } = req.params; db.run(`UPDATE "${sessionId}" SET state = 0 WHERE state = 1`); - db.run(`UPDATE "${sessionId}" SET ready = 0 WHERE ready = 1`); + //db.run(`UPDATE "${sessionId}" SET ready = 0 WHERE ready = 1`); db.run(`UPDATE words SET inUse = 0 WHERE inUse = 1`); return res.status(201).json({ success: true }); }); diff --git a/game/game.js b/game/game.js index c75ca1c..88445f3 100644 --- a/game/game.js +++ b/game/game.js @@ -6,20 +6,20 @@ show_user() async function show_user() { const res = await fetch(`/api/user/${sessionId}`); const users = await res.json(); + //todo: der check ob es schon einen imposter gibt sollte auf dem Server stattfinden! const allUsers = users.map((u) => u.state); if (allUsers.every((v) => v === 0)) { createImposter(); async function createImposter() { const res = await fetch(`/api/${sessionId}/${username}/createImposter`); - var imposterStatus = getImposter(); //var für globale variable, muss in dieser funktion sein wegen komischer race condition bug + getImposter(); } }else { - var imposterStatus = getImposter(); //var für globale variable, muss in dieser funktion sein wegen komischer race condition bug + getImposter(); + } } -//const imposterStatus = getImposter(); - async function getImposter() { const res = await fetch(`/api/${sessionId}/${username}/getImposter`); const stateObj = await res.json(); @@ -30,20 +30,14 @@ async function getImposter() { if (state == 1) { console.log("du bist imposter"); ImposterStateDiv.textContent = "Du bist der Imposter!"; - return true; + getWords(true); } else { console.log("du bist kein imposter"); ImposterStateDiv.textContent = "Du bist kein Imposter!"; - return false; + getWords(false); } } -// Initialisierung: await getImposter(), dann getWords aufrufen -async function init() { - const imposterStatus = await getImposter(); - await getWords(imposterStatus); -} -init(); async function getWords(imposterStatus) { const res = await fetch(`/api/getWords`); diff --git a/imposter.db b/imposter.db index ba503672285ecb7aeddce1ad916141517d16a38c..d0872396457914f98ba42296d595042df2b9959d 100644 GIT binary patch delta 588 zcmX|8L2DC17~O5VcA6&hWt*hS8jB|pZ!xuvo}>}eLXuicMCqxs$(P-syR%_;=MseE z2Y66CiXS?T_4Os)esiO)_Kzo1 zpaz_4@DtAA0zSjHnVJ6p4+~3%c88DzfhZ@`hpnvEO zdO<(YGdiVj>4XN#OO1|AOUZAM1195rbmmjpM{_fU_GA(^m=}#ux=>PvEONw0Blb9s zQDlpTRw$8YUUZB+u?vP)zD>I5;~*5xFbJgJr!3*2$ZaUG5@~V~Hn<;bn1;4xk%pYV zcbM;Y#=|g5a{2VlffW5N$B2T`w#l({pCVU(6{+HsNyC@!!b`*F=%UEy6sb(=Oa?~- zpNSFDtU@f(4n_Zv^}GbuQ`4PL2yF2MkV%2IjQMF(QCxFvtP-_Jr{_r@TNnuxl%y(k zjNC(($Ou-|-6n0s=s8oPN5yNYokw9XlnF*%?0ITfx~Rz_b=mV;s7%vEoh7n29H9Ti iiIYX8W`PVtwX&*z6`tzO+4QAjs#;YAOyxcJm-k=PRhiNN delta 137 zcmZp8z}WDBae@>R!}5tTPC#;F!V-QqCjJ);{GT@q2(0FxIKfzmlZll Imposter - + +

IMPOSTER

- - - + + +
-
+ \ No newline at end of file diff --git a/session/style.css b/session/style.css index 6f21a3f..5703f70 100644 --- a/session/style.css +++ b/session/style.css @@ -7,7 +7,8 @@ background-color: white; border-radius: 5px; border-width: 4px; - max-width: 100px; + max-width: fit-content; + min-width: 100px; margin: 5px auto; font-size: 30px; diff --git a/style.css b/style.css index c28bfdb..2101f6a 100644 --- a/style.css +++ b/style.css @@ -1,3 +1,49 @@ body { background-color: #09161E; } + + .username { + display: flex; + justify-content: center; + background-color: white; + border-radius: 5px; + border-width: 4px; + max-width: fit-content; + min-width: 100px; + margin: 5px auto; + font-size: 30px; + +} + + .session_id { + display: flex; + justify-content: center; + background-color: white; + border-radius: 5px; + border-width: 4px; + max-width: fit-content; + min-width: 100px; + margin: 5px auto; + font-size: 30px; + +} + +.joinButton { + display: flex; + justify-content: center; + background-color: white; + border: 2px solid #ccc; + border-radius: 5px; + border-width: 4px; + max-width: fit-content; + margin: 100px auto; + font-size: 30px; + +} + +.heading { + display: flex; + justify-content: center; + font-size: 50px; + color: white; +}