Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 18 additions & 12 deletions src/client/graphics/layers/PlayerPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,8 @@ export class PlayerPanel extends LitElement implements Layer {
if (!this.isVisible) return html``;

const my = this.g.myPlayer();
if (!my) return html``;
const isReplay = this.g.config().isReplay();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it maybe be cleaner to create:

this.g.isSpectator()

and it just does:

isSpectator() {
!(this.myPlayer()?.isAlive) || this.config.isReplay
}

if (!my && !isReplay) return html``;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so in this case we are in a live match but haven'ts spawned in? so we don't render the player panel?

if (!this.tile) return html``;

const owner = this.g.owner(this.tile);
Expand All @@ -877,8 +878,10 @@ export class PlayerPanel extends LitElement implements Layer {
return html``;
}
const other = owner as PlayerView;
const myGoldNum = my.gold();
const myTroopsNum = Number(my.troops());
// In replay mode myPlayer() is null; use other as stand-in so read-only rendering works
const viewer = my ?? other;
const myGoldNum = viewer.gold();
const myTroopsNum = Number(viewer.troops());

return html`
<style>
Expand Down Expand Up @@ -946,7 +949,7 @@ export class PlayerPanel extends LitElement implements Layer {
class="p-6 flex flex-col gap-2 font-sans antialiased text-[14.5px] leading-relaxed"
>
<!-- Identity (flag, name, type, traitor, relation) -->
<div class="mb-1">${this.renderIdentityRow(other, my)}</div>
<div class="mb-1">${this.renderIdentityRow(other, viewer)}</div>

${this.sendTarget
? html`
Expand All @@ -957,7 +960,7 @@ export class PlayerPanel extends LitElement implements Layer {
? myTroopsNum
: myGoldNum}
.uiState=${this.uiState}
.myPlayer=${my}
.myPlayer=${viewer}
.target=${this.sendTarget}
.gameView=${this.g}
.eventBus=${this.eventBus}
Expand All @@ -973,7 +976,7 @@ export class PlayerPanel extends LitElement implements Layer {
? html`
<player-moderation-modal
.open=${true}
.myPlayer=${my}
.myPlayer=${viewer}
.target=${this.moderationTarget}
.eventBus=${this.eventBus}
.isAdmin=${this.isAdminRole}
Expand All @@ -992,12 +995,12 @@ export class PlayerPanel extends LitElement implements Layer {
${this.renderResources(other)}

<!-- Rocket direction toggle -->
${other === my ? this.renderRocketDirectionToggle() : ""}
${other === viewer && !isReplay ? this.renderRocketDirectionToggle() : ""}

<ui-divider></ui-divider>

<!-- Stats: betrayals / trading -->
${this.renderStats(other, my)}
${this.renderStats(other, viewer)}

<ui-divider></ui-divider>

Expand All @@ -1007,10 +1010,13 @@ export class PlayerPanel extends LitElement implements Layer {
<!-- Alliance time remaining -->
${this.renderAllianceExpiry()}

<ui-divider></ui-divider>

<!-- Actions -->
${this.renderActions(my, other)}
${isReplay
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, instead of isReplay, it's isSpectator because being dead is the equivalent of watching a replay

? ""
: html`
<ui-divider></ui-divider>
<!-- Actions -->
${this.renderActions(viewer, other)}
`}
Comment on lines 1015 to +1022
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Hide or clear alliance-expiry state in replay mode

Line 1015 still renders alliance expiry in replay, but replay does not refresh that value (live-only update path), so stale text can leak from previous state.

Proposed fix
-                    <!-- Alliance time remaining -->
-                    ${this.renderAllianceExpiry()}
+                    <!-- Alliance time remaining -->
+                    ${isReplay ? "" : this.renderAllianceExpiry()}

Optionally also clear on replay entry in show()/tick() for extra safety.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/client/graphics/layers/PlayerPanel.ts` around lines 1015 - 1022,
renderAllianceExpiry() is still rendered when isReplay is true, causing stale
expiry text to persist because replay doesn't update the live-only value; stop
rendering or clear the underlying state when in replay: update the template
where renderAllianceExpiry() is used (near the current conditional around
renderActions) so it is not called when isReplay is true, and additionally
ensure show() and/or tick() detect entering replay mode and clear the
alliance-expiry state used by renderAllianceExpiry() (or set it to an
empty/undefined value) to be extra safe; reference renderAllianceExpiry(),
renderActions(), show(), and tick() when making the changes.

</div>
</div>
</div>
Expand Down
Loading