From 0e809e4e19927218db680dcb23f545c1fa672560 Mon Sep 17 00:00:00 2001 From: 1brucben <1benjbruce@gmail.com> Date: Thu, 5 Jun 2025 16:09:15 +0200 Subject: [PATCH] force modal --- src/client/Main.ts | 43 ++++++++++++++++++------------------ src/client/NewsModal.ts | 48 +++++++++++++++++++++++------------------ 2 files changed, 49 insertions(+), 42 deletions(-) diff --git a/src/client/Main.ts b/src/client/Main.ts index c4b877eaa..140c20e4e 100644 --- a/src/client/Main.ts +++ b/src/client/Main.ts @@ -1,6 +1,5 @@ import page from "page"; import favicon from "../../resources/images/Favicon.svg"; -import { consolex } from "../core/Consolex"; import { GameRecord, GameStartInfo } from "../core/Schemas"; import { getServerConfigFromClient } from "../core/configuration/ConfigLoader"; import { GameType } from "../core/game/Game"; @@ -62,16 +61,16 @@ class Client { initialize(): void { const newsModal = document.querySelector("news-modal") as NewsModal; if (!newsModal) { - consolex.warn("News modal element not found"); + console.warn("News modal element not found"); } else { - consolex.log("News modal element found"); + console.log("News modal element found"); } newsModal instanceof NewsModal; const newsButton = document.querySelector("news-button") as NewsButton; if (!newsButton) { - consolex.warn("News button element not found"); + console.warn("News button element not found"); } else { - consolex.log("News button element found"); + console.log("News button element found"); } // Comment out to show news button. @@ -84,22 +83,22 @@ class Client { "lang-selector", ) as LanguageModal; if (!langSelector) { - consolex.warn("Lang selector element not found"); + console.warn("Lang selector element not found"); } if (!LanguageModal) { - consolex.warn("Language modal element not found"); + console.warn("Language modal element not found"); } this.flagInput = document.querySelector("flag-input") as FlagInput; if (!this.flagInput) { - consolex.warn("Flag input element not found"); + console.warn("Flag input element not found"); } this.darkModeButton = document.querySelector( "dark-mode-button", ) as DarkModeButton; if (!this.darkModeButton) { - consolex.warn("Dark mode button element not found"); + console.warn("Dark mode button element not found"); } const loginDiscordButton = document.getElementById( @@ -113,7 +112,7 @@ class Client { "username-input", ) as UsernameInput; if (!this.usernameInput) { - consolex.warn("Username input element not found"); + console.warn("Username input element not found"); } this.publicLobby = document.querySelector("public-lobby") as PublicLobby; @@ -122,7 +121,7 @@ class Client { ) as NodeListOf; window.addEventListener("beforeunload", () => { - consolex.log("Browser is closing"); + console.log("Browser is closing"); if (this.gameStop !== null) { this.gameStop(); } @@ -240,21 +239,20 @@ class Client { page("/join/:lobbyId", (ctx) => { if (ctx.init && sessionStorage.getItem("inLobby")) { // On page reload, go back home - page.redirect("/"); + page("/"); return; } const lobbyId = ctx.params.lobbyId; - if (lobbyId?.endsWith("#")) { - // When the cookies button is pressed, '#' is added to the url - // causing the page to attempt to rejoin the lobby during game play. - console.error("Invalid lobby ID provided"); - return; + // Show news modal even if user loads game directly + const newsModal = document.querySelector("news-modal") as NewsModal; + if (newsModal) { + newsModal.open(); } this.joinModal.open(lobbyId); - consolex.log(`joining lobby ${lobbyId}`); + console.log(`joining lobby ${lobbyId}`); }); page(); @@ -270,13 +268,16 @@ class Client { updateSliderProgress(slider); slider.addEventListener("input", () => updateSliderProgress(slider)); }); + if (newsModal) { + newsModal.open(); + } } private async handleJoinLobby(event: CustomEvent) { const lobby = event.detail as JoinLobbyEvent; - consolex.log(`joining lobby ${lobby.gameID}`); + console.log(`joining lobby ${lobby.gameID}`); if (this.gameStop !== null) { - consolex.log("joining lobby, stopping existing game"); + console.log("joining lobby, stopping existing game"); this.gameStop(); } const config = await getServerConfigFromClient(); @@ -348,7 +349,7 @@ class Client { if (this.gameStop === null) { return; } - consolex.log("leaving lobby, cancelling game"); + console.log("leaving lobby, cancelling game"); this.gameStop(); this.gameStop = null; this.publicLobby.leaveLobby(); diff --git a/src/client/NewsModal.ts b/src/client/NewsModal.ts index 13ddb67bb..ff9b7aabc 100644 --- a/src/client/NewsModal.ts +++ b/src/client/NewsModal.ts @@ -1,6 +1,5 @@ import { LitElement, css, html } from "lit"; import { customElement, query } from "lit/decorators.js"; -import { translateText } from "../client/Utils"; import "./components/baseComponents/Button"; import "./components/baseComponents/Modal"; @@ -46,37 +45,44 @@ export class NewsModal extends LitElement { render() { return html` - +
-

Main things to note:

-
+

+ This test version introduces a new building: + Hospitals. Each hospital reduces your troop + losses in both offensive and defensive combat. +

+

+ The first hospital provides a + 10% reduction in combat casualties. Each + additional hospital reduces losses by + 75% of the previous reduction. +

    -
  • Workers reproduce faster than troops.
  • -
  • Defense = troops divided how much land you have.
  • -
  • Attacking troops count toward your population limit.
  • +
  • 1st hospital: 10% reduction
  • +
  • 2nd hospital: 7.5% additional reduction
  • +
  • 3rd hospital: 5.6% additional reduction
  • +
  • ... and so on
-
-
- See full changelog - here. +

These effects stack cumulatively.

+

+ For a full list of changes, join the + + Discord . +

- +
`; }