import { describe, it, expect } from 'vitest'; import { BattleEngine } from './BattleEngine'; import type { PicletDefinition } from './types'; import { PicletType, AttackType } from './types'; describe('Debug Field Effects', () => { it('should debug field effect creation and damage calculation', () => { const fieldUser: PicletDefinition = { name: "Field User", description: "Creates field effects", tier: 'medium', primaryType: PicletType.BEAST, // Changed to BEAST so opponent can damage it baseStats: { hp: 100, attack: 60, defense: 80, speed: 60 }, nature: "Calm", specialAbility: { name: "No Ability", description: "" }, movepool: [ { name: "Contact Barrier", type: AttackType.SPACE, power: 0, accuracy: 100, pp: 10, priority: 0, flags: [], effects: [ { type: 'fieldEffect', effect: 'reflect', target: 'playerSide', stackable: false } ] } ] }; const attacker: PicletDefinition = { name: "Contact Attacker", description: "Uses contact moves", tier: 'medium', primaryType: PicletType.BEAST, baseStats: { hp: 80, attack: 80, defense: 60, speed: 70 }, nature: "Adamant", specialAbility: { name: "No Ability", description: "" }, movepool: [ { name: "Physical Strike", type: AttackType.BEAST, power: 60, accuracy: 100, pp: 15, priority: 0, flags: ['contact'], effects: [{ type: 'damage', target: 'opponent', amount: 'normal' }] } ] }; const engine = new BattleEngine(fieldUser, attacker); console.log('Initial state:', { playerHp: engine.getState().playerPiclet.currentHp, opponentHp: engine.getState().opponentPiclet.currentHp, fieldEffects: engine.getState().fieldEffects }); // First turn: create barrier and get attacked engine.executeActions( { type: 'move', piclet: 'player', moveIndex: 0 }, // Contact Barrier { type: 'move', piclet: 'opponent', moveIndex: 0 } // Physical Strike ); console.log('After first turn:', { playerHp: engine.getState().playerPiclet.currentHp, opponentHp: engine.getState().opponentPiclet.currentHp, fieldEffects: engine.getState().fieldEffects, log: engine.getLog() }); // Second turn: opponent attacks again (should be reduced) const hpBeforeSecondAttack = engine.getState().playerPiclet.currentHp; engine.executeActions( { type: 'move', piclet: 'player', moveIndex: 0 }, // Contact Barrier (no effect) { type: 'move', piclet: 'opponent', moveIndex: 0 } // Physical Strike (should be reduced) ); const hpAfterSecondAttack = engine.getState().playerPiclet.currentHp; const damage = hpBeforeSecondAttack - hpAfterSecondAttack; console.log('After second turn:', { playerHp: hpAfterSecondAttack, damage: damage, fieldEffects: engine.getState().fieldEffects, log: engine.getLog() }); expect(engine.getState().fieldEffects.length).toBeGreaterThan(0); expect(damage).toBeGreaterThan(0); // Some damage should occur }); });