Enable the sort-imports eslint rule (#1849)

## Description:

Enable the `sort-imports` eslint rule.

Fixes #1784

## Please complete the following:

- [x] I have added screenshots for all UI updates
- [x] I process any text displayed to the user through translateText()
and I've added it to the en.json file
- [x] I have added relevant tests to the test directory
- [x] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced
This commit is contained in:
Scott Anderson
2025-08-17 20:53:44 -04:00
committed by GitHub
parent 62c08e25c2
commit 0a40bcebf0
180 changed files with 792 additions and 813 deletions
+5 -5
View File
@@ -1,13 +1,13 @@
import eslintConfigPrettier from "eslint-config-prettier/flat"; import eslintConfigPrettier from "eslint-config-prettier/flat";
import eslintPluginLocal from "./eslint-plugin-local/plugin.js";
import { fileURLToPath } from "node:url";
import globals from "globals"; import globals from "globals";
import { includeIgnoreFile } from "@eslint/compat";
import jest from "eslint-plugin-jest";
import path from "node:path"; import path from "node:path";
import pluginJs from "@eslint/js"; import pluginJs from "@eslint/js";
import stylistic from "@stylistic/eslint-plugin"; import stylistic from "@stylistic/eslint-plugin";
import jest from "eslint-plugin-jest";
import tseslint from "typescript-eslint"; import tseslint from "typescript-eslint";
import { fileURLToPath } from "node:url";
import { includeIgnoreFile } from "@eslint/compat";
import eslintPluginLocal from "./eslint-plugin-local/plugin.js";
const __filename = fileURLToPath(import.meta.url); const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename); const __dirname = path.dirname(__filename);
@@ -116,7 +116,7 @@ export default [
"no-undef": "error", "no-undef": "error",
"no-unused-vars": "off", // @typescript-eslint/no-unused-vars "no-unused-vars": "off", // @typescript-eslint/no-unused-vars
"quote-props": ["error", "consistent-as-needed"], "quote-props": ["error", "consistent-as-needed"],
// 'sort-imports': 'error', // TODO: Enable this rule, https://github.com/openfrontio/OpenFrontIO/issues/1787 'sort-imports': 'error',
"space-before-blocks": ["error", "always"], "space-before-blocks": ["error", "always"],
"space-before-function-paren": ["error", { "space-before-function-paren": ["error", {
anonymous: "always", anonymous: "always",
+31 -31
View File
@@ -1,30 +1,3 @@
import { translateText } from "../client/Utils";
import { EventBus } from "../core/EventBus";
import {
ClientID,
GameID,
GameRecord,
GameStartInfo,
PlayerRecord,
ServerMessage,
} from "../core/Schemas";
import { createGameRecord } from "../core/Util";
import { ServerConfig } from "../core/configuration/Config";
import { getConfig } from "../core/configuration/ConfigLoader";
import { PlayerActions, UnitType } from "../core/game/Game";
import { TileRef } from "../core/game/GameMap";
import { GameMapLoader } from "../core/game/GameMapLoader";
import {
ErrorUpdate,
GameUpdateType,
GameUpdateViewData,
HashUpdate,
WinUpdate,
} from "../core/game/GameUpdates";
import { GameView, PlayerView } from "../core/game/GameView";
import { loadTerrainMap, TerrainMapData } from "../core/game/TerrainMapLoader";
import { UserSettings } from "../core/game/UserSettings";
import { WorkerClient } from "../core/worker/WorkerClient";
import { import {
AutoUpgradeEvent, AutoUpgradeEvent,
DoBoatAttackEvent, DoBoatAttackEvent,
@@ -33,9 +6,24 @@ import {
MouseMoveEvent, MouseMoveEvent,
MouseUpEvent, MouseUpEvent,
} from "./InputHandler"; } from "./InputHandler";
import { endGame, startGame, startTime } from "./LocalPersistantStats"; import {
import { getPersistentID } from "./Main"; ClientID,
import { terrainMapFileLoader } from "./TerrainMapFileLoader"; GameID,
GameRecord,
GameStartInfo,
PlayerRecord,
ServerMessage,
} from "../core/Schemas";
import {
ErrorUpdate,
GameUpdateType,
GameUpdateViewData,
HashUpdate,
WinUpdate,
} from "../core/game/GameUpdates";
import { GameRenderer, createRenderer } from "./graphics/GameRenderer";
import { GameView, PlayerView } from "../core/game/GameView";
import { PlayerActions, UnitType } from "../core/game/Game";
import { import {
SendAttackIntentEvent, SendAttackIntentEvent,
SendBoatAttackIntentEvent, SendBoatAttackIntentEvent,
@@ -44,8 +32,20 @@ import {
SendUpgradeStructureIntentEvent, SendUpgradeStructureIntentEvent,
Transport, Transport,
} from "./Transport"; } from "./Transport";
import { TerrainMapData, loadTerrainMap } from "../core/game/TerrainMapLoader";
import { endGame, startGame, startTime } from "./LocalPersistantStats";
import { EventBus } from "../core/EventBus";
import { GameMapLoader } from "../core/game/GameMapLoader";
import { ServerConfig } from "../core/configuration/Config";
import { TileRef } from "../core/game/GameMap";
import { UserSettings } from "../core/game/UserSettings";
import { WorkerClient } from "../core/worker/WorkerClient";
import { createCanvas } from "./Utils"; import { createCanvas } from "./Utils";
import { createRenderer, GameRenderer } from "./graphics/GameRenderer"; import { createGameRecord } from "../core/Util";
import { getConfig } from "../core/configuration/ConfigLoader";
import { getPersistentID } from "./Main";
import { terrainMapFileLoader } from "./TerrainMapFileLoader";
import { translateText } from "../client/Utils";
export type LobbyConfig = { export type LobbyConfig = {
serverConfig: ServerConfig; serverConfig: ServerConfig;
+2 -2
View File
@@ -1,10 +1,10 @@
import { z } from "zod"; import { Cosmetics, CosmeticsSchema, Pattern } from "../core/CosmeticSchemas";
import { import {
StripeCreateCheckoutSessionResponseSchema, StripeCreateCheckoutSessionResponseSchema,
UserMeResponse, UserMeResponse,
} from "../core/ApiSchemas"; } from "../core/ApiSchemas";
import { Cosmetics, CosmeticsSchema, Pattern } from "../core/CosmeticSchemas";
import { getApiBase, getAuthHeader } from "./jwt"; import { getApiBase, getAuthHeader } from "./jwt";
import { z } from "zod";
export async function patterns( export async function patterns(
userMe: UserMeResponse | null, userMe: UserMeResponse | null,
+2 -2
View File
@@ -1,8 +1,8 @@
import "./components/Difficulties";
import "./components/Maps";
import { LitElement, html } from "lit"; import { LitElement, html } from "lit";
import { customElement, query } from "lit/decorators.js"; import { customElement, query } from "lit/decorators.js";
import { getAltKey, getModifierKey, translateText } from "../client/Utils"; import { getAltKey, getModifierKey, translateText } from "../client/Utils";
import "./components/Difficulties";
import "./components/Maps";
@customElement("help-modal") @customElement("help-modal")
export class HelpModal extends LitElement { export class HelpModal extends LitElement {
+17 -17
View File
@@ -1,9 +1,14 @@
/* eslint-disable max-lines */ /* eslint-disable max-lines */
import { LitElement, html } from "lit"; import "./components/Difficulties";
import { customElement, query, state } from "lit/decorators.js"; import "./components/Maps";
import randomMap from "../../resources/images/RandomMap.webp"; import "./components/baseComponents/Modal";
import { translateText } from "../client/Utils"; import {
import { getServerConfigFromClient } from "../core/configuration/ConfigLoader"; ClientInfo,
GameConfig,
GameInfo,
GameInfoSchema,
TeamCountConfig,
} from "../core/Schemas";
import { import {
Difficulty, Difficulty,
Duos, Duos,
@@ -14,21 +19,16 @@ import {
UnitType, UnitType,
mapCategories, mapCategories,
} from "../core/game/Game"; } from "../core/game/Game";
import { UserSettings } from "../core/game/UserSettings"; import { LitElement, html } from "lit";
import { import { customElement, query, state } from "lit/decorators.js";
ClientInfo,
GameConfig,
GameInfo,
GameInfoSchema,
TeamCountConfig,
} from "../core/Schemas";
import { generateID } from "../core/Util";
import "./components/baseComponents/Modal";
import "./components/Difficulties";
import { DifficultyDescription } from "./components/Difficulties"; import { DifficultyDescription } from "./components/Difficulties";
import "./components/Maps";
import { JoinLobbyEvent } from "./Main"; import { JoinLobbyEvent } from "./Main";
import { UserSettings } from "../core/game/UserSettings";
import { generateID } from "../core/Util";
import { getServerConfigFromClient } from "../core/configuration/ConfigLoader";
import randomMap from "../../resources/images/RandomMap.webp";
import { renderUnitTypeOptions } from "./utilities/RenderUnitTypeOptions"; import { renderUnitTypeOptions } from "./utilities/RenderUnitTypeOptions";
import { translateText } from "../client/Utils";
@customElement("host-lobby-modal") @customElement("host-lobby-modal")
export class HostLobbyModal extends LitElement { export class HostLobbyModal extends LitElement {
+3 -3
View File
@@ -1,8 +1,8 @@
import { EventBus, GameEvent } from "../core/EventBus"; import { EventBus, GameEvent } from "../core/EventBus";
import { ReplaySpeedMultiplier } from "./utilities/ReplaySpeedMultiplier";
import { UnitType } from "../core/game/Game"; import { UnitType } from "../core/game/Game";
import { UnitView } from "../core/game/GameView"; import { UnitView } from "../core/game/GameView";
import { UserSettings } from "../core/game/UserSettings"; import { UserSettings } from "../core/game/UserSettings";
import { ReplaySpeedMultiplier } from "./utilities/ReplaySpeedMultiplier";
export class MouseUpEvent implements GameEvent { export class MouseUpEvent implements GameEvent {
constructor( constructor(
@@ -70,7 +70,7 @@ export class AlternateViewEvent implements GameEvent {
export class CloseViewEvent implements GameEvent {} export class CloseViewEvent implements GameEvent {}
export class RefreshGraphicsEvent implements GameEvent {} export class RedrawGraphicsEvent implements GameEvent {}
export class TogglePerformanceOverlayEvent implements GameEvent {} export class TogglePerformanceOverlayEvent implements GameEvent {}
@@ -302,7 +302,7 @@ export class InputHandler {
if (e.key.toLowerCase() === "r" && e.altKey && !e.ctrlKey) { if (e.key.toLowerCase() === "r" && e.altKey && !e.ctrlKey) {
e.preventDefault(); e.preventDefault();
this.eventBus.emit(new RefreshGraphicsEvent()); this.eventBus.emit(new RedrawGraphicsEvent());
} }
if (e.code === this.keybinds.boatAttack) { if (e.code === this.keybinds.boatAttack) {
+7 -7
View File
@@ -1,16 +1,16 @@
import { LitElement, html } from "lit"; import "./components/baseComponents/Button";
import { customElement, query, state } from "lit/decorators.js"; import "./components/baseComponents/Modal";
import { translateText } from "../client/Utils";
import { GameInfo, GameInfoSchema } from "../core/Schemas"; import { GameInfo, GameInfoSchema } from "../core/Schemas";
import { generateID } from "../core/Util"; import { LitElement, html } from "lit";
import { import {
WorkerApiArchivedGameLobbySchema, WorkerApiArchivedGameLobbySchema,
WorkerApiGameIdExistsSchema, WorkerApiGameIdExistsSchema,
} from "../core/WorkerSchemas"; } from "../core/WorkerSchemas";
import { getServerConfigFromClient } from "../core/configuration/ConfigLoader"; import { customElement, query, state } from "lit/decorators.js";
import { JoinLobbyEvent } from "./Main"; import { JoinLobbyEvent } from "./Main";
import "./components/baseComponents/Button"; import { generateID } from "../core/Util";
import "./components/baseComponents/Modal"; import { getServerConfigFromClient } from "../core/configuration/ConfigLoader";
import { translateText } from "../client/Utils";
@customElement("join-private-lobby-modal") @customElement("join-private-lobby-modal")
export class JoinPrivateLobbyModal extends LitElement { export class JoinPrivateLobbyModal extends LitElement {
+1 -1
View File
@@ -1,8 +1,8 @@
/* eslint-disable @typescript-eslint/no-unsafe-member-access */ /* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable @typescript-eslint/no-unsafe-assignment */
import "./LanguageModal";
import { LitElement, html } from "lit"; import { LitElement, html } from "lit";
import { customElement, state } from "lit/decorators.js"; import { customElement, state } from "lit/decorators.js";
import "./LanguageModal";
import ar from "../../resources/lang/ar.json"; import ar from "../../resources/lang/ar.json";
import bg from "../../resources/lang/bg.json"; import bg from "../../resources/lang/bg.json";
+1 -1
View File
@@ -1,4 +1,3 @@
import { z } from "zod";
import { import {
GameConfig, GameConfig,
GameConfigSchema, GameConfigSchema,
@@ -8,6 +7,7 @@ import {
ID, ID,
} from "../core/Schemas"; } from "../core/Schemas";
import { replacer } from "../core/Util"; import { replacer } from "../core/Util";
import { z } from "zod";
const LocalStatsDataSchema = z.record( const LocalStatsDataSchema = z.record(
ID, ID,
+3 -3
View File
@@ -1,5 +1,3 @@
import { z } from "zod";
import { EventBus } from "../core/EventBus";
import { import {
AllPlayersStats, AllPlayersStats,
ClientMessage, ClientMessage,
@@ -12,10 +10,12 @@ import {
Turn, Turn,
} from "../core/Schemas"; } from "../core/Schemas";
import { createGameRecord, decompressGameRecord, replacer } from "../core/Util"; import { createGameRecord, decompressGameRecord, replacer } from "../core/Util";
import { EventBus } from "../core/EventBus";
import { LobbyConfig } from "./ClientGameRunner"; import { LobbyConfig } from "./ClientGameRunner";
import { ReplaySpeedChangeEvent } from "./InputHandler"; import { ReplaySpeedChangeEvent } from "./InputHandler";
import { getPersistentID } from "./Main";
import { defaultReplaySpeedMultiplier } from "./utilities/ReplaySpeedMultiplier"; import { defaultReplaySpeedMultiplier } from "./utilities/ReplaySpeedMultiplier";
import { getPersistentID } from "./Main";
import { z } from "zod";
export class LocalServer { export class LocalServer {
// All turns from the game record on replay. // All turns from the game record on replay.
+26 -30
View File
@@ -1,46 +1,42 @@
import version from "../../resources/version.txt";
import { UserMeResponse } from "../core/ApiSchemas";
import { EventBus } from "../core/EventBus";
import { GameRecord, GameStartInfo, ID } from "../core/Schemas";
import { ServerConfig } from "../core/configuration/Config";
import { getServerConfigFromClient } from "../core/configuration/ConfigLoader";
import { GameType } from "../core/game/Game";
import { UserSettings } from "../core/game/UserSettings";
import { joinLobby } from "./ClientGameRunner";
import "./DarkModeButton"; import "./DarkModeButton";
import { DarkModeButton } from "./DarkModeButton";
import "./FlagInput"; import "./FlagInput";
import "./GoogleAdElement";
import "./LangSelector";
import "./PublicLobby";
import "./UsernameInput";
import "./components/NewsButton";
import "./components/baseComponents/Button";
import "./components/baseComponents/Modal";
import "./styles.css";
import { GameRecord, GameStartInfo, ID } from "../core/Schemas";
import { discordLogin, getUserMe, isLoggedIn, logOut } from "./jwt";
import { generateCryptoRandomUUID, incrementGamesPlayed, translateText } from "./Utils";
import { DarkModeButton } from "./DarkModeButton";
import { EventBus } from "../core/EventBus";
import { FlagInput } from "./FlagInput"; import { FlagInput } from "./FlagInput";
import { FlagInputModal } from "./FlagInputModal"; import { FlagInputModal } from "./FlagInputModal";
import { GameStartingModal } from "./GameStartingModal"; import { GameStartingModal } from "./GameStartingModal";
import "./GoogleAdElement"; import { GameType } from "../core/game/Game";
import { HelpModal } from "./HelpModal"; import { HelpModal } from "./HelpModal";
import { HostLobbyModal as HostPrivateLobbyModal } from "./HostLobbyModal"; import { HostLobbyModal } from "./HostLobbyModal";
import { JoinPrivateLobbyModal } from "./JoinPrivateLobbyModal"; import { JoinPrivateLobbyModal } from "./JoinPrivateLobbyModal";
import "./LangSelector";
import { LangSelector } from "./LangSelector"; import { LangSelector } from "./LangSelector";
import { LanguageModal } from "./LanguageModal"; import { LanguageModal } from "./LanguageModal";
import { NewsButton } from "./components/NewsButton";
import { NewsModal } from "./NewsModal"; import { NewsModal } from "./NewsModal";
import "./PublicLobby"; import { OButton } from "./components/baseComponents/Button";
import { PublicLobby } from "./PublicLobby"; import { PublicLobby } from "./PublicLobby";
import { SendKickPlayerIntentEvent } from "./Transport";
import { ServerConfig } from "../core/configuration/Config";
import { SinglePlayerModal } from "./SinglePlayerModal"; import { SinglePlayerModal } from "./SinglePlayerModal";
import { TerritoryPatternsModal } from "./TerritoryPatternsModal"; import { TerritoryPatternsModal } from "./TerritoryPatternsModal";
import { SendKickPlayerIntentEvent } from "./Transport"; import { UserMeResponse } from "../core/ApiSchemas";
import { UserSettingModal } from "./UserSettingModal"; import { UserSettingModal } from "./UserSettingModal";
import "./UsernameInput"; import { UserSettings } from "../core/game/UserSettings";
import { UsernameInput } from "./UsernameInput"; import { UsernameInput } from "./UsernameInput";
import { import { getServerConfigFromClient } from "../core/configuration/ConfigLoader";
generateCryptoRandomUUID, import { joinLobby } from "./ClientGameRunner";
incrementGamesPlayed, import version from "../../resources/version.txt";
translateText,
} from "./Utils";
import "./components/NewsButton";
import { NewsButton } from "./components/NewsButton";
import "./components/baseComponents/Button";
import { OButton } from "./components/baseComponents/Button";
import "./components/baseComponents/Modal";
import { discordLogin, getUserMe, isLoggedIn, logOut } from "./jwt";
import "./styles.css";
declare global { declare global {
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions // eslint-disable-next-line @typescript-eslint/consistent-type-definitions
@@ -360,8 +356,8 @@ class Client {
const hostModal = document.querySelector( const hostModal = document.querySelector(
"host-lobby-modal", "host-lobby-modal",
) as HostPrivateLobbyModal; ) as HostLobbyModal;
hostModal instanceof HostPrivateLobbyModal; hostModal instanceof HostLobbyModal;
const hostLobbyButton = document.getElementById("host-lobby-button"); const hostLobbyButton = document.getElementById("host-lobby-button");
if (hostLobbyButton === null) throw new Error("Missing host-lobby-button"); if (hostLobbyButton === null) throw new Error("Missing host-lobby-button");
hostLobbyButton.addEventListener("click", () => { hostLobbyButton.addEventListener("click", () => {
+5 -5
View File
@@ -1,10 +1,10 @@
import { LitElement, css, html } from "lit";
import { resolveMarkdown } from "lit-markdown";
import { customElement, property, query } from "lit/decorators.js";
import changelog from "../../resources/changelog.md";
import { translateText } from "../client/Utils";
import "./components/baseComponents/Button"; import "./components/baseComponents/Button";
import "./components/baseComponents/Modal"; import "./components/baseComponents/Modal";
import { LitElement, css, html } from "lit";
import { customElement, property, query } from "lit/decorators.js";
import changelog from "../../resources/changelog.md";
import { resolveMarkdown } from "lit-markdown";
import { translateText } from "../client/Utils";
@customElement("news-modal") @customElement("news-modal")
export class NewsModal extends LitElement { export class NewsModal extends LitElement {
+4 -4
View File
@@ -1,12 +1,12 @@
import { GameID, GameInfo } from "../core/Schemas";
import { GameMapType, GameMode } from "../core/game/Game";
import { LitElement, html } from "lit"; import { LitElement, html } from "lit";
import { customElement, state } from "lit/decorators.js"; import { customElement, state } from "lit/decorators.js";
import { translateText } from "../client/Utils";
import { ApiPublicLobbiesResponseSchema } from "../core/ExpressSchemas"; import { ApiPublicLobbiesResponseSchema } from "../core/ExpressSchemas";
import { GameMapType, GameMode } from "../core/game/Game";
import { GameID, GameInfo } from "../core/Schemas";
import { generateID } from "../core/Util";
import { JoinLobbyEvent } from "./Main"; import { JoinLobbyEvent } from "./Main";
import { generateID } from "../core/Util";
import { terrainMapFileLoader } from "./TerrainMapFileLoader"; import { terrainMapFileLoader } from "./TerrainMapFileLoader";
import { translateText } from "../client/Utils";
@customElement("public-lobby") @customElement("public-lobby")
export class PublicLobby extends LitElement { export class PublicLobby extends LitElement {
+11 -11
View File
@@ -1,7 +1,7 @@
import { LitElement, html } from "lit"; import "./components/Difficulties";
import { customElement, query, state } from "lit/decorators.js"; import "./components/Maps";
import randomMap from "../../resources/images/RandomMap.webp"; import "./components/baseComponents/Button";
import { translateText } from "../client/Utils"; import "./components/baseComponents/Modal";
import { import {
Difficulty, Difficulty,
Duos, Duos,
@@ -13,18 +13,18 @@ import {
UnitType, UnitType,
mapCategories, mapCategories,
} from "../core/game/Game"; } from "../core/game/Game";
import { UserSettings } from "../core/game/UserSettings"; import { LitElement, html } from "lit";
import { TeamCountConfig } from "../core/Schemas"; import { customElement, query, state } from "lit/decorators.js";
import { generateID } from "../core/Util";
import "./components/baseComponents/Button";
import "./components/baseComponents/Modal";
import "./components/Difficulties";
import { DifficultyDescription } from "./components/Difficulties"; import { DifficultyDescription } from "./components/Difficulties";
import "./components/Maps";
import { FlagInput } from "./FlagInput"; import { FlagInput } from "./FlagInput";
import { JoinLobbyEvent } from "./Main"; import { JoinLobbyEvent } from "./Main";
import { TeamCountConfig } from "../core/Schemas";
import { UserSettings } from "../core/game/UserSettings";
import { UsernameInput } from "./UsernameInput"; import { UsernameInput } from "./UsernameInput";
import { generateID } from "../core/Util";
import randomMap from "../../resources/images/RandomMap.webp";
import { renderUnitTypeOptions } from "./utilities/RenderUnitTypeOptions"; import { renderUnitTypeOptions } from "./utilities/RenderUnitTypeOptions";
import { translateText } from "../client/Utils";
@customElement("single-player-modal") @customElement("single-player-modal")
export class SinglePlayerModal extends LitElement { export class SinglePlayerModal extends LitElement {
+1 -1
View File
@@ -1,4 +1,4 @@
import version from "../../resources/version.txt";
import { FetchGameMapLoader } from "../core/game/FetchGameMapLoader"; import { FetchGameMapLoader } from "../core/game/FetchGameMapLoader";
import version from "../../resources/version.txt";
export const terrainMapFileLoader = new FetchGameMapLoader(`/maps`, version); export const terrainMapFileLoader = new FetchGameMapLoader(`/maps`, version);
+8 -8
View File
@@ -1,14 +1,14 @@
import { base64url } from "jose";
import type { TemplateResult } from "lit";
import { html, LitElement, render } from "lit";
import { customElement, query, state } from "lit/decorators.js";
import { UserMeResponse } from "../core/ApiSchemas";
import { Pattern } from "../core/CosmeticSchemas";
import { UserSettings } from "../core/game/UserSettings";
import { PatternDecoder } from "../core/PatternDecoder";
import "./components/Difficulties"; import "./components/Difficulties";
import "./components/Maps"; import "./components/Maps";
import { LitElement, html, render } from "lit";
import { customElement, query, state } from "lit/decorators.js";
import { handlePurchase, patterns } from "./Cosmetics"; import { handlePurchase, patterns } from "./Cosmetics";
import { Pattern } from "../core/CosmeticSchemas";
import { PatternDecoder } from "../core/PatternDecoder";
import type { TemplateResult } from "lit";
import { UserMeResponse } from "../core/ApiSchemas";
import { UserSettings } from "../core/game/UserSettings";
import { base64url } from "jose";
import { translateText } from "./Utils"; import { translateText } from "./Utils";
@customElement("territory-patterns-modal") @customElement("territory-patterns-modal")
+5 -5
View File
@@ -1,5 +1,3 @@
import { z } from "zod";
import { EventBus, GameEvent } from "../core/EventBus";
import { import {
AllPlayers, AllPlayers,
GameType, GameType,
@@ -9,8 +7,6 @@ import {
Tick, Tick,
UnitType, UnitType,
} from "../core/game/Game"; } from "../core/game/Game";
import { TileRef } from "../core/game/GameMap";
import { PlayerView } from "../core/game/GameView";
import { import {
AllPlayersStats, AllPlayersStats,
ClientHashMessage, ClientHashMessage,
@@ -24,9 +20,13 @@ import {
ServerMessageSchema, ServerMessageSchema,
Winner, Winner,
} from "../core/Schemas"; } from "../core/Schemas";
import { replacer } from "../core/Util"; import { EventBus, GameEvent } from "../core/EventBus";
import { LobbyConfig } from "./ClientGameRunner"; import { LobbyConfig } from "./ClientGameRunner";
import { LocalServer } from "./LocalServer"; import { LocalServer } from "./LocalServer";
import { PlayerView } from "../core/game/GameView";
import { TileRef } from "../core/game/GameMap";
import { replacer } from "../core/Util";
import { z } from "zod";
export class PauseGameEvent implements GameEvent { export class PauseGameEvent implements GameEvent {
constructor(public readonly paused: boolean) {} constructor(public readonly paused: boolean) {}
+6 -6
View File
@@ -1,13 +1,13 @@
import { LitElement, html } from "lit";
import { customElement, query, state } from "lit/decorators.js";
import { z } from "zod";
import { translateText } from "../client/Utils";
import { UserSettings } from "../core/game/UserSettings";
import "./components/baseComponents/setting/SettingKeybind"; import "./components/baseComponents/setting/SettingKeybind";
import { SettingKeybind } from "./components/baseComponents/setting/SettingKeybind";
import "./components/baseComponents/setting/SettingNumber"; import "./components/baseComponents/setting/SettingNumber";
import "./components/baseComponents/setting/SettingSlider"; import "./components/baseComponents/setting/SettingSlider";
import "./components/baseComponents/setting/SettingToggle"; import "./components/baseComponents/setting/SettingToggle";
import { LitElement, html } from "lit";
import { customElement, query, state } from "lit/decorators.js";
import { SettingKeybind } from "./components/baseComponents/setting/SettingKeybind";
import { UserSettings } from "../core/game/UserSettings";
import { translateText } from "../client/Utils";
import { z } from "zod";
const KeybindSchema = z.record(z.string(), z.string()); const KeybindSchema = z.record(z.string(), z.string());
+4 -4
View File
@@ -1,12 +1,12 @@
import { LitElement, html } from "lit"; import { LitElement, html } from "lit";
import { customElement, property, state } from "lit/decorators.js";
import { v4 as uuidv4 } from "uuid";
import { translateText } from "../client/Utils";
import { UserSettings } from "../core/game/UserSettings";
import { import {
MAX_USERNAME_LENGTH, MAX_USERNAME_LENGTH,
validateUsername, validateUsername,
} from "../core/validations/username"; } from "../core/validations/username";
import { customElement, property, state } from "lit/decorators.js";
import { UserSettings } from "../core/game/UserSettings";
import { translateText } from "../client/Utils";
import { v4 as uuidv4 } from "uuid";
const usernameKey = "username"; const usernameKey = "username";
+1 -1
View File
@@ -1,6 +1,6 @@
import IntlMessageFormat from "intl-messageformat"; import IntlMessageFormat from "intl-messageformat";
import { MessageType } from "../core/game/Game";
import { LangSelector } from "./LangSelector"; import { LangSelector } from "./LangSelector";
import { MessageType } from "../core/game/Game";
export function renderTroops(troops: number): string { export function renderTroops(troops: number): string {
return renderNumber(troops / 10); return renderNumber(troops / 10);
+2 -2
View File
@@ -1,9 +1,9 @@
import { LitElement, html } from "lit"; import { LitElement, html } from "lit";
import { customElement, property, state } from "lit/decorators.js"; import { customElement, property, state } from "lit/decorators.js";
import megaphone from "../../../resources/images/Megaphone.svg";
import version from "../../../resources/version.txt";
import { NewsModal } from "../NewsModal"; import { NewsModal } from "../NewsModal";
import megaphone from "../../../resources/images/Megaphone.svg";
import { translateText } from "../Utils"; import { translateText } from "../Utils";
import version from "../../../resources/version.txt";
@customElement("news-button") @customElement("news-button")
export class NewsButton extends LitElement { export class NewsButton extends LitElement {
+13 -13
View File
@@ -1,19 +1,19 @@
import miniBigSmoke from "../../../resources/sprites/bigsmoke.png";
import conquestSword from "../../../resources/sprites/conquestSword.png";
import dust from "../../../resources/sprites/dust.png";
import miniExplosion from "../../../resources/sprites/miniExplosion.png";
import miniFire from "../../../resources/sprites/minifire.png";
import nuke from "../../../resources/sprites/nukeExplosion.png";
import SAMExplosion from "../../../resources/sprites/samExplosion.png";
import sinkingShip from "../../../resources/sprites/sinkingShip.png";
import miniSmoke from "../../../resources/sprites/smoke.png";
import miniSmokeAndFire from "../../../resources/sprites/smokeAndFire.png";
import unitExplosion from "../../../resources/sprites/unitExplosion.png";
import { Theme } from "../../core/configuration/Config";
import { PlayerView } from "../../core/game/GameView";
import { AnimatedSprite } from "./AnimatedSprite"; import { AnimatedSprite } from "./AnimatedSprite";
import { FxType } from "./fx/Fx"; import { FxType } from "./fx/Fx";
import { PlayerView } from "../../core/game/GameView";
import SAMExplosion from "../../../resources/sprites/samExplosion.png";
import { Theme } from "../../core/configuration/Config";
import { colorizeCanvas } from "./SpriteLoader"; import { colorizeCanvas } from "./SpriteLoader";
import conquestSword from "../../../resources/sprites/conquestSword.png";
import dust from "../../../resources/sprites/dust.png";
import miniBigSmoke from "../../../resources/sprites/bigsmoke.png";
import miniExplosion from "../../../resources/sprites/miniExplosion.png";
import miniFire from "../../../resources/sprites/minifire.png";
import miniSmoke from "../../../resources/sprites/smoke.png";
import miniSmokeAndFire from "../../../resources/sprites/smokeAndFire.png";
import nuke from "../../../resources/sprites/nukeExplosion.png";
import sinkingShip from "../../../resources/sprites/sinkingShip.png";
import unitExplosion from "../../../resources/sprites/unitExplosion.png";
type AnimatedSpriteConfig = { type AnimatedSpriteConfig = {
url: string; url: string;
+7 -7
View File
@@ -1,21 +1,17 @@
import { EventBus } from "../../core/EventBus";
import { GameView } from "../../core/game/GameView";
import { UserSettings } from "../../core/game/UserSettings";
import { GameStartingModal } from "../GameStartingModal";
import { RefreshGraphicsEvent as RedrawGraphicsEvent } from "../InputHandler";
import { TransformHandler } from "./TransformHandler";
import { UIState } from "./UIState";
import { AlertFrame } from "./layers/AlertFrame"; import { AlertFrame } from "./layers/AlertFrame";
import { BuildMenu } from "./layers/BuildMenu"; import { BuildMenu } from "./layers/BuildMenu";
import { ChatDisplay } from "./layers/ChatDisplay"; import { ChatDisplay } from "./layers/ChatDisplay";
import { ChatModal } from "./layers/ChatModal"; import { ChatModal } from "./layers/ChatModal";
import { ControlPanel } from "./layers/ControlPanel"; import { ControlPanel } from "./layers/ControlPanel";
import { EmojiTable } from "./layers/EmojiTable"; import { EmojiTable } from "./layers/EmojiTable";
import { EventBus } from "../../core/EventBus";
import { EventsDisplay } from "./layers/EventsDisplay"; import { EventsDisplay } from "./layers/EventsDisplay";
import { FPSDisplay } from "./layers/FPSDisplay"; import { FPSDisplay } from "./layers/FPSDisplay";
import { FxLayer } from "./layers/FxLayer"; import { FxLayer } from "./layers/FxLayer";
import { GameLeftSidebar } from "./layers/GameLeftSidebar"; import { GameLeftSidebar } from "./layers/GameLeftSidebar";
import { GameRightSidebar } from "./layers/GameRightSidebar"; import { GameRightSidebar } from "./layers/GameRightSidebar";
import { GameStartingModal } from "../GameStartingModal";
import { GameView } from "../../core/game/GameView";
import { GutterAdModal } from "./layers/GutterAdModal"; import { GutterAdModal } from "./layers/GutterAdModal";
import { HeadsUpMessage } from "./layers/HeadsUpMessage"; import { HeadsUpMessage } from "./layers/HeadsUpMessage";
import { Layer } from "./layers/Layer"; import { Layer } from "./layers/Layer";
@@ -26,6 +22,7 @@ import { NameLayer } from "./layers/NameLayer";
import { PlayerInfoOverlay } from "./layers/PlayerInfoOverlay"; import { PlayerInfoOverlay } from "./layers/PlayerInfoOverlay";
import { PlayerPanel } from "./layers/PlayerPanel"; import { PlayerPanel } from "./layers/PlayerPanel";
import { RailroadLayer } from "./layers/RailroadLayer"; import { RailroadLayer } from "./layers/RailroadLayer";
import { RedrawGraphicsEvent } from "../InputHandler";
import { ReplayPanel } from "./layers/ReplayPanel"; import { ReplayPanel } from "./layers/ReplayPanel";
import { SettingsModal } from "./layers/SettingsModal"; import { SettingsModal } from "./layers/SettingsModal";
import { SpawnAd } from "./layers/SpawnAd"; import { SpawnAd } from "./layers/SpawnAd";
@@ -35,9 +32,12 @@ import { StructureLayer } from "./layers/StructureLayer";
import { TeamStats } from "./layers/TeamStats"; import { TeamStats } from "./layers/TeamStats";
import { TerrainLayer } from "./layers/TerrainLayer"; import { TerrainLayer } from "./layers/TerrainLayer";
import { TerritoryLayer } from "./layers/TerritoryLayer"; import { TerritoryLayer } from "./layers/TerritoryLayer";
import { TransformHandler } from "./TransformHandler";
import { UILayer } from "./layers/UILayer"; import { UILayer } from "./layers/UILayer";
import { UIState } from "./UIState";
import { UnitDisplay } from "./layers/UnitDisplay"; import { UnitDisplay } from "./layers/UnitDisplay";
import { UnitLayer } from "./layers/UnitLayer"; import { UnitLayer } from "./layers/UnitLayer";
import { UserSettings } from "../../core/game/UserSettings";
import { WinModal } from "./layers/WinModal"; import { WinModal } from "./layers/WinModal";
export function createRenderer( export function createRenderer(
+4 -4
View File
@@ -1,17 +1,17 @@
import { TrainType, UnitType } from "../../core/game/Game";
import { Colord } from "colord"; import { Colord } from "colord";
import { Theme } from "../../core/configuration/Config";
import { UnitView } from "../../core/game/GameView";
import atomBombSprite from "../../../resources/sprites/atombomb.png"; import atomBombSprite from "../../../resources/sprites/atombomb.png";
import hydrogenBombSprite from "../../../resources/sprites/hydrogenbomb.png"; import hydrogenBombSprite from "../../../resources/sprites/hydrogenbomb.png";
import mirvSprite from "../../../resources/sprites/mirv2.png"; import mirvSprite from "../../../resources/sprites/mirv2.png";
import samMissileSprite from "../../../resources/sprites/samMissile.png"; import samMissileSprite from "../../../resources/sprites/samMissile.png";
import tradeShipSprite from "../../../resources/sprites/tradeship.png"; import tradeShipSprite from "../../../resources/sprites/tradeship.png";
import trainCarriageSprite from "../../../resources/sprites/trainCarriage.png"; import trainCarriageSprite from "../../../resources/sprites/trainCarriage.png";
import trainLoadedCarriageSprite from "../../../resources/sprites/trainCarriageLoaded.png";
import trainEngineSprite from "../../../resources/sprites/trainEngine.png"; import trainEngineSprite from "../../../resources/sprites/trainEngine.png";
import trainLoadedCarriageSprite from "../../../resources/sprites/trainCarriageLoaded.png";
import transportShipSprite from "../../../resources/sprites/transportship.png"; import transportShipSprite from "../../../resources/sprites/transportship.png";
import warshipSprite from "../../../resources/sprites/warship.png"; import warshipSprite from "../../../resources/sprites/warship.png";
import { Theme } from "../../core/configuration/Config";
import { TrainType, UnitType } from "../../core/game/Game";
import { UnitView } from "../../core/game/GameView";
// Can't reuse TrainType because "loaded" is not a type, just an attribute // Can't reuse TrainType because "loaded" is not a type, just an attribute
const TrainTypeSprite = { const TrainTypeSprite = {
+3 -3
View File
@@ -1,12 +1,12 @@
import { EventBus } from "../../core/EventBus";
import { Cell } from "../../core/game/Game";
import { GameView } from "../../core/game/GameView";
import { CenterCameraEvent, DragEvent, ZoomEvent } from "../InputHandler"; import { CenterCameraEvent, DragEvent, ZoomEvent } from "../InputHandler";
import { import {
GoToPlayerEvent, GoToPlayerEvent,
GoToPositionEvent, GoToPositionEvent,
GoToUnitEvent, GoToUnitEvent,
} from "./layers/Leaderboard"; } from "./layers/Leaderboard";
import { Cell } from "../../core/game/Game";
import { EventBus } from "../../core/EventBus";
import { GameView } from "../../core/game/GameView";
export const GOTO_INTERVAL_MS = 16; export const GOTO_INTERVAL_MS = 16;
export const CAMERA_MAX_SPEED = 15; export const CAMERA_MAX_SPEED = 15;
+4 -4
View File
@@ -1,10 +1,10 @@
import { FadeFx, SpriteFx } from "./SpriteFx";
import { Fx, FxType } from "./Fx";
import { AnimatedSpriteLoader } from "../AnimatedSpriteLoader";
import { ConquestUpdate } from "../../../core/game/GameUpdates"; import { ConquestUpdate } from "../../../core/game/GameUpdates";
import { GameView } from "../../../core/game/GameView"; import { GameView } from "../../../core/game/GameView";
import { renderNumber } from "../../Utils";
import { AnimatedSpriteLoader } from "../AnimatedSpriteLoader";
import { Fx, FxType } from "./Fx";
import { FadeFx, SpriteFx } from "./SpriteFx";
import { TextFx } from "./TextFx"; import { TextFx } from "./TextFx";
import { renderNumber } from "../../Utils";
/** /**
* Conquest FX: * Conquest FX:
+3 -3
View File
@@ -1,7 +1,7 @@
import { GameView } from "../../../core/game/GameView";
import { AnimatedSpriteLoader } from "../AnimatedSpriteLoader";
import { Fx, FxType } from "./Fx";
import { FadeFx, SpriteFx } from "./SpriteFx"; import { FadeFx, SpriteFx } from "./SpriteFx";
import { Fx, FxType } from "./Fx";
import { AnimatedSpriteLoader } from "../AnimatedSpriteLoader";
import { GameView } from "../../../core/game/GameView";
/** /**
* Shockwave effect: draw a growing 1px white circle * Shockwave effect: draw a growing 1px white circle
+3 -3
View File
@@ -1,8 +1,8 @@
import { Theme } from "../../../core/configuration/Config"; import { Fx, FxType } from "./Fx";
import { PlayerView } from "../../../core/game/GameView";
import { AnimatedSprite } from "../AnimatedSprite"; import { AnimatedSprite } from "../AnimatedSprite";
import { AnimatedSpriteLoader } from "../AnimatedSpriteLoader"; import { AnimatedSpriteLoader } from "../AnimatedSpriteLoader";
import { Fx, FxType } from "./Fx"; import { PlayerView } from "../../../core/game/GameView";
import { Theme } from "../../../core/configuration/Config";
function fadeInOut(t: number, fadeIn = 0.3, fadeOut = 0.7): number { function fadeInOut(t: number, fadeIn = 0.3, fadeOut = 0.7): number {
if (t < fadeIn) { if (t < fadeIn) {
+2 -2
View File
@@ -1,6 +1,6 @@
import { GameView } from "../../../core/game/GameView";
import { AnimatedSpriteLoader } from "../AnimatedSpriteLoader";
import { Fx, FxType } from "./Fx"; import { Fx, FxType } from "./Fx";
import { AnimatedSpriteLoader } from "../AnimatedSpriteLoader";
import { GameView } from "../../../core/game/GameView";
import { SpriteFx } from "./SpriteFx"; import { SpriteFx } from "./SpriteFx";
import { Timeline } from "./Timeline"; import { Timeline } from "./Timeline";
+3 -3
View File
@@ -1,12 +1,12 @@
import { LitElement, css, html } from "lit";
import { customElement, state } from "lit/decorators.js";
import { import {
BrokeAllianceUpdate, BrokeAllianceUpdate,
GameUpdateType, GameUpdateType,
} from "../../../core/game/GameUpdates"; } from "../../../core/game/GameUpdates";
import { LitElement, css, html } from "lit";
import { customElement, state } from "lit/decorators.js";
import { GameView } from "../../../core/game/GameView"; import { GameView } from "../../../core/game/GameView";
import { UserSettings } from "../../../core/game/UserSettings";
import { Layer } from "./Layer"; import { Layer } from "./Layer";
import { UserSettings } from "../../../core/game/UserSettings";
// Parameters for the alert animation // Parameters for the alert animation
const ALERT_SPEED = 1.6; const ALERT_SPEED = 1.6;
+23 -23
View File
@@ -1,39 +1,39 @@
import { LitElement, css, html } from "lit"; import {
import { customElement, state } from "lit/decorators.js"; BuildUnitIntentEvent,
import warshipIcon from "../../../../resources/images/BattleshipIconWhite.svg"; SendUpgradeStructureIntentEvent,
import cityIcon from "../../../../resources/images/CityIconWhite.svg"; } from "../../Transport";
import factoryIcon from "../../../../resources/images/FactoryIconWhite.svg";
import goldCoinIcon from "../../../../resources/images/GoldCoinIcon.svg";
import mirvIcon from "../../../../resources/images/MIRVIcon.svg";
import hydrogenBombIcon from "../../../../resources/images/MushroomCloudIconWhite.svg";
import atomBombIcon from "../../../../resources/images/NukeIconWhite.svg";
import portIcon from "../../../../resources/images/PortIcon.svg";
import shieldIcon from "../../../../resources/images/ShieldIconWhite.svg";
import missileSiloIcon from "../../../../resources/non-commercial/svg/MissileSiloIconWhite.svg";
import samlauncherIcon from "../../../../resources/non-commercial/svg/SamLauncherIconWhite.svg";
import { translateText } from "../../../client/Utils";
import { EventBus } from "../../../core/EventBus";
import { import {
BuildableUnit, BuildableUnit,
Gold, Gold,
PlayerActions, PlayerActions,
UnitType, UnitType,
} from "../../../core/game/Game"; } from "../../../core/game/Game";
import { TileRef } from "../../../core/game/GameMap";
import { GameView } from "../../../core/game/GameView";
import { import {
CloseViewEvent, CloseViewEvent,
MouseDownEvent, MouseDownEvent,
ShowBuildMenuEvent, ShowBuildMenuEvent,
ShowEmojiMenuEvent, ShowEmojiMenuEvent,
} from "../../InputHandler"; } from "../../InputHandler";
import { import { LitElement, css, html } from "lit";
BuildUnitIntentEvent, import { customElement, state } from "lit/decorators.js";
SendUpgradeStructureIntentEvent, import { EventBus } from "../../../core/EventBus";
} from "../../Transport"; import { GameView } from "../../../core/game/GameView";
import { renderNumber } from "../../Utils";
import { TransformHandler } from "../TransformHandler";
import { Layer } from "./Layer"; import { Layer } from "./Layer";
import { TileRef } from "../../../core/game/GameMap";
import { TransformHandler } from "../TransformHandler";
import atomBombIcon from "../../../../resources/images/NukeIconWhite.svg";
import cityIcon from "../../../../resources/images/CityIconWhite.svg";
import factoryIcon from "../../../../resources/images/FactoryIconWhite.svg";
import goldCoinIcon from "../../../../resources/images/GoldCoinIcon.svg";
import hydrogenBombIcon from "../../../../resources/images/MushroomCloudIconWhite.svg";
import mirvIcon from "../../../../resources/images/MIRVIcon.svg";
import missileSiloIcon from "../../../../resources/non-commercial/svg/MissileSiloIconWhite.svg";
import portIcon from "../../../../resources/images/PortIcon.svg";
import { renderNumber } from "../../Utils";
import samlauncherIcon from "../../../../resources/non-commercial/svg/SamLauncherIconWhite.svg";
import shieldIcon from "../../../../resources/images/ShieldIconWhite.svg";
import { translateText } from "../../../client/Utils";
import warshipIcon from "../../../../resources/images/BattleshipIconWhite.svg";
export type BuildItemDisplay = { export type BuildItemDisplay = {
unitType: UnitType; unitType: UnitType;
+7 -7
View File
@@ -1,16 +1,16 @@
import { html, LitElement } from "lit";
import { customElement, state } from "lit/decorators.js";
import { DirectiveResult } from "lit/directive.js";
import { unsafeHTML, UnsafeHTMLDirective } from "lit/directives/unsafe-html.js";
import { EventBus } from "../../../core/EventBus";
import { MessageType } from "../../../core/game/Game";
import { import {
DisplayMessageUpdate, DisplayMessageUpdate,
GameUpdateType, GameUpdateType,
} from "../../../core/game/GameUpdates"; } from "../../../core/game/GameUpdates";
import { LitElement, html } from "lit";
import { UnsafeHTMLDirective, unsafeHTML } from "lit/directives/unsafe-html.js";
import { customElement, state } from "lit/decorators.js";
import { DirectiveResult } from "lit/directive.js";
import { EventBus } from "../../../core/EventBus";
import { GameView } from "../../../core/game/GameView"; import { GameView } from "../../../core/game/GameView";
import { onlyImages } from "../../../core/Util";
import { Layer } from "./Layer"; import { Layer } from "./Layer";
import { MessageType } from "../../../core/game/Game";
import { onlyImages } from "../../../core/Util";
type ChatEvent = { type ChatEvent = {
description: string; description: string;
@@ -1,9 +1,9 @@
import { EventBus } from "../../../core/EventBus"; import { COLORS, MenuElement, MenuElementParams } from "./RadialMenuElements";
import { ChatModal, QuickChatPhrase, quickChatPhrases } from "./ChatModal";
import { GameView, PlayerView } from "../../../core/game/GameView"; import { GameView, PlayerView } from "../../../core/game/GameView";
import { EventBus } from "../../../core/EventBus";
import { SendQuickChatEvent } from "../../Transport"; import { SendQuickChatEvent } from "../../Transport";
import { translateText } from "../../Utils"; import { translateText } from "../../Utils";
import { ChatModal, QuickChatPhrase, quickChatPhrases } from "./ChatModal";
import { COLORS, MenuElement, MenuElementParams } from "./RadialMenuElements";
export class ChatIntegration { export class ChatIntegration {
private ctModal: ChatModal; private ctModal: ChatModal;
+4 -6
View File
@@ -1,13 +1,11 @@
import { GameView, PlayerView } from "../../../core/game/GameView";
import { LitElement, html } from "lit"; import { LitElement, html } from "lit";
import { customElement, query } from "lit/decorators.js"; import { customElement, query } from "lit/decorators.js";
import { PlayerType } from "../../../core/game/Game";
import { GameView, PlayerView } from "../../../core/game/GameView";
import quickChatData from "../../../../resources/QuickChat.json";
import { EventBus } from "../../../core/EventBus";
import { CloseViewEvent } from "../../InputHandler"; import { CloseViewEvent } from "../../InputHandler";
import { EventBus } from "../../../core/EventBus";
import { PlayerType } from "../../../core/game/Game";
import { SendQuickChatEvent } from "../../Transport"; import { SendQuickChatEvent } from "../../Transport";
import quickChatData from "../../../../resources/QuickChat.json";
import { translateText } from "../../Utils"; import { translateText } from "../../Utils";
export type QuickChatPhrase = { export type QuickChatPhrase = {
+7 -7
View File
@@ -1,14 +1,14 @@
import { LitElement, html } from "lit"; import { LitElement, html } from "lit";
import { customElement, state } from "lit/decorators.js"; import { customElement, state } from "lit/decorators.js";
import { translateText } from "../../../client/Utils";
import { EventBus } from "../../../core/EventBus";
import { Gold } from "../../../core/game/Game";
import { GameView } from "../../../core/game/GameView";
import { ClientID } from "../../../core/Schemas";
import { AttackRatioEvent } from "../../InputHandler";
import { renderNumber, renderTroops } from "../../Utils"; import { renderNumber, renderTroops } from "../../Utils";
import { UIState } from "../UIState"; import { AttackRatioEvent } from "../../InputHandler";
import { ClientID } from "../../../core/Schemas";
import { EventBus } from "../../../core/EventBus";
import { GameView } from "../../../core/game/GameView";
import { Gold } from "../../../core/game/Game";
import { Layer } from "./Layer"; import { Layer } from "./Layer";
import { UIState } from "../UIState";
import { translateText } from "../../../client/Utils";
@customElement("control-panel") @customElement("control-panel")
export class ControlPanel extends LitElement implements Layer { export class ControlPanel extends LitElement implements Layer {
+5 -5
View File
@@ -1,12 +1,12 @@
import { CloseViewEvent, ShowEmojiMenuEvent } from "../../InputHandler";
import { GameView, PlayerView } from "../../../core/game/GameView";
import { LitElement, html } from "lit"; import { LitElement, html } from "lit";
import { customElement, state } from "lit/decorators.js"; import { customElement, state } from "lit/decorators.js";
import { EventBus } from "../../../core/EventBus";
import { AllPlayers } from "../../../core/game/Game";
import { GameView, PlayerView } from "../../../core/game/GameView";
import { TerraNulliusImpl } from "../../../core/game/TerraNulliusImpl";
import { emojiTable, flattenedEmojiTable } from "../../../core/Util"; import { emojiTable, flattenedEmojiTable } from "../../../core/Util";
import { CloseViewEvent, ShowEmojiMenuEvent } from "../../InputHandler"; import { AllPlayers } from "../../../core/game/Game";
import { EventBus } from "../../../core/EventBus";
import { SendEmojiIntentEvent } from "../../Transport"; import { SendEmojiIntentEvent } from "../../Transport";
import { TerraNulliusImpl } from "../../../core/game/TerraNulliusImpl";
import { TransformHandler } from "../TransformHandler"; import { TransformHandler } from "../TransformHandler";
@customElement("emoji-table") @customElement("emoji-table")
+13 -15
View File
@@ -1,21 +1,12 @@
/* eslint-disable max-lines */ /* eslint-disable max-lines */
import { html, LitElement, TemplateResult } from "lit";
import { customElement, state } from "lit/decorators.js";
import { DirectiveResult } from "lit/directive.js";
import { unsafeHTML, UnsafeHTMLDirective } from "lit/directives/unsafe-html.js";
import allianceIcon from "../../../../resources/images/AllianceIconWhite.svg";
import chatIcon from "../../../../resources/images/ChatIconWhite.svg";
import donateGoldIcon from "../../../../resources/images/DonateGoldIconWhite.svg";
import swordIcon from "../../../../resources/images/SwordIconWhite.svg";
import { EventBus } from "../../../core/EventBus";
import { import {
AllPlayers, AllPlayers,
getMessageCategory,
MessageCategory, MessageCategory,
MessageType, MessageType,
PlayerType, PlayerType,
Tick, Tick,
UnitType, UnitType,
getMessageCategory,
} from "../../../core/game/Game"; } from "../../../core/game/Game";
import { import {
AllianceExpiredUpdate, AllianceExpiredUpdate,
@@ -36,18 +27,25 @@ import {
SendAllianceExtensionIntentEvent, SendAllianceExtensionIntentEvent,
SendAllianceReplyIntentEvent, SendAllianceReplyIntentEvent,
} from "../../Transport"; } from "../../Transport";
import { Layer } from "./Layer";
import { GameView, PlayerView, UnitView } from "../../../core/game/GameView"; import { GameView, PlayerView, UnitView } from "../../../core/game/GameView";
import { onlyImages } from "../../../core/Util";
import { renderNumber, renderTroops } from "../../Utils";
import { import {
GoToPlayerEvent, GoToPlayerEvent,
GoToPositionEvent, GoToPositionEvent,
GoToUnitEvent, GoToUnitEvent,
} from "./Leaderboard"; } from "./Leaderboard";
import { LitElement, TemplateResult, html } from "lit";
import { UnsafeHTMLDirective, unsafeHTML } from "lit/directives/unsafe-html.js";
import { customElement, state } from "lit/decorators.js";
import { getMessageTypeClasses, translateText } from "../../Utils"; import { getMessageTypeClasses, translateText } from "../../Utils";
import { renderNumber, renderTroops } from "../../Utils";
import { DirectiveResult } from "lit/directive.js";
import { EventBus } from "../../../core/EventBus";
import { Layer } from "./Layer";
import allianceIcon from "../../../../resources/images/AllianceIconWhite.svg";
import chatIcon from "../../../../resources/images/ChatIconWhite.svg";
import donateGoldIcon from "../../../../resources/images/DonateGoldIconWhite.svg";
import { onlyImages } from "../../../core/Util";
import swordIcon from "../../../../resources/images/SwordIconWhite.svg";
type GameEvent = { type GameEvent = {
description: string; description: string;
+2 -2
View File
@@ -1,9 +1,9 @@
import { LitElement, css, html } from "lit"; import { LitElement, css, html } from "lit";
import { customElement, property, state } from "lit/decorators.js"; import { customElement, property, state } from "lit/decorators.js";
import { EventBus } from "../../../core/EventBus"; import { EventBus } from "../../../core/EventBus";
import { UserSettings } from "../../../core/game/UserSettings";
import { TogglePerformanceOverlayEvent } from "../../InputHandler";
import { Layer } from "./Layer"; import { Layer } from "./Layer";
import { TogglePerformanceOverlayEvent } from "../../InputHandler";
import { UserSettings } from "../../../core/game/UserSettings";
@customElement("fps-display") @customElement("fps-display")
export class FPSDisplay extends LitElement implements Layer { export class FPSDisplay extends LitElement implements Layer {
+9 -8
View File
@@ -1,21 +1,22 @@
import { Theme } from "../../../core/configuration/Config";
import { UnitType } from "../../../core/game/Game";
import { import {
BonusEventUpdate, BonusEventUpdate,
ConquestUpdate, ConquestUpdate,
GameUpdateType, GameUpdateType,
RailroadUpdate, RailroadUpdate,
} from "../../../core/game/GameUpdates"; } from "../../../core/game/GameUpdates";
import { GameView, UnitView } from "../../../core/game/GameView";
import { renderNumber } from "../../Utils";
import { AnimatedSpriteLoader } from "../AnimatedSpriteLoader";
import { conquestFxFactory } from "../fx/ConquestFx";
import { Fx, FxType } from "../fx/Fx"; import { Fx, FxType } from "../fx/Fx";
import { nukeFxFactory, ShockwaveFx } from "../fx/NukeFx"; import { GameView, UnitView } from "../../../core/game/GameView";
import { ShockwaveFx, nukeFxFactory } from "../fx/NukeFx";
import { AnimatedSpriteLoader } from "../AnimatedSpriteLoader";
import { Layer } from "./Layer";
import { SpriteFx } from "../fx/SpriteFx"; import { SpriteFx } from "../fx/SpriteFx";
import { TextFx } from "../fx/TextFx"; import { TextFx } from "../fx/TextFx";
import { Theme } from "../../../core/configuration/Config";
import { UnitExplosionFx } from "../fx/UnitExplosionFx"; import { UnitExplosionFx } from "../fx/UnitExplosionFx";
import { Layer } from "./Layer"; import { UnitType } from "../../../core/game/Game";
import { conquestFxFactory } from "../fx/ConquestFx";
import { renderNumber } from "../../Utils";
export class FxLayer implements Layer { export class FxLayer implements Layer {
private canvas: HTMLCanvasElement; private canvas: HTMLCanvasElement;
private context: CanvasRenderingContext2D; private context: CanvasRenderingContext2D;
@@ -1,14 +1,14 @@
import { Colord } from "colord"; import { LitElement, html } from "lit";
import { html, LitElement } from "lit";
import { customElement, state } from "lit/decorators.js"; import { customElement, state } from "lit/decorators.js";
import { Colord } from "colord";
import { GameMode } from "../../../core/game/Game";
import { GameView } from "../../../core/game/GameView";
import { Layer } from "./Layer";
import leaderboardRegularIcon from "../../../../resources/images/LeaderboardIconRegularWhite.svg"; import leaderboardRegularIcon from "../../../../resources/images/LeaderboardIconRegularWhite.svg";
import leaderboardSolidIcon from "../../../../resources/images/LeaderboardIconSolidWhite.svg"; import leaderboardSolidIcon from "../../../../resources/images/LeaderboardIconSolidWhite.svg";
import teamRegularIcon from "../../../../resources/images/TeamIconRegularWhite.svg"; import teamRegularIcon from "../../../../resources/images/TeamIconRegularWhite.svg";
import teamSolidIcon from "../../../../resources/images/TeamIconSolidWhite.svg"; import teamSolidIcon from "../../../../resources/images/TeamIconSolidWhite.svg";
import { GameMode } from "../../../core/game/Game";
import { GameView } from "../../../core/game/GameView";
import { translateText } from "../../Utils"; import { translateText } from "../../Utils";
import { Layer } from "./Layer";
@customElement("game-left-sidebar") @customElement("game-left-sidebar")
export class GameLeftSidebar extends LitElement implements Layer { export class GameLeftSidebar extends LitElement implements Layer {
@@ -1,20 +1,20 @@
import { html, LitElement } from "lit"; import { LitElement, html } from "lit";
import { customElement, state } from "lit/decorators.js"; import { customElement, state } from "lit/decorators.js";
import { EventBus } from "../../../core/EventBus";
import { GameType } from "../../../core/game/Game";
import { GameUpdateType } from "../../../core/game/GameUpdates";
import { GameView } from "../../../core/game/GameView";
import { Layer } from "./Layer";
import { PauseGameEvent } from "../../Transport";
import { ShowReplayPanelEvent } from "./ReplayPanel";
import { ShowSettingsModalEvent } from "./SettingsModal";
import exitIcon from "../../../../resources/images/ExitIconWhite.svg"; import exitIcon from "../../../../resources/images/ExitIconWhite.svg";
import pauseIcon from "../../../../resources/images/PauseIconWhite.svg"; import pauseIcon from "../../../../resources/images/PauseIconWhite.svg";
import playIcon from "../../../../resources/images/PlayIconWhite.svg"; import playIcon from "../../../../resources/images/PlayIconWhite.svg";
import replayRegularIcon from "../../../../resources/images/ReplayRegularIconWhite.svg"; import replayRegularIcon from "../../../../resources/images/ReplayRegularIconWhite.svg";
import replaySolidIcon from "../../../../resources/images/ReplaySolidIconWhite.svg"; import replaySolidIcon from "../../../../resources/images/ReplaySolidIconWhite.svg";
import settingsIcon from "../../../../resources/images/SettingIconWhite.svg"; import settingsIcon from "../../../../resources/images/SettingIconWhite.svg";
import { EventBus } from "../../../core/EventBus";
import { GameType } from "../../../core/game/Game";
import { GameUpdateType } from "../../../core/game/GameUpdates";
import { GameView } from "../../../core/game/GameView";
import { PauseGameEvent } from "../../Transport";
import { translateText } from "../../Utils"; import { translateText } from "../../Utils";
import { Layer } from "./Layer";
import { ShowReplayPanelEvent } from "./ReplayPanel";
import { ShowSettingsModalEvent } from "./SettingsModal";
@customElement("game-right-sidebar") @customElement("game-right-sidebar")
export class GameRightSidebar extends LitElement implements Layer { export class GameRightSidebar extends LitElement implements Layer {
+2 -2
View File
@@ -1,8 +1,8 @@
import { EventBus, GameEvent } from "../../../core/EventBus";
import { LitElement, css, html } from "lit"; import { LitElement, css, html } from "lit";
import { customElement, state } from "lit/decorators.js"; import { customElement, state } from "lit/decorators.js";
import { EventBus, GameEvent } from "../../../core/EventBus";
import { getGamesPlayed } from "../../Utils";
import { Layer } from "./Layer"; import { Layer } from "./Layer";
import { getGamesPlayed } from "../../Utils";
export class GutterAdModalEvent implements GameEvent { export class GutterAdModalEvent implements GameEvent {
constructor(public readonly isVisible: boolean) {} constructor(public readonly isVisible: boolean) {}
+1 -1
View File
@@ -1,8 +1,8 @@
import { LitElement, html } from "lit"; import { LitElement, html } from "lit";
import { customElement, state } from "lit/decorators.js"; import { customElement, state } from "lit/decorators.js";
import { GameView } from "../../../core/game/GameView"; import { GameView } from "../../../core/game/GameView";
import { translateText } from "../../Utils";
import { Layer } from "./Layer"; import { Layer } from "./Layer";
import { translateText } from "../../Utils";
@customElement("heads-up-message") @customElement("heads-up-message")
export class HeadsUpMessage extends LitElement implements Layer { export class HeadsUpMessage extends LitElement implements Layer {
+5 -5
View File
@@ -1,11 +1,11 @@
import { LitElement, html } from "lit";
import { customElement, property, state } from "lit/decorators.js";
import { repeat } from "lit/directives/repeat.js";
import { translateText } from "../../../client/Utils";
import { EventBus, GameEvent } from "../../../core/EventBus"; import { EventBus, GameEvent } from "../../../core/EventBus";
import { GameView, PlayerView, UnitView } from "../../../core/game/GameView"; import { GameView, PlayerView, UnitView } from "../../../core/game/GameView";
import { renderNumber } from "../../Utils"; import { LitElement, html } from "lit";
import { customElement, property, state } from "lit/decorators.js";
import { Layer } from "./Layer"; import { Layer } from "./Layer";
import { renderNumber } from "../../Utils";
import { repeat } from "lit/directives/repeat.js";
import { translateText } from "../../../client/Utils";
type Entry = { type Entry = {
name: string; name: string;
+17 -18
View File
@@ -1,27 +1,26 @@
import { LitElement } from "lit";
import { customElement } from "lit/decorators.js";
import { EventBus } from "../../../core/EventBus";
import { PlayerActions } from "../../../core/game/Game";
import { TileRef } from "../../../core/game/GameMap";
import { GameView, PlayerView } from "../../../core/game/GameView";
import { TransformHandler } from "../TransformHandler";
import { UIState } from "../UIState";
import { BuildMenu } from "./BuildMenu";
import { ChatIntegration } from "./ChatIntegration";
import { EmojiTable } from "./EmojiTable";
import { Layer } from "./Layer";
import { PlayerActionHandler } from "./PlayerActionHandler";
import { PlayerPanel } from "./PlayerPanel";
import { RadialMenu, RadialMenuConfig } from "./RadialMenu";
import { import {
centerButtonElement,
COLORS, COLORS,
MenuElementParams, MenuElementParams,
centerButtonElement,
rootMenuElement, rootMenuElement,
} from "./RadialMenuElements"; } from "./RadialMenuElements";
import { GameView, PlayerView } from "../../../core/game/GameView";
import swordIcon from "../../../../resources/images/SwordIconWhite.svg"; import { RadialMenu, RadialMenuConfig } from "./RadialMenu";
import { BuildMenu } from "./BuildMenu";
import { ChatIntegration } from "./ChatIntegration";
import { ContextMenuEvent } from "../../InputHandler"; import { ContextMenuEvent } from "../../InputHandler";
import { EmojiTable } from "./EmojiTable";
import { EventBus } from "../../../core/EventBus";
import { Layer } from "./Layer";
import { LitElement } from "lit";
import { PlayerActionHandler } from "./PlayerActionHandler";
import { PlayerActions } from "../../../core/game/Game";
import { PlayerPanel } from "./PlayerPanel";
import { TileRef } from "../../../core/game/GameMap";
import { TransformHandler } from "../TransformHandler";
import { UIState } from "../UIState";
import { customElement } from "lit/decorators.js";
import swordIcon from "../../../../resources/images/SwordIconWhite.svg";
@customElement("main-radial-menu") @customElement("main-radial-menu")
export class MainRadialMenu extends LitElement implements Layer { export class MainRadialMenu extends LitElement implements Layer {
+1 -1
View File
@@ -3,9 +3,9 @@ import { customElement, property, state } from "lit/decorators.js";
import { GameEnv } from "../../../core/configuration/Config"; import { GameEnv } from "../../../core/configuration/Config";
import { GameType } from "../../../core/game/Game"; import { GameType } from "../../../core/game/Game";
import { GameView } from "../../../core/game/GameView"; import { GameView } from "../../../core/game/GameView";
import { Layer } from "./Layer";
import { MultiTabDetector } from "../../MultiTabDetector"; import { MultiTabDetector } from "../../MultiTabDetector";
import { translateText } from "../../Utils"; import { translateText } from "../../Utils";
import { Layer } from "./Layer";
@customElement("multi-tab-modal") @customElement("multi-tab-modal")
export class MultiTabModal extends LitElement implements Layer { export class MultiTabModal extends LitElement implements Layer {
+11 -11
View File
@@ -1,3 +1,13 @@
import { AllPlayers, Cell, nukeTypes } from "../../../core/game/Game";
import { GameView, PlayerView } from "../../../core/game/GameView";
import { createCanvas, renderNumber, renderTroops } from "../../Utils";
import { AlternateViewEvent } from "../../InputHandler";
import { EventBus } from "../../../core/EventBus";
import { Layer } from "./Layer";
import { PseudoRandom } from "../../../core/PseudoRandom";
import { Theme } from "../../../core/configuration/Config";
import { TransformHandler } from "../TransformHandler";
import { UserSettings } from "../../../core/game/UserSettings";
import allianceIcon from "../../../../resources/images/AllianceIcon.svg"; import allianceIcon from "../../../../resources/images/AllianceIcon.svg";
import allianceRequestBlackIcon from "../../../../resources/images/AllianceRequestBlackIcon.svg"; import allianceRequestBlackIcon from "../../../../resources/images/AllianceRequestBlackIcon.svg";
import allianceRequestWhiteIcon from "../../../../resources/images/AllianceRequestWhiteIcon.svg"; import allianceRequestWhiteIcon from "../../../../resources/images/AllianceRequestWhiteIcon.svg";
@@ -7,20 +17,10 @@ import embargoBlackIcon from "../../../../resources/images/EmbargoBlackIcon.svg"
import embargoWhiteIcon from "../../../../resources/images/EmbargoWhiteIcon.svg"; import embargoWhiteIcon from "../../../../resources/images/EmbargoWhiteIcon.svg";
import nukeRedIcon from "../../../../resources/images/NukeIconRed.svg"; import nukeRedIcon from "../../../../resources/images/NukeIconRed.svg";
import nukeWhiteIcon from "../../../../resources/images/NukeIconWhite.svg"; import nukeWhiteIcon from "../../../../resources/images/NukeIconWhite.svg";
import { renderPlayerFlag } from "../../../core/CustomFlag";
import shieldIcon from "../../../../resources/images/ShieldIconBlack.svg"; import shieldIcon from "../../../../resources/images/ShieldIconBlack.svg";
import targetIcon from "../../../../resources/images/TargetIcon.svg"; import targetIcon from "../../../../resources/images/TargetIcon.svg";
import traitorIcon from "../../../../resources/images/TraitorIcon.svg"; import traitorIcon from "../../../../resources/images/TraitorIcon.svg";
import { renderPlayerFlag } from "../../../core/CustomFlag";
import { EventBus } from "../../../core/EventBus";
import { PseudoRandom } from "../../../core/PseudoRandom";
import { Theme } from "../../../core/configuration/Config";
import { AllPlayers, Cell, nukeTypes } from "../../../core/game/Game";
import { GameView, PlayerView } from "../../../core/game/GameView";
import { UserSettings } from "../../../core/game/UserSettings";
import { AlternateViewEvent } from "../../InputHandler";
import { createCanvas, renderNumber, renderTroops } from "../../Utils";
import { TransformHandler } from "../TransformHandler";
import { Layer } from "./Layer";
class RenderInfo { class RenderInfo {
public icons: Map<string, HTMLImageElement> = new Map(); // Track icon elements public icons: Map<string, HTMLImageElement> = new Map(); // Track icon elements
+6 -6
View File
@@ -1,14 +1,14 @@
import { html, LitElement } from "lit"; import { AlternateViewEvent, RedrawGraphicsEvent } from "../../InputHandler";
import { LitElement, html } from "lit";
import { customElement, state } from "lit/decorators.js"; import { customElement, state } from "lit/decorators.js";
import { EventBus } from "../../../core/EventBus"; import { EventBus } from "../../../core/EventBus";
import { GameType } from "../../../core/game/Game"; import { GameType } from "../../../core/game/Game";
import { GameUpdateType } from "../../../core/game/GameUpdates"; import { GameUpdateType } from "../../../core/game/GameUpdates";
import { GameView } from "../../../core/game/GameView"; import { GameView } from "../../../core/game/GameView";
import { UserSettings } from "../../../core/game/UserSettings";
import { AlternateViewEvent, RefreshGraphicsEvent } from "../../InputHandler";
import { PauseGameEvent } from "../../Transport";
import { translateText } from "../../Utils";
import { Layer } from "./Layer"; import { Layer } from "./Layer";
import { PauseGameEvent } from "../../Transport";
import { UserSettings } from "../../../core/game/UserSettings";
import { translateText } from "../../Utils";
const button = ({ const button = ({
classes = "", classes = "",
@@ -116,7 +116,7 @@ export class OptionsMenu extends LitElement implements Layer {
private onToggleDarkModeButtonClick() { private onToggleDarkModeButtonClick() {
this.userSettings.toggleDarkMode(); this.userSettings.toggleDarkMode();
this.requestUpdate(); this.requestUpdate();
this.eventBus.emit(new RefreshGraphicsEvent()); this.eventBus.emit(new RedrawGraphicsEvent());
} }
private onToggleRandomNameModeButtonClick() { private onToggleRandomNameModeButtonClick() {
@@ -1,7 +1,4 @@
import { EventBus } from "../../../core/EventBus";
import { PlayerActions, PlayerID } from "../../../core/game/Game"; import { PlayerActions, PlayerID } from "../../../core/game/Game";
import { TileRef } from "../../../core/game/GameMap";
import { PlayerView } from "../../../core/game/GameView";
import { import {
SendAllianceRequestIntentEvent, SendAllianceRequestIntentEvent,
SendAttackIntentEvent, SendAttackIntentEvent,
@@ -16,6 +13,9 @@ import {
SendSpawnIntentEvent, SendSpawnIntentEvent,
SendTargetPlayerIntentEvent, SendTargetPlayerIntentEvent,
} from "../../Transport"; } from "../../Transport";
import { EventBus } from "../../../core/EventBus";
import { PlayerView } from "../../../core/game/GameView";
import { TileRef } from "../../../core/game/GameMap";
import { UIState } from "../UIState"; import { UIState } from "../UIState";
export class PlayerActionHandler { export class PlayerActionHandler {
+10 -10
View File
@@ -1,9 +1,6 @@
import { ContextMenuEvent, MouseMoveEvent } from "../../InputHandler";
import { GameView, PlayerView, UnitView } from "../../../core/game/GameView";
import { LitElement, TemplateResult, html } from "lit"; import { LitElement, TemplateResult, html } from "lit";
import { ref } from "lit-html/directives/ref.js";
import { customElement, property, state } from "lit/decorators.js";
import { translateText } from "../../../client/Utils";
import { renderPlayerFlag } from "../../../core/CustomFlag";
import { EventBus } from "../../../core/EventBus";
import { import {
PlayerProfile, PlayerProfile,
PlayerType, PlayerType,
@@ -11,13 +8,16 @@ import {
Unit, Unit,
UnitType, UnitType,
} from "../../../core/game/Game"; } from "../../../core/game/Game";
import { TileRef } from "../../../core/game/GameMap"; import { customElement, property, state } from "lit/decorators.js";
import { GameView, PlayerView, UnitView } from "../../../core/game/GameView";
import { ContextMenuEvent, MouseMoveEvent } from "../../InputHandler";
import { renderNumber, renderTroops } from "../../Utils"; import { renderNumber, renderTroops } from "../../Utils";
import { TransformHandler } from "../TransformHandler";
import { Layer } from "./Layer";
import { CloseRadialMenuEvent } from "./RadialMenu"; import { CloseRadialMenuEvent } from "./RadialMenu";
import { EventBus } from "../../../core/EventBus";
import { Layer } from "./Layer";
import { TileRef } from "../../../core/game/GameMap";
import { TransformHandler } from "../TransformHandler";
import { ref } from "lit-html/directives/ref.js";
import { renderPlayerFlag } from "../../../core/CustomFlag";
import { translateText } from "../../../client/Utils";
function euclideanDistWorld( function euclideanDistWorld(
coord: { x: number; y: number }, coord: { x: number; y: number },
+15 -15
View File
@@ -1,19 +1,7 @@
import { html, LitElement } from "lit";
import { customElement, state } from "lit/decorators.js";
import allianceIcon from "../../../../resources/images/AllianceIconWhite.svg";
import chatIcon from "../../../../resources/images/ChatIconWhite.svg";
import donateGoldIcon from "../../../../resources/images/DonateGoldIconWhite.svg";
import donateTroopIcon from "../../../../resources/images/DonateTroopIconWhite.svg";
import emojiIcon from "../../../../resources/images/EmojiIconWhite.svg";
import targetIcon from "../../../../resources/images/TargetIconWhite.svg";
import traitorIcon from "../../../../resources/images/TraitorIconWhite.svg";
import { translateText } from "../../../client/Utils";
import { EventBus } from "../../../core/EventBus";
import { AllPlayers, PlayerActions } from "../../../core/game/Game"; import { AllPlayers, PlayerActions } from "../../../core/game/Game";
import { TileRef } from "../../../core/game/GameMap";
import { GameView, PlayerView } from "../../../core/game/GameView";
import { flattenedEmojiTable } from "../../../core/Util";
import { CloseViewEvent, MouseUpEvent } from "../../InputHandler"; import { CloseViewEvent, MouseUpEvent } from "../../InputHandler";
import { GameView, PlayerView } from "../../../core/game/GameView";
import { LitElement, html } from "lit";
import { import {
SendAllianceRequestIntentEvent, SendAllianceRequestIntentEvent,
SendBreakAllianceIntentEvent, SendBreakAllianceIntentEvent,
@@ -23,11 +11,23 @@ import {
SendEmojiIntentEvent, SendEmojiIntentEvent,
SendTargetPlayerIntentEvent, SendTargetPlayerIntentEvent,
} from "../../Transport"; } from "../../Transport";
import { customElement, state } from "lit/decorators.js";
import { renderNumber, renderTroops } from "../../Utils"; import { renderNumber, renderTroops } from "../../Utils";
import { UIState } from "../UIState";
import { ChatModal } from "./ChatModal"; import { ChatModal } from "./ChatModal";
import { EmojiTable } from "./EmojiTable"; import { EmojiTable } from "./EmojiTable";
import { EventBus } from "../../../core/EventBus";
import { Layer } from "./Layer"; import { Layer } from "./Layer";
import { TileRef } from "../../../core/game/GameMap";
import { UIState } from "../UIState";
import allianceIcon from "../../../../resources/images/AllianceIconWhite.svg";
import chatIcon from "../../../../resources/images/ChatIconWhite.svg";
import donateGoldIcon from "../../../../resources/images/DonateGoldIconWhite.svg";
import donateTroopIcon from "../../../../resources/images/DonateTroopIconWhite.svg";
import emojiIcon from "../../../../resources/images/EmojiIconWhite.svg";
import { flattenedEmojiTable } from "../../../core/Util";
import targetIcon from "../../../../resources/images/TargetIconWhite.svg";
import traitorIcon from "../../../../resources/images/TraitorIconWhite.svg";
import { translateText } from "../../../client/Utils";
@customElement("player-panel") @customElement("player-panel")
export class PlayerPanel extends LitElement implements Layer { export class PlayerPanel extends LitElement implements Layer {
+5 -5
View File
@@ -1,16 +1,16 @@
/* eslint-disable max-lines */ /* eslint-disable max-lines */
import * as d3 from "d3"; import * as d3 from "d3";
import backIcon from "../../../../resources/images/BackIconWhite.svg";
import { EventBus, GameEvent } from "../../../core/EventBus";
import { CloseViewEvent } from "../../InputHandler";
import { translateText } from "../../Utils";
import { Layer } from "./Layer";
import { import {
CenterButtonElement, CenterButtonElement,
MenuElement, MenuElement,
MenuElementParams, MenuElementParams,
TooltipKey, TooltipKey,
} from "./RadialMenuElements"; } from "./RadialMenuElements";
import { EventBus, GameEvent } from "../../../core/EventBus";
import { CloseViewEvent } from "../../InputHandler";
import { Layer } from "./Layer";
import backIcon from "../../../../resources/images/BackIconWhite.svg";
import { translateText } from "../../Utils";
export class CloseRadialMenuEvent implements GameEvent { export class CloseRadialMenuEvent implements GameEvent {
constructor() {} constructor() {}
@@ -1,16 +1,15 @@
import { Config } from "../../../core/configuration/Config";
import { AllPlayers, PlayerActions, UnitType } from "../../../core/game/Game"; import { AllPlayers, PlayerActions, UnitType } from "../../../core/game/Game";
import { TileRef } from "../../../core/game/GameMap";
import { GameView, PlayerView } from "../../../core/game/GameView";
import { flattenedEmojiTable } from "../../../core/Util";
import { renderNumber, translateText } from "../../Utils";
import { BuildItemDisplay, BuildMenu, flattenedBuildTable } from "./BuildMenu"; import { BuildItemDisplay, BuildMenu, flattenedBuildTable } from "./BuildMenu";
import { GameView, PlayerView } from "../../../core/game/GameView";
import { renderNumber, translateText } from "../../Utils";
import { ChatIntegration } from "./ChatIntegration"; import { ChatIntegration } from "./ChatIntegration";
import { Config } from "../../../core/configuration/Config";
import { EmojiTable } from "./EmojiTable"; import { EmojiTable } from "./EmojiTable";
import { EventBus } from "../../../core/EventBus";
import { PlayerActionHandler } from "./PlayerActionHandler"; import { PlayerActionHandler } from "./PlayerActionHandler";
import { PlayerPanel } from "./PlayerPanel"; import { PlayerPanel } from "./PlayerPanel";
import { TileRef } from "../../../core/game/GameMap";
import { TooltipItem } from "./RadialMenu"; import { TooltipItem } from "./RadialMenu";
import allianceIcon from "../../../../resources/images/AllianceIconWhite.svg"; import allianceIcon from "../../../../resources/images/AllianceIconWhite.svg";
import boatIcon from "../../../../resources/images/BoatIconWhite.svg"; import boatIcon from "../../../../resources/images/BoatIconWhite.svg";
import buildIcon from "../../../../resources/images/BuildIconWhite.svg"; import buildIcon from "../../../../resources/images/BuildIconWhite.svg";
@@ -18,12 +17,12 @@ import chatIcon from "../../../../resources/images/ChatIconWhite.svg";
import donateGoldIcon from "../../../../resources/images/DonateGoldIconWhite.svg"; import donateGoldIcon from "../../../../resources/images/DonateGoldIconWhite.svg";
import donateTroopIcon from "../../../../resources/images/DonateTroopIconWhite.svg"; import donateTroopIcon from "../../../../resources/images/DonateTroopIconWhite.svg";
import emojiIcon from "../../../../resources/images/EmojiIconWhite.svg"; import emojiIcon from "../../../../resources/images/EmojiIconWhite.svg";
import { flattenedEmojiTable } from "../../../core/Util";
import infoIcon from "../../../../resources/images/InfoIcon.svg"; import infoIcon from "../../../../resources/images/InfoIcon.svg";
import swordIcon from "../../../../resources/images/SwordIconWhite.svg"; import swordIcon from "../../../../resources/images/SwordIconWhite.svg";
import targetIcon from "../../../../resources/images/TargetIconWhite.svg"; import targetIcon from "../../../../resources/images/TargetIconWhite.svg";
import traitorIcon from "../../../../resources/images/TraitorIconWhite.svg"; import traitorIcon from "../../../../resources/images/TraitorIconWhite.svg";
import xIcon from "../../../../resources/images/XIcon.svg"; import xIcon from "../../../../resources/images/XIcon.svg";
import { EventBus } from "../../../core/EventBus";
export type MenuElementParams = { export type MenuElementParams = {
myPlayer: PlayerView; myPlayer: PlayerView;
+5 -5
View File
@@ -1,15 +1,15 @@
import { Colord } from "colord";
import { Theme } from "../../../core/configuration/Config";
import { PlayerID } from "../../../core/game/Game";
import { TileRef } from "../../../core/game/GameMap";
import { import {
GameUpdateType, GameUpdateType,
RailroadUpdate,
RailTile, RailTile,
RailType, RailType,
RailroadUpdate,
} from "../../../core/game/GameUpdates"; } from "../../../core/game/GameUpdates";
import { Colord } from "colord";
import { GameView } from "../../../core/game/GameView"; import { GameView } from "../../../core/game/GameView";
import { Layer } from "./Layer"; import { Layer } from "./Layer";
import { PlayerID } from "../../../core/game/Game";
import { Theme } from "../../../core/configuration/Config";
import { TileRef } from "../../../core/game/GameMap";
import { getRailroadRects } from "./RailroadSprites"; import { getRailroadRects } from "./RailroadSprites";
type RailRef = { type RailRef = {
+7 -7
View File
@@ -1,14 +1,14 @@
import { html, LitElement } from "lit"; import { LitElement, html } from "lit";
import {
ReplaySpeedMultiplier,
defaultReplaySpeedMultiplier,
} from "../../utilities/ReplaySpeedMultiplier";
import { customElement, property, state } from "lit/decorators.js"; import { customElement, property, state } from "lit/decorators.js";
import { EventBus } from "../../../core/EventBus"; import { EventBus } from "../../../core/EventBus";
import { GameView } from "../../../core/game/GameView"; import { GameView } from "../../../core/game/GameView";
import { ReplaySpeedChangeEvent } from "../../InputHandler";
import {
defaultReplaySpeedMultiplier,
ReplaySpeedMultiplier,
} from "../../utilities/ReplaySpeedMultiplier";
import { translateText } from "../../Utils";
import { Layer } from "./Layer"; import { Layer } from "./Layer";
import { ReplaySpeedChangeEvent } from "../../InputHandler";
import { translateText } from "../../Utils";
export class ShowReplayPanelEvent { export class ShowReplayPanelEvent {
constructor( constructor(
+9 -9
View File
@@ -1,6 +1,10 @@
import { html, LitElement } from "lit"; import { AlternateViewEvent, RedrawGraphicsEvent } from "../../InputHandler";
import { LitElement, html } from "lit";
import { customElement, property, query, state } from "lit/decorators.js"; import { customElement, property, query, state } from "lit/decorators.js";
import structureIcon from "../../../../resources/images/CityIconWhite.svg"; import { EventBus } from "../../../core/EventBus";
import { Layer } from "./Layer";
import { PauseGameEvent } from "../../Transport";
import { UserSettings } from "../../../core/game/UserSettings";
import darkModeIcon from "../../../../resources/images/DarkModeIconWhite.svg"; import darkModeIcon from "../../../../resources/images/DarkModeIconWhite.svg";
import emojiIcon from "../../../../resources/images/EmojiIconWhite.svg"; import emojiIcon from "../../../../resources/images/EmojiIconWhite.svg";
import exitIcon from "../../../../resources/images/ExitIconWhite.svg"; import exitIcon from "../../../../resources/images/ExitIconWhite.svg";
@@ -8,13 +12,9 @@ import explosionIcon from "../../../../resources/images/ExplosionIconWhite.svg";
import mouseIcon from "../../../../resources/images/MouseIconWhite.svg"; import mouseIcon from "../../../../resources/images/MouseIconWhite.svg";
import ninjaIcon from "../../../../resources/images/NinjaIconWhite.svg"; import ninjaIcon from "../../../../resources/images/NinjaIconWhite.svg";
import settingsIcon from "../../../../resources/images/SettingIconWhite.svg"; import settingsIcon from "../../../../resources/images/SettingIconWhite.svg";
import treeIcon from "../../../../resources/images/TreeIconWhite.svg"; import structureIcon from "../../../../resources/images/CityIconWhite.svg";
import { EventBus } from "../../../core/EventBus";
import { UserSettings } from "../../../core/game/UserSettings";
import { AlternateViewEvent, RefreshGraphicsEvent } from "../../InputHandler";
import { PauseGameEvent } from "../../Transport";
import { translateText } from "../../Utils"; import { translateText } from "../../Utils";
import { Layer } from "./Layer"; import treeIcon from "../../../../resources/images/TreeIconWhite.svg";
export class ShowSettingsModalEvent { export class ShowSettingsModalEvent {
constructor( constructor(
@@ -126,7 +126,7 @@ export class SettingsModal extends LitElement implements Layer {
private onToggleDarkModeButtonClick() { private onToggleDarkModeButtonClick() {
this.userSettings.toggleDarkMode(); this.userSettings.toggleDarkMode();
this.eventBus.emit(new RefreshGraphicsEvent()); this.eventBus.emit(new RedrawGraphicsEvent());
this.requestUpdate(); this.requestUpdate();
} }
+2 -2
View File
@@ -1,9 +1,9 @@
import { LitElement, css, html } from "lit"; import { LitElement, css, html } from "lit";
import { customElement, state } from "lit/decorators.js"; import { customElement, state } from "lit/decorators.js";
import { translateText } from "../../../client/Utils";
import { GameView } from "../../../core/game/GameView"; import { GameView } from "../../../core/game/GameView";
import { getGamesPlayed } from "../../Utils";
import { Layer } from "./Layer"; import { Layer } from "./Layer";
import { getGamesPlayed } from "../../Utils";
import { translateText } from "../../../client/Utils";
const AD_TYPE = "bottom_rail"; const AD_TYPE = "bottom_rail";
const AD_CONTAINER_ID = "bottom-rail-ad-container"; const AD_CONTAINER_ID = "bottom-rail-ad-container";
+1 -1
View File
@@ -1,7 +1,7 @@
import { GameMode, Team } from "../../../core/game/Game"; import { GameMode, Team } from "../../../core/game/Game";
import { GameView } from "../../../core/game/GameView"; import { GameView } from "../../../core/game/GameView";
import { TransformHandler } from "../TransformHandler";
import { Layer } from "./Layer"; import { Layer } from "./Layer";
import { TransformHandler } from "../TransformHandler";
export class SpawnTimer implements Layer { export class SpawnTimer implements Layer {
private ratios = [0]; private ratios = [0];
@@ -1,20 +1,20 @@
import { OutlineFilter } from "pixi-filters";
import * as PIXI from "pixi.js"; import * as PIXI from "pixi.js";
import bitmapFont from "../../../../resources/fonts/round_6x6_modified.xml"; import { Cell, PlayerID, UnitType } from "../../../core/game/Game";
import { GameView, PlayerView, UnitView } from "../../../core/game/GameView";
import { EventBus } from "../../../core/EventBus";
import { GameUpdateType } from "../../../core/game/GameUpdates";
import { Layer } from "./Layer";
import { OutlineFilter } from "pixi-filters";
import SAMMissileIcon from "../../../../resources/images/SamLauncherUnit.png";
import { Theme } from "../../../core/configuration/Config";
import { ToggleStructureEvent } from "../../InputHandler";
import { TransformHandler } from "../TransformHandler";
import anchorIcon from "../../../../resources/images/AnchorIcon.png"; import anchorIcon from "../../../../resources/images/AnchorIcon.png";
import bitmapFont from "../../../../resources/fonts/round_6x6_modified.xml";
import cityIcon from "../../../../resources/images/CityIcon.png"; import cityIcon from "../../../../resources/images/CityIcon.png";
import factoryIcon from "../../../../resources/images/FactoryUnit.png"; import factoryIcon from "../../../../resources/images/FactoryUnit.png";
import missileSiloIcon from "../../../../resources/images/MissileSiloUnit.png"; import missileSiloIcon from "../../../../resources/images/MissileSiloUnit.png";
import SAMMissileIcon from "../../../../resources/images/SamLauncherUnit.png";
import shieldIcon from "../../../../resources/images/ShieldIcon.png"; import shieldIcon from "../../../../resources/images/ShieldIcon.png";
import { Theme } from "../../../core/configuration/Config";
import { EventBus } from "../../../core/EventBus";
import { Cell, PlayerID, UnitType } from "../../../core/game/Game";
import { GameUpdateType } from "../../../core/game/GameUpdates";
import { GameView, PlayerView, UnitView } from "../../../core/game/GameView";
import { ToggleStructureEvent } from "../../InputHandler";
import { TransformHandler } from "../TransformHandler";
import { Layer } from "./Layer";
type ShapeType = "triangle" | "square" | "pentagon" | "octagon" | "circle"; type ShapeType = "triangle" | "square" | "pentagon" | "octagon" | "circle";
+10 -11
View File
@@ -1,19 +1,18 @@
import { colord, Colord } from "colord"; import { Cell, UnitType } from "../../../core/game/Game";
import { Theme } from "../../../core/configuration/Config"; import { Colord, colord } from "colord";
import { GameView, UnitView } from "../../../core/game/GameView";
import { euclDistFN, isometricDistFN } from "../../../core/game/GameMap";
import { EventBus } from "../../../core/EventBus"; import { EventBus } from "../../../core/EventBus";
import { TransformHandler } from "../TransformHandler"; import { GameUpdateType } from "../../../core/game/GameUpdates";
import { Layer } from "./Layer"; import { Layer } from "./Layer";
import SAMMissileIcon from "../../../../resources/non-commercial/images/buildings/silo4.png";
import { Theme } from "../../../core/configuration/Config";
import { TransformHandler } from "../TransformHandler";
import anchorIcon from "../../../../resources/non-commercial/images/buildings/port1.png";
import cityIcon from "../../../../resources/non-commercial/images/buildings/cityAlt1.png"; import cityIcon from "../../../../resources/non-commercial/images/buildings/cityAlt1.png";
import factoryIcon from "../../../../resources/non-commercial/images/buildings/factoryAlt1.png"; import factoryIcon from "../../../../resources/non-commercial/images/buildings/factoryAlt1.png";
import shieldIcon from "../../../../resources/non-commercial/images/buildings/fortAlt3.png";
import anchorIcon from "../../../../resources/non-commercial/images/buildings/port1.png";
import missileSiloIcon from "../../../../resources/non-commercial/images/buildings/silo1.png"; import missileSiloIcon from "../../../../resources/non-commercial/images/buildings/silo1.png";
import SAMMissileIcon from "../../../../resources/non-commercial/images/buildings/silo4.png"; import shieldIcon from "../../../../resources/non-commercial/images/buildings/fortAlt3.png";
import { Cell, UnitType } from "../../../core/game/Game";
import { euclDistFN, isometricDistFN } from "../../../core/game/GameMap";
import { GameUpdateType } from "../../../core/game/GameUpdates";
import { GameView, UnitView } from "../../../core/game/GameView";
const underConstructionColor = colord({ r: 150, g: 150, b: 150 }); const underConstructionColor = colord({ r: 150, g: 150, b: 150 });
+3 -3
View File
@@ -1,9 +1,9 @@
import { LitElement, html } from "lit";
import { customElement, property } from "lit/decorators.js";
import { EventBus } from "../../../core/EventBus";
import { GameMode, Team, UnitType } from "../../../core/game/Game"; import { GameMode, Team, UnitType } from "../../../core/game/Game";
import { GameView, PlayerView } from "../../../core/game/GameView"; import { GameView, PlayerView } from "../../../core/game/GameView";
import { LitElement, html } from "lit";
import { customElement, property } from "lit/decorators.js";
import { renderNumber, translateText } from "../../Utils"; import { renderNumber, translateText } from "../../Utils";
import { EventBus } from "../../../core/EventBus";
import { Layer } from "./Layer"; import { Layer } from "./Layer";
type TeamEntry = { type TeamEntry = {
+2 -2
View File
@@ -1,7 +1,7 @@
import { Theme } from "../../../core/configuration/Config";
import { GameView } from "../../../core/game/GameView"; import { GameView } from "../../../core/game/GameView";
import { TransformHandler } from "../TransformHandler";
import { Layer } from "./Layer"; import { Layer } from "./Layer";
import { Theme } from "../../../core/configuration/Config";
import { TransformHandler } from "../TransformHandler";
export class TerrainLayer implements Layer { export class TerrainLayer implements Layer {
private canvas: HTMLCanvasElement; private canvas: HTMLCanvasElement;
+13 -13
View File
@@ -1,21 +1,21 @@
import { PriorityQueue } from "@datastructures-js/priority-queue";
import { Colord } from "colord";
import { Theme } from "../../../core/configuration/Config";
import { EventBus } from "../../../core/EventBus";
import { Cell, PlayerType, UnitType } from "../../../core/game/Game";
import { euclDistFN, TileRef } from "../../../core/game/GameMap";
import { GameUpdateType } from "../../../core/game/GameUpdates";
import { GameView, PlayerView } from "../../../core/game/GameView";
import { UserSettings } from "../../../core/game/UserSettings";
import { PseudoRandom } from "../../../core/PseudoRandom";
import { import {
AlternateViewEvent, AlternateViewEvent,
DragEvent, DragEvent,
MouseOverEvent, MouseOverEvent,
RefreshGraphicsEvent, RedrawGraphicsEvent,
} from "../../InputHandler"; } from "../../InputHandler";
import { TransformHandler } from "../TransformHandler"; import { Cell, PlayerType, UnitType } from "../../../core/game/Game";
import { GameView, PlayerView } from "../../../core/game/GameView";
import { TileRef, euclDistFN } from "../../../core/game/GameMap";
import { Colord } from "colord";
import { EventBus } from "../../../core/EventBus";
import { GameUpdateType } from "../../../core/game/GameUpdates";
import { Layer } from "./Layer"; import { Layer } from "./Layer";
import { PriorityQueue } from "@datastructures-js/priority-queue";
import { PseudoRandom } from "../../../core/PseudoRandom";
import { Theme } from "../../../core/configuration/Config";
import { TransformHandler } from "../TransformHandler";
import { UserSettings } from "../../../core/game/UserSettings";
export class TerritoryLayer implements Layer { export class TerritoryLayer implements Layer {
private userSettings: UserSettings; private userSettings: UserSettings;
@@ -77,7 +77,7 @@ export class TerritoryLayer implements Layer {
const prev = this.cachedTerritoryPatternsEnabled; const prev = this.cachedTerritoryPatternsEnabled;
this.cachedTerritoryPatternsEnabled = this.userSettings.territoryPatterns(); this.cachedTerritoryPatternsEnabled = this.userSettings.territoryPatterns();
if (prev !== undefined && prev !== this.cachedTerritoryPatternsEnabled) { if (prev !== undefined && prev !== this.cachedTerritoryPatternsEnabled) {
this.eventBus.emit(new RefreshGraphicsEvent()); this.eventBus.emit(new RedrawGraphicsEvent());
} }
this.game.recentlyUpdatedTiles().forEach((t) => this.enqueueTile(t)); this.game.recentlyUpdatedTiles().forEach((t) => this.enqueueTile(t));
const updates = this.game.updatesSinceLastTick(); const updates = this.game.updatesSinceLastTick();
+7 -7
View File
@@ -1,14 +1,14 @@
import { GameView, UnitView } from "../../../core/game/GameView";
import { Colord } from "colord"; import { Colord } from "colord";
import { EventBus } from "../../../core/EventBus"; import { EventBus } from "../../../core/EventBus";
import { Theme } from "../../../core/configuration/Config";
import { UnitType } from "../../../core/game/Game";
import { GameUpdateType } from "../../../core/game/GameUpdates"; import { GameUpdateType } from "../../../core/game/GameUpdates";
import { GameView, UnitView } from "../../../core/game/GameView";
import { UserSettings } from "../../../core/game/UserSettings";
import { UnitSelectionEvent } from "../../InputHandler";
import { ProgressBar } from "../ProgressBar";
import { TransformHandler } from "../TransformHandler";
import { Layer } from "./Layer"; import { Layer } from "./Layer";
import { ProgressBar } from "../ProgressBar";
import { Theme } from "../../../core/configuration/Config";
import { TransformHandler } from "../TransformHandler";
import { UnitSelectionEvent } from "../../InputHandler";
import { UnitType } from "../../../core/game/Game";
import { UserSettings } from "../../../core/game/UserSettings";
const COLOR_PROGRESSION = [ const COLOR_PROGRESSION = [
"rgb(232, 25, 25)", "rgb(232, 25, 25)",
+10 -10
View File
@@ -1,17 +1,17 @@
import { html, LitElement } from "lit"; import { LitElement, html } from "lit";
import { customElement } from "lit/decorators.js"; import { EventBus } from "../../../core/EventBus";
import portIcon from "../../../../resources/images/AnchorIcon.png"; import { GameView } from "../../../core/game/GameView";
import { Layer } from "./Layer";
import { ToggleStructureEvent } from "../../InputHandler";
import { UnitType } from "../../../core/game/Game";
import cityIcon from "../../../../resources/images/CityIconWhite.svg"; import cityIcon from "../../../../resources/images/CityIconWhite.svg";
import { customElement } from "lit/decorators.js";
import defensePostIcon from "../../../../resources/images/ShieldIconWhite.svg";
import factoryIcon from "../../../../resources/images/FactoryIconWhite.svg"; import factoryIcon from "../../../../resources/images/FactoryIconWhite.svg";
import missileSiloIcon from "../../../../resources/images/MissileSiloUnit.png"; import missileSiloIcon from "../../../../resources/images/MissileSiloUnit.png";
import defensePostIcon from "../../../../resources/images/ShieldIconWhite.svg"; import portIcon from "../../../../resources/images/AnchorIcon.png";
import samLauncherIcon from "../../../../resources/non-commercial/svg/SamLauncherIconWhite.svg";
import { EventBus } from "../../../core/EventBus";
import { UnitType } from "../../../core/game/Game";
import { GameView } from "../../../core/game/GameView";
import { ToggleStructureEvent } from "../../InputHandler";
import { renderNumber } from "../../Utils"; import { renderNumber } from "../../Utils";
import { Layer } from "./Layer"; import samLauncherIcon from "../../../../resources/non-commercial/svg/SamLauncherIconWhite.svg";
@customElement("unit-display") @customElement("unit-display")
export class UnitDisplay extends LitElement implements Layer { export class UnitDisplay extends LitElement implements Layer {
+11 -12
View File
@@ -1,25 +1,24 @@
import { colord, Colord } from "colord";
import { EventBus } from "../../../core/EventBus";
import { Theme } from "../../../core/configuration/Config";
import { UnitType } from "../../../core/game/Game";
import { TileRef } from "../../../core/game/GameMap";
import { GameView, UnitView } from "../../../core/game/GameView";
import { BezenhamLine } from "../../../core/utilities/Line";
import { import {
AlternateViewEvent, AlternateViewEvent,
MouseUpEvent, MouseUpEvent,
UnitSelectionEvent, UnitSelectionEvent,
} from "../../InputHandler"; } from "../../InputHandler";
import { MoveWarshipIntentEvent } from "../../Transport"; import { Colord, colord } from "colord";
import { TransformHandler } from "../TransformHandler"; import { GameView, UnitView } from "../../../core/game/GameView";
import { Layer } from "./Layer";
import { GameUpdateType } from "../../../core/game/GameUpdates";
import { import {
getColoredSprite, getColoredSprite,
isSpriteReady, isSpriteReady,
loadAllSprites, loadAllSprites,
} from "../SpriteLoader"; } from "../SpriteLoader";
import { BezenhamLine } from "../../../core/utilities/Line";
import { EventBus } from "../../../core/EventBus";
import { GameUpdateType } from "../../../core/game/GameUpdates";
import { Layer } from "./Layer";
import { MoveWarshipIntentEvent } from "../../Transport";
import { Theme } from "../../../core/configuration/Config";
import { TileRef } from "../../../core/game/GameMap";
import { TransformHandler } from "../TransformHandler";
import { UnitType } from "../../../core/game/Game";
enum Relationship { enum Relationship {
Self, Self,
+2 -2
View File
@@ -1,12 +1,12 @@
import { LitElement, css, html } from "lit"; import { LitElement, css, html } from "lit";
import { customElement, state } from "lit/decorators.js"; import { customElement, state } from "lit/decorators.js";
import { translateText } from "../../../client/Utils";
import { EventBus } from "../../../core/EventBus"; import { EventBus } from "../../../core/EventBus";
import { GameUpdateType } from "../../../core/game/GameUpdates"; import { GameUpdateType } from "../../../core/game/GameUpdates";
import { GameView } from "../../../core/game/GameView"; import { GameView } from "../../../core/game/GameView";
import { SendWinnerEvent } from "../../Transport";
import { GutterAdModalEvent } from "./GutterAdModal"; import { GutterAdModalEvent } from "./GutterAdModal";
import { Layer } from "./Layer"; import { Layer } from "./Layer";
import { SendWinnerEvent } from "../../Transport";
import { translateText } from "../../../client/Utils";
@customElement("win-modal") @customElement("win-modal")
export class WinModal extends LitElement implements Layer { export class WinModal extends LitElement implements Layer {
+2 -2
View File
@@ -1,5 +1,3 @@
import { decodeJwt } from "jose";
import { z } from "zod";
import { import {
RefreshResponseSchema, RefreshResponseSchema,
TokenPayload, TokenPayload,
@@ -7,7 +5,9 @@ import {
UserMeResponse, UserMeResponse,
UserMeResponseSchema, UserMeResponseSchema,
} from "../core/ApiSchemas"; } from "../core/ApiSchemas";
import { decodeJwt } from "jose";
import { getServerConfigFromClient } from "../core/configuration/ConfigLoader"; import { getServerConfigFromClient } from "../core/configuration/ConfigLoader";
import { z } from "zod";
function getAudience() { function getAudience() {
const { hostname } = new URL(window.location.href); const { hostname } = new URL(window.location.href);
@@ -1,5 +1,5 @@
// renderUnitTypeOptions.ts // renderUnitTypeOptions.ts
import { html, TemplateResult } from "lit"; import { TemplateResult, html } from "lit";
import { UnitType } from "../../core/game/Game"; import { UnitType } from "../../core/game/Game";
import { translateText } from "../Utils"; import { translateText } from "../Utils";
+1 -1
View File
@@ -1,6 +1,6 @@
// This file contains schemas for api.openfront.io // This file contains schemas for api.openfront.io
import { z } from "zod";
import { base64urlToUuid } from "./Base64"; import { base64urlToUuid } from "./Base64";
import { z } from "zod";
export const RefreshResponseSchema = z.object({ export const RefreshResponseSchema = z.object({
token: z.string(), token: z.string(),
+1 -1
View File
@@ -1,5 +1,5 @@
import { z } from "zod";
import { RequiredPatternSchema } from "./Schemas"; import { RequiredPatternSchema } from "./Schemas";
import { z } from "zod";
export const ProductSchema = z.object({ export const ProductSchema = z.object({
productId: z.string(), productId: z.string(),
+1 -1
View File
@@ -1,6 +1,6 @@
// This file contians schemas for the primary openfront express server // This file contians schemas for the primary openfront express server
import { z } from "zod";
import { GameInfoSchema } from "./Schemas"; import { GameInfoSchema } from "./Schemas";
import { z } from "zod";
export const ApiEnvResponseSchema = z.object({ export const ApiEnvResponseSchema = z.object({
game_env: z.string(), game_env: z.string(),
+11 -11
View File
@@ -1,7 +1,3 @@
import { placeName } from "../client/graphics/NameBoxCalculator";
import { getConfig } from "./configuration/ConfigLoader";
import { Executor } from "./execution/ExecutionManager";
import { WinCheckExecution } from "./execution/WinCheckExecution";
import { import {
AllPlayers, AllPlayers,
Attack, Attack,
@@ -18,19 +14,23 @@ import {
PlayerProfile, PlayerProfile,
PlayerType, PlayerType,
} from "./game/Game"; } from "./game/Game";
import { createGame } from "./game/GameImpl"; import { ClientID, GameStartInfo, Turn } from "./Schemas";
import { TileRef } from "./game/GameMap";
import { GameMapLoader } from "./game/GameMapLoader";
import { import {
ErrorUpdate, ErrorUpdate,
GameUpdateType, GameUpdateType,
GameUpdateViewData, GameUpdateViewData,
} from "./game/GameUpdates"; } from "./game/GameUpdates";
import { loadTerrainMap as loadGameMap } from "./game/TerrainMapLoader";
import { PseudoRandom } from "./PseudoRandom";
import { ClientID, GameStartInfo, Turn } from "./Schemas";
import { sanitize, simpleHash } from "./Util"; import { sanitize, simpleHash } from "./Util";
import { Executor } from "./execution/ExecutionManager";
import { GameMapLoader } from "./game/GameMapLoader";
import { PseudoRandom } from "./PseudoRandom";
import { TileRef } from "./game/GameMap";
import { WinCheckExecution } from "./execution/WinCheckExecution";
import { createGame } from "./game/GameImpl";
import { fixProfaneUsername } from "./validations/username"; import { fixProfaneUsername } from "./validations/username";
import { getConfig } from "./configuration/ConfigLoader";
import { loadTerrainMap } from "./game/TerrainMapLoader";
import { placeName } from "../client/graphics/NameBoxCalculator";
export async function createGameRunner( export async function createGameRunner(
gameStart: GameStartInfo, gameStart: GameStartInfo,
@@ -39,7 +39,7 @@ export async function createGameRunner(
callBack: (gu: GameUpdateViewData | ErrorUpdate) => void, callBack: (gu: GameUpdateViewData | ErrorUpdate) => void,
): Promise<GameRunner> { ): Promise<GameRunner> {
const config = await getConfig(gameStart.config, null); const config = await getConfig(gameStart.config, null);
const gameMap = await loadGameMap(gameStart.config.gameMap, mapLoader); const gameMap = await loadTerrainMap(gameStart.config.gameMap, mapLoader);
const random = new PseudoRandom(simpleHash(gameStart.gameID)); const random = new PseudoRandom(simpleHash(gameStart.gameID));
const humans = gameStart.players.map( const humans = gameStart.players.map(
+4 -4
View File
@@ -1,7 +1,3 @@
import { base64url } from "jose";
import { z } from "zod";
import quickChatData from "../../resources/QuickChat.json" with { type: "json" };
import countries from "../client/data/countries.json" with { type: "json" };
import { import {
AllPlayers, AllPlayers,
Difficulty, Difficulty,
@@ -16,7 +12,11 @@ import {
} from "./game/Game"; } from "./game/Game";
import { PatternDecoder } from "./PatternDecoder"; import { PatternDecoder } from "./PatternDecoder";
import { PlayerStatsSchema } from "./StatsSchemas"; import { PlayerStatsSchema } from "./StatsSchemas";
import { base64url } from "jose";
import countries from "../client/data/countries.json" with { type: "json" };
import { flattenedEmojiTable } from "./Util"; import { flattenedEmojiTable } from "./Util";
import quickChatData from "../../resources/QuickChat.json" with { type: "json" };
import { z } from "zod";
export type GameID = string; export type GameID = string;
export type ClientID = string; export type ClientID = string;
+1 -1
View File
@@ -1,5 +1,5 @@
import { z } from "zod";
import { UnitType } from "./game/Game"; import { UnitType } from "./game/Game";
import { z } from "zod";
export const BombUnitSchema = z.union([ export const BombUnitSchema = z.union([
z.literal("abomb"), z.literal("abomb"),
+7 -8
View File
@@ -1,7 +1,8 @@
import DOMPurify from "dompurify"; import {
import { customAlphabet } from "nanoid"; BOT_NAME_PREFIXES,
BOT_NAME_SUFFIXES,
} from "./execution/utils/BotNames";
import { Cell, Unit } from "./game/Game"; import { Cell, Unit } from "./game/Game";
import { GameMap, TileRef } from "./game/GameMap";
import { import {
GameConfig, GameConfig,
GameID, GameID,
@@ -10,12 +11,10 @@ import {
Turn, Turn,
Winner, Winner,
} from "./Schemas"; } from "./Schemas";
import { GameMap, TileRef } from "./game/GameMap";
import DOMPurify from "dompurify";
import { ServerConfig } from "./configuration/Config"; import { ServerConfig } from "./configuration/Config";
import { import { customAlphabet } from "nanoid";
BOT_NAME_PREFIXES,
BOT_NAME_SUFFIXES,
} from "./execution/utils/BotNames";
export function manhattanDistWrapped( export function manhattanDistWrapped(
c1: Cell, c1: Cell,
+1 -1
View File
@@ -1,6 +1,6 @@
// This file contians schemas for the openfront worker express server // This file contians schemas for the openfront worker express server
import { z } from "zod";
import { GameConfigSchema, GameRecordSchema } from "./Schemas"; import { GameConfigSchema, GameRecordSchema } from "./Schemas";
import { z } from "zod";
export const CreateGameInputSchema = GameConfigSchema.or( export const CreateGameInputSchema = GameConfigSchema.or(
z z
+5 -5
View File
@@ -1,10 +1,5 @@
import { Colord, extend } from "colord"; import { Colord, extend } from "colord";
import labPlugin from "colord/plugins/lab";
import lchPlugin from "colord/plugins/lch";
import Color from "colorjs.io";
import { ColoredTeams, Team } from "../game/Game"; import { ColoredTeams, Team } from "../game/Game";
import { PseudoRandom } from "../PseudoRandom";
import { simpleHash } from "../Util";
import { import {
blueTeamColors, blueTeamColors,
botTeamColors, botTeamColors,
@@ -15,6 +10,11 @@ import {
tealTeamColors, tealTeamColors,
yellowTeamColors, yellowTeamColors,
} from "./Colors"; } from "./Colors";
import Color from "colorjs.io";
import { PseudoRandom } from "../PseudoRandom";
import labPlugin from "colord/plugins/lab";
import lchPlugin from "colord/plugins/lch";
import { simpleHash } from "../Util";
extend([lchPlugin]); extend([lchPlugin]);
extend([labPlugin]); extend([labPlugin]);
+1 -1
View File
@@ -1,4 +1,4 @@
import { colord, Colord, extend } from "colord"; import { Colord, colord, extend } from "colord";
import labPlugin from "colord/plugins/lab"; import labPlugin from "colord/plugins/lab";
import lchPlugin from "colord/plugins/lch"; import lchPlugin from "colord/plugins/lch";
+4 -4
View File
@@ -1,5 +1,3 @@
import { Colord } from "colord";
import { JWK } from "jose";
import { import {
Difficulty, Difficulty,
Game, Game,
@@ -14,11 +12,13 @@ import {
UnitInfo, UnitInfo,
UnitType, UnitType,
} from "../game/Game"; } from "../game/Game";
import { GameConfig, GameID, TeamCountConfig } from "../Schemas";
import { GameMap, TileRef } from "../game/GameMap"; import { GameMap, TileRef } from "../game/GameMap";
import { Colord } from "colord";
import { JWK } from "jose";
import { NukeType } from "../StatsSchemas";
import { PlayerView } from "../game/GameView"; import { PlayerView } from "../game/GameView";
import { UserSettings } from "../game/UserSettings"; import { UserSettings } from "../game/UserSettings";
import { GameConfig, GameID, TeamCountConfig } from "../Schemas";
import { NukeType } from "../StatsSchemas";
export enum GameEnv { export enum GameEnv {
Dev, Dev,
+4 -4
View File
@@ -1,9 +1,9 @@
import { ApiEnvResponseSchema } from "../ExpressSchemas";
import { UserSettings } from "../game/UserSettings";
import { GameConfig } from "../Schemas";
import { Config, GameEnv, ServerConfig } from "./Config"; import { Config, GameEnv, ServerConfig } from "./Config";
import { DefaultConfig } from "./DefaultConfig";
import { DevConfig, DevServerConfig } from "./DevConfig"; import { DevConfig, DevServerConfig } from "./DevConfig";
import { ApiEnvResponseSchema } from "../ExpressSchemas";
import { DefaultConfig } from "./DefaultConfig";
import { GameConfig } from "../Schemas";
import { UserSettings } from "../game/UserSettings";
import { preprodConfig } from "./PreprodConfig"; import { preprodConfig } from "./PreprodConfig";
import { prodConfig } from "./ProdConfig"; import { prodConfig } from "./ProdConfig";
+8 -8
View File
@@ -1,6 +1,5 @@
/* eslint-disable max-lines */ /* eslint-disable max-lines */
import { JWK } from "jose"; import { Config, GameEnv, NukeMagnitude, ServerConfig, Theme } from "./Config";
import { z } from "zod";
import { import {
Difficulty, Difficulty,
Duos, Duos,
@@ -13,22 +12,23 @@ import {
PlayerInfo, PlayerInfo,
PlayerType, PlayerType,
Quads, Quads,
TerrainType,
TerraNullius, TerraNullius,
TerrainType,
Tick, Tick,
Trios, Trios,
UnitInfo, UnitInfo,
UnitType, UnitType,
} from "../game/Game"; } from "../game/Game";
import { TileRef } from "../game/GameMap";
import { PlayerView } from "../game/GameView";
import { UserSettings } from "../game/UserSettings";
import { GameConfig, GameID, TeamCountConfig } from "../Schemas"; import { GameConfig, GameID, TeamCountConfig } from "../Schemas";
import { NukeType } from "../StatsSchemas";
import { assertNever, simpleHash, within } from "../Util"; import { assertNever, simpleHash, within } from "../Util";
import { Config, GameEnv, NukeMagnitude, ServerConfig, Theme } from "./Config"; import { JWK } from "jose";
import { NukeType } from "../StatsSchemas";
import { PastelTheme } from "./PastelTheme"; import { PastelTheme } from "./PastelTheme";
import { PastelThemeDark } from "./PastelThemeDark"; import { PastelThemeDark } from "./PastelThemeDark";
import { PlayerView } from "../game/GameView";
import { TileRef } from "../game/GameMap";
import { UserSettings } from "../game/UserSettings";
import { z } from "zod";
const JwksSchema = z.object({ const JwksSchema = z.object({
keys: z keys: z
+4 -4
View File
@@ -1,8 +1,8 @@
import { UnitInfo, UnitType } from "../game/Game";
import { UserSettings } from "../game/UserSettings";
import { GameConfig } from "../Schemas";
import { GameEnv, ServerConfig } from "./Config";
import { DefaultConfig, DefaultServerConfig } from "./DefaultConfig"; import { DefaultConfig, DefaultServerConfig } from "./DefaultConfig";
import { GameEnv, ServerConfig } from "./Config";
import { UnitInfo, UnitType } from "../game/Game";
import { GameConfig } from "../Schemas";
import { UserSettings } from "../game/UserSettings";
export class DevServerConfig extends DefaultServerConfig { export class DevServerConfig extends DefaultServerConfig {
adminToken(): string { adminToken(): string {
+4 -4
View File
@@ -1,10 +1,10 @@
import { Colord, colord } from "colord"; import { Colord, colord } from "colord";
import { PseudoRandom } from "../PseudoRandom";
import { PlayerType, Team, TerrainType } from "../game/Game";
import { GameMap, TileRef } from "../game/GameMap"; import { GameMap, TileRef } from "../game/GameMap";
import { PlayerView } from "../game/GameView"; import { PlayerType, Team, TerrainType } from "../game/Game";
import { ColorAllocator } from "./ColorAllocator";
import { botColors, fallbackColors, humanColors, nationColors } from "./Colors"; import { botColors, fallbackColors, humanColors, nationColors } from "./Colors";
import { ColorAllocator } from "./ColorAllocator";
import { PlayerView } from "../game/GameView";
import { PseudoRandom } from "../PseudoRandom";
import { Theme } from "./Config"; import { Theme } from "./Config";
type ColorCache = Map<string, Colord>; type ColorCache = Map<string, Colord>;
+4 -4
View File
@@ -1,10 +1,10 @@
import { Colord, colord } from "colord"; import { Colord, colord } from "colord";
import { PseudoRandom } from "../PseudoRandom";
import { PlayerType, Team, TerrainType } from "../game/Game";
import { GameMap, TileRef } from "../game/GameMap"; import { GameMap, TileRef } from "../game/GameMap";
import { PlayerView } from "../game/GameView"; import { PlayerType, Team, TerrainType } from "../game/Game";
import { ColorAllocator } from "./ColorAllocator";
import { botColors, fallbackColors, humanColors, nationColors } from "./Colors"; import { botColors, fallbackColors, humanColors, nationColors } from "./Colors";
import { ColorAllocator } from "./ColorAllocator";
import { PlayerView } from "../game/GameView";
import { PseudoRandom } from "../PseudoRandom";
import { Theme } from "./Config"; import { Theme } from "./Config";
type ColorCache = Map<string, Colord>; type ColorCache = Map<string, Colord>;
+1 -1
View File
@@ -1,5 +1,5 @@
import { GameEnv } from "./Config";
import { DefaultServerConfig } from "./DefaultConfig"; import { DefaultServerConfig } from "./DefaultConfig";
import { GameEnv } from "./Config";
export const preprodConfig = new (class extends DefaultServerConfig { export const preprodConfig = new (class extends DefaultServerConfig {
env(): GameEnv { env(): GameEnv {
+1 -1
View File
@@ -1,5 +1,5 @@
import { GameEnv } from "./Config";
import { DefaultServerConfig } from "./DefaultConfig"; import { DefaultServerConfig } from "./DefaultConfig";
import { GameEnv } from "./Config";
export const prodConfig = new (class extends DefaultServerConfig { export const prodConfig = new (class extends DefaultServerConfig {
numWorkers(): number { numWorkers(): number {
+4 -4
View File
@@ -1,4 +1,3 @@
import { renderTroops } from "../../client/Utils";
import { import {
Attack, Attack,
Execution, Execution,
@@ -7,12 +6,13 @@ import {
Player, Player,
PlayerID, PlayerID,
PlayerType, PlayerType,
TerrainType,
TerraNullius, TerraNullius,
TerrainType,
} from "../game/Game"; } from "../game/Game";
import { TileRef } from "../game/GameMap";
import { PseudoRandom } from "../PseudoRandom";
import { FlatBinaryHeap } from "./utils/FlatBinaryHeap"; // adjust path if needed import { FlatBinaryHeap } from "./utils/FlatBinaryHeap"; // adjust path if needed
import { PseudoRandom } from "../PseudoRandom";
import { TileRef } from "../game/GameMap";
import { renderTroops } from "../../client/Utils";
const malusForRetreat = 25; const malusForRetreat = 25;
export class AttackExecution implements Execution { export class AttackExecution implements Execution {
+1 -1
View File
@@ -1,7 +1,7 @@
import { Execution, Game, Player } from "../game/Game"; import { Execution, Game, Player } from "../game/Game";
import { BotBehavior } from "./utils/BotBehavior";
import { PseudoRandom } from "../PseudoRandom"; import { PseudoRandom } from "../PseudoRandom";
import { simpleHash } from "../Util"; import { simpleHash } from "../Util";
import { BotBehavior } from "./utils/BotBehavior";
export class BotExecution implements Execution { export class BotExecution implements Execution {
private active = true; private active = true;
+6 -6
View File
@@ -1,10 +1,10 @@
import { Game, PlayerInfo, PlayerType } from "../game/Game";
import { TileRef } from "../game/GameMap";
import { PseudoRandom } from "../PseudoRandom";
import { GameID } from "../Schemas";
import { simpleHash } from "../Util";
import { SpawnExecution } from "./SpawnExecution";
import { BOT_NAME_PREFIXES, BOT_NAME_SUFFIXES } from "./utils/BotNames"; import { BOT_NAME_PREFIXES, BOT_NAME_SUFFIXES } from "./utils/BotNames";
import { Game, PlayerInfo, PlayerType } from "../game/Game";
import { GameID } from "../Schemas";
import { PseudoRandom } from "../PseudoRandom";
import { SpawnExecution } from "./SpawnExecution";
import { TileRef } from "../game/GameMap";
import { simpleHash } from "../Util";
export class BotSpawner { export class BotSpawner {
private random: PseudoRandom; private random: PseudoRandom;
+1 -1
View File
@@ -7,7 +7,6 @@ import {
Unit, Unit,
UnitType, UnitType,
} from "../game/Game"; } from "../game/Game";
import { TileRef } from "../game/GameMap";
import { CityExecution } from "./CityExecution"; import { CityExecution } from "./CityExecution";
import { DefensePostExecution } from "./DefensePostExecution"; import { DefensePostExecution } from "./DefensePostExecution";
import { FactoryExecution } from "./FactoryExecution"; import { FactoryExecution } from "./FactoryExecution";
@@ -16,6 +15,7 @@ import { MissileSiloExecution } from "./MissileSiloExecution";
import { NukeExecution } from "./NukeExecution"; import { NukeExecution } from "./NukeExecution";
import { PortExecution } from "./PortExecution"; import { PortExecution } from "./PortExecution";
import { SAMLauncherExecution } from "./SAMLauncherExecution"; import { SAMLauncherExecution } from "./SAMLauncherExecution";
import { TileRef } from "../game/GameMap";
import { WarshipExecution } from "./WarshipExecution"; import { WarshipExecution } from "./WarshipExecution";
export class ConstructionExecution implements Execution { export class ConstructionExecution implements Execution {
+1 -1
View File
@@ -1,6 +1,6 @@
import { Execution, Game, Player, Unit, UnitType } from "../game/Game"; import { Execution, Game, Player, Unit, UnitType } from "../game/Game";
import { TileRef } from "../game/GameMap";
import { ShellExecution } from "./ShellExecution"; import { ShellExecution } from "./ShellExecution";
import { TileRef } from "../game/GameMap";
export class DefensePostExecution implements Execution { export class DefensePostExecution implements Execution {
private mg: Game; private mg: Game;
+4 -4
View File
@@ -1,14 +1,12 @@
import { Execution, Game } from "../game/Game";
import { PseudoRandom } from "../PseudoRandom";
import { ClientID, GameID, Intent, Turn } from "../Schemas"; import { ClientID, GameID, Intent, Turn } from "../Schemas";
import { simpleHash } from "../Util"; import { Execution, Game } from "../game/Game";
import { AllianceExtensionExecution } from "./alliance/AllianceExtensionExecution"; import { AllianceExtensionExecution } from "./alliance/AllianceExtensionExecution";
import { AllianceRequestExecution } from "./alliance/AllianceRequestExecution"; import { AllianceRequestExecution } from "./alliance/AllianceRequestExecution";
import { AllianceRequestReplyExecution } from "./alliance/AllianceRequestReplyExecution"; import { AllianceRequestReplyExecution } from "./alliance/AllianceRequestReplyExecution";
import { BreakAllianceExecution } from "./alliance/BreakAllianceExecution";
import { AttackExecution } from "./AttackExecution"; import { AttackExecution } from "./AttackExecution";
import { BoatRetreatExecution } from "./BoatRetreatExecution"; import { BoatRetreatExecution } from "./BoatRetreatExecution";
import { BotSpawner } from "./BotSpawner"; import { BotSpawner } from "./BotSpawner";
import { BreakAllianceExecution } from "./alliance/BreakAllianceExecution";
import { ConstructionExecution } from "./ConstructionExecution"; import { ConstructionExecution } from "./ConstructionExecution";
import { DeleteUnitExecution } from "./DeleteUnitExecution"; import { DeleteUnitExecution } from "./DeleteUnitExecution";
import { DonateGoldExecution } from "./DonateGoldExecution"; import { DonateGoldExecution } from "./DonateGoldExecution";
@@ -19,12 +17,14 @@ import { FakeHumanExecution } from "./FakeHumanExecution";
import { MarkDisconnectedExecution } from "./MarkDisconnectedExecution"; import { MarkDisconnectedExecution } from "./MarkDisconnectedExecution";
import { MoveWarshipExecution } from "./MoveWarshipExecution"; import { MoveWarshipExecution } from "./MoveWarshipExecution";
import { NoOpExecution } from "./NoOpExecution"; import { NoOpExecution } from "./NoOpExecution";
import { PseudoRandom } from "../PseudoRandom";
import { QuickChatExecution } from "./QuickChatExecution"; import { QuickChatExecution } from "./QuickChatExecution";
import { RetreatExecution } from "./RetreatExecution"; import { RetreatExecution } from "./RetreatExecution";
import { SpawnExecution } from "./SpawnExecution"; import { SpawnExecution } from "./SpawnExecution";
import { TargetPlayerExecution } from "./TargetPlayerExecution"; import { TargetPlayerExecution } from "./TargetPlayerExecution";
import { TransportShipExecution } from "./TransportShipExecution"; import { TransportShipExecution } from "./TransportShipExecution";
import { UpgradeStructureExecution } from "./UpgradeStructureExecution"; import { UpgradeStructureExecution } from "./UpgradeStructureExecution";
import { simpleHash } from "../Util";
export class Executor { export class Executor {
// private random = new PseudoRandom(999) // private random = new PseudoRandom(999)
+4 -4
View File
@@ -14,17 +14,17 @@ import {
Unit, Unit,
UnitType, UnitType,
} from "../game/Game"; } from "../game/Game";
import { euclDistFN, manhattanDistFN, TileRef } from "../game/GameMap"; import { TileRef, euclDistFN, manhattanDistFN } from "../game/GameMap";
import { PseudoRandom } from "../PseudoRandom";
import { GameID } from "../Schemas";
import { calculateBoundingBox, flattenedEmojiTable, simpleHash } from "../Util"; import { calculateBoundingBox, flattenedEmojiTable, simpleHash } from "../Util";
import { BotBehavior } from "./utils/BotBehavior";
import { ConstructionExecution } from "./ConstructionExecution"; import { ConstructionExecution } from "./ConstructionExecution";
import { EmojiExecution } from "./EmojiExecution"; import { EmojiExecution } from "./EmojiExecution";
import { GameID } from "../Schemas";
import { NukeExecution } from "./NukeExecution"; import { NukeExecution } from "./NukeExecution";
import { PseudoRandom } from "../PseudoRandom";
import { SpawnExecution } from "./SpawnExecution"; import { SpawnExecution } from "./SpawnExecution";
import { TransportShipExecution } from "./TransportShipExecution"; import { TransportShipExecution } from "./TransportShipExecution";
import { closestTwoTiles } from "./Util"; import { closestTwoTiles } from "./Util";
import { BotBehavior } from "./utils/BotBehavior";
export class FakeHumanExecution implements Execution { export class FakeHumanExecution implements Execution {
private active = true; private active = true;
+2 -2
View File
@@ -7,11 +7,11 @@ import {
Unit, Unit,
UnitType, UnitType,
} from "../game/Game"; } from "../game/Game";
import { TileRef } from "../game/GameMap"; import { NukeExecution } from "./NukeExecution";
import { ParabolaPathFinder } from "../pathfinding/PathFinding"; import { ParabolaPathFinder } from "../pathfinding/PathFinding";
import { PseudoRandom } from "../PseudoRandom"; import { PseudoRandom } from "../PseudoRandom";
import { TileRef } from "../game/GameMap";
import { simpleHash } from "../Util"; import { simpleHash } from "../Util";
import { NukeExecution } from "./NukeExecution";
export class MirvExecution implements Execution { export class MirvExecution implements Execution {
private active = true; private active = true;
+3 -3
View File
@@ -1,18 +1,18 @@
import { import {
Execution, Execution,
Game, Game,
isStructureType,
MessageType, MessageType,
Player, Player,
TerraNullius, TerraNullius,
TrajectoryTile, TrajectoryTile,
Unit, Unit,
UnitType, UnitType,
isStructureType,
} from "../game/Game"; } from "../game/Game";
import { TileRef } from "../game/GameMap"; import { NukeType } from "../StatsSchemas";
import { ParabolaPathFinder } from "../pathfinding/PathFinding"; import { ParabolaPathFinder } from "../pathfinding/PathFinding";
import { PseudoRandom } from "../PseudoRandom"; import { PseudoRandom } from "../PseudoRandom";
import { NukeType } from "../StatsSchemas"; import { TileRef } from "../game/GameMap";
const SPRITE_RADIUS = 16; const SPRITE_RADIUS = 16;
+2 -2
View File
@@ -1,8 +1,8 @@
import { Config } from "../configuration/Config";
import { Execution, Game, Player, UnitType } from "../game/Game"; import { Execution, Game, Player, UnitType } from "../game/Game";
import { GameImpl } from "../game/GameImpl";
import { GameMap, TileRef } from "../game/GameMap"; import { GameMap, TileRef } from "../game/GameMap";
import { calculateBoundingBox, getMode, inscribed, simpleHash } from "../Util"; import { calculateBoundingBox, getMode, inscribed, simpleHash } from "../Util";
import { Config } from "../configuration/Config";
import { GameImpl } from "../game/GameImpl";
export class PlayerExecution implements Execution { export class PlayerExecution implements Execution {
private readonly ticksPerClusterCalc = 20; private readonly ticksPerClusterCalc = 20;
+1 -1
View File
@@ -1,6 +1,6 @@
import { Execution, Game, Player, Unit, UnitType } from "../game/Game"; import { Execution, Game, Player, Unit, UnitType } from "../game/Game";
import { TileRef } from "../game/GameMap";
import { PseudoRandom } from "../PseudoRandom"; import { PseudoRandom } from "../PseudoRandom";
import { TileRef } from "../game/GameMap";
import { TradeShipExecution } from "./TradeShipExecution"; import { TradeShipExecution } from "./TradeShipExecution";
import { TrainStationExecution } from "./TrainStationExecution"; import { TrainStationExecution } from "./TrainStationExecution";
+1 -1
View File
@@ -1,7 +1,7 @@
import { Execution, Game } from "../game/Game"; import { Execution, Game } from "../game/Game";
import { TileRef } from "../game/GameMap";
import { GameUpdateType, RailTile, RailType } from "../game/GameUpdates"; import { GameUpdateType, RailTile, RailType } from "../game/GameUpdates";
import { Railroad } from "../game/Railroad"; import { Railroad } from "../game/Railroad";
import { TileRef } from "../game/GameMap";
export class RailroadExecution implements Execution { export class RailroadExecution implements Execution {
private mg: Game; private mg: Game;
+2 -2
View File
@@ -1,15 +1,15 @@
import { import {
Execution, Execution,
Game, Game,
isUnit,
MessageType, MessageType,
Player, Player,
Unit, Unit,
UnitType, UnitType,
isUnit,
} from "../game/Game"; } from "../game/Game";
import { TileRef } from "../game/GameMap";
import { PseudoRandom } from "../PseudoRandom"; import { PseudoRandom } from "../PseudoRandom";
import { SAMMissileExecution } from "./SAMMissileExecution"; import { SAMMissileExecution } from "./SAMMissileExecution";
import { TileRef } from "../game/GameMap";
type Target = { type Target = {
unit: Unit; unit: Unit;

Some files were not shown because too many files have changed in this diff Show More