rm legacy
Browse files- src/lib/components/Battle/BattleControls.svelte +1 -1
- src/lib/components/Battle/BattleField.svelte +0 -4
- src/lib/components/Battle/PicletInfo.svelte +0 -4
- src/lib/components/Pages/Encounters.svelte +0 -28
- src/lib/components/Pages/Pictuary.svelte +14 -23
- src/lib/components/Pages/ViewAll.svelte +9 -14
- src/lib/components/Piclets/AbilityDisplay.svelte +0 -74
- src/lib/components/Piclets/DiscoveredCard.svelte +0 -87
- src/lib/components/Piclets/NewlyCaughtPicletDetail.svelte +10 -6
- src/lib/db/index.ts +13 -27
- src/lib/db/monsters.ts +0 -36
- src/lib/db/piclets.ts +1 -122
- src/lib/db/resetGame.ts +9 -7
- src/lib/db/schema.ts +0 -12
- src/lib/utils/battleConversion.ts +1 -1
- src/tests/encounterService.test.ts +35 -11
src/lib/components/Battle/BattleControls.svelte
CHANGED
|
@@ -34,7 +34,7 @@
|
|
| 34 |
<div class="action-area">
|
| 35 |
{#if waitingForContinue}
|
| 36 |
<!-- Tap to continue overlay -->
|
| 37 |
-
<div class="tap-continue-overlay"
|
| 38 |
<div class="tap-indicator">
|
| 39 |
<span>Tap to continue</span>
|
| 40 |
</div>
|
|
|
|
| 34 |
<div class="action-area">
|
| 35 |
{#if waitingForContinue}
|
| 36 |
<!-- Tap to continue overlay -->
|
| 37 |
+
<div class="tap-continue-overlay" role="button" tabindex="0" onclick={onContinueTap}>
|
| 38 |
<div class="tap-indicator">
|
| 39 |
<span>Tap to continue</span>
|
| 40 |
</div>
|
src/lib/components/Battle/BattleField.svelte
CHANGED
|
@@ -37,8 +37,6 @@
|
|
| 37 |
let playerTrainerSliding = false;
|
| 38 |
let enemyTrainerSliding = false;
|
| 39 |
|
| 40 |
-
// Calculate player XP percentage (0-100% of current level)
|
| 41 |
-
const playerXpPercentage = (playerPiclet.xp / 100) * 100; // Simplified, should use actual XP curve
|
| 42 |
|
| 43 |
onMount(() => {
|
| 44 |
if (!showIntro) {
|
|
@@ -124,7 +122,6 @@
|
|
| 124 |
<PicletInfo
|
| 125 |
piclet={enemyPiclet}
|
| 126 |
hpPercentage={enemyHpPercentage}
|
| 127 |
-
xpPercentage={0}
|
| 128 |
isPlayer={false}
|
| 129 |
/>
|
| 130 |
|
|
@@ -215,7 +212,6 @@
|
|
| 215 |
<PicletInfo
|
| 216 |
piclet={playerPiclet}
|
| 217 |
hpPercentage={playerHpPercentage}
|
| 218 |
-
xpPercentage={playerXpPercentage}
|
| 219 |
isPlayer={true}
|
| 220 |
/>
|
| 221 |
</div>
|
|
|
|
| 37 |
let playerTrainerSliding = false;
|
| 38 |
let enemyTrainerSliding = false;
|
| 39 |
|
|
|
|
|
|
|
| 40 |
|
| 41 |
onMount(() => {
|
| 42 |
if (!showIntro) {
|
|
|
|
| 122 |
<PicletInfo
|
| 123 |
piclet={enemyPiclet}
|
| 124 |
hpPercentage={enemyHpPercentage}
|
|
|
|
| 125 |
isPlayer={false}
|
| 126 |
/>
|
| 127 |
|
|
|
|
| 212 |
<PicletInfo
|
| 213 |
piclet={playerPiclet}
|
| 214 |
hpPercentage={playerHpPercentage}
|
|
|
|
| 215 |
isPlayer={true}
|
| 216 |
/>
|
| 217 |
</div>
|
src/lib/components/Battle/PicletInfo.svelte
CHANGED
|
@@ -5,11 +5,7 @@
|
|
| 5 |
|
| 6 |
export let piclet: PicletInstance;
|
| 7 |
export let hpPercentage: number;
|
| 8 |
-
export let xpPercentage: number = 0; // Legacy prop - will be overridden for players
|
| 9 |
export let isPlayer: boolean;
|
| 10 |
-
|
| 11 |
-
// Calculate real XP percentage using levelingService
|
| 12 |
-
$: realXpPercentage = isPlayer ? getXpProgress(piclet.xp, piclet.level, piclet.tier) : 0;
|
| 13 |
$: xpTowardsNext = isPlayer ? getXpTowardsNextLevel(piclet.xp, piclet.level, piclet.tier) : { current: 0, needed: 0, percentage: 0 };
|
| 14 |
|
| 15 |
// Type-based styling
|
|
|
|
| 5 |
|
| 6 |
export let piclet: PicletInstance;
|
| 7 |
export let hpPercentage: number;
|
|
|
|
| 8 |
export let isPlayer: boolean;
|
|
|
|
|
|
|
|
|
|
| 9 |
$: xpTowardsNext = isPlayer ? getXpTowardsNextLevel(piclet.xp, piclet.level, piclet.tier) : { current: 0, needed: 0, percentage: 0 };
|
| 10 |
|
| 11 |
// Type-based styling
|
src/lib/components/Pages/Encounters.svelte
CHANGED
|
@@ -493,36 +493,8 @@
|
|
| 493 |
border-radius: 8px;
|
| 494 |
}
|
| 495 |
|
| 496 |
-
.piclet-silhouette {
|
| 497 |
-
width: 100%;
|
| 498 |
-
height: 100%;
|
| 499 |
-
border-radius: 8px;
|
| 500 |
-
display: flex;
|
| 501 |
-
align-items: center;
|
| 502 |
-
justify-content: center;
|
| 503 |
-
position: relative;
|
| 504 |
-
overflow: hidden;
|
| 505 |
-
}
|
| 506 |
|
| 507 |
-
.silhouette-img {
|
| 508 |
-
width: 100%;
|
| 509 |
-
height: 100%;
|
| 510 |
-
object-fit: cover;
|
| 511 |
-
filter: grayscale(100%) brightness(0.3) contrast(0.5);
|
| 512 |
-
opacity: 0.8;
|
| 513 |
-
}
|
| 514 |
|
| 515 |
-
.silhouette-fallback {
|
| 516 |
-
font-size: 2rem;
|
| 517 |
-
font-weight: bold;
|
| 518 |
-
color: #999;
|
| 519 |
-
background: #e0e0e0;
|
| 520 |
-
width: 100%;
|
| 521 |
-
height: 100%;
|
| 522 |
-
display: flex;
|
| 523 |
-
align-items: center;
|
| 524 |
-
justify-content: center;
|
| 525 |
-
}
|
| 526 |
|
| 527 |
.type-icon, .fallback-icon {
|
| 528 |
font-size: 2rem;
|
|
|
|
| 493 |
border-radius: 8px;
|
| 494 |
}
|
| 495 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 496 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 497 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 498 |
|
| 499 |
.type-icon, .fallback-icon {
|
| 500 |
font-size: 2rem;
|
src/lib/components/Pages/Pictuary.svelte
CHANGED
|
@@ -1,11 +1,9 @@
|
|
| 1 |
<script lang="ts">
|
| 2 |
import { onMount } from 'svelte';
|
| 3 |
-
import {
|
| 4 |
-
import {
|
| 5 |
-
import type { Monster, PicletInstance } from '$lib/db/schema';
|
| 6 |
import PicletCard from '../Piclets/PicletCard.svelte';
|
| 7 |
import EmptySlotCard from '../Piclets/EmptySlotCard.svelte';
|
| 8 |
-
import DiscoveredCard from '../Piclets/DiscoveredCard.svelte';
|
| 9 |
import DraggablePicletCard from '../Piclets/DraggablePicletCard.svelte';
|
| 10 |
import RosterSlot from '../Piclets/RosterSlot.svelte';
|
| 11 |
import PicletDetail from '../Piclets/PicletDetail.svelte';
|
|
@@ -15,7 +13,7 @@
|
|
| 15 |
|
| 16 |
let rosterPiclets: PicletInstance[] = $state([]);
|
| 17 |
let storagePiclets: PicletInstance[] = $state([]);
|
| 18 |
-
let
|
| 19 |
let isLoading = $state(true);
|
| 20 |
let currentlyDragging: PicletInstance | null = $state(null);
|
| 21 |
let selectedPiclet: PicletInstance | null = $state(null);
|
|
@@ -84,12 +82,8 @@
|
|
| 84 |
p.rosterPosition > 5
|
| 85 |
);
|
| 86 |
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
const caughtTypeIds = new Set(allInstances.map(p => p.typeId));
|
| 90 |
-
discoveredMonsters = allMonsters.filter(m =>
|
| 91 |
-
!caughtTypeIds.has(m.name.toLowerCase().replace(/\s+/g, '-'))
|
| 92 |
-
);
|
| 93 |
} catch (err) {
|
| 94 |
console.error('Failed to load piclets:', err);
|
| 95 |
} finally {
|
|
@@ -114,9 +108,6 @@
|
|
| 114 |
selectedPiclet = piclet;
|
| 115 |
}
|
| 116 |
|
| 117 |
-
function handleDiscoveredClick(monster: Monster) {
|
| 118 |
-
console.log('View discovered monster:', monster);
|
| 119 |
-
}
|
| 120 |
|
| 121 |
function handleDragStart(instance: PicletInstance) {
|
| 122 |
currentlyDragging = instance;
|
|
@@ -169,7 +160,7 @@
|
|
| 169 |
<ViewAll
|
| 170 |
title="Discovered"
|
| 171 |
type="discovered"
|
| 172 |
-
items={
|
| 173 |
onBack={() => viewAllMode = null}
|
| 174 |
/>
|
| 175 |
{:else}
|
|
@@ -179,7 +170,7 @@
|
|
| 179 |
<div class="spinner"></div>
|
| 180 |
<p>Loading collection...</p>
|
| 181 |
</div>
|
| 182 |
-
{:else if rosterPiclets.length === 0 && storagePiclets.length === 0 &&
|
| 183 |
<div class="empty-state">
|
| 184 |
<svg width="64" height="64" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
| 185 |
<path d="M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"></path>
|
|
@@ -233,20 +224,20 @@
|
|
| 233 |
{/if}
|
| 234 |
|
| 235 |
<!-- Discovered Section -->
|
| 236 |
-
{#if
|
| 237 |
<section class="discovered-section">
|
| 238 |
<div class="section-header">
|
| 239 |
-
<h2>Discovered ({
|
| 240 |
-
{#if
|
| 241 |
<button class="view-all-btn">View All</button>
|
| 242 |
{/if}
|
| 243 |
</div>
|
| 244 |
<div class="horizontal-scroll">
|
| 245 |
-
{#each
|
| 246 |
-
<
|
| 247 |
-
{
|
| 248 |
size={100}
|
| 249 |
-
onClick={() =>
|
| 250 |
/>
|
| 251 |
{/each}
|
| 252 |
</div>
|
|
|
|
| 1 |
<script lang="ts">
|
| 2 |
import { onMount } from 'svelte';
|
| 3 |
+
import { getCaughtPiclets, getRosterPiclets, moveToRoster, swapRosterPositions, moveToStorage, getUncaughtPiclets } from '$lib/db/piclets';
|
| 4 |
+
import type { PicletInstance } from '$lib/db/schema';
|
|
|
|
| 5 |
import PicletCard from '../Piclets/PicletCard.svelte';
|
| 6 |
import EmptySlotCard from '../Piclets/EmptySlotCard.svelte';
|
|
|
|
| 7 |
import DraggablePicletCard from '../Piclets/DraggablePicletCard.svelte';
|
| 8 |
import RosterSlot from '../Piclets/RosterSlot.svelte';
|
| 9 |
import PicletDetail from '../Piclets/PicletDetail.svelte';
|
|
|
|
| 13 |
|
| 14 |
let rosterPiclets: PicletInstance[] = $state([]);
|
| 15 |
let storagePiclets: PicletInstance[] = $state([]);
|
| 16 |
+
let discoveredPiclets: PicletInstance[] = $state([]);
|
| 17 |
let isLoading = $state(true);
|
| 18 |
let currentlyDragging: PicletInstance | null = $state(null);
|
| 19 |
let selectedPiclet: PicletInstance | null = $state(null);
|
|
|
|
| 82 |
p.rosterPosition > 5
|
| 83 |
);
|
| 84 |
|
| 85 |
+
// Get all uncaught piclets (discovered but not caught)
|
| 86 |
+
discoveredPiclets = await getUncaughtPiclets();
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
} catch (err) {
|
| 88 |
console.error('Failed to load piclets:', err);
|
| 89 |
} finally {
|
|
|
|
| 108 |
selectedPiclet = piclet;
|
| 109 |
}
|
| 110 |
|
|
|
|
|
|
|
|
|
|
| 111 |
|
| 112 |
function handleDragStart(instance: PicletInstance) {
|
| 113 |
currentlyDragging = instance;
|
|
|
|
| 160 |
<ViewAll
|
| 161 |
title="Discovered"
|
| 162 |
type="discovered"
|
| 163 |
+
items={discoveredPiclets}
|
| 164 |
onBack={() => viewAllMode = null}
|
| 165 |
/>
|
| 166 |
{:else}
|
|
|
|
| 170 |
<div class="spinner"></div>
|
| 171 |
<p>Loading collection...</p>
|
| 172 |
</div>
|
| 173 |
+
{:else if rosterPiclets.length === 0 && storagePiclets.length === 0 && discoveredPiclets.length === 0}
|
| 174 |
<div class="empty-state">
|
| 175 |
<svg width="64" height="64" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
| 176 |
<path d="M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"></path>
|
|
|
|
| 224 |
{/if}
|
| 225 |
|
| 226 |
<!-- Discovered Section -->
|
| 227 |
+
{#if discoveredPiclets.length > 0}
|
| 228 |
<section class="discovered-section">
|
| 229 |
<div class="section-header">
|
| 230 |
+
<h2>Discovered ({discoveredPiclets.length})</h2>
|
| 231 |
+
{#if discoveredPiclets.length > 10}
|
| 232 |
<button class="view-all-btn">View All</button>
|
| 233 |
{/if}
|
| 234 |
</div>
|
| 235 |
<div class="horizontal-scroll">
|
| 236 |
+
{#each discoveredPiclets.slice(0, 10) as piclet}
|
| 237 |
+
<PicletCard
|
| 238 |
+
piclet={piclet}
|
| 239 |
size={100}
|
| 240 |
+
onClick={() => selectedPiclet = piclet}
|
| 241 |
/>
|
| 242 |
{/each}
|
| 243 |
</div>
|
src/lib/components/Pages/ViewAll.svelte
CHANGED
|
@@ -1,14 +1,13 @@
|
|
| 1 |
<script lang="ts">
|
| 2 |
-
import type { PicletInstance
|
| 3 |
import PicletCard from '../Piclets/PicletCard.svelte';
|
| 4 |
import DraggablePicletCard from '../Piclets/DraggablePicletCard.svelte';
|
| 5 |
-
import DiscoveredCard from '../Piclets/DiscoveredCard.svelte';
|
| 6 |
import PicletDetail from '../Piclets/PicletDetail.svelte';
|
| 7 |
|
| 8 |
interface Props {
|
| 9 |
title: string;
|
| 10 |
type: 'storage' | 'discovered';
|
| 11 |
-
items: PicletInstance[]
|
| 12 |
onBack: () => void;
|
| 13 |
onItemsChanged?: () => void;
|
| 14 |
onDragStart?: (instance: PicletInstance) => void;
|
|
@@ -18,12 +17,8 @@
|
|
| 18 |
let { title, type, items, onBack, onItemsChanged, onDragStart, onDragEnd }: Props = $props();
|
| 19 |
let selectedPiclet: PicletInstance | null = $state(null);
|
| 20 |
|
| 21 |
-
function handleItemClick(item: PicletInstance
|
| 22 |
-
|
| 23 |
-
selectedPiclet = item as PicletInstance;
|
| 24 |
-
} else {
|
| 25 |
-
console.log('View discovered monster:', item);
|
| 26 |
-
}
|
| 27 |
}
|
| 28 |
</script>
|
| 29 |
|
|
@@ -46,17 +41,17 @@
|
|
| 46 |
{:else}
|
| 47 |
<div class="items-grid">
|
| 48 |
{#each items as item}
|
| 49 |
-
{#if type === 'storage'
|
| 50 |
<DraggablePicletCard
|
| 51 |
-
instance={item
|
| 52 |
size={100}
|
| 53 |
onClick={() => handleItemClick(item)}
|
| 54 |
onDragStart={onDragStart}
|
| 55 |
onDragEnd={onDragEnd}
|
| 56 |
/>
|
| 57 |
-
{:else if type === 'discovered'
|
| 58 |
-
<
|
| 59 |
-
|
| 60 |
size={100}
|
| 61 |
onClick={() => handleItemClick(item)}
|
| 62 |
/>
|
|
|
|
| 1 |
<script lang="ts">
|
| 2 |
+
import type { PicletInstance } from '$lib/db/schema';
|
| 3 |
import PicletCard from '../Piclets/PicletCard.svelte';
|
| 4 |
import DraggablePicletCard from '../Piclets/DraggablePicletCard.svelte';
|
|
|
|
| 5 |
import PicletDetail from '../Piclets/PicletDetail.svelte';
|
| 6 |
|
| 7 |
interface Props {
|
| 8 |
title: string;
|
| 9 |
type: 'storage' | 'discovered';
|
| 10 |
+
items: PicletInstance[];
|
| 11 |
onBack: () => void;
|
| 12 |
onItemsChanged?: () => void;
|
| 13 |
onDragStart?: (instance: PicletInstance) => void;
|
|
|
|
| 17 |
let { title, type, items, onBack, onItemsChanged, onDragStart, onDragEnd }: Props = $props();
|
| 18 |
let selectedPiclet: PicletInstance | null = $state(null);
|
| 19 |
|
| 20 |
+
function handleItemClick(item: PicletInstance) {
|
| 21 |
+
selectedPiclet = item;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
}
|
| 23 |
</script>
|
| 24 |
|
|
|
|
| 41 |
{:else}
|
| 42 |
<div class="items-grid">
|
| 43 |
{#each items as item}
|
| 44 |
+
{#if type === 'storage'}
|
| 45 |
<DraggablePicletCard
|
| 46 |
+
instance={item}
|
| 47 |
size={100}
|
| 48 |
onClick={() => handleItemClick(item)}
|
| 49 |
onDragStart={onDragStart}
|
| 50 |
onDragEnd={onDragEnd}
|
| 51 |
/>
|
| 52 |
+
{:else if type === 'discovered'}
|
| 53 |
+
<PicletCard
|
| 54 |
+
piclet={item}
|
| 55 |
size={100}
|
| 56 |
onClick={() => handleItemClick(item)}
|
| 57 |
/>
|
src/lib/components/Piclets/AbilityDisplay.svelte
CHANGED
|
@@ -217,30 +217,6 @@
|
|
| 217 |
line-height: 1.4;
|
| 218 |
}
|
| 219 |
|
| 220 |
-
.ability-counts {
|
| 221 |
-
display: flex;
|
| 222 |
-
flex-direction: column;
|
| 223 |
-
gap: 4px;
|
| 224 |
-
align-items: flex-end;
|
| 225 |
-
}
|
| 226 |
-
|
| 227 |
-
.count-badge {
|
| 228 |
-
font-size: 11px;
|
| 229 |
-
padding: 3px 8px;
|
| 230 |
-
border-radius: 12px;
|
| 231 |
-
font-weight: 500;
|
| 232 |
-
white-space: nowrap;
|
| 233 |
-
}
|
| 234 |
-
|
| 235 |
-
.count-badge.effects {
|
| 236 |
-
background: #e3f2fd;
|
| 237 |
-
color: #1976d2;
|
| 238 |
-
}
|
| 239 |
-
|
| 240 |
-
.count-badge.triggers {
|
| 241 |
-
background: #fff3e0;
|
| 242 |
-
color: #f57c00;
|
| 243 |
-
}
|
| 244 |
|
| 245 |
.ability-details {
|
| 246 |
margin-top: 16px;
|
|
@@ -262,57 +238,7 @@
|
|
| 262 |
font-size: 16px;
|
| 263 |
}
|
| 264 |
|
| 265 |
-
.effects-section,
|
| 266 |
-
.triggers-section {
|
| 267 |
-
margin-bottom: 16px;
|
| 268 |
-
}
|
| 269 |
-
|
| 270 |
-
.effects-list,
|
| 271 |
-
.triggers-list {
|
| 272 |
-
display: flex;
|
| 273 |
-
flex-direction: column;
|
| 274 |
-
gap: 8px;
|
| 275 |
-
}
|
| 276 |
-
|
| 277 |
-
.effect-item {
|
| 278 |
-
display: flex;
|
| 279 |
-
align-items: flex-start;
|
| 280 |
-
gap: 10px;
|
| 281 |
-
padding: 8px 12px;
|
| 282 |
-
background: rgba(255, 255, 255, 0.7);
|
| 283 |
-
border-radius: 8px;
|
| 284 |
-
border: 1px solid rgba(0, 0, 0, 0.08);
|
| 285 |
-
}
|
| 286 |
-
|
| 287 |
-
.effect-icon {
|
| 288 |
-
font-size: 16px;
|
| 289 |
-
margin-top: 1px;
|
| 290 |
-
}
|
| 291 |
-
|
| 292 |
-
.effect-icon.small {
|
| 293 |
-
font-size: 14px;
|
| 294 |
-
}
|
| 295 |
|
| 296 |
-
.effect-details {
|
| 297 |
-
flex: 1;
|
| 298 |
-
display: flex;
|
| 299 |
-
flex-direction: column;
|
| 300 |
-
gap: 2px;
|
| 301 |
-
}
|
| 302 |
-
|
| 303 |
-
.effect-type {
|
| 304 |
-
font-size: 12px;
|
| 305 |
-
font-weight: 600;
|
| 306 |
-
color: #495057;
|
| 307 |
-
text-transform: uppercase;
|
| 308 |
-
letter-spacing: 0.5px;
|
| 309 |
-
}
|
| 310 |
-
|
| 311 |
-
.effect-description {
|
| 312 |
-
font-size: 13px;
|
| 313 |
-
color: #6c757d;
|
| 314 |
-
line-height: 1.3;
|
| 315 |
-
}
|
| 316 |
|
| 317 |
.trigger-item {
|
| 318 |
background: rgba(255, 255, 255, 0.7);
|
|
|
|
| 217 |
line-height: 1.4;
|
| 218 |
}
|
| 219 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 220 |
|
| 221 |
.ability-details {
|
| 222 |
margin-top: 16px;
|
|
|
|
| 238 |
font-size: 16px;
|
| 239 |
}
|
| 240 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 241 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 242 |
|
| 243 |
.trigger-item {
|
| 244 |
background: rgba(255, 255, 255, 0.7);
|
src/lib/components/Piclets/DiscoveredCard.svelte
DELETED
|
@@ -1,87 +0,0 @@
|
|
| 1 |
-
<script lang="ts">
|
| 2 |
-
import type { Monster } from '$lib/db/schema';
|
| 3 |
-
|
| 4 |
-
interface Props {
|
| 5 |
-
monster: Monster;
|
| 6 |
-
size?: number;
|
| 7 |
-
onClick?: () => void;
|
| 8 |
-
}
|
| 9 |
-
|
| 10 |
-
let { monster, size = 100, onClick }: Props = $props();
|
| 11 |
-
|
| 12 |
-
// Default type color
|
| 13 |
-
const typeColor = '#007bff';
|
| 14 |
-
</script>
|
| 15 |
-
|
| 16 |
-
<button
|
| 17 |
-
class="discovered-card"
|
| 18 |
-
style="width: {size}px; height: {size + 30}px;"
|
| 19 |
-
onclick={onClick}
|
| 20 |
-
type="button"
|
| 21 |
-
>
|
| 22 |
-
<div class="image-container" style="background-color: {typeColor}10;">
|
| 23 |
-
<img
|
| 24 |
-
src={monster.imageData || monster.imageUrl}
|
| 25 |
-
alt={monster.name}
|
| 26 |
-
class="piclet-image"
|
| 27 |
-
style="width: {size * 0.9}px; height: {size * 0.9}px;"
|
| 28 |
-
/>
|
| 29 |
-
</div>
|
| 30 |
-
|
| 31 |
-
<div class="name-section">
|
| 32 |
-
<p class="name">{monster.name}</p>
|
| 33 |
-
</div>
|
| 34 |
-
</button>
|
| 35 |
-
|
| 36 |
-
<style>
|
| 37 |
-
.discovered-card {
|
| 38 |
-
display: flex;
|
| 39 |
-
flex-direction: column;
|
| 40 |
-
background: white;
|
| 41 |
-
border-radius: 12px;
|
| 42 |
-
border: 2px solid;
|
| 43 |
-
border-color: color-mix(in srgb, var(--type-color, #007bff) 30%, transparent);
|
| 44 |
-
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
| 45 |
-
padding: 0;
|
| 46 |
-
cursor: pointer;
|
| 47 |
-
transition: transform 0.2s;
|
| 48 |
-
opacity: 0.8;
|
| 49 |
-
}
|
| 50 |
-
|
| 51 |
-
.discovered-card:active {
|
| 52 |
-
transform: scale(0.95);
|
| 53 |
-
}
|
| 54 |
-
|
| 55 |
-
.image-container {
|
| 56 |
-
flex: 1;
|
| 57 |
-
position: relative;
|
| 58 |
-
display: flex;
|
| 59 |
-
align-items: center;
|
| 60 |
-
justify-content: center;
|
| 61 |
-
border-radius: 10px 10px 0 0;
|
| 62 |
-
overflow: hidden;
|
| 63 |
-
}
|
| 64 |
-
|
| 65 |
-
.piclet-image {
|
| 66 |
-
object-fit: contain;
|
| 67 |
-
filter: brightness(0.9);
|
| 68 |
-
}
|
| 69 |
-
|
| 70 |
-
.name-section {
|
| 71 |
-
height: 30px;
|
| 72 |
-
padding: 4px 6px;
|
| 73 |
-
display: flex;
|
| 74 |
-
align-items: center;
|
| 75 |
-
justify-content: center;
|
| 76 |
-
}
|
| 77 |
-
|
| 78 |
-
.name {
|
| 79 |
-
margin: 0;
|
| 80 |
-
font-size: 11px;
|
| 81 |
-
font-weight: 600;
|
| 82 |
-
text-align: center;
|
| 83 |
-
overflow: hidden;
|
| 84 |
-
text-overflow: ellipsis;
|
| 85 |
-
white-space: nowrap;
|
| 86 |
-
}
|
| 87 |
-
</style>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/lib/components/Piclets/NewlyCaughtPicletDetail.svelte
CHANGED
|
@@ -56,14 +56,18 @@
|
|
| 56 |
showCelebration = false;
|
| 57 |
if (celebrationTimeout) clearTimeout(celebrationTimeout);
|
| 58 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
</script>
|
| 60 |
|
| 61 |
-
<div class="detail-overlay"
|
| 62 |
-
<div class="detail-container newly-caught"
|
| 63 |
|
| 64 |
<!-- Celebration overlay -->
|
| 65 |
{#if showCelebration}
|
| 66 |
-
<div class="celebration-overlay"
|
| 67 |
<div class="celebration-content">
|
| 68 |
<div class="celebration-sparkles">✨</div>
|
| 69 |
<h1 class="celebration-title">Welcome to your team!</h1>
|
|
@@ -77,7 +81,7 @@
|
|
| 77 |
|
| 78 |
<!-- Header with special "newly caught" styling -->
|
| 79 |
<div class="detail-header" style="background: {tier().bg}">
|
| 80 |
-
<button class="close-button"
|
| 81 |
<div class="newly-caught-badge">
|
| 82 |
<span class="badge-text">✨ NEWLY CAUGHT ✨</span>
|
| 83 |
</div>
|
|
@@ -110,14 +114,14 @@
|
|
| 110 |
<button
|
| 111 |
class="tab-button"
|
| 112 |
class:active={selectedTab === 'about'}
|
| 113 |
-
|
| 114 |
>
|
| 115 |
About
|
| 116 |
</button>
|
| 117 |
<button
|
| 118 |
class="tab-button"
|
| 119 |
class:active={selectedTab === 'abilities'}
|
| 120 |
-
|
| 121 |
>
|
| 122 |
Abilities
|
| 123 |
</button>
|
|
|
|
| 56 |
showCelebration = false;
|
| 57 |
if (celebrationTimeout) clearTimeout(celebrationTimeout);
|
| 58 |
}
|
| 59 |
+
|
| 60 |
+
function handleContainerClick(event: MouseEvent) {
|
| 61 |
+
event.stopPropagation();
|
| 62 |
+
}
|
| 63 |
</script>
|
| 64 |
|
| 65 |
+
<div class="detail-overlay" role="dialog" aria-modal="true" tabindex="-1" onclick={onClose}>
|
| 66 |
+
<div class="detail-container newly-caught" role="document" onclick={handleContainerClick}>
|
| 67 |
|
| 68 |
<!-- Celebration overlay -->
|
| 69 |
{#if showCelebration}
|
| 70 |
+
<div class="celebration-overlay" role="button" tabindex="0" onclick={dismissCelebration}>
|
| 71 |
<div class="celebration-content">
|
| 72 |
<div class="celebration-sparkles">✨</div>
|
| 73 |
<h1 class="celebration-title">Welcome to your team!</h1>
|
|
|
|
| 81 |
|
| 82 |
<!-- Header with special "newly caught" styling -->
|
| 83 |
<div class="detail-header" style="background: {tier().bg}">
|
| 84 |
+
<button class="close-button" onclick={onClose}>×</button>
|
| 85 |
<div class="newly-caught-badge">
|
| 86 |
<span class="badge-text">✨ NEWLY CAUGHT ✨</span>
|
| 87 |
</div>
|
|
|
|
| 114 |
<button
|
| 115 |
class="tab-button"
|
| 116 |
class:active={selectedTab === 'about'}
|
| 117 |
+
onclick={() => selectedTab = 'about'}
|
| 118 |
>
|
| 119 |
About
|
| 120 |
</button>
|
| 121 |
<button
|
| 122 |
class="tab-button"
|
| 123 |
class:active={selectedTab === 'abilities'}
|
| 124 |
+
onclick={() => selectedTab = 'abilities'}
|
| 125 |
>
|
| 126 |
Abilities
|
| 127 |
</button>
|
src/lib/db/index.ts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
| 1 |
import Dexie, { type Table } from 'dexie';
|
| 2 |
-
import type {
|
| 3 |
|
| 4 |
export class PicletDatabase extends Dexie {
|
| 5 |
-
//
|
| 6 |
-
monsters!: Table<Monster>;
|
| 7 |
-
|
| 8 |
-
// New game tables
|
| 9 |
picletInstances!: Table<PicletInstance>;
|
| 10 |
encounters!: Table<Encounter>;
|
| 11 |
gameState!: Table<GameState>;
|
|
@@ -13,37 +10,26 @@ export class PicletDatabase extends Dexie {
|
|
| 13 |
constructor() {
|
| 14 |
super('PicletGameDB');
|
| 15 |
|
| 16 |
-
|
| 17 |
-
monsters: '++id, name, createdAt'
|
| 18 |
-
});
|
| 19 |
|
| 20 |
-
// Version 2:
|
| 21 |
-
this.version(2).stores({
|
| 22 |
-
monsters: '++id, name, createdAt'
|
| 23 |
-
}).upgrade(tx => {
|
| 24 |
-
// No data migration needed, just schema update
|
| 25 |
-
return tx.table('monsters').toCollection().modify(monster => {
|
| 26 |
-
monster.imageData = monster.imageData || null;
|
| 27 |
-
});
|
| 28 |
-
});
|
| 29 |
|
| 30 |
-
// Version 3:
|
| 31 |
-
this.version(3).stores({
|
| 32 |
-
monsters: '++id, name, createdAt'
|
| 33 |
-
}).upgrade(tx => {
|
| 34 |
-
// No data migration needed, just schema update
|
| 35 |
-
return tx.table('monsters').toCollection().modify(monster => {
|
| 36 |
-
monster.stats = monster.stats || null;
|
| 37 |
-
});
|
| 38 |
-
});
|
| 39 |
|
| 40 |
-
// Version 4: Add new game tables
|
| 41 |
this.version(4).stores({
|
| 42 |
monsters: '++id, name, createdAt',
|
| 43 |
picletInstances: '++id, typeId, nickname, isInRoster, rosterPosition, caughtAt',
|
| 44 |
encounters: '++id, type, createdAt',
|
| 45 |
gameState: '++id, lastPlayed'
|
| 46 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
}
|
| 48 |
}
|
| 49 |
|
|
|
|
| 1 |
import Dexie, { type Table } from 'dexie';
|
| 2 |
+
import type { PicletInstance, Encounter, GameState } from './schema';
|
| 3 |
|
| 4 |
export class PicletDatabase extends Dexie {
|
| 5 |
+
// Game tables
|
|
|
|
|
|
|
|
|
|
| 6 |
picletInstances!: Table<PicletInstance>;
|
| 7 |
encounters!: Table<Encounter>;
|
| 8 |
gameState!: Table<GameState>;
|
|
|
|
| 10 |
constructor() {
|
| 11 |
super('PicletGameDB');
|
| 12 |
|
| 13 |
+
// Version 1: Legacy monsters table (removed in v5)
|
|
|
|
|
|
|
| 14 |
|
| 15 |
+
// Version 2: Legacy monsters table with imageData (removed in v5)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
+
// Version 3: Legacy monsters table with stats (removed in v5)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
+
// Version 4: Add new game tables with legacy monsters
|
| 20 |
this.version(4).stores({
|
| 21 |
monsters: '++id, name, createdAt',
|
| 22 |
picletInstances: '++id, typeId, nickname, isInRoster, rosterPosition, caughtAt',
|
| 23 |
encounters: '++id, type, createdAt',
|
| 24 |
gameState: '++id, lastPlayed'
|
| 25 |
});
|
| 26 |
+
|
| 27 |
+
// Version 5: Remove legacy monsters table
|
| 28 |
+
this.version(5).stores({
|
| 29 |
+
picletInstances: '++id, typeId, nickname, isInRoster, rosterPosition, caughtAt',
|
| 30 |
+
encounters: '++id, type, createdAt',
|
| 31 |
+
gameState: '++id, lastPlayed'
|
| 32 |
+
});
|
| 33 |
}
|
| 34 |
}
|
| 35 |
|
src/lib/db/monsters.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
| 1 |
-
import { db } from './index';
|
| 2 |
-
import type { Monster } from './schema';
|
| 3 |
-
import { monsterToPicletInstance, savePicletInstance } from './piclets';
|
| 4 |
-
|
| 5 |
-
export async function saveMonster(monsterData: Omit<Monster, 'id' | 'createdAt'>, createPiclet: boolean = true): Promise<number> {
|
| 6 |
-
const monster: Omit<Monster, 'id'> = {
|
| 7 |
-
...monsterData,
|
| 8 |
-
createdAt: new Date()
|
| 9 |
-
};
|
| 10 |
-
|
| 11 |
-
const monsterId = await db.monsters.add(monster);
|
| 12 |
-
|
| 13 |
-
// Also create a PicletInstance if requested and stats are available
|
| 14 |
-
if (createPiclet && monster.stats) {
|
| 15 |
-
try {
|
| 16 |
-
const picletData = await monsterToPicletInstance({ ...monster, id: monsterId }, 5);
|
| 17 |
-
await savePicletInstance(picletData);
|
| 18 |
-
} catch (err) {
|
| 19 |
-
console.error('Failed to create PicletInstance:', err);
|
| 20 |
-
}
|
| 21 |
-
}
|
| 22 |
-
|
| 23 |
-
return monsterId;
|
| 24 |
-
}
|
| 25 |
-
|
| 26 |
-
export async function getAllMonsters(): Promise<Monster[]> {
|
| 27 |
-
return await db.monsters.toArray();
|
| 28 |
-
}
|
| 29 |
-
|
| 30 |
-
export async function getMonster(id: number): Promise<Monster | undefined> {
|
| 31 |
-
return await db.monsters.get(id);
|
| 32 |
-
}
|
| 33 |
-
|
| 34 |
-
export async function deleteMonster(id: number): Promise<void> {
|
| 35 |
-
await db.monsters.delete(id);
|
| 36 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/lib/db/piclets.ts
CHANGED
|
@@ -1,130 +1,9 @@
|
|
| 1 |
import { db } from './index';
|
| 2 |
-
import type { PicletInstance,
|
| 3 |
import { PicletType, AttackType, getTypeFromConcept } from '../types/picletTypes';
|
| 4 |
import type { PicletStats } from '../types';
|
| 5 |
import { generateUnlockLevels } from '../services/unlockLevels';
|
| 6 |
|
| 7 |
-
// Convert a generated Monster to a PicletInstance
|
| 8 |
-
export async function monsterToPicletInstance(monster: Monster, level: number = 5): Promise<Omit<PicletInstance, 'id'>> {
|
| 9 |
-
if (!monster.stats) {
|
| 10 |
-
throw new Error('Monster must have stats to create PicletInstance');
|
| 11 |
-
}
|
| 12 |
-
|
| 13 |
-
// All monsters must now have the battle-ready format
|
| 14 |
-
const stats = monster.stats as PicletStats;
|
| 15 |
-
|
| 16 |
-
if (!stats.baseStats || !stats.specialAbility || !stats.movepool) {
|
| 17 |
-
throw new Error('Monster stats must be in battle-ready format with baseStats, specialAbility, and movepool');
|
| 18 |
-
}
|
| 19 |
-
|
| 20 |
-
// Calculate base stats from battle-ready format
|
| 21 |
-
const baseHp = Math.floor(stats.baseStats.hp * 2 + 50);
|
| 22 |
-
const baseAttack = Math.floor(stats.baseStats.attack * 1.5 + 30);
|
| 23 |
-
const baseDefense = Math.floor(stats.baseStats.defense * 1.5 + 30);
|
| 24 |
-
const baseSpeed = Math.floor(stats.baseStats.speed * 1.5 + 30);
|
| 25 |
-
|
| 26 |
-
// Determine primary type from battle stats
|
| 27 |
-
const normalizedType = stats.primaryType.toLowerCase();
|
| 28 |
-
const validType = Object.values(PicletType).find(type => type === normalizedType);
|
| 29 |
-
const primaryType = validType || getTypeFromConcept(monster.concept, monster.imageCaption);
|
| 30 |
-
|
| 31 |
-
if (!validType) {
|
| 32 |
-
console.warn(`Invalid primaryType "${stats.primaryType}" from stats, falling back to concept detection`);
|
| 33 |
-
}
|
| 34 |
-
|
| 35 |
-
// Create moves from battle-ready format (without unlock levels initially)
|
| 36 |
-
const baseMoves: BattleMove[] = stats.movepool.map(move => ({
|
| 37 |
-
name: move.name,
|
| 38 |
-
type: move.type as unknown as AttackType,
|
| 39 |
-
power: move.power,
|
| 40 |
-
accuracy: move.accuracy,
|
| 41 |
-
pp: move.pp,
|
| 42 |
-
currentPp: move.pp,
|
| 43 |
-
description: move.description,
|
| 44 |
-
unlockLevel: 1 // Temporary, will be set below
|
| 45 |
-
}));
|
| 46 |
-
|
| 47 |
-
// Generate unlock levels for moves and special ability
|
| 48 |
-
const { movesWithUnlocks, abilityUnlockLevel } = generateUnlockLevels(baseMoves, stats.specialAbility);
|
| 49 |
-
const moves = movesWithUnlocks;
|
| 50 |
-
|
| 51 |
-
// Field stats are variations of regular stats
|
| 52 |
-
const baseFieldAttack = Math.floor(baseAttack * 0.8);
|
| 53 |
-
const baseFieldDefense = Math.floor(baseDefense * 0.8);
|
| 54 |
-
|
| 55 |
-
// Use Pokemon-accurate stat calculations (matching levelingService)
|
| 56 |
-
const calculateStat = (base: number, level: number) => {
|
| 57 |
-
if (level === 1) {
|
| 58 |
-
return Math.max(1, Math.floor(base / 10) + 5);
|
| 59 |
-
}
|
| 60 |
-
return Math.floor((2 * base * level) / 100) + 5;
|
| 61 |
-
};
|
| 62 |
-
|
| 63 |
-
const calculateHp = (base: number, level: number) => {
|
| 64 |
-
if (level === 1) {
|
| 65 |
-
return Math.max(1, Math.floor(base / 10) + 11);
|
| 66 |
-
}
|
| 67 |
-
return Math.floor((2 * base * level) / 100) + level + 10;
|
| 68 |
-
};
|
| 69 |
-
|
| 70 |
-
const maxHp = calculateHp(baseHp, level);
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
const bst = baseHp + baseAttack + baseDefense + baseFieldAttack + baseFieldDefense + baseSpeed;
|
| 74 |
-
|
| 75 |
-
return {
|
| 76 |
-
// Type Info
|
| 77 |
-
typeId: monster.name.toLowerCase().replace(/\s+/g, '-'),
|
| 78 |
-
nickname: monster.name,
|
| 79 |
-
primaryType: primaryType,
|
| 80 |
-
secondaryType: undefined,
|
| 81 |
-
|
| 82 |
-
// Current Stats
|
| 83 |
-
currentHp: maxHp,
|
| 84 |
-
maxHp,
|
| 85 |
-
level,
|
| 86 |
-
xp: 0,
|
| 87 |
-
attack: calculateStat(baseAttack, level),
|
| 88 |
-
defense: calculateStat(baseDefense, level),
|
| 89 |
-
fieldAttack: calculateStat(baseFieldAttack, level),
|
| 90 |
-
fieldDefense: calculateStat(baseFieldDefense, level),
|
| 91 |
-
speed: calculateStat(baseSpeed, level),
|
| 92 |
-
|
| 93 |
-
// Base Stats
|
| 94 |
-
baseHp,
|
| 95 |
-
baseAttack,
|
| 96 |
-
baseDefense,
|
| 97 |
-
baseFieldAttack,
|
| 98 |
-
baseFieldDefense,
|
| 99 |
-
baseSpeed,
|
| 100 |
-
|
| 101 |
-
// Battle
|
| 102 |
-
moves,
|
| 103 |
-
nature: stats.nature,
|
| 104 |
-
specialAbility: stats.specialAbility,
|
| 105 |
-
specialAbilityUnlockLevel: abilityUnlockLevel,
|
| 106 |
-
|
| 107 |
-
// Roster
|
| 108 |
-
isInRoster: false,
|
| 109 |
-
rosterPosition: undefined,
|
| 110 |
-
|
| 111 |
-
// Metadata
|
| 112 |
-
caught: false, // Scanned Piclets start as uncaught
|
| 113 |
-
caughtAt: undefined, // Will be set when caught
|
| 114 |
-
bst,
|
| 115 |
-
tier: stats.tier, // Use tier from stats
|
| 116 |
-
role: 'balanced', // Could be enhanced based on stat distribution
|
| 117 |
-
variance: 0,
|
| 118 |
-
|
| 119 |
-
// Original generation data
|
| 120 |
-
imageUrl: monster.imageUrl,
|
| 121 |
-
imageData: monster.imageData,
|
| 122 |
-
imageCaption: monster.imageCaption,
|
| 123 |
-
concept: monster.concept,
|
| 124 |
-
description: stats.description,
|
| 125 |
-
imagePrompt: monster.imagePrompt
|
| 126 |
-
};
|
| 127 |
-
}
|
| 128 |
|
| 129 |
// Save a new PicletInstance
|
| 130 |
export async function savePicletInstance(piclet: Omit<PicletInstance, 'id'>): Promise<number> {
|
|
|
|
| 1 |
import { db } from './index';
|
| 2 |
+
import type { PicletInstance, BattleMove } from './schema';
|
| 3 |
import { PicletType, AttackType, getTypeFromConcept } from '../types/picletTypes';
|
| 4 |
import type { PicletStats } from '../types';
|
| 5 |
import { generateUnlockLevels } from '../services/unlockLevels';
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
// Save a new PicletInstance
|
| 9 |
export async function savePicletInstance(piclet: Omit<PicletInstance, 'id'>): Promise<number> {
|
src/lib/db/resetGame.ts
CHANGED
|
@@ -7,20 +7,22 @@ export async function resetGameState() {
|
|
| 7 |
await db.encounters.clear();
|
| 8 |
await db.gameState.clear();
|
| 9 |
|
| 10 |
-
// Note:
|
| 11 |
console.log('Game state reset - all caught piclets and encounters cleared');
|
| 12 |
}
|
| 13 |
|
| 14 |
-
// Clear only
|
| 15 |
export async function clearDiscoveredPiclets() {
|
| 16 |
-
|
| 17 |
-
|
|
|
|
| 18 |
}
|
| 19 |
|
| 20 |
-
// Full reset including
|
| 21 |
export async function fullGameReset() {
|
| 22 |
-
await
|
| 23 |
-
await
|
|
|
|
| 24 |
console.log('Full game reset - all data cleared');
|
| 25 |
}
|
| 26 |
|
|
|
|
| 7 |
await db.encounters.clear();
|
| 8 |
await db.gameState.clear();
|
| 9 |
|
| 10 |
+
// Note: All Piclets are now stored in picletInstances table
|
| 11 |
console.log('Game state reset - all caught piclets and encounters cleared');
|
| 12 |
}
|
| 13 |
|
| 14 |
+
// Clear only uncaught piclets (discovered but not caught)
|
| 15 |
export async function clearDiscoveredPiclets() {
|
| 16 |
+
// Remove all uncaught piclets from the database
|
| 17 |
+
await db.picletInstances.where('caught').equals(false).delete();
|
| 18 |
+
console.log('Uncaught piclets cleared');
|
| 19 |
}
|
| 20 |
|
| 21 |
+
// Full reset including all piclets
|
| 22 |
export async function fullGameReset() {
|
| 23 |
+
await db.picletInstances.clear();
|
| 24 |
+
await db.encounters.clear();
|
| 25 |
+
await db.gameState.clear();
|
| 26 |
console.log('Full game reset - all data cleared');
|
| 27 |
}
|
| 28 |
|
src/lib/db/schema.ts
CHANGED
|
@@ -141,15 +141,3 @@ export interface BattleState {
|
|
| 141 |
capturedPiclet?: PicletInstance;
|
| 142 |
}
|
| 143 |
|
| 144 |
-
// Monster interface - now only supports battle-ready format
|
| 145 |
-
export interface Monster {
|
| 146 |
-
id?: number;
|
| 147 |
-
name: string;
|
| 148 |
-
imageUrl: string;
|
| 149 |
-
imageData?: string;
|
| 150 |
-
imageCaption: string;
|
| 151 |
-
concept: string;
|
| 152 |
-
imagePrompt: string;
|
| 153 |
-
stats?: import('../types').PicletStats; // Only battle-ready format
|
| 154 |
-
createdAt: Date;
|
| 155 |
-
}
|
|
|
|
| 141 |
capturedPiclet?: PicletInstance;
|
| 142 |
}
|
| 143 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/lib/utils/battleConversion.ts
CHANGED
|
@@ -41,7 +41,7 @@ export function picletInstanceToBattleDefinition(instance: PicletInstance): Picl
|
|
| 41 |
|
| 42 |
// All Piclets must now have special abilities
|
| 43 |
if (!instance.specialAbility) {
|
| 44 |
-
throw new Error('Piclet must have a special ability.
|
| 45 |
}
|
| 46 |
|
| 47 |
// Only include special ability if unlocked
|
|
|
|
| 41 |
|
| 42 |
// All Piclets must now have special abilities
|
| 43 |
if (!instance.specialAbility) {
|
| 44 |
+
throw new Error('Piclet must have a special ability.');
|
| 45 |
}
|
| 46 |
|
| 47 |
// Only include special ability if unlocked
|
src/tests/encounterService.test.ts
CHANGED
|
@@ -2,12 +2,11 @@ import { describe, it, expect, beforeEach } from 'vitest';
|
|
| 2 |
import { EncounterService } from '../lib/db/encounterService';
|
| 3 |
import { db } from '../lib/db';
|
| 4 |
import { EncounterType } from '../lib/db/schema';
|
| 5 |
-
import type {
|
| 6 |
|
| 7 |
describe('EncounterService', () => {
|
| 8 |
beforeEach(async () => {
|
| 9 |
// Clear all data before each test
|
| 10 |
-
await db.monsters.clear();
|
| 11 |
await db.picletInstances.clear();
|
| 12 |
await db.encounters.clear();
|
| 13 |
await db.gameState.clear();
|
|
@@ -16,9 +15,7 @@ describe('EncounterService', () => {
|
|
| 16 |
describe('generateEncounters', () => {
|
| 17 |
it('should return empty array when no piclets are discovered', async () => {
|
| 18 |
// Arrange - ensure database is empty
|
| 19 |
-
const monsterCount = await db.monsters.count();
|
| 20 |
const picletCount = await db.picletInstances.count();
|
| 21 |
-
expect(monsterCount).toBe(0);
|
| 22 |
expect(picletCount).toBe(0);
|
| 23 |
|
| 24 |
// Act
|
|
@@ -33,16 +30,43 @@ describe('EncounterService', () => {
|
|
| 33 |
});
|
| 34 |
|
| 35 |
it('should return only "Your First Piclet!" when piclets are discovered but not caught', async () => {
|
| 36 |
-
// Arrange - add a discovered piclet (
|
| 37 |
-
const
|
| 38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
imageUrl: 'https://test.com/piclet.png',
|
| 40 |
-
concept: 'test',
|
| 41 |
-
imagePrompt: 'test prompt',
|
| 42 |
imageCaption: 'test caption',
|
| 43 |
-
|
|
|
|
|
|
|
| 44 |
};
|
| 45 |
-
await db.
|
| 46 |
|
| 47 |
// Act
|
| 48 |
const encounters = await EncounterService.generateEncounters();
|
|
|
|
| 2 |
import { EncounterService } from '../lib/db/encounterService';
|
| 3 |
import { db } from '../lib/db';
|
| 4 |
import { EncounterType } from '../lib/db/schema';
|
| 5 |
+
import type { PicletInstance } from '../lib/db/schema';
|
| 6 |
|
| 7 |
describe('EncounterService', () => {
|
| 8 |
beforeEach(async () => {
|
| 9 |
// Clear all data before each test
|
|
|
|
| 10 |
await db.picletInstances.clear();
|
| 11 |
await db.encounters.clear();
|
| 12 |
await db.gameState.clear();
|
|
|
|
| 15 |
describe('generateEncounters', () => {
|
| 16 |
it('should return empty array when no piclets are discovered', async () => {
|
| 17 |
// Arrange - ensure database is empty
|
|
|
|
| 18 |
const picletCount = await db.picletInstances.count();
|
|
|
|
| 19 |
expect(picletCount).toBe(0);
|
| 20 |
|
| 21 |
// Act
|
|
|
|
| 30 |
});
|
| 31 |
|
| 32 |
it('should return only "Your First Piclet!" when piclets are discovered but not caught', async () => {
|
| 33 |
+
// Arrange - add a discovered piclet (uncaught)
|
| 34 |
+
const testPiclet: Omit<PicletInstance, 'id'> = {
|
| 35 |
+
typeId: 'test-piclet',
|
| 36 |
+
nickname: 'Test Piclet',
|
| 37 |
+
primaryType: 'beast' as any,
|
| 38 |
+
currentHp: 100,
|
| 39 |
+
maxHp: 100,
|
| 40 |
+
level: 5,
|
| 41 |
+
xp: 0,
|
| 42 |
+
attack: 50,
|
| 43 |
+
defense: 50,
|
| 44 |
+
fieldAttack: 40,
|
| 45 |
+
fieldDefense: 40,
|
| 46 |
+
speed: 50,
|
| 47 |
+
baseHp: 100,
|
| 48 |
+
baseAttack: 50,
|
| 49 |
+
baseDefense: 50,
|
| 50 |
+
baseFieldAttack: 40,
|
| 51 |
+
baseFieldDefense: 40,
|
| 52 |
+
baseSpeed: 50,
|
| 53 |
+
moves: [],
|
| 54 |
+
nature: 'hardy',
|
| 55 |
+
specialAbility: { name: 'Test', description: 'Test', trigger: 'onBattleStart', effects: [] },
|
| 56 |
+
specialAbilityUnlockLevel: 1,
|
| 57 |
+
isInRoster: false,
|
| 58 |
+
caught: false,
|
| 59 |
+
bst: 300,
|
| 60 |
+
tier: 'low',
|
| 61 |
+
role: 'balanced',
|
| 62 |
+
variance: 0,
|
| 63 |
imageUrl: 'https://test.com/piclet.png',
|
|
|
|
|
|
|
| 64 |
imageCaption: 'test caption',
|
| 65 |
+
concept: 'test',
|
| 66 |
+
description: 'A test piclet',
|
| 67 |
+
imagePrompt: 'test prompt'
|
| 68 |
};
|
| 69 |
+
await db.picletInstances.add(testPiclet);
|
| 70 |
|
| 71 |
// Act
|
| 72 |
const encounters = await EncounterService.generateEncounters();
|