Waving Hands: a duel

Waving Hands

{#if room?.remote?.started && watching}

From the Peanut Gallery you watch {#each room.others as id, i (id)}{#if i > 0}{i === room.others.length - 1 ? ' and ' : ', '}{/if}{room.state.wizards[id].name}{/each} duel. {#if !room.remote.connected}Reconnecting to the duel.{/if}

{:else if room?.remote?.started}

You are {room.you.name}, duelling {#each room.others as id, i (id)}{#if i > 0}{i === room.others.length - 1 ? ' and ' : ', '}{/if}{room.state.wizards[id].name}{/each}. {#if !room.remote.connected}Reconnecting to the duel.{/if}

{:else}

A duel between people, played by turns whenever each of you has a moment.

{/if}
{#if error}

{error}

{/if} {#if joining && seatFree}

room {roomId}

Take a seat

A wizard has opened this table and is gathering opponents. Choose a name and sit; the duel begins when the host says.

Just watching? You are in the Peanut Gallery until you sit.

{/if} {#if room && lobby} {@const r = room.remote!} {@const hostName = r.seats.find((s) => s.id === r.host)?.name ?? 'the host'}
{#if watching}

At the table

{#if seatFree}

{hostName} is gathering wizards. Sit down above, or watch from the gallery until the duel begins.

{:else}

The table is full. You watch from the Peanut Gallery; the duel begins when {hostName} says.

{/if} {:else}

room {roomId}

The table is laid

Send this link, or the code. Whoever opens it takes a seat; the table holds a dozen. Anyone who arrives once the duel has begun watches from the Peanut Gallery.

{/if} {#if !watching}
{#if r.seats.length < r.size} {/if} {#if room.isHost} {r.seats.length < 2 ? 'once a second wizard is seated' : `with ${r.seats.length} wizards`} {:else} {hostName} will begin the duel when the table is ready. {/if}
{/if} {#if r.error}

{r.error}

{/if}
{:else if room} {:else if !error}

{joining ? 'Finding the table.' : 'Finding your seat.'}

{/if}