refactor: fin de la premiere refactorisation du projet
This commit is contained in:
@@ -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);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user