diff --git a/client/src/app/ai/page.tsx b/client/src/app/ai/page.tsx index 9db2845..d9e1ec7 100644 --- a/client/src/app/ai/page.tsx +++ b/client/src/app/ai/page.tsx @@ -5,20 +5,13 @@ import { Chessboard } from "react-chessboard"; import { Chess } from "chess.js"; import { API_URL } from "@/config"; import { useSession } from "@/context/session"; +import { BOTS } from "@/bots"; import type { CSSProperties } from "react"; -const AI_LEVELS = [ - { level: 1, name: "Anfänger" }, - { level: 2, name: "Leicht" }, - { level: 3, name: "Mittel" }, - { level: 4, name: "Fortgeschritten" }, - { level: 5, name: "Experte" }, - { level: 6, name: "Meister" }, -]; - export default function AiGamePage() { const { user } = useSession(); - const [selectedLevel, setSelectedLevel] = useState(3); + const [selectedBot, setSelectedBot] = useState(BOTS[2]); + const selectedLevel = selectedBot.level; const [gameStarted, setGameStarted] = useState(false); const [game, setGame] = useState(new Chess()); const [playerColor, setPlayerColor] = useState<"white" | "black">("white"); @@ -152,15 +145,20 @@ export default function AiGamePage() {
-

Schwierigkeitsgrad

-
- {AI_LEVELS.map((l) => ( +

Gegner wählen

+
+ {BOTS.map((b) => ( ))}
@@ -196,7 +194,7 @@ export default function AiGamePage() {
-

Niveau: {AI_LEVELS.find(l => l.level === selectedLevel)?.name}

+

Gegner: {selectedBot.emoji} {selectedBot.name}

Du spielst: {playerColor === "white" ? "Weiß ♔" : "Schwarz ♚"}

diff --git a/client/src/app/tournament/[code]/page.tsx b/client/src/app/tournament/[code]/page.tsx index 842b1b7..9a99c99 100644 --- a/client/src/app/tournament/[code]/page.tsx +++ b/client/src/app/tournament/[code]/page.tsx @@ -2,7 +2,8 @@ import InviteFriendsModal from "@/components/InviteFriendsModal"; import { useSession } from "@/context/session"; -import { fetchTournament, joinTournament, startTournament } from "@/lib/tournament"; +import { fetchTournament, joinTournament, startTournament, addBotToTournament } from "@/lib/tournament"; +import { BOTS } from "@/bots"; import type { Tournament, TournamentRound } from "@michess/types"; import Link from "next/link"; import { useParams } from "next/navigation"; @@ -16,6 +17,7 @@ export default function TournamentDetailPage() { const [tournament, setTournament] = useState(null); const [loading, setLoading] = useState(true); const [actionLoading, setActionLoading] = useState(false); + const [selectedBot, setSelectedBot] = useState(BOTS[0].name); const intervalRef = useRef | null>(null); async function load() { @@ -47,6 +49,13 @@ export default function TournamentDetailPage() { setActionLoading(false); } + async function handleAddBot() { + setActionLoading(true); + const updated = await addBotToTournament(code, selectedBot); + if (updated) setTournament(updated); + setActionLoading(false); + } + async function handleStart() { if (!user?.id) return; setActionLoading(true); @@ -123,6 +132,27 @@ export default function TournamentDetailPage() { {tournament.status === "waiting" && isJoined && ( )} + {isHost && tournament.status === "waiting" && ( +
+ + +
+ )} {canStart && (