From bfd14206a9b9882aeb69cf35180a08bff1b29fda Mon Sep 17 00:00:00 2001 From: claude-code-best Date: Wed, 22 Apr 2026 08:37:03 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20BattleView=20?= =?UTF-8?q?=E6=B8=B2=E6=9F=93=20@pkmn/sim=20=E5=8E=9F=E5=A7=8B=20move=20?= =?UTF-8?q?=E5=AF=B9=E8=B1=A1=E5=AF=BC=E8=87=B4=E7=9A=84=20React=20?= =?UTF-8?q?=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit projectPokemon 中 moveSlots 的 name 字段可能为 undefined, 导致整个对象被当作 React child 渲染。现在优先从 Dex 查询招式名称。 Co-Authored-By: Claude Opus 4.6 --- packages/pokemon/src/battle/engine.ts | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/packages/pokemon/src/battle/engine.ts b/packages/pokemon/src/battle/engine.ts index fbc425faf..ed3b29498 100644 --- a/packages/pokemon/src/battle/engine.ts +++ b/packages/pokemon/src/battle/engine.ts @@ -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),