mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-04 16:02:33 +00:00
fix
This commit is contained in:
@@ -109,7 +109,7 @@ export async function createClientGame(
|
||||
userSettings: UserSettings,
|
||||
terrainLoad: Promise<TerrainMapData> | null,
|
||||
): Promise<ClientGameRunner> {
|
||||
if (typeof lobbyConfig.gameStartInfo === "undefined") {
|
||||
if (lobbyConfig.gameStartInfo === undefined) {
|
||||
throw new Error("missing gameStartInfo");
|
||||
}
|
||||
const config = await getConfig(
|
||||
@@ -204,7 +204,7 @@ export class ClientGameRunner {
|
||||
winner = update.winner as Team;
|
||||
}
|
||||
|
||||
if (typeof this.lobby.gameStartInfo === "undefined") {
|
||||
if (this.lobby.gameStartInfo === undefined) {
|
||||
throw new Error("missing gameStartInfo");
|
||||
}
|
||||
const record = createGameRecord(
|
||||
@@ -239,7 +239,7 @@ export class ClientGameRunner {
|
||||
this.renderer.initialize();
|
||||
this.input.initialize();
|
||||
this.worker.start((gu: GameUpdateViewData | ErrorUpdate) => {
|
||||
if (typeof this.lobby.gameStartInfo === "undefined") {
|
||||
if (this.lobby.gameStartInfo === undefined) {
|
||||
throw new Error("missing gameStartInfo");
|
||||
}
|
||||
if ("errMsg" in gu) {
|
||||
@@ -296,7 +296,7 @@ export class ClientGameRunner {
|
||||
}
|
||||
}
|
||||
if (message.type === "desync") {
|
||||
if (typeof this.lobby.gameStartInfo === "undefined") {
|
||||
if (this.lobby.gameStartInfo === undefined) {
|
||||
throw new Error("missing gameStartInfo");
|
||||
}
|
||||
showErrorModal(
|
||||
|
||||
@@ -87,7 +87,7 @@ export class GoogleAdElement extends LitElement {
|
||||
const isElectron = () => {
|
||||
// Renderer process
|
||||
if (
|
||||
typeof window !== "undefined" &&
|
||||
window !== undefined &&
|
||||
typeof window.process === "object" &&
|
||||
// @ts-expect-error hidden
|
||||
window.process.type === "renderer"
|
||||
@@ -97,7 +97,7 @@ const isElectron = () => {
|
||||
|
||||
// Main process
|
||||
if (
|
||||
typeof process !== "undefined" &&
|
||||
process !== undefined &&
|
||||
typeof process.versions === "object" &&
|
||||
!!process.versions.electron
|
||||
) {
|
||||
|
||||
@@ -27,7 +27,7 @@ function save(stats: LocalStatsData) {
|
||||
// The user can quit the game anytime so better save the lobby as soon as the
|
||||
// game starts.
|
||||
export function startGame(id: GameID, lobby: Partial<GameConfig>) {
|
||||
if (typeof localStorage === "undefined") {
|
||||
if (localStorage === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ export function startTime() {
|
||||
}
|
||||
|
||||
export function endGame(gameRecord: GameRecord) {
|
||||
if (typeof localStorage === "undefined") {
|
||||
if (localStorage === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -176,7 +176,7 @@ export class Transport {
|
||||
// If gameRecord is not null, we are replaying an archived game.
|
||||
// For multiplayer games, GameConfig is not known until game starts.
|
||||
this.isLocal =
|
||||
typeof lobbyConfig.gameRecord !== "undefined" ||
|
||||
lobbyConfig.gameRecord !== undefined ||
|
||||
lobbyConfig.gameStartInfo?.config.gameType === GameType.Singleplayer;
|
||||
|
||||
this.eventBus.on(SendAllianceRequestIntentEvent, (e) =>
|
||||
@@ -291,7 +291,7 @@ export class Transport {
|
||||
while (this.buffer.length > 0) {
|
||||
console.log("sending dropped message");
|
||||
const msg = this.buffer.pop();
|
||||
if (typeof msg === "undefined") {
|
||||
if (msg === undefined) {
|
||||
console.warn("msg is undefined");
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -281,7 +281,7 @@ export class UserSettingModal extends LitElement {
|
||||
easter="true"
|
||||
@change=${(e: CustomEvent) => {
|
||||
const value = e.detail?.value;
|
||||
if (typeof value !== "undefined") {
|
||||
if (value !== undefined) {
|
||||
console.log("Changed:", value);
|
||||
} else {
|
||||
console.warn("Slider event missing detail.value", e);
|
||||
@@ -300,7 +300,7 @@ export class UserSettingModal extends LitElement {
|
||||
easter="true"
|
||||
@change=${(e: CustomEvent) => {
|
||||
const value = e.detail?.value;
|
||||
if (typeof value !== "undefined") {
|
||||
if (value !== undefined) {
|
||||
console.log("Changed:", value);
|
||||
} else {
|
||||
console.warn("Slider event missing detail.value", e);
|
||||
|
||||
+2
-2
@@ -45,12 +45,12 @@ export function createCanvas(): HTMLCanvasElement {
|
||||
*/
|
||||
export function generateCryptoRandomUUID(): string {
|
||||
// Type guard to check if randomUUID is available
|
||||
if (typeof crypto !== "undefined" && "randomUUID" in crypto) {
|
||||
if (crypto !== undefined && "randomUUID" in crypto) {
|
||||
return crypto.randomUUID();
|
||||
}
|
||||
|
||||
// Fallback using crypto.getRandomValues
|
||||
if (typeof crypto !== "undefined" && "getRandomValues" in crypto) {
|
||||
if (crypto !== undefined && "getRandomValues" in crypto) {
|
||||
return (([1e7] as any) + -1e3 + -4e3 + -8e3 + -1e11).replace(
|
||||
/[018]/g,
|
||||
(c: number): string =>
|
||||
|
||||
@@ -30,7 +30,7 @@ export class SettingSlider extends LitElement {
|
||||
|
||||
private handleSliderChange(e: Event) {
|
||||
const detail = (e as CustomEvent)?.detail;
|
||||
if (!detail || typeof detail.value === "undefined") {
|
||||
if (!detail || detail.value === undefined) {
|
||||
console.warn("Invalid slider change event", e);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -462,7 +462,7 @@ export class NameLayer implements Layer {
|
||||
});
|
||||
const isMyPlayerTarget = nukesSentByOtherPlayer.find((unit) => {
|
||||
const detonationDst = unit.detonationDst();
|
||||
if (typeof detonationDst === "undefined") return false;
|
||||
if (detonationDst === undefined) return false;
|
||||
const targetId = this.game.owner(detonationDst).id();
|
||||
return myPlayer && targetId === myPlayer.id();
|
||||
});
|
||||
|
||||
@@ -488,7 +488,7 @@ export class RadialMenu implements Layer {
|
||||
action: () => void,
|
||||
) {
|
||||
const menuItem = this.menuItems.get(slot);
|
||||
if (typeof menuItem === "undefined") return;
|
||||
if (menuItem === undefined) return;
|
||||
menuItem.action = action;
|
||||
menuItem.disabled = false;
|
||||
menuItem.color = color;
|
||||
|
||||
@@ -140,7 +140,7 @@ export class StructureLayer implements Layer {
|
||||
const unitUpdates = updates !== null ? updates[GameUpdateType.Unit] : [];
|
||||
for (const u of unitUpdates) {
|
||||
const unit = this.game.unit(u.id);
|
||||
if (typeof unit === "undefined") continue;
|
||||
if (unit === undefined) continue;
|
||||
this.handleUnitRendering(unit);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -304,7 +304,7 @@ export class UnitLayer implements Layer {
|
||||
// Clear current and previous positions
|
||||
this.clearCell(this.game.x(unit.lastTile()), this.game.y(unit.lastTile()));
|
||||
const oldTile = this.oldShellTile.get(unit);
|
||||
if (typeof oldTile !== "undefined") {
|
||||
if (oldTile !== undefined) {
|
||||
this.clearCell(this.game.x(oldTile), this.game.y(oldTile));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user