|
<script lang="ts"> |
|
import type { PicletInstance } from '$lib/db/schema'; |
|
|
|
export let piclet: PicletInstance; |
|
export let hpPercentage: number; |
|
export let xpPercentage: number = 0; |
|
export let isPlayer: boolean; |
|
|
|
$: hpColor = hpPercentage > 0.5 ? '#4caf50' : hpPercentage > 0.2 ? '#ffc107' : '#f44336'; |
|
$: displayHp = Math.ceil(piclet.currentHp * hpPercentage); |
|
|
|
|
|
const typeEmoji = '🔥'; |
|
</script> |
|
|
|
<div class="piclet-info-wrapper {isPlayer ? 'player-info-wrapper' : 'enemy-info-wrapper'}"> |
|
<div class="piclet-info"> |
|
|
|
<div class="name-row"> |
|
<span class="piclet-name">{piclet.nickname}</span> |
|
<span class="type-emoji">{typeEmoji}</span> |
|
<span class="level-badge">Lv.{piclet.level}</span> |
|
</div> |
|
|
|
|
|
<div class="hp-bar"> |
|
<div |
|
class="hp-fill" |
|
style="width: {hpPercentage * 100}%; background-color: {hpColor}" |
|
></div> |
|
</div> |
|
|
|
|
|
{#if isPlayer} |
|
<div class="hp-text"> |
|
<span class="hp-values">{displayHp}/{piclet.maxHp} HP</span> |
|
</div> |
|
|
|
|
|
<div class="xp-bar"> |
|
<div |
|
class="xp-fill" |
|
style="width: {xpPercentage}%" |
|
></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; |
|
} |
|
|
|
|
|
.name-row { |
|
display: flex; |
|
align-items: center; |
|
gap: 4px; |
|
margin-bottom: 8px; |
|
} |
|
|
|
.piclet-name { |
|
font-weight: 600; |
|
font-size: 14px; |
|
color: #1a1a1a; |
|
flex: 1; |
|
} |
|
|
|
.type-emoji { |
|
font-size: 12px; |
|
} |
|
|
|
.level-badge { |
|
background: rgba(142, 142, 147, 0.3); |
|
padding: 2px 6px; |
|
border-radius: 12px; |
|
font-size: 11px; |
|
font-weight: 700; |
|
color: #333; |
|
} |
|
|
|
|
|
.hp-bar { |
|
width: 120px; |
|
height: 8px; |
|
background: #e0e0e0; |
|
border-radius: 4px; |
|
overflow: hidden; |
|
margin-bottom: 4px; |
|
} |
|
|
|
.hp-fill { |
|
height: 100%; |
|
transition: width 0.5s ease, background-color 0.3s ease; |
|
} |
|
|
|
|
|
.hp-text { |
|
font-size: 11px; |
|
color: #666; |
|
margin-bottom: 4px; |
|
} |
|
|
|
.hp-values { |
|
font-weight: 600; |
|
} |
|
|
|
|
|
.xp-bar { |
|
width: 120px; |
|
height: 4px; |
|
background: #e0e0e0; |
|
border-radius: 2px; |
|
overflow: hidden; |
|
} |
|
|
|
.xp-fill { |
|
height: 100%; |
|
background: #2196f3; |
|
transition: width 0.5s ease; |
|
} |
|
|
|
|
|
.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 { |
|
width: 100px; |
|
} |
|
|
|
.xp-bar { |
|
width: 100px; |
|
} |
|
} |
|
</style> |