mirror of
https://git.rezel.net/LudoTech/traque.git
synced 2026-02-09 10:20:16 +01:00
36 lines
1.1 KiB
JavaScript
36 lines
1.1 KiB
JavaScript
"use client";
|
|
|
|
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 { teamInfos, gameState } = useTeamContext();
|
|
|
|
function sendCurrentPosition() {
|
|
teamSocket.emit("send_position");
|
|
}
|
|
|
|
function capture(captureCode) {
|
|
teamSocket.emit("capture", captureCode);
|
|
}
|
|
|
|
return {
|
|
sendCurrentPosition,
|
|
capture,
|
|
enemyPosition: teamInfos?.enemyLocation || null,
|
|
currentPosition: teamInfos?.currentLocation || null,
|
|
startingArea: teamInfos?.startingArea || null,
|
|
captureCode: teamInfos?.captureCode || null,
|
|
name: teamInfos?.name || null,
|
|
ready: teamInfos?.ready || false,
|
|
captured: teamInfos?.captured || false,
|
|
locationSendDeadline: teamInfos?.locationSendDeadline || null,
|
|
penalties: teamInfos?.penalties || 0,
|
|
teamId,
|
|
gameState,
|
|
};
|
|
} |