File size: 5,115 Bytes
00d1c08
 
a46ce65
782d90b
00d1c08
 
 
 
 
 
 
a92c5da
00d1c08
 
 
 
 
 
 
 
a46ce65
a92c5da
782d90b
 
cf131a8
 
00d1c08
 
 
 
a92c5da
00d1c08
 
 
a92c5da
00d1c08
 
 
 
a92c5da
00d1c08
 
 
 
 
 
a92c5da
 
 
 
00d1c08
 
 
 
 
 
 
782d90b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a92c5da
00d1c08
 
 
 
 
 
ddfebff
00d1c08
 
a519169
00d1c08
 
 
 
 
 
 
 
 
 
 
14271d4
00d1c08
 
 
 
 
 
 
a92c5da
00d1c08
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ddfebff
00d1c08
 
 
a92c5da
 
00d1c08
 
 
a92c5da
 
ddfebff
00d1c08
 
 
a92c5da
 
00d1c08
 
 
 
 
a92c5da
 
 
 
 
 
 
 
 
 
 
 
 
 
00d1c08
 
 
 
 
 
 
 
 
 
 
 
 
 
782d90b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
00d1c08
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
<script lang="ts">
  import type { PicletInstance } from '$lib/db/schema';
  import { TYPE_DATA } from '$lib/types/picletTypes';
  import { picletInstanceToBattleDefinition } from '$lib/utils/battleConversion';
  
  interface Props {
    instance: PicletInstance;
    size?: number;
    onClick?: () => void;
  }
  
  let { instance, size = 100, onClick }: Props = $props();
  
  const hpPercentage = $derived(instance.currentHp / instance.maxHp);
  const hpColor = $derived(
    hpPercentage > 0.5 ? '#34c759' : 
    hpPercentage > 0.25 ? '#ffcc00' : 
    '#ff3b30'
  );
  
  const typeColor = $derived(TYPE_DATA[instance.primaryType].color);
  const softTypeColor = $derived(`${typeColor}20`); // Add 20% opacity for soft background
  
  // Get battle definition for enhanced ability info
  const battleDefinition = $derived(picletInstanceToBattleDefinition(instance));
  const ability = $derived(battleDefinition.specialAbility);
</script>

<button 
  class="piclet-card" 
  style="width: {size}px; height: {size + 40}px; --type-color: {typeColor}; --soft-type-color: {softTypeColor};"
  onclick={onClick}
  type="button"
>
  <div class="image-container">
    <img 
      src={instance.imageData || instance.imageUrl} 
      alt={instance.nickname || 'Piclet'}
      class="piclet-image"
      style="width: {size * 0.8}px; height: {size * 0.8}px;"
    />
    <div class="level-badge">
      Lv.{instance.level}
    </div>
  </div>
  
  <div class="details-section">
    <p class="nickname">{instance.nickname || 'Unknown'}</p>
    <div class="hp-section">
      <span class="hp-text">HP: {instance.currentHp}/{instance.maxHp}</span>
      <div class="hp-bar">
        <div 
          class="hp-fill" 
          style="width: {hpPercentage * 100}%; background-color: {hpColor};"
        ></div>
      </div>
    </div>
    
    <!-- Ability Preview -->
    <div class="ability-preview">
      <div class="ability-info">
        <span class="ability-icon"></span>
        <div class="ability-text">
          <span class="ability-name">{ability.name}</span>
          <div class="ability-counts">
            {#if ability.effects?.length || ability.triggers?.length}
              <span class="ability-count">
                {(ability.effects?.length || 0) + (ability.triggers?.length || 0)} effects
              </span>
            {/if}
          </div>
        </div>
      </div>
    </div>
  </div>
</button>

<style>
  .piclet-card {
    display: flex;
    flex-direction: column;
    background: var(--type-color, #007bff);
    border-radius: 12px;
    border: 2px solid;
    border-color: var(--type-color, #007bff);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 0;
    cursor: pointer;
    transition: transform 0.2s;
  }
  
  .piclet-card:active {
    transform: scale(0.95);
  }
  
  .image-container {
    width: 100%;
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px 10px 0 0;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.7);
  }
  
  .piclet-image {
    object-fit: contain;
  }
  
  .level-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(255, 255, 255, 0.9);
    padding: 2px 6px;
    border-radius: 8px;
    font-size: 10px;
    font-weight: bold;
    color: black;
  }
  
  .details-section {
    height: 50px;
    padding: 6px 8px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 0 0 10px 10px;
    width: 100%;
  }
  
  .nickname {
    margin: 0 0 2px 0;
    font-size: 10px;
    font-weight: 600;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #333;
  }
  
  .hp-section {
    display: flex;
    flex-direction: column;
    gap: 1px;
  }
  
  .hp-text {
    font-size: 8px;
    font-weight: 500;
    text-align: center;
    color: #666;
  }
  
  .hp-bar {
    height: 3px;
    background: #f0f0f0;
    border-radius: 1.5px;
    overflow: hidden;
  }
  
  .hp-fill {
    height: 100%;
    border-radius: 1.5px;
    transition: width 0.3s ease;
  }
  
  /* Ability Preview Styles */
  .ability-preview {
    margin-top: 4px;
    padding: 4px 6px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 6px;
    border: 1px solid rgba(0, 0, 0, 0.1);
  }
  
  .ability-info {
    display: flex;
    align-items: center;
    gap: 4px;
  }
  
  .ability-icon {
    font-size: 10px;
    line-height: 1;
  }
  
  .ability-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
  }
  
  .ability-name {
    font-size: 8px;
    font-weight: 600;
    color: #495057;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  
  .ability-counts {
    display: flex;
    justify-content: flex-end;
  }
  
  .ability-count {
    font-size: 7px;
    padding: 1px 3px;
    background: rgba(0, 123, 255, 0.1);
    color: #0066cc;
    border-radius: 4px;
    font-weight: 500;
    line-height: 1;
  }
</style>