-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbrowser-mock-client.html
More file actions
827 lines (695 loc) · 25.7 KB
/
Copy pathbrowser-mock-client.html
File metadata and controls
827 lines (695 loc) · 25.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>UniQuake Browser Client</title>
<style>
body {
font-family: 'Courier New', monospace;
background-color: #1e1e1e;
color: #e0e0e0;
margin: 0;
padding: 20px;
}
.container {
display: flex;
flex-direction: column;
height: calc(100vh - 40px);
max-width: 1200px;
margin: 0 auto;
}
.header {
margin-bottom: 20px;
}
.header h1 {
margin: 0;
color: #4fc3f7;
}
.main-content {
display: flex;
flex: 1;
gap: 20px;
}
.panel {
background-color: #2d2d2d;
border-radius: 5px;
padding: 15px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}
.server-list {
flex: 1;
overflow-y: auto;
}
.server-item {
background-color: #3d3d3d;
border-radius: 3px;
padding: 10px;
margin-bottom: 10px;
cursor: pointer;
transition: background-color 0.2s;
}
.server-item:hover {
background-color: #4d4d4d;
}
.server-item.selected {
background-color: #2196f3;
}
.right-panels {
display: flex;
flex-direction: column;
flex: 2;
gap: 20px;
}
.game-panel {
flex: 2;
display: flex;
flex-direction: column;
}
.chat-panel {
flex: 0.5;
display: flex;
flex-direction: column;
}
.token-panel {
flex: 1;
}
.log {
flex: 1;
background-color: #252525;
border-radius: 3px;
padding: 10px;
overflow-y: auto;
font-size: 14px;
}
.chat-log {
flex: 1;
background-color: #252525;
border-radius: 3px;
padding: 10px;
overflow-y: auto;
font-size: 14px;
margin-bottom: 10px;
}
.chat-input {
display: flex;
gap: 10px;
}
input, button {
background-color: #3d3d3d;
border: none;
border-radius: 3px;
padding: 8px 12px;
color: #e0e0e0;
font-family: 'Courier New', monospace;
}
input {
flex: 1;
}
button {
background-color: #2196f3;
cursor: pointer;
transition: background-color 0.2s;
}
button:hover {
background-color: #1976d2;
}
button:disabled {
background-color: #555;
cursor: not-allowed;
}
.button-row {
display: flex;
gap: 10px;
margin-top: 10px;
}
.status-row {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 10px;
font-size: 14px;
}
.ping-display {
color: #4caf50;
}
.player-list {
background-color: #252525;
border-radius: 3px;
padding: 10px;
margin-bottom: 10px;
font-size: 14px;
}
.game-state {
flex: 1;
overflow-y: visible;
background-color: #252525;
border-radius: 3px;
padding: 10px;
font-size: 14px;
}
.token-info {
background-color: #252525;
border-radius: 3px;
padding: 10px;
margin-bottom: 10px;
}
.verification-info {
background-color: #252525;
border-radius: 3px;
padding: 10px;
}
.server-name {
font-weight: bold;
color: #4fc3f7;
}
.server-info {
font-size: 12px;
color: #aaa;
}
.status-indicator {
display: inline-block;
width: 10px;
height: 10px;
border-radius: 50%;
margin-right: 5px;
}
.status-connected {
background-color: #4caf50;
}
.status-disconnected {
background-color: #f44336;
}
/* ANSI color simulation */
.ansi-green {
color: #4caf50;
}
.ansi-red {
color: #f44336;
}
.ansi-yellow {
color: #ffeb3b;
}
.ansi-blue {
color: #2196f3;
}
.ansi-cyan {
color: #00bcd4;
}
.ansi-magenta {
color: #e91e63;
}
.ansi-white {
color: #ffffff;
}
.ansi-gray {
color: #9e9e9e;
}
.chat-message {
margin-bottom: 5px;
}
.chat-timestamp {
color: #9e9e9e;
font-size: 12px;
margin-right: 5px;
}
.chat-sender {
font-weight: bold;
margin-right: 5px;
}
.chat-sender-server {
color: #ffeb3b;
}
.chat-sender-self {
color: #4fc3f7;
}
.chat-text {
word-break: break-word;
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1>UniQuake Browser Client</h1>
</div>
<div class="main-content">
<div class="server-list panel">
<div class="status-row">
<div>
<span class="status-indicator" id="connection-status"></span>
<span id="connection-text">Disconnected</span>
</div>
<div class="ping-display" id="ping-display"></div>
</div>
<h2>Game Servers</h2>
<div id="servers-container"></div>
<div class="button-row">
<button id="refresh-button">Refresh Servers</button>
<button id="connect-button" disabled>Connect</button>
<button id="disconnect-button" disabled>Disconnect</button>
</div>
</div>
<div class="right-panels">
<div class="game-panel panel">
<h2>Game State</h2>
<div class="game-state" id="game-state">No game state available</div>
</div>
<div class="token-panel panel">
<h2>Token System</h2>
<div class="token-info" id="token-info">Token system initializing...</div>
</div>
<div class="chat-panel panel">
<h2>Chat</h2>
<div class="chat-log" id="chat-log"></div>
<div class="chat-input">
<input type="text" id="chat-input" placeholder="Type your message..." disabled>
<button id="send-button" disabled>Send</button>
</div>
</div>
</div>
</div>
</div>
<!-- Load scripts -->
<script src="lib/client/uniquake-token-service.js"></script>
<script src="lib/client/browser-mock-game.js"></script>
<script src="lib/client/browser-mock-client.js"></script>
<script src="lib/client/game-integration.js"></script>
<script>
// Load WebRTC adapter directly, bypassing the auto-connect behavior
window.UNIQUAKE_CONFIG = {
useWebRTC: true,
masterServer: 'ws://localhost:27950',
noAutoConnect: true // Flag to prevent auto-connection
};
// Load the adapter script
var script = document.createElement('script');
script.src = '/webrtc-adapter.js';
script.onload = function() {
console.log('WebRTC adapter loaded, initializing client');
initializeClient();
};
document.head.appendChild(script);
// Main client, game, and integration instances
let client, game, integration;
let selectedServerId = null;
// Initialize client
async function initializeClient() {
// Create mock game
game = new BrowserMockGame({
updateInterval: 2000,
onStateChange: updateGameState
});
// Generate a unique player name with random suffix
const playerName = 'Player_' + Math.floor(Math.random() * 1000);
// Create mock client
client = new BrowserMockClient({
masterServer: window.UNIQUAKE_CONFIG.masterServer || 'ws://localhost:27950',
name: playerName,
verbose: true,
debug: true,
mintTokens: 5,
onStatusUpdate: updateClientStatus,
onChatMessage: displayChatMessage,
onConnectionChange: handleConnectionChange,
onServerList: updateServerList,
// Add handler for the new serverStateUpdate event
onServerStateUpdate: function(serverInfo) {
console.log("[SERVER_STATE] Received server state update event:", JSON.stringify(serverInfo));
// Call updateGameState to refresh the UI with the latest server info
if (game) {
updateGameState(game.getGameState());
}
}
});
// Create game integration
integration = new GameIntegration({
client: client,
debug: true,
onGameStateUpdate: updateGameState,
onTokenEvent: handleTokenEvent
});
// Initialize all components
await game.init();
await client.init();
await integration.init(game);
// Store reference to game integration for syncing
client.gameIntegration = integration;
console.log('Client system initialized');
// Set up UI event handlers
setupUIHandlers();
// Connect to master server and fetch server list
client.connectToMasterServer().then(() => {
// Automatically request the server list
client.requestServerList();
});
// Update initial token info
updateTokenInfo();
// Initialize verification info with static message
updateVerificationInfo();
// Set up automatic game state verification every 2 seconds when connected
// This ensures the frame counter is updated frequently
setInterval(() => {
if (client.clientState.connected) {
// Request verification from server
client.sendMessage({
type: 'request:game:state:token'
});
// Only log in debug mode to avoid console spam
if (client.config.debug) {
console.log('Auto-requesting game state verification...');
}
}
}, 2000);
}
// Set up UI event handlers
function setupUIHandlers() {
// Server list buttons
document.getElementById('refresh-button').addEventListener('click', () => {
client.requestServerList();
});
document.getElementById('connect-button').addEventListener('click', () => {
if (selectedServerId) {
client.connectToServer(selectedServerId);
}
});
document.getElementById('disconnect-button').addEventListener('click', () => {
client.disconnect();
});
// Chat input
document.getElementById('chat-input').addEventListener('keypress', (e) => {
if (e.key === 'Enter') {
sendChatMessage();
}
});
document.getElementById('send-button').addEventListener('click', sendChatMessage);
}
// Send a chat message
function sendChatMessage() {
const input = document.getElementById('chat-input');
const message = input.value.trim();
if (message && client.clientState.connected) {
client.sendChatMessage(message);
input.value = '';
}
}
// Update server list
function updateServerList(servers) {
const container = document.getElementById('servers-container');
container.innerHTML = '';
if (servers.length === 0) {
container.innerHTML = '<div class="server-item">No servers available</div>';
return;
}
servers.forEach(server => {
const serverElem = document.createElement('div');
serverElem.className = 'server-item';
serverElem.setAttribute('data-server-id', server.peerId);
if (selectedServerId === server.peerId) {
serverElem.classList.add('selected');
}
serverElem.innerHTML = `
<div class="server-name">${server.name}</div>
<div class="server-info">Map: ${server.map} | Players: ${server.players}/${server.maxPlayers}</div>
<div class="server-info">ID: ${server.peerId}</div>
`;
serverElem.addEventListener('click', () => {
// Deselect previous selection
document.querySelectorAll('.server-item.selected').forEach(item => {
item.classList.remove('selected');
});
// Select this server
serverElem.classList.add('selected');
selectedServerId = server.peerId;
// Enable connect button if not connected
document.getElementById('connect-button').disabled = client.clientState.connected;
});
container.appendChild(serverElem);
});
}
// Handle connection changes
function handleConnectionChange(status) {
const connectButton = document.getElementById('connect-button');
const disconnectButton = document.getElementById('disconnect-button');
const chatInput = document.getElementById('chat-input');
const sendButton = document.getElementById('send-button');
const connectionStatus = document.getElementById('connection-status');
const connectionText = document.getElementById('connection-text');
if (status.connected) {
connectButton.disabled = true;
disconnectButton.disabled = false;
chatInput.disabled = false;
sendButton.disabled = false;
connectionStatus.className = 'status-indicator status-connected';
connectionText.textContent = 'Connected';
// Start the game
game.start();
} else {
connectButton.disabled = false;
disconnectButton.disabled = true;
chatInput.disabled = true;
sendButton.disabled = true;
connectionStatus.className = 'status-indicator status-disconnected';
connectionText.textContent = 'Disconnected';
document.getElementById('ping-display').textContent = '';
// Stop the game
game.stop();
}
}
// Update client status
function updateClientStatus(status) {
// Update ping display if available
if (status.ping && status.ping.last) {
document.getElementById('ping-display').textContent = `Ping: ${status.ping.last}ms`;
}
// Update token info if available
if (status.tokens) {
updateTokenInfo(status.tokens);
}
console.log('Client status updated:', status);
}
// Update game state display
function updateGameState(gameState) {
if (!gameState) return;
// Calculate state hash for local state if token service is available
let localStateHash = 'N/A';
if (client && client.clientState.tokenService && client.clientState.tokenService.hashGameState) {
try {
// Enable debug mode temporarily to see serialization and hash details
const debugEnabled = client.clientState.tokenService.debugMode;
client.clientState.tokenService.debugMode = true;
// Use the token service's normalization and hash calculation
// This ensures we use exactly the same process as the server
localStateHash = client.clientState.tokenService.hashGameState(gameState);
console.log(`Calculated local hash for frame ${gameState.frame}:`, localStateHash);
// Restore previous debug setting
client.clientState.tokenService.debugMode = debugEnabled;
} catch (error) {
console.error('Failed to calculate game state hash:', error.message);
}
}
// Get server hash from verification if available
const serverHash = gameState.serverHash ||
client?.clientState?.lastGameStateVerification?.stateHash ||
'Not verified';
// Check if hashes match
const hashesMatch = localStateHash !== 'N/A' && serverHash !== 'Not verified' &&
localStateHash === serverHash;
// Get verified frame number from token verification if available
const verifiedFrame = client?.clientState?.lastGameStateVerification?.frame || gameState.frame;
const serverFrame = client?.clientState?.lastGameStateVerification?.serverFrame || verifiedFrame;
// IMPORTANT: Get server info prioritizing the dedicated server state info message
console.log("[SERVER_STATE] Looking for server state info sources");
let serverInfo;
// First priority: Use dedicated server state info from client state (from server:state:update message)
if (client?.clientState?.serverStateInfo) {
serverInfo = client.clientState.serverStateInfo;
console.log("[SERVER_STATE] Using dedicated server state info:", JSON.stringify(serverInfo));
}
// Second priority: Use server info from verification object
else if (client?.clientState?.lastGameStateVerification?.serverInfo) {
serverInfo = client.clientState.lastGameStateVerification.serverInfo;
console.log("[SERVER_STATE] Using server info from verification:", JSON.stringify(serverInfo));
}
// Fallback: Use client-side data
else {
serverInfo = {
playerCount: Object.keys(gameState.players).length,
itemCount: Object.keys(gameState.items || {}).length,
timestamp: gameState.timestamp
};
console.log("[SERVER_STATE] Using fallback client-side server info:", JSON.stringify(serverInfo));
}
// Check if serverInfo has all required fields and enforce them
if (!serverInfo.playerCount && serverInfo.playerCount !== 0) {
console.log("[SERVER_STATE] playerCount missing, setting to 0");
serverInfo.playerCount = 0;
}
if (!serverInfo.itemCount && serverInfo.itemCount !== 0) {
console.log("[SERVER_STATE] itemCount missing, setting to 0");
serverInfo.itemCount = 0;
}
if (!serverInfo.timestamp) {
console.log("[SERVER_STATE] timestamp missing, setting to current time");
serverInfo.timestamp = Date.now();
}
// Format server timestamp with error handling
let serverTime = 'Unknown';
try {
// Make sure timestamp is valid
if (serverInfo && serverInfo.timestamp) {
const timestamp = new Date(serverInfo.timestamp);
// Check if date is valid
if (!isNaN(timestamp.getTime())) {
serverTime = timestamp.toLocaleTimeString();
} else {
console.warn('Invalid server timestamp:', serverInfo.timestamp);
}
}
} catch (error) {
console.error('Error formatting server timestamp:', error);
}
// Recalculate the local hash using the EXACT same normalization as the token service
if (client && client.clientState.tokenService) {
// Ensure we're using the exactly same state normalization as the server
const normalizedState = client.clientState.tokenService.normalizeGameState(gameState);
localStateHash = client.clientState.tokenService.hashGameState(normalizedState);
console.log(`Recalculated hash using normalized state with only frame and gameId:`, localStateHash);
}
// Update game state display
const gameStateElem = document.getElementById('game-state');
gameStateElem.innerHTML = `
<div style="font-size: 18px; margin-bottom: 10px; border-bottom: 1px solid #444; padding-bottom: 5px;">
<strong>Frame:</strong> <span class="ansi-blue" style="font-weight: bold;">${verifiedFrame}</span>
<span style="font-size: 12px; color: #aaa; margin-left: 10px;">Verified with server</span>
</div>
<!-- Enhanced Server State Section -->
<div style="margin-bottom: 15px; background-color: #2a2a2a; border-radius: 5px; padding: 10px; border-left: 4px solid #00bcd4;">
<div style="font-size: 16px; font-weight: bold; margin-bottom: 8px; color: #00bcd4; display: flex; justify-content: space-between; align-items: center;">
<span>SERVER STATE</span>
<span style="font-size: 12px; background-color: #333; padding: 2px 6px; border-radius: 10px;">Direct from server</span>
</div>
<div style="display: grid; grid-template-columns: auto 1fr; gap: 8px; align-items: center;">
<div><strong>Connected Players:</strong></div>
<div style="font-size: 16px; color: #4fc3f7;">${serverInfo.playerCount}</div>
<div><strong>Server Timestamp:</strong></div>
<div style="font-size: 16px; color: #4fc3f7;">${serverTime}</div>
<div><strong>Last Update:</strong></div>
<div style="font-size: 16px; color: #4fc3f7;">${(() => {
try {
if (serverInfo && serverInfo.timestamp && !isNaN(serverInfo.timestamp)) {
const secondsAgo = Math.round((Date.now() - serverInfo.timestamp) / 1000);
if (secondsAgo >= 0) {
return `${secondsAgo} seconds ago`;
} else {
return 'Just now';
}
}
return 'Unknown';
} catch (e) {
console.error('Error calculating time since update:', e);
return 'Unknown';
}
})()}</div>
</div>
</div>
<!-- Verification Status Section -->
<div style="border: 1px solid ${hashesMatch ? '#4caf50' : '#f44336'}; padding: 10px; border-radius: 4px; margin: 10px 0; background-color: ${hashesMatch ? 'rgba(76, 175, 80, 0.1)' : 'rgba(244, 67, 54, 0.1)'};">
<div style="display: flex; align-items: center; margin-bottom: 5px;">
<strong style="margin-right: 10px;">Verification Status:</strong>
<span class="${hashesMatch ? 'ansi-green' : 'ansi-red'}" style="font-weight: bold; font-size: 16px;">
${hashesMatch ? '✓ VERIFIED' : '✗ VERIFICATION FAILED'}
</span>
</div>
<div style="display: grid; grid-template-columns: auto 1fr; gap: 5px; font-family: monospace; font-size: 12px;">
<div><strong>Server Hash:</strong></div>
<div style="word-break: break-all; color: #ffeb3b;">
${typeof serverHash === 'string' && serverHash.length > 20 ? serverHash.substring(0, 20) + '...' : serverHash}
</div>
<div><strong>Local Hash:</strong></div>
<div style="word-break: break-all; color: #4fc3f7;">
${localStateHash.substring(0, 20)}...
</div>
</div>
</div>
`;
if (gameState.ended) {
gameStateElem.innerHTML += `
<strong>Game Ended</strong><br>
<strong>Winner:</strong> ${gameState.winner ? gameState.players[gameState.winner]?.name || gameState.winner : 'None'}<br>
`;
}
// Also update verification info if we have verification data
if (client?.clientState?.lastGameStateVerification?.timestamp) {
updateVerificationInfo({
verified: hashesMatch,
frame: gameState.frame,
stateHash: serverHash,
error: hashesMatch ? null : 'Local state hash does not match server hash'
});
}
}
// Display chat message
function displayChatMessage(message) {
const chatLog = document.getElementById('chat-log');
const messageElem = document.createElement('div');
messageElem.className = 'chat-message';
const time = new Date(message.timestamp).toLocaleTimeString();
let senderClass = '';
if (message.from === 'SERVER') {
senderClass = 'chat-sender-server';
} else if (message.from === client.clientState.clientId) {
senderClass = 'chat-sender-self';
}
messageElem.innerHTML = `
<span class="chat-timestamp">[${time}]</span>
<span class="chat-sender ${senderClass}">${message.from}:</span>
<span class="chat-text">${message.message}</span>
`;
chatLog.appendChild(messageElem);
chatLog.scrollTop = chatLog.scrollHeight;
}
// Update token information
function updateTokenInfo(tokens) {
const tokenInfo = document.getElementById('token-info');
if (!client || !client.clientState.tokenService) {
tokenInfo.innerHTML = 'Token service not available';
return;
}
const inventory = client.getTokenInventory();
const identity = client.clientState.tokenService.getIdentity();
tokenInfo.innerHTML = `
<strong>Identity:</strong> ${identity.username} (${identity.pubkey.substring(0, 10)}...)<br>
<strong>Tokens:</strong> ${inventory.total || 0}<br>
<strong>Value:</strong> ${inventory.value || '0'}<br>
<strong>Entry Token Sent:</strong> ${client.clientState.entryTokenSent ? 'Yes' : 'No'}<br>
`;
}
// Update verification information
function updateVerificationInfo(result) {
// Verification info panel has been removed - no longer needed
}
// Handle token events
function handleTokenEvent(event) {
console.log('Token event:', event);
// Update token info
updateTokenInfo();
// If it's a verification event, update the game state display only
if (event.type === 'game_state_verification') {
// We no longer update the verification info panel
// updateVerificationInfo(event.result);
// Update game state display to show current hash status
if (client?.gameIntegration?.game) {
updateGameState(client.gameIntegration.game.getGameState());
}
// Log verification result for debugging
if (event.result.verified) {
console.log(`Game state verified at frame ${event.frame}: Hash matches`);
} else {
console.warn(`Game state verification failed at frame ${event.frame}: ${event.result.error || 'Hash mismatch'}`);
}
}
}
</script>
</body>
</html>