mirror of
https://git.rezel.net/LudoTech/traque.git
synced 2026-02-09 10:20:16 +01:00
implemented game state in front end
This commit is contained in:
@@ -1,12 +1,22 @@
|
||||
"use client";
|
||||
import BlueButton, { GreenButton, RedButton } from "@/components/util/button";
|
||||
import { useAdminConnexion } from "@/context/adminConnexionContext";
|
||||
import useAdmin from "@/hook/useAdmin";
|
||||
import { GameState } from "@/util/gameState";
|
||||
|
||||
export default function AdminPage() {
|
||||
const { useProtect } = useAdminConnexion();
|
||||
const { gameState, changeState } = useAdmin();
|
||||
useProtect();
|
||||
return (
|
||||
<div>
|
||||
<h1>Admin page</h1>
|
||||
<div className='h-full bg-gray-200 p-10 flex flex-col justify-between'>
|
||||
<div className='w-max gap-3 bg-gray-200 p-10 flex flex-col text-center shadow-2xl '>
|
||||
<h2 className="text-2xl">Game state </h2>
|
||||
<strong className="p-5 bg-gray-900 text-white text-xl rounded">Current : {gameState}</strong>
|
||||
<RedButton onClick={() => changeState(GameState.SETUP)}>Reset game</RedButton>
|
||||
<GreenButton onClick={() => changeState(GameState.PLACEMENT)}>Start placement</GreenButton>
|
||||
<BlueButton onClick={() => changeState(GameState.PLAYING)}>Start game</BlueButton>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
"use client";
|
||||
import ActionDrawer from '@/components/team/actionDrawer';
|
||||
import { useTeamConnexion } from '@/context/teamConnexionContext';
|
||||
import useGame from '@/hook/useGame';
|
||||
import useGame, { GameState } from '@/hook/useGame';
|
||||
import dynamic from 'next/dynamic';
|
||||
import React from 'react'
|
||||
|
||||
@@ -11,11 +11,11 @@ const LiveMap = dynamic(() => import('@/components/team/map'), {
|
||||
});
|
||||
|
||||
export default function Track() {
|
||||
const { currentPosition, enemyPosition } = useGame();
|
||||
const { gameState } = useGame();
|
||||
const {useProtect} = useTeamConnexion();
|
||||
useProtect();
|
||||
return (
|
||||
<div className='h-full'>
|
||||
return (
|
||||
gameState == GameState.PLAYING && <div className='h-full'>
|
||||
<LiveMap currentPosition={currentPosition} enemyPosition={enemyPosition} />
|
||||
<ActionDrawer />
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user