Skip to content

Commit 9d19396

Browse files
authored
Merge branch 'main' into testaskin
2 parents af2fe78 + d4e0964 commit 9d19396

35 files changed

+736
-356
lines changed

CODEOWNERS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners
2-
* @openfrontio/review-approver
2+
* @openfrontio/maintainer
33
resources/lang @openfrontio/translation-approver
4-
resources/lang/en.json @openfrontio/review-approver
4+
resources/lang/en.json @openfrontio/maintainer

package-lock.json

Lines changed: 82 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"dev:prod": "cross-env GAME_ENV=dev API_DOMAIN=api.openfront.io concurrently \"npm run start:client\" \"npm run start:server-dev\"",
1212
"docs:map-generator": "cd map-generator && go doc -cmd -u -all",
1313
"tunnel": "npm run build-prod && npm run start:server",
14-
"test": "vitest run",
14+
"test": "vitest run && vitest run tests/server",
1515
"perf": "npx tsx tests/perf/*.ts",
1616
"test:coverage": "vitest run --coverage",
1717
"format": "prettier --ignore-unknown --write .",
@@ -75,7 +75,7 @@
7575
"prettier-plugin-organize-imports": "^4.1.0",
7676
"prettier-plugin-sh": "^0.17.4",
7777
"protobufjs": "^7.5.3",
78-
"sinon": "^21.0.0",
78+
"sinon": "^21.0.1",
7979
"sinon-chai": "^4.0.0",
8080
"tailwindcss": "^4.1.18",
8181
"tsconfig-paths": "^4.2.0",

