BATTLE
Browse files
src/lib/components/Battle/BattleControls.svelte
CHANGED
|
@@ -2,6 +2,7 @@
|
|
| 2 |
import type { PicletInstance } from '$lib/db/schema';
|
| 3 |
import { db } from '$lib/db';
|
| 4 |
import ActionButtons from './ActionButtons.svelte';
|
|
|
|
| 5 |
|
| 6 |
export let currentMessage: string;
|
| 7 |
export let battlePhase: 'intro' | 'main' | 'moveSelect' | 'picletSelect' | 'ended';
|
|
@@ -33,7 +34,7 @@
|
|
| 33 |
<div class="battle-controls">
|
| 34 |
<!-- Message Bar -->
|
| 35 |
<div class="message-bar {battleEnded ? 'special' : ''}">
|
| 36 |
-
<p
|
| 37 |
</div>
|
| 38 |
|
| 39 |
<!-- Action Area -->
|
|
|
|
| 2 |
import type { PicletInstance } from '$lib/db/schema';
|
| 3 |
import { db } from '$lib/db';
|
| 4 |
import ActionButtons from './ActionButtons.svelte';
|
| 5 |
+
import TypewriterText from './TypewriterText.svelte';
|
| 6 |
|
| 7 |
export let currentMessage: string;
|
| 8 |
export let battlePhase: 'intro' | 'main' | 'moveSelect' | 'picletSelect' | 'ended';
|
|
|
|
| 34 |
<div class="battle-controls">
|
| 35 |
<!-- Message Bar -->
|
| 36 |
<div class="message-bar {battleEnded ? 'special' : ''}">
|
| 37 |
+
<p><TypewriterText text={currentMessage} speed={25} /></p>
|
| 38 |
</div>
|
| 39 |
|
| 40 |
<!-- Action Area -->
|
src/lib/components/Battle/BattleField.svelte
CHANGED
|
@@ -255,21 +255,21 @@
|
|
| 255 |
|
| 256 |
@media (max-width: 768px) {
|
| 257 |
.enemy-image {
|
| 258 |
-
width:
|
| 259 |
-
height:
|
| 260 |
}
|
| 261 |
|
| 262 |
.player-image {
|
| 263 |
-
width:
|
| 264 |
-
height:
|
| 265 |
}
|
| 266 |
|
| 267 |
.enemy-piclet-wrapper {
|
| 268 |
-
right:
|
| 269 |
}
|
| 270 |
|
| 271 |
.player-piclet-wrapper {
|
| 272 |
-
left:
|
| 273 |
}
|
| 274 |
}
|
| 275 |
</style>
|
|
|
|
| 255 |
|
| 256 |
@media (max-width: 768px) {
|
| 257 |
.enemy-image {
|
| 258 |
+
width: 100px;
|
| 259 |
+
height: 100px;
|
| 260 |
}
|
| 261 |
|
| 262 |
.player-image {
|
| 263 |
+
width: 120px;
|
| 264 |
+
height: 120px;
|
| 265 |
}
|
| 266 |
|
| 267 |
.enemy-piclet-wrapper {
|
| 268 |
+
right: 40px;
|
| 269 |
}
|
| 270 |
|
| 271 |
.player-piclet-wrapper {
|
| 272 |
+
left: 40px;
|
| 273 |
}
|
| 274 |
}
|
| 275 |
</style>
|
src/lib/components/Battle/PicletInfo.svelte
CHANGED
|
@@ -33,7 +33,8 @@
|
|
| 33 |
<!-- HP Text (Player only) -->
|
| 34 |
{#if isPlayer}
|
| 35 |
<div class="hp-text">
|
| 36 |
-
|
|
|
|
| 37 |
</div>
|
| 38 |
|
| 39 |
<!-- XP Bar (Player only) -->
|
|
@@ -121,12 +122,22 @@
|
|
| 121 |
|
| 122 |
/* HP Text */
|
| 123 |
.hp-text {
|
|
|
|
|
|
|
|
|
|
| 124 |
font-size: 11px;
|
| 125 |
color: #666;
|
| 126 |
-
text-align: right;
|
| 127 |
margin-bottom: 4px;
|
| 128 |
}
|
| 129 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 130 |
/* XP Bar */
|
| 131 |
.xp-bar {
|
| 132 |
width: 120px;
|
|
|
|
| 33 |
<!-- HP Text (Player only) -->
|
| 34 |
{#if isPlayer}
|
| 35 |
<div class="hp-text">
|
| 36 |
+
<span class="hp-label">HP</span>
|
| 37 |
+
<span class="hp-values">{displayHp}/{piclet.maxHp}</span>
|
| 38 |
</div>
|
| 39 |
|
| 40 |
<!-- XP Bar (Player only) -->
|
|
|
|
| 122 |
|
| 123 |
/* HP Text */
|
| 124 |
.hp-text {
|
| 125 |
+
display: flex;
|
| 126 |
+
justify-content: space-between;
|
| 127 |
+
align-items: center;
|
| 128 |
font-size: 11px;
|
| 129 |
color: #666;
|
|
|
|
| 130 |
margin-bottom: 4px;
|
| 131 |
}
|
| 132 |
|
| 133 |
+
.hp-label {
|
| 134 |
+
font-weight: 600;
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
.hp-values {
|
| 138 |
+
text-align: right;
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
/* XP Bar */
|
| 142 |
.xp-bar {
|
| 143 |
width: 120px;
|
src/lib/components/Battle/TypewriterText.svelte
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script lang="ts">
|
| 2 |
+
import { onMount } from 'svelte';
|
| 3 |
+
|
| 4 |
+
export let text: string = '';
|
| 5 |
+
export let speed: number = 30; // milliseconds per character
|
| 6 |
+
|
| 7 |
+
let displayedText = '';
|
| 8 |
+
let currentIndex = 0;
|
| 9 |
+
let intervalId: number | null = null;
|
| 10 |
+
|
| 11 |
+
function startTyping() {
|
| 12 |
+
// Reset when text changes
|
| 13 |
+
displayedText = '';
|
| 14 |
+
currentIndex = 0;
|
| 15 |
+
|
| 16 |
+
// Clear any existing interval
|
| 17 |
+
if (intervalId) {
|
| 18 |
+
clearInterval(intervalId);
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
// Start typing effect
|
| 22 |
+
intervalId = setInterval(() => {
|
| 23 |
+
if (currentIndex < text.length) {
|
| 24 |
+
displayedText += text[currentIndex];
|
| 25 |
+
currentIndex++;
|
| 26 |
+
} else {
|
| 27 |
+
if (intervalId) {
|
| 28 |
+
clearInterval(intervalId);
|
| 29 |
+
intervalId = null;
|
| 30 |
+
}
|
| 31 |
+
}
|
| 32 |
+
}, speed);
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
// Watch for text changes
|
| 36 |
+
$: if (text) {
|
| 37 |
+
startTyping();
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
onMount(() => {
|
| 41 |
+
return () => {
|
| 42 |
+
if (intervalId) {
|
| 43 |
+
clearInterval(intervalId);
|
| 44 |
+
}
|
| 45 |
+
};
|
| 46 |
+
});
|
| 47 |
+
</script>
|
| 48 |
+
|
| 49 |
+
<span>{displayedText}</span>
|