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
67
68
69
70
71
72
73
74
75
76
77
|
<!--
One loot-card enhancement counter (the reference
`EnhancementCounterButton`): [−] <value> [+], the minus only enabled
while the card is enhanced. `value` is the card's `enhanced` amount.
-->
<script lang="ts">
import type { GameSession } from '$lib/state/session';
let {
session,
id,
gfx,
value
}: {
session: GameSession;
id: number;
/** The card's `gfx` (the wire `resourceType`). */
gfx: string;
value: number;
} = $props();
const player = session.player;
function cmd(delta: number) {
if ($player) {
session.command('enhanceLootCard', {
id,
value: value + delta,
resourceType: gfx
});
}
}
</script>
<div class="counters">
<button class="cbtn" disabled={!player || value <= 0} onclick={() => cmd(-1)}>−</button>
<span class="cval">{value}</span>
<button class="cbtn" disabled={!player} onclick={() => cmd(1)}>+</button>
</div>
<style>
.counters {
display: flex;
align-items: center;
justify-content: center;
gap: 6px;
padding: 3px;
}
.cbtn {
width: 24px;
height: 24px;
font-size: 16px;
line-height: 1;
border: none;
border-radius: 4px;
background: rgba(255, 255, 255, 0.15);
color: inherit;
cursor: pointer;
}
.cbtn:hover:not(:disabled) {
background: rgba(255, 255, 255, 0.3);
}
.cbtn:disabled {
opacity: 0.35;
cursor: default;
}
.cval {
min-width: 24px;
padding: 2px 6px;
text-align: center;
font-size: 13px;
font-weight: 700;
border-radius: 2px;
background: #fff;
color: #000;
}
</style>
|