src/client/ClientGameRunner.ts

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -759,17 +759,12 @@ export class ClientGameRunner {
759759
private sendBoatAttackIntent(tile: TileRef) {
760760
if (!this.myPlayer) return;
761761

762-
this.myPlayer.bestTransportShipSpawn(tile).then((spawn: number | false) => {
763-
if (this.myPlayer === null) throw new Error("not initialized");
764-
this.eventBus.emit(
765-
new SendBoatAttackIntentEvent(
766-
this.gameView.owner(tile).id(),
767-
tile,
768-
this.myPlayer.troops() * this.renderer.uiState.attackRatio,
769-
spawn === false ? null : spawn,
770-
),
771-
);
772-
});
762+
this.eventBus.emit(
763+
new SendBoatAttackIntentEvent(
764+
tile,
765+
this.myPlayer.troops() * this.renderer.uiState.attackRatio,
766+
),
767+
);
773768
}
774769

775770
private canAutoBoat(actions: PlayerActions, tile: TileRef): boolean {

src/client/LanguageModal.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,13 @@ export class LanguageModal extends BaseModal {
7575
/>
7676
<div class="flex flex-col items-start min-w-0">
7777
<span
78-
class="text-sm font-bold uppercase tracking-wider truncate w-full text-left ${isActive
78+
class="text-sm font-bold uppercase tracking-wider whitespace-normal break-words w-full text-left ${isActive
7979
? "text-white"
8080
: "text-gray-200 group-hover:text-white"}"
8181
>${lang.native}</span
8282
>
8383
<span
84-
class="text-xs text-white/40 uppercase tracking-widest group-hover:text-white/60 transition-colors truncate w-full text-left"
84+
class="text-xs text-white/40 uppercase tracking-widest group-hover:text-white/60 transition-colors whitespace-normal break-words w-full text-left"
8585
>${lang.en}</span
8686
>
8787
</div>

src/client/Main.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -589,12 +589,8 @@ class Client {
589589
const onHashUpdate = () => {
590590
// Reset the UI to its initial state
591591
this.joinModal?.close();
592-
if (this.gameStop !== null) {
593-
this.handleLeaveLobby();
594-
}
595592

596-
// Attempt to join lobby
597-
this.handleUrl();
593+
onJoinChanged();
598594
};
599595

600596
const onPopState = () => {
@@ -628,10 +624,19 @@ class Client {
628624
}
629625
};
630626

627+
const onJoinChanged = () => {
628+
if (this.gameStop !== null) {
629+
this.handleLeaveLobby();
630+
}
631+
632+
// Attempt to join lobby
633+
this.handleUrl();
634+
};
635+
631636
// Handle browser navigation & manual hash edits
632637
window.addEventListener("popstate", onPopState);
633638
window.addEventListener("hashchange", onHashUpdate);
634-
window.addEventListener("join-changed", onHashUpdate);
639+
window.addEventListener("join-changed", onJoinChanged);
635640

636641
function updateSliderProgress(slider: HTMLInputElement) {
637642
const percent =

src/client/NewsModal.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export class NewsModal extends BaseModal {
3333
[&_h1]:text-2xl [&_h1]:font-bold [&_h1]:mb-4 [&_h1]:text-white [&_h1]:border-b [&_h1]:border-white/10 [&_h1]:pb-2
3434
[&_h2]:text-xl [&_h2]:font-bold [&_h2]:mt-6 [&_h2]:mb-3 [&_h2]:text-blue-200
3535
[&_h3]:text-lg [&_h3]:font-semibold [&_h3]:mt-4 [&_h3]:mb-2 [&_h3]:text-blue-100
36-
[&_ul]:pl-5 [&_ul]:list-disc [&_ul]:space-y-1
36+
[&_ul]:pl-5 [&_ul]:my-3 [&_ul]:list-disc [&_ul]:space-y-1
3737
[&_li]:text-gray-300 [&_li]:leading-relaxed
3838
[&_p]:text-gray-300 [&_p]:mb-3 [&_strong]:text-white [&_strong]:font-bold
3939
scrollbar-thin scrollbar-thumb-white/20 scrollbar-track-transparent"

src/client/Transport.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,8 @@ export class SendAttackIntentEvent implements GameEvent {
8181

8282
export class SendBoatAttackIntentEvent implements GameEvent {
8383
constructor(
84-
public readonly targetID: PlayerID | null,
8584
public readonly dst: TileRef,
8685
public readonly troops: number,
87-
public readonly src: TileRef | null = null,
8886
) {}
8987
}
9088

@@ -498,10 +496,8 @@ export class Transport {
498496
this.sendIntent({
499497
type: "boat",
500498
clientID: this.lobbyConfig.clientID,
501-
targetID: event.targetID,
502499
troops: event.troops,
503500
dst: event.dst,
504-
src: event.src,
505501
});
506502
}
507503

src/client/graphics/layers/ControlPanel.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,7 @@ export class ControlPanel extends LitElement implements Layer {
201201
<span>
202202
(${renderTroops(
203203
(this.game?.myPlayer()?.troops() ?? 0) * this.attackRatio,
204-
)}
205-
)
204+
)})
206205
</span>
207206
</span>
208207
</label>

src/client/graphics/layers/DynamicUILayer.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,25 @@ export class DynamicUILayer implements Layer {
116116
}
117117

118118
onBombEvent(unit: UnitView) {
119-
if (this.createdThisTick(unit) && this.isOwnedByPlayer(unit)) {
119+
const myPlayer = this.game.myPlayer();
120+
if (!myPlayer) {
121+
return;
122+
}
123+
if (
124+
this.createdThisTick(unit) &&
125+
(unit.owner() === myPlayer || unit.owner().isOnSameTeam(myPlayer))
126+
) {
120127
const target = new NukeTelegraph(this.transformHandler, this.game, unit);
121128
this.uiElements.push(target);
122129
}
123130
}
124131

125132
onTransportShipEvent(unit: UnitView) {
126-
if (this.createdThisTick(unit) && this.isOwnedByPlayer(unit)) {
133+
const myPlayer = this.game.myPlayer();
134+
if (!myPlayer) {
135+
return;
136+
}
137+
if (this.createdThisTick(unit) && unit.owner() === myPlayer) {
127138
const target = new NavalTarget(this.transformHandler, this.game, unit);
128139
this.uiElements.push(target);
129140
}
@@ -146,11 +157,6 @@ export class DynamicUILayer implements Layer {
146157
}
147158
}
148159

149-
private isOwnedByPlayer(unit: UnitView): boolean {
150-
const my = this.game.myPlayer();
151-
return my !== null && unit.owner() === my;
152-
}
153-
154160
private createdThisTick(unit: UnitView): boolean {
155161
return unit.createdAt() === this.game.ticks();
156162
}

0 commit comments

Comments
 (0)