implemented game state in front end

This commit is contained in:
Quentin Roussel
2024-03-29 00:33:40 +01:00
parent ba2a4a0ea1
commit ae2587bc3a
14 changed files with 51 additions and 35 deletions

View File

@@ -2,7 +2,7 @@ import { useAdminContext } from "@/context/adminContext";
import { useSocket } from "@/context/socketContext";
export default function useAdmin(){
const {teams, started } = useAdminContext();
const {teams, gameState } = useAdminContext();
const {adminSocket} = useSocket();
function pollTeams() {
@@ -34,14 +34,10 @@ export default function useAdmin(){
adminSocket.emit("update_team", teamId, team);
}
function startGame() {
adminSocket.emit("start_game");
function changeState(state) {
adminSocket.emit("change_state", state);
}
function stopGame() {
adminSocket.emit("stop_game");
}
return {teams, started, pollTeams, getTeam, getTeamName, reorderTeams, addTeam, removeTeam, startGame, stopGame, updateTeam };
return {teams, gameState, pollTeams, getTeam, getTeamName, reorderTeams, addTeam, removeTeam, changeState, updateTeam };
}