Add spectator watch page, forfeit-on-new-game, CPU self-play, and threefold repetition
- /watch live feed of active games with click-to-fullscreen and per-game back button - Starting a new game forfeits the in-progress game; opponent is flagged the winner - Watch CPU vs CPU self-play games; results shown for ~30s before cleanup - Detect threefold repetition in the C# rules layer and end the game as a draw Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
fc2a2e122b
commit
2db95cec34
@@ -1,5 +1,19 @@
|
||||
async function forfeitCurrentGame() {
|
||||
const gameId = ChessUtils.getCookie("chessGameId");
|
||||
const playerId = ChessUtils.getCookie("chessPlayerId");
|
||||
|
||||
if (!gameId || !playerId) return;
|
||||
|
||||
try {
|
||||
await ChessAPI.forfeit(gameId, playerId);
|
||||
} catch (err) {
|
||||
console.warn("Could not forfeit previous game.", err);
|
||||
}
|
||||
}
|
||||
|
||||
async function startNewGame() {
|
||||
await ChessSignalR.stopConnection();
|
||||
await forfeitCurrentGame();
|
||||
|
||||
try {
|
||||
const gameData = await ChessAPI.joinGame();
|
||||
@@ -25,6 +39,7 @@ async function startNewGame() {
|
||||
|
||||
async function startCPUGame() {
|
||||
await ChessSignalR.stopConnection();
|
||||
await forfeitCurrentGame();
|
||||
|
||||
try {
|
||||
const difficulty = await ChessModals.promptDifficulty();
|
||||
|
||||
Reference in New Issue
Block a user