From 060f2a61cc99329ca967f7f1d7b7aed23d1e312a Mon Sep 17 00:00:00 2001 From: Scott Hadfield Date: Wed, 15 Apr 2026 22:25:45 -0700 Subject: [PATCH] Fix rollback losing opponent move and rematch not swapping colors --- src/routes/game/[did]/[rkey]/+page.svelte | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/routes/game/[did]/[rkey]/+page.svelte b/src/routes/game/[did]/[rkey]/+page.svelte index d3b406d..7a53861 100644 --- a/src/routes/game/[did]/[rkey]/+page.svelte +++ b/src/routes/game/[did]/[rkey]/+page.svelte @@ -340,6 +340,7 @@ const pgn = record.pgn as string; if (pgn && game.applyOpponentMove(pgn)) { + lastPersistedPgn = pgn; sound.play('notify'); } @@ -574,10 +575,12 @@ rematchCreating = true; try { const opponentDid = game.myColor === 'white' ? game.blackDid : game.whiteDid; + const newWhite = game.myColor === 'white' ? opponentDid : auth.did; + const newBlack = game.myColor === 'white' ? auth.did : opponentDid; const isVariant = game.startingFen != null; const result = await createGame(auth.agent, { - white: opponentDid, - black: auth.did, + white: newWhite, + black: newBlack, status: 'waiting', variant: isVariant ? 'really-bad-chess' : undefined, pgn: isVariant ? makeInitialPgn(generateRandomFen(), 'Really Bad Chess') : undefined, -- 2.51.2