blob: 4430de5f22f3295ea2f54d350ffdcb3b103f8bb6 (
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
45
46
47
48
49
50
51
52
|
<!--
The bottom-bar level widget (the reference `BottomBarLevelWidget`): the
scenario name, the scenario level, and the derived trap / hazard / XP /
coin values (GameMethods port). Tapping it opens the Set Level menu.
-->
<script lang="ts">
import type { GameSession } from '$lib/state/session';
import { coinValue, hazardValue, trapValue, xpValue } from '$lib/game/levelValues';
import { t } from '$lib/i18n';
let {
session,
onOpenMenu
}: {
session: GameSession;
onOpenMenu: () => void;
} = $props();
const gameState = session.state;
const player = session.player;
const scenario = $derived($gameState?.scenario ?? '');
const level = $derived($gameState?.level ?? 1);
const campaign = $derived($gameState?.currentCampaign ?? '');
const isOgGloom = $derived(campaign === 'Gloomhaven');
function onTap() {
// Spectators can view but not change the level.
if (!$player) return;
onOpenMenu();
}
</script>
<div class="levelwidget" onclick={onTap} role="button" tabindex="0"
onkeydown={(e) => {
if (e.key === 'Enter') onTap();
}}>
{#if scenario}
<div class="levelwidget__scenario">{scenario}</div>
{/if}
{#if $gameState}
<div class="levelwidget__stats">
{t('web:level')} {level} ·
{trapValue(level)} {t('levelLegendLabel')}
</div>
<div class="levelwidget__stats">
T {trapValue(level)} / H {hazardValue(level, isOgGloom, false)} /
X {xpValue(level)} / C {coinValue(level)}
</div>
{/if}
</div>
|