mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-23 08:45:50 +00:00
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:
@@ -81,8 +81,8 @@ describe('Battle Scenario: 单回合事件', () => {
|
|||||||
|
|
||||||
battleTest('回合数递增', async () => {
|
battleTest('回合数递增', async () => {
|
||||||
const s = await battleScenario()
|
const s = await battleScenario()
|
||||||
.party('charmander', 50, ['flamethrower'])
|
.party('pikachu', 50, ['thundershock'])
|
||||||
.opponent('squirtle', 50)
|
.opponent('pikachu', 50) // Same type matchup for neutral/longer battle
|
||||||
.start()
|
.start()
|
||||||
|
|
||||||
const state = await s.useMove(0).runTurn()
|
const state = await s.useMove(0).runTurn()
|
||||||
|
|||||||
@@ -46,12 +46,14 @@ describe('generateCreature', () => {
|
|||||||
describe('calculateStats', () => {
|
describe('calculateStats', () => {
|
||||||
test('level 1 stats are reasonable', async () => {
|
test('level 1 stats are reasonable', async () => {
|
||||||
const c = await generateCreature('bulbasaur', 0)
|
const c = await generateCreature('bulbasaur', 0)
|
||||||
|
// Use deterministic nature to avoid flaky test from randomNature()
|
||||||
|
c.nature = 'hardy'
|
||||||
const stats = calculateStats(c)
|
const stats = calculateStats(c)
|
||||||
// HP at lv1: floor((2*45 + iv + floor(0/4)) * 1/100) + 1 + 10
|
// 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
|
// With any IV: floor((90 + iv) / 100) + 11 = 0 + 11 = 11
|
||||||
expect(stats.hp).toBeGreaterThanOrEqual(11)
|
expect(stats.hp).toBeGreaterThanOrEqual(11)
|
||||||
expect(stats.hp).toBeLessThanOrEqual(12)
|
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).toBeGreaterThanOrEqual(5)
|
||||||
expect(stats.attack).toBeLessThanOrEqual(6)
|
expect(stats.attack).toBeLessThanOrEqual(6)
|
||||||
})
|
})
|
||||||
@@ -70,9 +72,11 @@ describe('calculateStats', () => {
|
|||||||
|
|
||||||
test('EVs affect stats', async () => {
|
test('EVs affect stats', async () => {
|
||||||
const c = await generateCreature('pikachu', 0)
|
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)
|
const statsWithEV = calculateStats(cWithEV)
|
||||||
|
|
||||||
expect(statsWithEV.attack).toBeGreaterThan(statsNoEV.attack)
|
expect(statsWithEV.attack).toBeGreaterThan(statsNoEV.attack)
|
||||||
|
|||||||
Reference in New Issue
Block a user