Commit 85d39aa0 authored by Mahmoud Aglan's avatar Mahmoud Aglan

fix: bot games now create real match record (appear in match history)

Previously bot games used matchId='local' which meant no DB record was
created. Now on bot game start, calls game.php 'start' to insert a real
match row. When game completes, the 'complete' action updates that row
with result/fen/pgn/rating. Matches now appear in مبارياتي.
Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent cb7dd082
......@@ -144,6 +144,19 @@ export function mountGame(el, params) {
el.querySelector('#btn-draw').addEventListener('click', () => audio.play('click'));
el.querySelector('#btn-flip').addEventListener('click', () => { audio.play('click'); board.flip(); });
// Create a real match record for bot games (so they appear in history)
if (mode === 'bot' && !matchId) {
net.post('game.php', {
action: 'start',
game_key: 'chess',
mode: 'bot',
time_control: timeControl,
bot_id: botId
}).then(data => {
if (data && data.id) gameState.matchId = data.id;
}).catch(() => {});
}
// Start bot if playing as black
if (playerColor === 'b' && mode === 'bot') {
clock.start('w');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment