summaryrefslogtreecommitdiff
path: root/web/src/lib/ui/MainList.svelte
blob: cb5ad495cc05a6b9f640eea522fb981583f0219e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<!--
	The main list (the reference `MainList`/`GameList`): one row per entry of
	the server's `currentList`. The reference lays wide screens out as two
	reorderable columns; the web Phase 3 uses a single centred, scrollable
	column (reordering arrives later, if at all).
-->
<script lang="ts">
	import type { GameSession } from '$lib/state/session';
	import { isCharacter, isMonster, isNoteRow } from '$lib/protocol/types';
	import type { FigureRef } from './StatusMenu.svelte';
	import CharacterRow from './CharacterRow.svelte';
	import MonsterRow from './MonsterRow.svelte';
	import NoteRow from './NoteRow.svelte';

	let {
		session,
		onOpenMenu
	}: {
		session: GameSession;
		onOpenMenu: (figure: FigureRef) => void;
	} = $props();

	const gameState = session.state;
</script>

<div class="list">
	{#if $gameState}
		{#each $gameState.currentList as item (item.id)}
			{#if isCharacter(item)}
				<CharacterRow {session} {item} {onOpenMenu} />
			{:else if isMonster(item)}
				<MonsterRow {session} {item} {onOpenMenu} />
			{:else if isNoteRow(item)}
				<NoteRow {session} {item} />
			{/if}
		{/each}
		{#if $gameState.currentList.length === 0}
			<p style="padding: 40px 12px; text-align: center; opacity: 0.7">
				No characters or monsters yet — use the menu to set a scenario
				and add characters.
			</p>
		{/if}
	{/if}
</div>