From d415d41e15ba53be72ee2812e6828a0b696c0281 Mon Sep 17 00:00:00 2001
From: 1brucben <1benjbruce@gmail.com>
Date: Sun, 20 Apr 2025 16:52:48 +0200
Subject: [PATCH 1/4] Remove defenseposture after merge for clean copy.
---
src/client/graphics/layers/ControlPanel.ts | 38 ----------------------
1 file changed, 38 deletions(-)
diff --git a/src/client/graphics/layers/ControlPanel.ts b/src/client/graphics/layers/ControlPanel.ts
index b3a9bc23e..ae73daf51 100644
--- a/src/client/graphics/layers/ControlPanel.ts
+++ b/src/client/graphics/layers/ControlPanel.ts
@@ -315,44 +315,6 @@ export class ControlPanel extends LitElement implements Layer {
/>
-
`;
}
From b93e84c5ba1b96c52e59a83c0fd70d19b8929587 Mon Sep 17 00:00:00 2001
From: 1brucben <1benjbruce@gmail.com>
Date: Sun, 20 Apr 2025 19:22:38 +0200
Subject: [PATCH 2/4] Gold Adjustment
---
src/core/configuration/DefaultConfig.ts | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/src/core/configuration/DefaultConfig.ts b/src/core/configuration/DefaultConfig.ts
index 33ac35294..d75a1d896 100644
--- a/src/core/configuration/DefaultConfig.ts
+++ b/src/core/configuration/DefaultConfig.ts
@@ -638,7 +638,28 @@ export class DefaultConfig implements Config {
}
goldAdditionRate(player: Player): number {
- return (player.workers() ** 0.6 * player.numTilesOwned() ** 0.4) / 400;
+ const numCities = player.units(UnitType.City).length;
+ const baseCityPopulation = numCities * this.cityPopulationIncrease();
+
+ const totalWorkers = player.workers();
+ const totalPopulation = player.population();
+ const maxPopulation = this.maxPopulation(player);
+ const numTiles = player.numTilesOwned();
+
+ const populationRatio =
+ maxPopulation > 0 ? totalPopulation / maxPopulation : 0;
+ const adjustedCityPopulation = baseCityPopulation * populationRatio;
+
+ const cityWorkers =
+ (adjustedCityPopulation * totalWorkers) / totalPopulation;
+ const ruralWorkers = totalWorkers - cityWorkers;
+
+ const cityGold = cityWorkers / 1950;
+ const tileGold = (ruralWorkers ** 0.6 * numTiles ** 0.4) / 500;
+
+ const totalGold = cityGold + tileGold;
+
+ return totalGold;
}
troopAdjustmentRate(player: Player): number {
From df9329f0f7b40d6295c5401dbf4f23953fb73349 Mon Sep 17 00:00:00 2001
From: 1brucben <1benjbruce@gmail.com>
Date: Sun, 20 Apr 2025 19:29:45 +0200
Subject: [PATCH 3/4] fixed broken retreat
---
src/core/execution/AttackExecution.ts | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/core/execution/AttackExecution.ts b/src/core/execution/AttackExecution.ts
index ac774b557..6bf06ef2b 100644
--- a/src/core/execution/AttackExecution.ts
+++ b/src/core/execution/AttackExecution.ts
@@ -208,7 +208,11 @@ export class AttackExecution implements Execution {
return;
}
- if (this.attack.retreating() || !this.attack.isActive()) {
+ if (this.attack.retreating()) {
+ return; // Keep waiting for retreat flag to become "retreated"
+ }
+
+ if (!this.attack.isActive()) {
this.active = false;
return;
}
From 2d53938c089226aa7809e79d5b9fb947b595779b Mon Sep 17 00:00:00 2001
From: 1brucben <1benjbruce@gmail.com>
Date: Sun, 20 Apr 2025 19:37:22 +0200
Subject: [PATCH 4/4] removed remnants of defensive posture (to place in
another branch)
---
src/client/Transport.ts | 14 -------
src/client/graphics/layers/ControlPanel.ts | 20 +--------
src/core/Schemas.ts | 12 +-----
src/core/configuration/DefaultConfig.ts | 23 +----------
src/core/execution/ExecutionManager.ts | 4 --
.../execution/SetDefensivePostureExecution.ts | 41 -------------------
src/core/game/Game.ts | 2 -
src/core/game/PlayerImpl.ts | 8 ----
8 files changed, 4 insertions(+), 120 deletions(-)
delete mode 100644 src/core/execution/SetDefensivePostureExecution.ts
diff --git a/src/client/Transport.ts b/src/client/Transport.ts
index 247686e05..d3c570a9b 100644
--- a/src/client/Transport.ts
+++ b/src/client/Transport.ts
@@ -98,9 +98,6 @@ export class SendDonateGoldIntentEvent implements GameEvent {
public readonly gold: number | null,
) {}
}
-export class SendSetDefensivePostureEvent {
- constructor(public readonly posture: "retreat" | "balanced" | "hold") {}
-}
export class SendDonateTroopsIntentEvent implements GameEvent {
constructor(
@@ -216,9 +213,6 @@ export class Transport {
this.eventBus.on(MoveWarshipIntentEvent, (e) => {
this.onMoveWarshipEvent(e);
});
- this.eventBus.on(SendSetDefensivePostureEvent, (e) =>
- this.onSendSetDefensivePostureEvent(e),
- );
}
private startPing() {
@@ -558,14 +552,6 @@ export class Transport {
});
}
- private onSendSetDefensivePostureEvent(event: SendSetDefensivePostureEvent) {
- this.sendIntent({
- type: "setDefensivePosture",
- clientID: this.lobbyConfig.clientID,
- posture: event.posture,
- });
- }
-
private sendIntent(intent: Intent) {
if (this.isLocal || this.socket.readyState === WebSocket.OPEN) {
const msg = ClientIntentMessageSchema.parse({
diff --git a/src/client/graphics/layers/ControlPanel.ts b/src/client/graphics/layers/ControlPanel.ts
index ae73daf51..fac9fb6b6 100644
--- a/src/client/graphics/layers/ControlPanel.ts
+++ b/src/client/graphics/layers/ControlPanel.ts
@@ -4,10 +4,7 @@ import { EventBus } from "../../../core/EventBus";
import { GameView } from "../../../core/game/GameView";
import { ClientID } from "../../../core/Schemas";
import { AttackRatioEvent } from "../../InputHandler";
-import {
- SendSetDefensivePostureEvent,
- SendSetTargetTroopRatioEvent,
-} from "../../Transport";
+import { SendSetTargetTroopRatioEvent } from "../../Transport";
import { renderNumber, renderTroops } from "../../Utils";
import { UIState } from "../UIState";
import { Layer } from "./Layer";
@@ -25,9 +22,6 @@ export class ControlPanel extends LitElement implements Layer {
@state()
private targetTroopRatio = 0.95;
- @state()
- private defensivePosture: "retreat" | "balanced" | "hold" = "balanced";
-
@state()
private currentTroopRatio = 0.95;
@@ -71,8 +65,6 @@ export class ControlPanel extends LitElement implements Layer {
this.targetTroopRatio = Number(
localStorage.getItem("settings.troopRatio") ?? "0.95",
);
- this.defensivePosture =
- (localStorage.getItem("settings.defensivePosture") as any) ?? "balanced";
this.init_ = true;
this.uiState.attackRatio = this.attackRatio;
this.currentTroopRatio = this.targetTroopRatio;
@@ -143,16 +135,6 @@ export class ControlPanel extends LitElement implements Layer {
this.uiState.attackRatio = newRatio;
}
- private onPostureChange(e: Event) {
- const raw = (e.target as HTMLInputElement).value;
-
- if (raw === "retreat" || raw === "balanced" || raw === "hold") {
- const value = raw as "retreat" | "balanced" | "hold";
- this.eventBus.emit(new SendSetDefensivePostureEvent(value));
- } else {
- console.warn(`Unexpected posture value: ${raw}`);
- }
- }
renderLayer(context: CanvasRenderingContext2D) {
// Render any necessary canvas elements
}
diff --git a/src/core/Schemas.ts b/src/core/Schemas.ts
index c9cd90dc2..7fc8e63a5 100644
--- a/src/core/Schemas.ts
+++ b/src/core/Schemas.ts
@@ -28,8 +28,7 @@ export type Intent =
| TargetTroopRatioIntent
| BuildUnitIntent
| EmbargoIntent
- | MoveWarshipIntent
- | SetDefensivePostureIntent;
+ | MoveWarshipIntent;
export type AttackIntent = z.infer