feat: add error handling for game actions in GameManager and update service worker revision for index.html.

This commit is contained in:
2025-12-22 23:28:53 +01:00
parent 41be1d49c4
commit 66836cfde5
2 changed files with 26 additions and 20 deletions

View File

@@ -82,7 +82,7 @@ define(['./workbox-5a5d9309'], (function (workbox) { 'use strict';
"revision": "3ca0b8505b4bec776b69afdba2768812"
}, {
"url": "index.html",
"revision": "0.99c1h4jant"
"revision": "0.r2hp08ujhtk"
}], {});
workbox.cleanupOutdatedCaches();
workbox.registerRoute(new workbox.NavigationRoute(workbox.createHandlerBoundToURL("index.html"), {

View File

@@ -366,25 +366,31 @@ export class GameManager extends EventEmitter {
console.log(`[GameManager] Handling Action: ${action.type} for ${roomId} by ${actorId}`);
switch (action.type) {
case 'UPDATE_LIFE':
if (game.players[actorId]) {
game.players[actorId].life += (action.amount || 0);
}
break;
case 'MOVE_CARD':
this.moveCard(game, action, actorId);
break;
case 'TAP_CARD':
this.tapCard(game, action, actorId);
break;
case 'DRAW_CARD':
const engine = new RulesEngine(game);
engine.drawCard(actorId);
break;
case 'RESTART_GAME':
this.restartGame(roomId);
break;
try {
switch (action.type) {
case 'UPDATE_LIFE':
if (game.players[actorId]) {
game.players[actorId].life += (action.amount || 0);
}
break;
case 'MOVE_CARD':
this.moveCard(game, action, actorId);
break;
case 'TAP_CARD':
this.tapCard(game, action, actorId);
break;
case 'DRAW_CARD':
const engine = new RulesEngine(game);
engine.drawCard(actorId);
break;
case 'RESTART_GAME':
this.restartGame(roomId);
break;
}
} catch (e: any) {
console.error(`Legacy Action Error [${action?.type}]: ${e.message}`);
this.emit('game_error', roomId, { message: e.message, userId: actorId });
return null;
}
return game;