fix: 蛋孵化步数改用真实 hatchCounter 数据

- 孵化步数从 captureRate 反推改为 hatchCounter * 257(原版公式)
- getHatchCounter 支持进化阶段/传说回退分类
- fetch-pokedex-data.ts 已更新以采集 hatchCounter 字段
- 解决 #17 蛋系统孵化步数不准确

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
claude-code-best
2026-04-24 08:56:45 +08:00
parent e16b5667a8
commit c37b274406

View File

@@ -1,7 +1,7 @@
import { randomUUID } from 'node:crypto'
import type { BuddyData, Creature, Egg, SpeciesId } from '../types'
import { ALL_SPECIES_IDS } from '../types'
import { getSpeciesData } from '../dex/species'
import { getHatchCounter } from '../dex/pokedex-data'
import { generateCreature } from './creature'
import { addToParty, depositToBox } from './storage'
@@ -34,9 +34,9 @@ export function generateEgg(buddyData: BuddyData): Egg {
? uncollected[Math.floor(Math.random() * uncollected.length)]
: starters[Math.floor(Math.random() * starters.length)]
// Steps based on rarity (capture rate: lower = rarer = more steps)
const species = getSpeciesData(speciesId)
const baseSteps = Math.floor(2000 + ((255 - species.captureRate) / 255) * 3000)
// Steps based on real hatch_counter from PokeAPI (steps = cycles * 257)
const hatchCounter = getHatchCounter(speciesId)
const baseSteps = hatchCounter * 257
return {
id: randomUUID(),