fix build errors from cherry-pick

This commit is contained in:
Evan
2025-03-02 09:51:25 -08:00
parent d8841924e2
commit 5e09c0db47
2 changed files with 12 additions and 11 deletions
+1 -1
View File
@@ -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;
}
+11 -10
View File
@@ -49,32 +49,33 @@ async function getGatekeeper(): Promise<Gatekeeper> {
!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);
});