Boat attack event (#177)

Allow user to focus on outgoing boats

Partial #133 


https://github.com/user-attachments/assets/0e287bf5-71bb-4def-a3ca-f0b652ed6d69
This commit is contained in:
Maeght Loan
2025-03-08 10:44:27 -08:00
committed by GitHub
parent afe4f85919
commit e1ed8dbe36
3 changed files with 61 additions and 8 deletions
+7 -3
View File
@@ -2,7 +2,7 @@ import { LitElement, css, html } from "lit";
import { customElement, state } from "lit/decorators.js";
import { unsafeHTML } from "lit/directives/unsafe-html.js";
import { EventBus, GameEvent } from "../../../core/EventBus";
import { GameView, PlayerView } from "../../../core/game/GameView";
import { GameView, PlayerView, UnitView } from "../../../core/game/GameView";
import { ClientID } from "../../../core/Schemas";
import { renderNumber } from "../../Utils";
import { Layer } from "./Layer";
@@ -21,6 +21,10 @@ export class GoToPlayerEvent implements GameEvent {
constructor(public player: PlayerView) {}
}
export class GoToUnitEvent implements GameEvent {
constructor(public unit: UnitView) {}
}
@customElement("leader-board")
export class Leaderboard extends LitElement implements Layer {
public game: GameView;
@@ -116,7 +120,7 @@ export class Leaderboard extends LitElement implements Layer {
this.requestUpdate();
}
private handleRowClick(player: PlayerView) {
private handleRowClickPlayer(player: PlayerView) {
this.eventBus.emit(new GoToPlayerEvent(player));
}
@@ -274,7 +278,7 @@ export class Leaderboard extends LitElement implements Layer {
(player) => html`
<tr
class="${player.isMyPlayer ? "myPlayer" : "otherPlayer"}"
@click=${() => this.handleRowClick(player.player)}
@click=${() => this.handleRowClickPlayer(player.player)}
>
<td>${player.position}</td>
<td class="player-name">${unsafeHTML(player.name)}</td>