summaryrefslogtreecommitdiff
path: root/web/src/lib/ui/cards/ModifierCard.svelte
blob: 15519daa92cb7c4eff2d673da9309fb7c6ab4bca (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
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
115
116
117
118
119
120
121
122
123
124
<!--
	One modifier (AMD) card (the reference `ModifierCardFront` /
	`ModifierCardRear`): the `gfx` image with an optional corner marker
	(imbue / faction / perk / class icon). `name` is the owning deck — the
	shared party deck (""), "allies", or a character-class name. Pass
	`perks` for a character deck so `P<n>` graphics resolve.
-->
<script lang="ts">
	import type { ModifierCard as Card } from '$lib/protocol/types';
	import {
		extraGfxUrl,
		gfxUrl,
		hasExtra,
		rearMarker
	} from '$lib/game/cards/modifierCardGfx';

	let {
		card,
		name,
		revealed,
		perks = null,
		scale = 1
	}: {
		card: Card;
		name: string;
		revealed: boolean;
		perks?: string[][] | null;
		scale?: number;
	} = $props();

	const width = $derived(58.6666 * scale);
	const height = $derived(39 * scale);

	const frontGfx = $derived(gfxUrl(card, name, perks));
	const frontExtra = $derived(extraGfxUrl(card, name));
	const showExtra = $derived(hasExtra(card, name));
	const rear = $derived(rearMarker(name));
</script>

<div
	class="modcard"
	style="width: {width}px; height: {height}px; --scale: {scale}"
>
	{#if revealed}
		<img
			class="modcard__bg"
			src={frontGfx}
			alt={card.gfx}
			draggable="false"
		/>
		{#if showExtra}
			<img
				class="modcard__marker-bg"
				src="/images/attack/class-marker-background.png"
				alt=""
				draggable="false"
			/>
			<img class="modcard__marker-icon" src={frontExtra} alt="" draggable="false" />
		{/if}
	{:else}
		<img
			class="modcard__bg"
			src="/images/attack/back.png"
			alt=""
			draggable="false"
		/>
		{#if rear.has}
			<img
				class="modcard__rear-bg"
				src="/images/attack/class-marker-background.png"
				alt=""
				draggable="false"
			/>
			<img class="modcard__rear-icon" src={rear.gfx} alt="" draggable="false" />
		{/if}
	{/if}
</div>

<style>
	.modcard {
		position: relative;
		border-radius: 4px;
		flex-shrink: 0;
		box-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
	}
	.modcard__bg {
		position: absolute;
		inset: 0;
		width: 100%;
		height: 100%;
		border-radius: 4px;
		object-fit: fill;
	}
	.modcard__marker-bg {
		position: absolute;
		top: calc(26.5 * var(--scale) * 1px);
		left: calc(3 * var(--scale) * 1px);
		width: calc(10 * var(--scale) * 1px);
		height: calc(10 * var(--scale) * 1px);
	}
	.modcard__marker-icon {
		position: absolute;
		top: calc(27.75 * var(--scale) * 1px);
		left: calc(4.2 * var(--scale) * 1px);
		width: calc(7.5 * var(--scale) * 1px);
		height: calc(7.5 * var(--scale) * 1px);
		filter: brightness(0) invert(1);
	}
	.modcard__rear-bg {
		position: absolute;
		top: calc(5.5 * var(--scale) * 1px);
		left: calc(15.7 * var(--scale) * 1px);
		width: calc(27 * var(--scale) * 1px);
		height: calc(27 * var(--scale) * 1px);
	}
	.modcard__rear-icon {
		position: absolute;
		top: calc(9 * var(--scale) * 1px);
		left: calc(19 * var(--scale) * 1px);
		width: calc(20 * var(--scale) * 1px);
		height: calc(20 * var(--scale) * 1px);
		filter: brightness(0) invert(1);
	}
</style>