Show visual voting progress and submitted nominee
This commit is contained in:
@@ -21,6 +21,12 @@
|
||||
try { return JSON.parse(value || '[]'); } catch { return []; }
|
||||
}
|
||||
|
||||
function voteStatus(p) {
|
||||
if ((state.votes || []).some(v => v.voter_player_id === p.id)) return { icon: '✓', label: 'Voted', done: true };
|
||||
const canVote = state.players.some(candidate => candidate.id !== p.id && candidate.role !== 'deep' && !candidate.is_dead && !candidate.needs_reroll);
|
||||
return canVote ? { icon: '○', label: 'Choosing a nominee', done: false } : { icon: '—', label: 'No eligible nominee', done: true };
|
||||
}
|
||||
|
||||
function statusFor(p) {
|
||||
const phase = state.game.phase;
|
||||
if (phase === 'lobby') {
|
||||
@@ -44,13 +50,7 @@
|
||||
if (p.role === 'pirat') return `Pi-Rat · Rank ${p.rank}`;
|
||||
return 'Choosing a role…';
|
||||
}
|
||||
if (phase === 'between_scenes') {
|
||||
const voted = (state.votes || []).some(v => v.voter_player_id === p.id);
|
||||
const canVote = state.players.some(candidate =>
|
||||
candidate.id !== p.id && candidate.role !== 'deep' && !candidate.is_dead && !candidate.needs_reroll
|
||||
);
|
||||
return `Rank ${p.rank} · ${voted ? 'Nomination done' : canVote ? 'Nominating…' : 'No vote'}`;
|
||||
}
|
||||
if (phase === 'between_scenes') return `Rank ${p.rank}`;
|
||||
if (phase === 'deep_upkeep') return `Rank ${p.rank} · ${p.is_ready ? 'Ready' : 'Finishing upkeep…'}`;
|
||||
if (phase === 'recruit_creation') return p.needs_reroll ? 'Creating a new Pi-Rat' : `Rank ${p.rank} · Helping recruits`;
|
||||
if (phase === 'ended') {
|
||||
@@ -83,6 +83,9 @@
|
||||
title="View {p.name}'s character sheet"
|
||||
on:click={() => openTargetId = p.id}
|
||||
>
|
||||
{#if state.game.phase === 'between_scenes'}
|
||||
<span class="vote-status" class:done={voteStatus(p).done} title={voteStatus(p).label} aria-label={voteStatus(p).label}>{voteStatus(p).icon}</span>
|
||||
{/if}
|
||||
<span class="bubble-icon">{iconFor(p)}</span>
|
||||
<span class="bubble-name">{crewLabel(p, captainId)}</span>
|
||||
<span class="bubble-meta">{statusFor(p)}</span>
|
||||
@@ -95,3 +98,8 @@
|
||||
{#if openTarget}
|
||||
<CharacterSheet {state} target={openTarget} on:close={() => openTargetId = null} />
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
.vote-status { position: absolute; top: 8px; right: 10px; display: grid; place-items: center; width: 1.5rem; height: 1.5rem; border: 1px solid currentColor; border-radius: 50%; color: var(--text-muted); font-size: 1rem; }
|
||||
.vote-status.done { color: var(--success); }
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user