btl sys
Browse files
src/lib/components/Battle/BattleControls.svelte
CHANGED
@@ -93,5 +93,41 @@
|
|
93 |
padding: 1rem;
|
94 |
display: flex;
|
95 |
flex-direction: column;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
}
|
97 |
</style>
|
|
|
93 |
padding: 1rem;
|
94 |
display: flex;
|
95 |
flex-direction: column;
|
96 |
+
position: relative;
|
97 |
+
}
|
98 |
+
|
99 |
+
.tap-continue-overlay {
|
100 |
+
position: absolute;
|
101 |
+
top: 0;
|
102 |
+
left: 0;
|
103 |
+
right: 0;
|
104 |
+
bottom: 0;
|
105 |
+
background: rgba(0, 0, 0, 0.1);
|
106 |
+
display: flex;
|
107 |
+
align-items: center;
|
108 |
+
justify-content: center;
|
109 |
+
cursor: pointer;
|
110 |
+
border-radius: 8px;
|
111 |
+
}
|
112 |
+
|
113 |
+
.tap-indicator {
|
114 |
+
background: rgba(0, 122, 255, 0.9);
|
115 |
+
color: white;
|
116 |
+
padding: 8px 16px;
|
117 |
+
border-radius: 20px;
|
118 |
+
font-size: 14px;
|
119 |
+
font-weight: 500;
|
120 |
+
animation: pulse 2s infinite;
|
121 |
+
}
|
122 |
+
|
123 |
+
@keyframes pulse {
|
124 |
+
0%, 100% {
|
125 |
+
opacity: 0.9;
|
126 |
+
transform: scale(1);
|
127 |
+
}
|
128 |
+
50% {
|
129 |
+
opacity: 1;
|
130 |
+
transform: scale(1.05);
|
131 |
+
}
|
132 |
}
|
133 |
</style>
|
src/lib/components/Pages/Battle.svelte
CHANGED
@@ -220,10 +220,32 @@
|
|
220 |
await handleBattleResults(battleState.winner === 'player');
|
221 |
}, 2500); // Wait time for faint message and animation
|
222 |
} else {
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
227 |
}
|
228 |
}
|
229 |
} catch (error) {
|
@@ -370,12 +392,65 @@
|
|
370 |
}
|
371 |
}
|
372 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
373 |
function updateUIFromBattleState() {
|
374 |
if (!battleState) return;
|
375 |
|
376 |
-
//
|
377 |
-
|
378 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
379 |
|
380 |
// Update enemy piclet state
|
381 |
currentEnemyPiclet = battlePicletToInstance(battleState.opponentPiclet, currentEnemyPiclet);
|
@@ -605,10 +680,12 @@
|
|
605 |
enemyPiclet={currentEnemyPiclet}
|
606 |
{rosterPiclets}
|
607 |
{battleState}
|
|
|
608 |
onAction={handleAction}
|
609 |
onMoveSelect={handleMoveSelect}
|
610 |
onPicletSelect={handlePicletSelect}
|
611 |
onBack={handleBack}
|
|
|
612 |
/>
|
613 |
</div>
|
614 |
|
|
|
220 |
await handleBattleResults(battleState.winner === 'player');
|
221 |
}, 2500); // Wait time for faint message and animation
|
222 |
} else {
|
223 |
+
// Check if player Piclet switched due to fainting
|
224 |
+
const newPlayerPiclet = battlePicletToInstance(battleState.playerPiclet, currentPlayerPiclet);
|
225 |
+
const playerPicletChanged = currentPlayerPiclet.id !== newPlayerPiclet.id;
|
226 |
+
|
227 |
+
if (playerPicletChanged) {
|
228 |
+
// Player Piclet fainted and auto-switched - show faint message first
|
229 |
+
const faintedPiclet = currentPlayerPiclet;
|
230 |
+
currentMessage = `${faintedPiclet.nickname} fainted!`;
|
231 |
+
playerFaint = true;
|
232 |
+
|
233 |
+
// Wait for faint message, then show switch and continue
|
234 |
+
setTimeout(() => {
|
235 |
+
currentMessage = `Go, ${newPlayerPiclet.nickname}!`;
|
236 |
+
// updateUIFromBattleState will handle the white flash transition
|
237 |
+
setTimeout(() => {
|
238 |
+
currentMessage = `What will ${currentPlayerPiclet.nickname} do?`;
|
239 |
+
processingTurn = false;
|
240 |
+
}, 1000);
|
241 |
+
}, 2500);
|
242 |
+
} else {
|
243 |
+
// Normal turn end - no faint or switch
|
244 |
+
setTimeout(() => {
|
245 |
+
currentMessage = `What will ${currentPlayerPiclet.nickname} do?`;
|
246 |
+
processingTurn = false;
|
247 |
+
}, 1000);
|
248 |
+
}
|
249 |
}
|
250 |
}
|
251 |
} catch (error) {
|
|
|
392 |
}
|
393 |
}
|
394 |
|
395 |
+
function showMessageSequence(messages: string[], callback: () => void) {
|
396 |
+
if (!messages || messages.length === 0) {
|
397 |
+
callback();
|
398 |
+
return;
|
399 |
+
}
|
400 |
+
|
401 |
+
messageQueue = messages;
|
402 |
+
currentMessageIndex = 0;
|
403 |
+
continueCallback = callback;
|
404 |
+
|
405 |
+
// Show first message
|
406 |
+
currentMessage = messageQueue[0];
|
407 |
+
waitingForContinue = true;
|
408 |
+
}
|
409 |
+
|
410 |
+
function handleContinueTap() {
|
411 |
+
if (!waitingForContinue || !messageQueue.length) return;
|
412 |
+
|
413 |
+
// Trigger visual effects for current message
|
414 |
+
triggerVisualEffectsFromMessage(currentMessage);
|
415 |
+
|
416 |
+
currentMessageIndex++;
|
417 |
+
|
418 |
+
if (currentMessageIndex >= messageQueue.length) {
|
419 |
+
// Sequence finished
|
420 |
+
waitingForContinue = false;
|
421 |
+
messageQueue = [];
|
422 |
+
currentMessageIndex = 0;
|
423 |
+
|
424 |
+
if (continueCallback) {
|
425 |
+
continueCallback();
|
426 |
+
continueCallback = null;
|
427 |
+
}
|
428 |
+
} else {
|
429 |
+
// Show next message
|
430 |
+
currentMessage = messageQueue[currentMessageIndex];
|
431 |
+
}
|
432 |
+
}
|
433 |
+
|
434 |
function updateUIFromBattleState() {
|
435 |
if (!battleState) return;
|
436 |
|
437 |
+
// Check if player Piclet has changed (indicating auto-switch due to fainting)
|
438 |
+
const newPlayerPiclet = battlePicletToInstance(battleState.playerPiclet, currentPlayerPiclet);
|
439 |
+
const playerPicletChanged = currentPlayerPiclet.id !== newPlayerPiclet.id;
|
440 |
+
|
441 |
+
if (playerPicletChanged) {
|
442 |
+
// Player Piclet auto-switched due to fainting - show transition
|
443 |
+
showWhiteFlash = true;
|
444 |
+
setTimeout(() => {
|
445 |
+
currentPlayerPiclet = newPlayerPiclet;
|
446 |
+
playerHpPercentage = battleState.playerPiclet.currentHp / battleState.playerPiclet.maxHp;
|
447 |
+
showWhiteFlash = false;
|
448 |
+
}, 300);
|
449 |
+
} else {
|
450 |
+
// Normal update without switch
|
451 |
+
currentPlayerPiclet = newPlayerPiclet;
|
452 |
+
playerHpPercentage = battleState.playerPiclet.currentHp / battleState.playerPiclet.maxHp;
|
453 |
+
}
|
454 |
|
455 |
// Update enemy piclet state
|
456 |
currentEnemyPiclet = battlePicletToInstance(battleState.opponentPiclet, currentEnemyPiclet);
|
|
|
680 |
enemyPiclet={currentEnemyPiclet}
|
681 |
{rosterPiclets}
|
682 |
{battleState}
|
683 |
+
{waitingForContinue}
|
684 |
onAction={handleAction}
|
685 |
onMoveSelect={handleMoveSelect}
|
686 |
onPicletSelect={handlePicletSelect}
|
687 |
onBack={handleBack}
|
688 |
+
onContinueTap={handleContinueTap}
|
689 |
/>
|
690 |
</div>
|
691 |
|