|
<script lang="ts"> |
|
import type { PicletInstance } from '$lib/db/schema'; |
|
import { getXpProgress, getXpTowardsNextLevel } from '$lib/services/levelingService'; |
|
import { TYPE_DATA } from '$lib/types/picletTypes'; |
|
|
|
export let piclet: PicletInstance; |
|
export let hpPercentage: number; |
|
export let xpPercentage: number = 0; |
|
export let isPlayer: boolean; |
|
|
|
|
|
$: realXpPercentage = isPlayer ? getXpProgress(piclet.xp, piclet.level, piclet.tier) : 0; |
|
$: xpTowardsNext = isPlayer ? getXpTowardsNextLevel(piclet.xp, piclet.level, piclet.tier) : { current: 0, needed: 0, percentage: 0 }; |
|
|
|
|
|
$: typeData = TYPE_DATA[piclet.primaryType]; |
|
$: typeColor = typeData.color; |
|
$: typeLogoPath = `/classes/${piclet.primaryType}.png`; |
|
|
|
$: hpColor = hpPercentage > 0.5 ? '#34c759' : hpPercentage > 0.25 ? '#ffcc00' : '#ff3b30'; |
|
</script> |
|
|
|
<div class="piclet-info-wrapper {isPlayer ? 'player-info-wrapper' : 'enemy-info-wrapper'}"> |
|
<div class="piclet-info" style="--type-logo: url('{typeLogoPath}')"> |
|
|
|
<div class="type-logo-background"></div> |
|
|
|
|
|
<div class="name-row"> |
|
<span class="piclet-name">{piclet.nickname}</span> |
|
<span class="level-badge">Lv.{piclet.level}</span> |
|
</div> |
|
|
|
|
|
<div class="stat-row"> |
|
<div class="stat-label">HP</div> |
|
<div class="hp-bar"> |
|
<div |
|
class="hp-fill" |
|
style="width: {hpPercentage * 100}%; background-color: {hpColor}" |
|
></div> |
|
</div> |
|
</div> |
|
|
|
|
|
{#if isPlayer} |
|
<div class="stat-row"> |
|
<div class="stat-label">XP</div> |
|
<div class="xp-bar"> |
|
<div |
|
class="xp-fill" |
|
style="width: {xpTowardsNext.percentage}%" |
|
></div> |
|
</div> |
|
</div> |
|
{/if} |
|
</div> |
|
|
|
|
|
<div class="triangle-pointer {isPlayer ? 'player-pointer' : 'enemy-pointer'}"></div> |
|
</div> |
|
|
|
<style> |
|
.piclet-info-wrapper { |
|
position: absolute; |
|
display: flex; |
|
align-items: center; |
|
} |
|
|
|
.player-info-wrapper { |
|
right: 16px; |
|
bottom: 20px; |
|
flex-direction: row-reverse; |
|
} |
|
|
|
.enemy-info-wrapper { |
|
left: 16px; |
|
top: 20px; |
|
flex-direction: row; |
|
} |
|
|
|
.piclet-info { |
|
background: rgba(255, 255, 255, 0.9); |
|
border-radius: 8px; |
|
padding: 12px; |
|
min-width: 160px; |
|
position: relative; |
|
overflow: hidden; |
|
} |
|
|
|
|
|
.type-logo-background { |
|
position: absolute; |
|
bottom: -4px; |
|
right: 0px; |
|
width: 35px; |
|
height: 35px; |
|
background-image: var(--type-logo); |
|
background-size: contain; |
|
background-repeat: no-repeat; |
|
background-position: center; |
|
opacity: 0.12; |
|
pointer-events: none; |
|
z-index: 1; |
|
} |
|
|
|
|
|
.name-row { |
|
display: flex; |
|
align-items: center; |
|
justify-content: space-between; |
|
margin-bottom: 8px; |
|
position: relative; |
|
z-index: 2; |
|
} |
|
|
|
.piclet-name { |
|
font-weight: 600; |
|
font-size: 14px; |
|
color: #1a1a1a; |
|
} |
|
|
|
.level-badge { |
|
background: rgba(142, 142, 147, 0.3); |
|
padding: 2px 6px; |
|
border-radius: 12px; |
|
font-size: 11px; |
|
font-weight: 700; |
|
color: #333; |
|
} |
|
|
|
|
|
.stat-row { |
|
display: flex; |
|
align-items: center; |
|
gap: 8px; |
|
margin-bottom: 4px; |
|
position: relative; |
|
z-index: 2; |
|
} |
|
|
|
.stat-row:last-child { |
|
margin-bottom: 0; |
|
} |
|
|
|
.stat-label { |
|
font-size: 10px; |
|
font-weight: 600; |
|
color: #666; |
|
text-transform: uppercase; |
|
letter-spacing: 0.5px; |
|
width: 18px; |
|
flex-shrink: 0; |
|
} |
|
|
|
|
|
.hp-bar { |
|
width: 120px; |
|
height: 8px; |
|
background: #e0e0e0; |
|
border-radius: 4px; |
|
overflow: hidden; |
|
flex: 1; |
|
} |
|
|
|
.hp-fill { |
|
height: 100%; |
|
transition: width 0.5s ease, background-color 0.3s ease; |
|
} |
|
|
|
|
|
.xp-bar { |
|
width: 120px; |
|
height: 6px; |
|
background: #e0e0e0; |
|
border-radius: 3px; |
|
overflow: hidden; |
|
flex: 1; |
|
} |
|
|
|
.xp-fill { |
|
height: 100%; |
|
background: #2196f3; |
|
transition: width 1.2s ease-out; |
|
} |
|
|
|
|
|
|
|
.triangle-pointer { |
|
width: 0; |
|
height: 0; |
|
border-style: solid; |
|
} |
|
|
|
.player-pointer { |
|
border-width: 8px 16px 8px 0; |
|
border-color: transparent rgba(255, 255, 255, 0.9) transparent transparent; |
|
margin-right: -1px; |
|
} |
|
|
|
.enemy-pointer { |
|
border-width: 8px 0 8px 16px; |
|
border-color: transparent transparent transparent rgba(255, 255, 255, 0.9); |
|
margin-left: -1px; |
|
} |
|
|
|
@media (max-width: 768px) { |
|
.piclet-info { |
|
min-width: 140px; |
|
padding: 8px; |
|
} |
|
|
|
.piclet-name { |
|
font-size: 12px; |
|
} |
|
|
|
.hp-bar, .xp-bar { |
|
width: 100px; |
|
} |
|
} |
|
</style> |