mirror of
https://git.rezel.net/LudoTech/traque.git
synced 2026-02-09 10:20:16 +01:00
wrapped all team data in a single object and socket message
This commit is contained in:
@@ -3,16 +3,28 @@
|
||||
import { useSocket } from "@/context/socketContext";
|
||||
import { useTeamConnexion } from "@/context/teamConnexionContext";
|
||||
import { useTeamContext } from "@/context/teamContext";
|
||||
import { useEffect } from "react";
|
||||
|
||||
export default function useGame() {
|
||||
const {teamSocket} = useSocket();
|
||||
const {teamId} = useTeamConnexion();
|
||||
const {currentPosition, enemyPosition, gameState} = useTeamContext();
|
||||
const { teamSocket } = useSocket();
|
||||
const { teamId } = useTeamConnexion();
|
||||
const { teamInfos, gameState } = useTeamContext();
|
||||
|
||||
function sendCurrentPosition() {
|
||||
teamSocket.emit("send_position");
|
||||
}
|
||||
|
||||
useEffect(() => console.log("teamInfos", teamInfos), [teamInfos]);
|
||||
|
||||
return { sendCurrentPosition, enemyPosition, currentPosition, teamId, gameState};
|
||||
|
||||
return {
|
||||
sendCurrentPosition,
|
||||
enemyPosition: teamInfos?.enemyLocation || null,
|
||||
currentPosition: teamInfos?.currentLocation || null,
|
||||
startingArea: teamInfos?.startingArea || null,
|
||||
captureCode: teamInfos?.captureCode || null,
|
||||
name: teamInfos?.name || null,
|
||||
teamId,
|
||||
gameState,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user