fix: 修复测试因 IV/性格非确定性导致的间歇失败

- battle-scenarios: 回合测试改用 pikachu vs pikachi 避免非确定性一击倒
- creature: EV 测试提升至 level 50 以确保 EV 贡献可见
- creature: level 1 stat 测试使用确定性 Hardy 性格避免 flaky

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
claude-code-best
2026-04-24 08:57:04 +08:00
parent 192221eafc
commit c5c7202348
2 changed files with 9 additions and 5 deletions

View File

@@ -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()

View File

@@ -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)