Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export default [
rules: {
// Disable rules that would fail. The failures should be fixed, and the entries here removed.
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-expressions": "off",
"no-unused-vars": "off",
},
},
Expand Down
53 changes: 41 additions & 12 deletions src/client/Main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,9 @@ class Client {
gameVersion.innerText = version;

const newsModal = document.querySelector("news-modal") as NewsModal;
if (!newsModal) {
if (!newsModal || !(newsModal instanceof NewsModal)) {
console.warn("News modal element not found");
}
newsModal instanceof NewsModal;
const newsButton = document.querySelector("news-button") as NewsButton;
if (!newsButton) {
console.warn("News button element not found");
Expand Down Expand Up @@ -168,7 +167,9 @@ class Client {
const spModal = document.querySelector(
"single-player-modal",
) as SinglePlayerModal;
spModal instanceof SinglePlayerModal;
if (!spModal || !(spModal instanceof SinglePlayerModal)) {
console.warn("Singleplayer modal element not found");
}

const singlePlayer = document.getElementById("single-player");
if (singlePlayer === null) throw new Error("Missing single-player");
Expand All @@ -185,7 +186,9 @@ class Client {
// });

const hlpModal = document.querySelector("help-modal") as HelpModal;
hlpModal instanceof HelpModal;
if (!hlpModal || !(hlpModal instanceof HelpModal)) {
console.warn("Help modal element not found");
}
const helpButton = document.getElementById("help-button");
if (helpButton === null) throw new Error("Missing help-button");
helpButton.addEventListener("click", () => {
Expand All @@ -195,7 +198,10 @@ class Client {
const flagInputModal = document.querySelector(
"flag-input-modal",
) as FlagInputModal;
flagInputModal instanceof FlagInputModal;
if (!flagInputModal || !(flagInputModal instanceof FlagInputModal)) {
console.warn("Flag input modal element not found");
}

const flgInput = document.getElementById("flag-input_");
if (flgInput === null) throw new Error("Missing flag-input_");
flgInput.addEventListener("click", () => {
Expand All @@ -205,14 +211,25 @@ class Client {
this.patternsModal = document.querySelector(
"territory-patterns-modal",
) as TerritoryPatternsModal;
if (
!this.patternsModal ||
!(this.patternsModal instanceof TerritoryPatternsModal)
) {
console.warn("Territory patterns modal element not found");
}
const patternButton = document.getElementById(
"territory-patterns-input-preview-button",
);
if (isInIframe() && patternButton) {
patternButton.style.display = "none";
}

this.patternsModal instanceof TerritoryPatternsModal;
if (
!this.patternsModal ||
!(this.patternsModal instanceof TerritoryPatternsModal)
) {
console.warn("Territory patterns modal element not found");
}
if (patternButton === null)
throw new Error("territory-patterns-input-preview-button");
this.patternsModal.previewButton = patternButton;
Expand All @@ -224,7 +241,12 @@ class Client {
this.tokenLoginModal = document.querySelector(
"token-login",
) as TokenLoginModal;
this.tokenLoginModal instanceof TokenLoginModal;
if (
!this.tokenLoginModal ||
!(this.tokenLoginModal instanceof TokenLoginModal)
) {
console.warn("Token login modal element not found");
}

const onUserMe = async (userMeResponse: UserMeResponse | false) => {
document.dispatchEvent(
Expand Down Expand Up @@ -335,7 +357,9 @@ class Client {
const settingsModal = document.querySelector(
"user-setting",
) as UserSettingModal;
settingsModal instanceof UserSettingModal;
if (!settingsModal || !(settingsModal instanceof UserSettingModal)) {
console.warn("User settings modal element not found");
}
document
.getElementById("settings-button")
?.addEventListener("click", () => {
Expand All @@ -345,7 +369,9 @@ class Client {
const hostModal = document.querySelector(
"host-lobby-modal",
) as HostPrivateLobbyModal;
hostModal instanceof HostPrivateLobbyModal;
if (!hostModal || !(hostModal instanceof HostPrivateLobbyModal)) {
console.warn("Host private lobby modal element not found");
}
const hostLobbyButton = document.getElementById("host-lobby-button");
if (hostLobbyButton === null) throw new Error("Missing host-lobby-button");
hostLobbyButton.addEventListener("click", () => {
Expand All @@ -358,7 +384,9 @@ class Client {
this.joinModal = document.querySelector(
"join-private-lobby-modal",
) as JoinPrivateLobbyModal;
this.joinModal instanceof JoinPrivateLobbyModal;
if (!this.joinModal || !(this.joinModal instanceof JoinPrivateLobbyModal)) {
console.warn("Join private lobby modal element not found");
}
const joinPrivateLobbyButton = document.getElementById(
"join-private-lobby-button",
);
Expand Down Expand Up @@ -573,8 +601,9 @@ class Client {
const startingModal = document.querySelector(
"game-starting-modal",
) as GameStartingModal;
startingModal instanceof GameStartingModal;
startingModal.show();
if (startingModal && startingModal instanceof GameStartingModal) {
startingModal.show();
}
},
() => {
this.joinModal.close();
Expand Down
4 changes: 2 additions & 2 deletions src/client/graphics/layers/EventsDisplay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1051,7 +1051,7 @@ export class EventsDisplay extends LitElement implements Layer {
? this.renderButton({
content: this.getEventDescription(event),
onClick: () => {
event.focusID &&
if (event.focusID)
this.emitGoToPlayerEvent(event.focusID);
},
className: "text-left",
Expand All @@ -1060,7 +1060,7 @@ export class EventsDisplay extends LitElement implements Layer {
? this.renderButton({
content: this.getEventDescription(event),
onClick: () => {
event.unitView &&
if (event.unitView)
this.emitGoToUnitEvent(
event.unitView,
);
Expand Down
4 changes: 3 additions & 1 deletion src/client/graphics/layers/StructureIconsLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,9 @@ export class StructureIconsLayer implements Layer {
this.potentialUpgrade.iconContainer.filters = [];
this.potentialUpgrade.dotContainer.filters = [];
}
this.ghostUnit?.container && (this.ghostUnit.container.filters = []);
if (this.ghostUnit?.container) {
this.ghostUnit.container.filters = [];
}

if (!this.ghostUnit) return;

Expand Down
4 changes: 2 additions & 2 deletions src/core/execution/RailroadExecution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export class RailroadExecution implements Execution {
}

private redrawBuildings() {
this.railRoad.from.unit.isActive() && this.railRoad.from.unit.touch();
this.railRoad.to.unit.isActive() && this.railRoad.to.unit.touch();
if (this.railRoad.from.unit.isActive()) this.railRoad.from.unit.touch();
if (this.railRoad.to.unit.isActive()) this.railRoad.to.unit.touch();
}
}
Loading