mirror of
https://git.rezel.net/LudoTech/traque.git
synced 2026-02-09 02:10:18 +01:00
implemented game state in front end
This commit is contained in:
@@ -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 };
|
||||
|
||||
}
|
||||
@@ -7,12 +7,12 @@ import { useTeamContext } from "@/context/teamContext";
|
||||
export default function useGame() {
|
||||
const {teamSocket} = useSocket();
|
||||
const {teamId} = useTeamConnexion();
|
||||
const {currentPosition, enemyPosition} = useTeamContext();
|
||||
const {currentPosition, enemyPosition, gameState} = useTeamContext();
|
||||
|
||||
function sendCurrentPosition() {
|
||||
teamSocket.emit("send_position");
|
||||
}
|
||||
|
||||
|
||||
return { sendCurrentPosition, enemyPosition, currentPosition, teamId };
|
||||
return { sendCurrentPosition, enemyPosition, currentPosition, teamId, gameState};
|
||||
}
|
||||
Reference in New Issue
Block a user