test: 添加 PP 递减测试

验证使用招式后 PP 减少 1,maxPp 保持不变。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
claude-code-best
2026-04-24 09:07:46 +08:00
parent a58a36c35a
commit 4cf1a8353e
2 changed files with 27 additions and 0 deletions

View File

@@ -146,6 +146,8 @@ export interface BattleAssertions {
turnIs(n: number): BattleAssertions
/** Player party has N alive (hp > 0) Pokémon */
aliveInParty(n: number): BattleAssertions
/** Player's move at index has expected pp and maxPp */
playerMovePp(moveIndex: number, pp: number, maxPp: number): BattleAssertions
/** Generic assertion */
satisfies(fn: (state: BattleState) => boolean, msg?: string): BattleAssertions
}
@@ -297,6 +299,14 @@ class BattleAssertionsImpl implements BattleAssertions {
return this
}
playerMovePp(moveIndex: number, pp: number, maxPp: number) {
const move = this.s.playerPokemon.moves[moveIndex]
expect(move).toBeDefined()
expect(move!.pp).toBe(pp)
expect(move!.maxPp).toBe(maxPp)
return this
}
satisfies(fn: (state: BattleState) => boolean, msg?: string) {
expect(fn(this.s), msg).toBe(true)
return this

View File

@@ -69,6 +69,23 @@ describe('Battle Scenario: 单回合事件', () => {
.hasMove('opponent')
})
battleTest('使用招式后 PP 递减', async () => {
const s = await battleScenario()
.party('charmander', 50, ['flamethrower', 'scratch'])
.opponent('squirtle', 50)
.start()
// Record initial PP
const initialState = s.state
const initialPp = initialState.playerPokemon.moves[0]!.pp
const maxPp = initialState.playerPokemon.moves[0]!.maxPp
expect(initialPp).toBe(maxPp)
const state = await s.useMove(0).runTurn()
// PP should decrease by 1, maxPp stays the same
s.expect(state).playerMovePp(0, initialPp - 1, maxPp)
})
battleTest('等级碾压一击击杀', async () => {
const s = await battleScenario()
.party('charmander', 100, ['flamethrower'], { ev: { hp: 252, attack: 252, speed: 252 } })