MORE LOGS
Browse files
src/lib/battle-engine/BattleEngine.ts
CHANGED
|
@@ -230,21 +230,39 @@ export class BattleEngine {
|
|
| 230 |
}
|
| 231 |
|
| 232 |
private executeMove(action: MoveAction & { executor: 'player' | 'opponent' }): void {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 233 |
const attacker = action.executor === 'player' ? this.state.playerPiclet : this.state.opponentPiclet;
|
| 234 |
const defender = action.executor === 'player' ? this.state.opponentPiclet : this.state.playerPiclet;
|
| 235 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 236 |
// Check if attacker can act due to status effects
|
| 237 |
if (!this.canPicletAct(attacker)) {
|
|
|
|
| 238 |
return; // Skip this action
|
| 239 |
}
|
| 240 |
|
| 241 |
const moveData = attacker.moves[action.moveIndex];
|
| 242 |
if (!moveData || moveData.currentPP <= 0) {
|
|
|
|
| 243 |
this.log(`${attacker.definition.name} has no PP left for that move!`);
|
| 244 |
return;
|
| 245 |
}
|
| 246 |
|
| 247 |
const move = moveData.move;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 248 |
|
| 249 |
// Trigger before move use
|
| 250 |
this.triggerBeforeMoveUse(attacker, move);
|
|
@@ -269,8 +287,20 @@ export class BattleEngine {
|
|
| 269 |
const luckyRoll = Math.random() < 0.5;
|
| 270 |
|
| 271 |
// Process effects
|
| 272 |
-
|
| 273 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 274 |
}
|
| 275 |
|
| 276 |
// Trigger after move use
|
|
|
|
| 230 |
}
|
| 231 |
|
| 232 |
private executeMove(action: MoveAction & { executor: 'player' | 'opponent' }): void {
|
| 233 |
+
console.log('π executeMove started:', {
|
| 234 |
+
executor: action.executor,
|
| 235 |
+
moveIndex: action.moveIndex
|
| 236 |
+
});
|
| 237 |
+
|
| 238 |
const attacker = action.executor === 'player' ? this.state.playerPiclet : this.state.opponentPiclet;
|
| 239 |
const defender = action.executor === 'player' ? this.state.opponentPiclet : this.state.playerPiclet;
|
| 240 |
|
| 241 |
+
console.log('π₯ Attacker/Defender:', {
|
| 242 |
+
attacker: attacker.definition.name,
|
| 243 |
+
defender: defender.definition.name
|
| 244 |
+
});
|
| 245 |
+
|
| 246 |
// Check if attacker can act due to status effects
|
| 247 |
if (!this.canPicletAct(attacker)) {
|
| 248 |
+
console.log('β Attacker cannot act due to status effects');
|
| 249 |
return; // Skip this action
|
| 250 |
}
|
| 251 |
|
| 252 |
const moveData = attacker.moves[action.moveIndex];
|
| 253 |
if (!moveData || moveData.currentPP <= 0) {
|
| 254 |
+
console.log('β No move data or no PP:', { moveData: !!moveData, pp: moveData?.currentPP });
|
| 255 |
this.log(`${attacker.definition.name} has no PP left for that move!`);
|
| 256 |
return;
|
| 257 |
}
|
| 258 |
|
| 259 |
const move = moveData.move;
|
| 260 |
+
console.log('β
Move to execute:', {
|
| 261 |
+
name: move.name,
|
| 262 |
+
type: move.type,
|
| 263 |
+
power: move.power,
|
| 264 |
+
effects: move.effects?.length || 0
|
| 265 |
+
});
|
| 266 |
|
| 267 |
// Trigger before move use
|
| 268 |
this.triggerBeforeMoveUse(attacker, move);
|
|
|
|
| 287 |
const luckyRoll = Math.random() < 0.5;
|
| 288 |
|
| 289 |
// Process effects
|
| 290 |
+
console.log('π Processing effects:', move.effects.length);
|
| 291 |
+
for (let i = 0; i < move.effects.length; i++) {
|
| 292 |
+
const effect = move.effects[i];
|
| 293 |
+
console.log(`π Processing effect ${i + 1}/${move.effects.length}:`, {
|
| 294 |
+
type: effect.type,
|
| 295 |
+
effect: effect
|
| 296 |
+
});
|
| 297 |
+
try {
|
| 298 |
+
this.processEffect(effect, attacker, defender, move, luckyRoll);
|
| 299 |
+
console.log(`β
Effect ${i + 1} completed successfully`);
|
| 300 |
+
} catch (error) {
|
| 301 |
+
console.error(`β Effect ${i + 1} failed:`, error);
|
| 302 |
+
throw error; // Re-throw to maintain error behavior
|
| 303 |
+
}
|
| 304 |
}
|
| 305 |
|
| 306 |
// Trigger after move use
|