diff --git a/src/core/game/UnitImpl.ts b/src/core/game/UnitImpl.ts index baa5f1f05..b6a925a4a 100644 --- a/src/core/game/UnitImpl.ts +++ b/src/core/game/UnitImpl.ts @@ -23,7 +23,7 @@ export class UnitImpl implements Unit { public _owner: PlayerImpl, ) { // default to 60% health (or 1.2 is no health specified) - this._health = (this.mg.unitInfo(_type).maxHealth ?? 2) * 0.6; + this._health = toInt((this.mg.unitInfo(_type).maxHealth ?? 2) * 0.6); this._lastTile = _tile; } diff --git a/src/server/Gatekeeper.ts b/src/server/Gatekeeper.ts index bfbb8b4a9..694b7a493 100644 --- a/src/server/Gatekeeper.ts +++ b/src/server/Gatekeeper.ts @@ -49,32 +49,33 @@ async function getGatekeeper(): Promise { !fs.existsSync(tsMiddlewarePath) ) { console.log( - "RealSecurityMiddleware file not found, using NoOpSecurityMiddleware", + "RealSecurityMiddleware file not found, using NoOpGatekeeper", ); return new NoOpGatekeeper(); } // Use dynamic import for ES modules - const module = await import("./gatekeeper/RealGatekeeper.js").catch( - () => import("./gatekeeper/RealGatekeeper.js"), - ); + // Using a type assertion to avoid TypeScript errors for optional modules + const module = await import( + "./gatekeeper/RealGatekeeper.js" as any + ).catch(() => import("./gatekeeper/RealGatekeeper.js" as any)); if (!module || !module.RealSecurityMiddleware) { console.log( - "RealSecurityMiddleware class not found in module, using NoOpSecurityMiddleware", + "RealSecurityMiddleware class not found in module, using NoOpGatekeeper", ); return new NoOpGatekeeper(); } - console.log("Successfully loaded real security middleware"); - return new module.RealSecurityMiddleware(); + console.log("Successfully loaded real gatekeeper"); + return new module.RealGatekeeper(); } catch (error) { - console.log("Failed to load real security middleware:", error); + console.log("Failed to load real gatekeeper:", error); return new NoOpGatekeeper(); } } catch (e) { // Fall back to no-op if real implementation isn't available - console.log("using no-op security middleware", e); + console.log("using no-op gatekeeper", e); return new NoOpGatekeeper(); } } @@ -121,5 +122,5 @@ getGatekeeper() Object.assign(gatekeeper, middleware); }) .catch((error) => { - console.error("Failed to initialize security middleware:", error); + console.error("Failed to initialize gatekeeper:", error); });