From c5c7202348abf82e8c99912d9830b275e3a41dc0 Mon Sep 17 00:00:00 2001 From: claude-code-best Date: Fri, 24 Apr 2026 08:57:04 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E5=9B=A0=20IV/=E6=80=A7=E6=A0=BC=E9=9D=9E=E7=A1=AE=E5=AE=9A?= =?UTF-8?q?=E6=80=A7=E5=AF=BC=E8=87=B4=E7=9A=84=E9=97=B4=E6=AD=87=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - battle-scenarios: 回合测试改用 pikachu vs pikachi 避免非确定性一击倒 - creature: EV 测试提升至 level 50 以确保 EV 贡献可见 - creature: level 1 stat 测试使用确定性 Hardy 性格避免 flaky Co-Authored-By: Claude Opus 4.7 --- .../pokemon/src/__tests__/battle-scenarios.test.ts | 4 ++-- packages/pokemon/src/__tests__/creature.test.ts | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/pokemon/src/__tests__/battle-scenarios.test.ts b/packages/pokemon/src/__tests__/battle-scenarios.test.ts index 14dc9f9da..75be2d2c3 100644 --- a/packages/pokemon/src/__tests__/battle-scenarios.test.ts +++ b/packages/pokemon/src/__tests__/battle-scenarios.test.ts @@ -81,8 +81,8 @@ describe('Battle Scenario: 单回合事件', () => { battleTest('回合数递增', async () => { const s = await battleScenario() - .party('charmander', 50, ['flamethrower']) - .opponent('squirtle', 50) + .party('pikachu', 50, ['thundershock']) + .opponent('pikachu', 50) // Same type matchup for neutral/longer battle .start() const state = await s.useMove(0).runTurn() diff --git a/packages/pokemon/src/__tests__/creature.test.ts b/packages/pokemon/src/__tests__/creature.test.ts index f5288c788..fb72b3f5e 100644 --- a/packages/pokemon/src/__tests__/creature.test.ts +++ b/packages/pokemon/src/__tests__/creature.test.ts @@ -46,12 +46,14 @@ describe('generateCreature', () => { describe('calculateStats', () => { test('level 1 stats are reasonable', async () => { const c = await generateCreature('bulbasaur', 0) + // Use deterministic nature to avoid flaky test from randomNature() + c.nature = 'hardy' const stats = calculateStats(c) // HP at lv1: floor((2*45 + iv + floor(0/4)) * 1/100) + 1 + 10 // With any IV: floor((90 + iv) / 100) + 11 = 0 + 11 = 11 expect(stats.hp).toBeGreaterThanOrEqual(11) expect(stats.hp).toBeLessThanOrEqual(12) - // Attack: floor((2*49 + iv) * 1/100) + 5 = 0 + 5 = 5 + // Attack with Hardy (neutral): floor((2*49 + iv) * 1/100 + 5) expect(stats.attack).toBeGreaterThanOrEqual(5) expect(stats.attack).toBeLessThanOrEqual(6) }) @@ -70,9 +72,11 @@ describe('calculateStats', () => { test('EVs affect stats', async () => { const c = await generateCreature('pikachu', 0) - const statsNoEV = calculateStats(c) + // Level must be high enough for EV contribution to be visible in stat formula + const c50 = { ...c, level: 50 } + const statsNoEV = calculateStats(c50) - const cWithEV = { ...c, ev: { ...c.ev, attack: 252 } } + const cWithEV = { ...c50, ev: { ...c50.ev, attack: 252 } } const statsWithEV = calculateStats(cWithEV) expect(statsWithEV.attack).toBeGreaterThan(statsNoEV.attack)