diff --git a/traque-front/app/team/track/page.js b/traque-front/app/team/track/page.js index 7e133d5..d7a6db1 100644 --- a/traque-front/app/team/track/page.js +++ b/traque-front/app/team/track/page.js @@ -17,16 +17,20 @@ const PlacementMap = dynamic(() => import('@/components/team/map').then((mod) => }); export default function Track() { - const { gameState} = useGame(); + const { gameState, captured} = useGame(); const { useProtect } = useTeamConnexion(); useProtect(); return <> {gameState == GameState.SETUP && } - {gameState == GameState.PLAYING &&
+ {gameState == GameState.PLAYING && !captured &&
} + {gameState == GameState.PLAYING && captured &&
+
Vous avez été capturé
+
Instructions de retour ici
+
} {gameState == GameState.PLACEMENT &&
diff --git a/traque-front/components/team/actionDrawer.jsx b/traque-front/components/team/actionDrawer.jsx index 17610e7..fe9dfce 100644 --- a/traque-front/components/team/actionDrawer.jsx +++ b/traque-front/components/team/actionDrawer.jsx @@ -6,9 +6,15 @@ import { useTeamConnexion } from "@/context/teamConnexionContext"; export default function ActionDrawer() { const [visible, setVisible] = useState(false); - const { sendCurrentPosition, name, captureCode } = useGame(); + const [enemyCaptureCode, setEnemyCaptureCode] = useState(""); + const { sendCurrentPosition, name, captureCode, capture } = useGame(); const {logout} = useTeamConnexion(); + function handleCapture() { + capture(enemyCaptureCode); + setEnemyCaptureCode(""); + } + return (
setVisible(!visible)} /> @@ -43,8 +49,8 @@ export default function ActionDrawer() { See target info
- { console.log(i) }} /> - Capture target + setEnemyCaptureCode(e.target.value)} /> + Capture target
diff --git a/traque-front/hook/useGame.jsx b/traque-front/hook/useGame.jsx index c867a23..6fd468c 100644 --- a/traque-front/hook/useGame.jsx +++ b/traque-front/hook/useGame.jsx @@ -14,17 +14,20 @@ export default function useGame() { teamSocket.emit("send_position"); } - useEffect(() => console.log("teamInfos", teamInfos), [teamInfos]); - + 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, teamId, gameState, };