This commit is contained in:
Scott Anderson
2025-05-13 02:13:27 -04:00
parent 781ddb5911
commit a38d3d986f
23 changed files with 39 additions and 42 deletions
+4 -4
View File
@@ -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(
+2 -2
View File
@@ -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
) {
+2 -2
View File
@@ -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;
}
+2 -2
View File
@@ -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;
}
+2 -2
View File
@@ -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
View File
@@ -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;
}
+1 -1
View File
@@ -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();
});
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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);
}
}
+1 -1
View File
@@ -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));
}