API data types rework

This commit is contained in:
aronmal 2023-04-25 22:27:03 +02:00
parent 207cf47c10
commit 4af85bb572
Signed by: aronmal
GPG key ID: 816B7707426FC612
16 changed files with 342 additions and 245 deletions

View file

@ -7,18 +7,20 @@ function LobbyFrame({ openSettings }: { openSettings: () => void }) {
const { gameProps } = useGameState()
const [dots, setDots] = useState(1)
const { gamePin, player1, player2 } = gameProps.payload
useEffect(() => {
if (gameProps.enemy) return
if (player2) return
const interval = setInterval(() => setDots((e) => (e % 3) + 1), 1000)
return () => clearInterval(interval)
}, [gameProps.enemy])
}, [player2])
return (
<div className="mx-32 flex flex-col self-stretch rounded-3xl bg-gray-400">
<div className="flex items-center justify-between border-b-2 border-slate-900">
<Icon src="speech_bubble.png">Chat</Icon>
<h1 className="font-farro text-5xl font-medium">
Game-PIN: <span className="underline">{gameProps.pin}</span>
Game-PIN: <span className="underline">{gamePin?.pin}</span>
</h1>
<Icon src="gear.png" onClick={openSettings}>
Settings
@ -27,16 +29,13 @@ function LobbyFrame({ openSettings }: { openSettings: () => void }) {
<div className="flex items-center justify-around">
<Player
src="player_blue.png"
text={gameProps.player?.name ?? "Spieler 1 (Du)"}
text={player1?.name ?? "Spieler 1 (Du)"}
primary={true}
edit={true}
/>
<p className="font-farro m-4 text-6xl font-semibold">VS</p>
{gameProps.enemy ? (
<Player
src="player_red.png"
text={gameProps.enemy.name ?? "Spieler 2"}
/>
{player2 ? (
<Player src="player_red.png" text={player2.name ?? "Spieler 2"} />
) : (
<p className="font-farro w-96 text-center text-4xl font-medium">
Warte auf Spieler 2 {Array.from(Array(dots), () => ".").join("")}