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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
<!--
One loot card (the reference `LootCardFront` / `LootCardRear`): the loot
`gfx` image with its value (`+n`), the 1418/1419 special text, the
enhancement level, and the owning character's class icon.
-->
<script lang="ts">
import type { LootCard as Card } from '$lib/protocol/types';
import { lootValue } from '$lib/game/cards/lootCard';
import { t } from '$lib/i18n';
let {
card,
revealed,
ownerName = '',
characterCount = 4,
scale = 1
}: {
card: Card;
revealed: boolean;
/** The owning character's class name (for the corner icon). */
ownerName?: string;
/** Party size (the value table depends on it). */
characterCount?: number;
scale?: number;
} = $props();
const width = $derived(39 * scale);
const height = $derived(58.6666 * scale);
const value = $derived(revealed ? lootValue(card, characterCount) : null);
const special = $derived(
revealed
? card.gfx.includes('1418')
? '1418'
: card.gfx.includes('1419')
? '1419'
: ''
: ''
);
const showOwner = $derived(revealed && card.owner.length > 0);
</script>
<div class="lootcard" style="width: {width}px; height: {height}px">
<img
class="lootcard__bg"
src={revealed ? `/images/loot/${card.gfx}.png` : '/images/loot/back.png'}
alt={card.gfx}
draggable="false"
/>
{#if value !== null}
<div class="lootcard__value" style="font-size: {30 * scale}px">+{value}</div>
{/if}
{#if special}
<div class="lootcard__value" style="font-size: {25 * scale}px">{special}</div>
{/if}
{#if revealed && card.enhanced > 0}
<div class="lootcard__enhanced" style="font-size: {9 * scale}px">
{t('enhancedLevel', { level: card.enhanced })}
</div>
{/if}
{#if showOwner}
<img
class="lootcard__owner"
src="/images/class-icons/{ownerName}.png"
alt={ownerName}
style="width: {15 * scale}px; height: {15 * scale}px"
draggable="false"
/>
{/if}
</div>
<style>
.lootcard {
position: relative;
border-radius: 4px;
flex-shrink: 0;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}
.lootcard__bg {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
border-radius: 4px;
object-fit: fill;
}
.lootcard__value {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-family: system-ui, sans-serif;
font-weight: 700;
color: #fff;
text-shadow: 0.6px 0.6px 1px rgba(0, 0, 0, 0.87);
pointer-events: none;
}
.lootcard__enhanced {
position: absolute;
bottom: 5px;
left: 0;
right: 0;
text-align: center;
color: #fff;
text-shadow: 0.3px 0.3px 0.8px rgba(0, 0, 0, 0.87);
pointer-events: none;
}
.lootcard__owner {
position: absolute;
top: 2px;
right: 2px;
filter: brightness(0) invert(1);
}
</style>
|