refactor: fin de la premiere refactorisation du projet

This commit is contained in:
2026-08-02 22:27:00 +02:00
parent c709064062
commit 45ad31d0ae
14 changed files with 299 additions and 142 deletions

View File

@@ -1 +1,49 @@
/*
main.js
point d'entree pour les scripts
*/
import { socket } from "./socket.js";
import { player } from "./player.js";
import { roleState } from "./role.js";
import { render, drawBlind } from "./canvas.js";
import { setupMovement } from "./movement.js";
import { showGameOver, showVictory, updateTimerDisplay } from "./ui.js";
setupMovement();
socket.on("status", (msg) => console.log("Status: ", (msg));
roleState.current = role;
if (role === "explorateur") {
render();
} else {
drawBlind();
}
});
socket.on("new_round", (startPos) => {
player.x = startPos.x;
player.y = startPos.y;
});
socket.on("door_result", (result) => {
if (!result.correct){
roleState.current = null;
showGameOver("Mauvaise porte. Vous avez perdu.");
}
});
socket.on("timeout", () => {
roleState.current = null;
showGameOver("Temps ecoule. Vous avez perdu.");
});
socket.on("victory", () => {
roleState.current = null;
showVictory();
});
socket.on("timer", (timeLeft) => {
updateTimerDisplay(timeLeft);
});