feat: add error handling for game actions in GameManager and update service worker revision for index.html.
This commit is contained in:
@@ -82,7 +82,7 @@ define(['./workbox-5a5d9309'], (function (workbox) { 'use strict';
|
|||||||
"revision": "3ca0b8505b4bec776b69afdba2768812"
|
"revision": "3ca0b8505b4bec776b69afdba2768812"
|
||||||
}, {
|
}, {
|
||||||
"url": "index.html",
|
"url": "index.html",
|
||||||
"revision": "0.99c1h4jant"
|
"revision": "0.r2hp08ujhtk"
|
||||||
}], {});
|
}], {});
|
||||||
workbox.cleanupOutdatedCaches();
|
workbox.cleanupOutdatedCaches();
|
||||||
workbox.registerRoute(new workbox.NavigationRoute(workbox.createHandlerBoundToURL("index.html"), {
|
workbox.registerRoute(new workbox.NavigationRoute(workbox.createHandlerBoundToURL("index.html"), {
|
||||||
|
|||||||
@@ -366,25 +366,31 @@ export class GameManager extends EventEmitter {
|
|||||||
|
|
||||||
console.log(`[GameManager] Handling Action: ${action.type} for ${roomId} by ${actorId}`);
|
console.log(`[GameManager] Handling Action: ${action.type} for ${roomId} by ${actorId}`);
|
||||||
|
|
||||||
switch (action.type) {
|
try {
|
||||||
case 'UPDATE_LIFE':
|
switch (action.type) {
|
||||||
if (game.players[actorId]) {
|
case 'UPDATE_LIFE':
|
||||||
game.players[actorId].life += (action.amount || 0);
|
if (game.players[actorId]) {
|
||||||
}
|
game.players[actorId].life += (action.amount || 0);
|
||||||
break;
|
}
|
||||||
case 'MOVE_CARD':
|
break;
|
||||||
this.moveCard(game, action, actorId);
|
case 'MOVE_CARD':
|
||||||
break;
|
this.moveCard(game, action, actorId);
|
||||||
case 'TAP_CARD':
|
break;
|
||||||
this.tapCard(game, action, actorId);
|
case 'TAP_CARD':
|
||||||
break;
|
this.tapCard(game, action, actorId);
|
||||||
case 'DRAW_CARD':
|
break;
|
||||||
const engine = new RulesEngine(game);
|
case 'DRAW_CARD':
|
||||||
engine.drawCard(actorId);
|
const engine = new RulesEngine(game);
|
||||||
break;
|
engine.drawCard(actorId);
|
||||||
case 'RESTART_GAME':
|
break;
|
||||||
this.restartGame(roomId);
|
case 'RESTART_GAME':
|
||||||
break;
|
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;
|
return game;
|
||||||
|
|||||||
Reference in New Issue
Block a user