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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
<!--
Set Level (the reference `SetLevelMenu`): the scenario level, difficulty,
solo, and automatic-level toggles. Each control sends its command
immediately (the reference behaviour); the derived trap/hazard/XP/coin
values update live.
-->
<script lang="ts">
import type { GameSession } from '$lib/state/session';
import { coinValue, hazardValue, trapValue, xpValue } from '$lib/game/levelValues';
import { t } from '$lib/i18n';
import Menu from '../Menu.svelte';
let {
session,
open = $bindable(true)
}: {
session: GameSession;
open?: boolean;
} = $props();
const gameState = $derived(session.state);
const player = $derived(session.player);
const level = $derived($gameState?.level ?? 1);
const difficulty = $derived($gameState?.difficulty ?? 0);
const solo = $derived($gameState?.solo ?? false);
const autoLevel = $derived($gameState?.autoScenarioLevel ?? false);
const isOgGloom = $derived(($gameState?.currentCampaign ?? '') === 'Gloomhaven');
function cmd(name: string, args: Record<string, unknown>) {
if ($player) session.command(name, args);
}
</script>
<Menu open={open} title={t('setScenarioLevel')}>
{#if $gameState}
<div class="statrow">
<span class="statrow__label">{t('web:level')}</span>
<button class="stepbtn" disabled={!$player || level <= 1} onclick={() => cmd('setLevel', { level: level - 1 })}>−</button>
<span class="statrow__value">{level}</span>
<button class="stepbtn" disabled={!$player || level >= 10} onclick={() => cmd('setLevel', { level: level + 1 })}>+</button>
</div>
<div class="statrow">
<span class="statrow__label">{t('difficultyLabel')}</span>
<button class="stepbtn" disabled={!$player || difficulty <= 0} onclick={() => cmd('setDifficulty', { difficulty: difficulty - 1 })}>−</button>
<span class="statrow__value">{difficulty}</span>
<button class="stepbtn" disabled={!$player || difficulty >= 10} onclick={() => cmd('setDifficulty', { difficulty: difficulty + 1 })}>+</button>
</div>
<div class="statrow">
<span class="statrow__label">{t('soloLabel')}</span>
<input type="checkbox" disabled={!$player} checked={solo} onchange={() => cmd('setSolo', { solo: !solo })} />
</div>
<div class="statrow">
<span class="statrow__label">{t('automaticScenarioLevel')}</span>
<input type="checkbox" disabled={!$player} checked={autoLevel} onchange={() => cmd('setAutoLevelAdjust', { on: !autoLevel })} />
</div>
<div style="padding: 8px 4px; font-size: 13px; opacity: 0.8">
T {trapValue(level)} / H {hazardValue(level, isOgGloom, false)} /
X {xpValue(level)} / C {coinValue(level)}
</div>
{/if}
</Menu>
|