File size: 4,398 Bytes
7428b13 c703ea3 81b3c3b c703ea3 74f8c2c c703ea3 566cdc0 c703ea3 4c208f2 c703ea3 4c208f2 c703ea3 9774b79 c703ea3 e8aa797 7428b13 c703ea3 7428b13 c703ea3 e8aa797 c703ea3 e8aa797 c703ea3 7428b13 c703ea3 7428b13 c703ea3 7428b13 c703ea3 7428b13 c703ea3 7428b13 e8aa797 c703ea3 e8aa797 c703ea3 e8aa797 c703ea3 e8aa797 c703ea3 e8aa797 c703ea3 e8aa797 c703ea3 e8aa797 c703ea3 e8aa797 c703ea3 e8aa797 c703ea3 e8aa797 c703ea3 e8aa797 c703ea3 e8aa797 c703ea3 e8aa797 c703ea3 e8aa797 c703ea3 e8aa797 7428b13 |
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 |
<script lang="ts">
import { fade } from 'svelte/transition';
import type { PicletInstance } from '$lib/db/schema';
import LLMBattleEngine from '../Battle/LLMBattleEngine.svelte';
import type { GradioClient } from '$lib/types';
interface Props {
playerPiclet: PicletInstance;
enemyPiclet: PicletInstance;
isWildBattle: boolean;
rosterPiclets?: PicletInstance[];
onBattleEnd: (result: { winner: 'player' | 'enemy'; capturedPiclet?: PicletInstance }) => void;
commandClient: GradioClient;
}
let { playerPiclet, enemyPiclet, isWildBattle, rosterPiclets, onBattleEnd, commandClient }: Props = $props();
// Simple battle state
let battleEnded = $state(false);
let battleResult: { winner: 'player' | 'enemy'; capturedPiclet?: PicletInstance } | null = $state(null);
// Handle battle end
function handleBattleEnd(winner: 'player' | 'enemy') {
battleEnded = true;
// Simplified: no capture mechanics since Piclets are auto-captured when scanned
battleResult = { winner };
// Give time for final battle messages, then call parent handler
setTimeout(() => {
onBattleEnd(battleResult!);
}, 2000);
}
</script>
<div class="battle-page" transition:fade>
<!-- Header -->
<div class="battle-header">
<h2>{isWildBattle ? 'Wild Battle' : 'Trainer Battle'}</h2>
<div class="battle-participants">
<div class="participant player">
<img src={playerPiclet.imageUrl} alt={playerPiclet.typeId} />
<h3>{playerPiclet.typeId}</h3>
<span class="tier tier-{playerPiclet.tier}">{playerPiclet.tier}</span>
</div>
<div class="vs-indicator">
<span>VS</span>
</div>
<div class="participant enemy">
<img src={enemyPiclet.imageUrl} alt={enemyPiclet.typeId} />
<h3>{enemyPiclet.typeId}</h3>
<span class="tier tier-{enemyPiclet.tier}">{enemyPiclet.tier}</span>
</div>
</div>
</div>
<!-- Main Battle Area -->
<div class="battle-main">
{#if !battleEnded}
<LLMBattleEngine
{playerPiclet}
{enemyPiclet}
{rosterPiclets}
{commandClient}
onBattleEnd={handleBattleEnd}
/>
{:else}
<div class="battle-results">
<h2>{battleResult?.winner === 'player' ? 'π Victory!' : 'π Defeat!'}</h2>
{#if battleResult?.winner === 'player'}
<p>You defeated {enemyPiclet.typeId}!</p>
{:else}
<p>{playerPiclet.typeId} was defeated by {enemyPiclet.typeId}...</p>
<p>Better luck next time!</p>
{/if}
</div>
{/if}
</div>
</div>
<style>
.battle-page {
height: 100vh;
display: flex;
flex-direction: column;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
}
.battle-header {
padding: 1rem;
text-align: center;
background: rgba(0, 0, 0, 0.1);
backdrop-filter: blur(10px);
}
.battle-participants {
display: flex;
align-items: center;
justify-content: center;
gap: 2rem;
margin-top: 1rem;
}
.participant {
display: flex;
flex-direction: column;
align-items: center;
gap: 0.5rem;
}
.participant img {
width: 80px;
height: 80px;
object-fit: cover;
border-radius: 50%;
border: 3px solid rgba(255, 255, 255, 0.3);
}
.participant.player img {
border-color: #007bff;
}
.participant.enemy img {
border-color: #dc3545;
}
.tier {
padding: 0.25rem 0.5rem;
border-radius: 12px;
font-size: 0.8rem;
font-weight: bold;
text-transform: uppercase;
}
.tier-low { background: #6c757d; }
.tier-medium { background: #28a745; }
.tier-high { background: #fd7e14; }
.tier-legendary { background: #dc3545; }
.vs-indicator {
font-size: 2rem;
font-weight: bold;
color: #ffd700;
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}
.battle-main {
flex: 1;
display: flex;
flex-direction: column;
background: white;
color: #333;
border-radius: 20px 20px 0 0;
overflow: hidden;
}
.battle-results {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
text-align: center;
padding: 2rem;
gap: 1rem;
}
.battle-results h2 {
font-size: 2.5rem;
margin: 0;
}
</style> |