diff options
Diffstat (limited to 'web/src/lib/ui/cards/LootCard.svelte')
| -rw-r--r-- | web/src/lib/ui/cards/LootCard.svelte | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/web/src/lib/ui/cards/LootCard.svelte b/web/src/lib/ui/cards/LootCard.svelte new file mode 100644 index 0000000..49ddb2b --- /dev/null +++ b/web/src/lib/ui/cards/LootCard.svelte @@ -0,0 +1,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 = 39 * scale; + const height = 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> |
