mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-15 12:55:51 +00:00
fix: 修复 BattleView 渲染 @pkmn/sim 原始 move 对象导致的 React 报错
projectPokemon 中 moveSlots 的 name 字段可能为 undefined, 导致整个对象被当作 React child 渲染。现在优先从 Dex 查询招式名称。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -95,14 +95,17 @@ function projectPokemon(pkm: any): BattlePokemon {
|
||||
hp,
|
||||
maxHp,
|
||||
types: species.types?.map((t: string) => t.toLowerCase()) ?? [],
|
||||
moves: (pkm.moveSlots ?? pkm.baseMoveset ?? []).filter(Boolean).map((m: any) => ({
|
||||
id: toID(m.name ?? m),
|
||||
name: m.name ?? m,
|
||||
type: m.type ?? 'Normal',
|
||||
pp: m.pp ?? 0,
|
||||
maxPp: m.maxPp ?? m.pp ?? 0,
|
||||
disabled: m.disabled ?? false,
|
||||
})),
|
||||
moves: (pkm.moveSlots ?? pkm.baseMoveset ?? []).filter(Boolean).map((m: any) => {
|
||||
const moveName = typeof m === 'string' ? m : (m.name ?? m.move?.name ?? Dex.moves.get(m.id ?? m.move)?.name ?? String(m.id ?? '???'))
|
||||
return {
|
||||
id: toID(moveName),
|
||||
name: moveName,
|
||||
type: m.type ?? Dex.moves.get(m.id ?? toID(moveName))?.type?.toLowerCase() ?? 'normal',
|
||||
pp: m.pp ?? 0,
|
||||
maxPp: m.maxPp ?? m.pp ?? 0,
|
||||
disabled: m.disabled ?? false,
|
||||
}
|
||||
}),
|
||||
ability: pkm.ability ?? '',
|
||||
heldItem: pkm.item ?? null,
|
||||
status: mapStatus(pkm.status),
|
||||
|
||||
Reference in New Issue
Block a user