feat: Phase 3 — 战斗 UI 终端交互组件

- BattleConfigPanel: 战斗前配置(队伍展示 + 对手选择)
- BattleView: 战斗主界面(双方 HP + 招式选择 + 事件日志)
- SwitchPanel: 换人选择面板
- ItemPanel: 道具使用面板
- BattleResultPanel: 战斗结算展示
- MoveLearnPanel: 新招式学习面板
- HP 条颜色分级(绿/黄/红)
- 事件日志中文格式化

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
claude-code-best
2026-04-22 00:37:26 +08:00
parent a3fc348421
commit f5a97011e8
7 changed files with 375 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
import React from 'react'
import { Box, Text } from '@anthropic/ink'
import type { Creature } from '../types'
import { getCreatureName } from '../core/creature'
import { calculateStats } from '../core/creature'
const CYAN = 'ansi:cyan'
const GREEN = 'ansi:green'
const YELLOW = 'ansi:yellow'
const RED = 'ansi:red'
const GRAY = 'ansi:white'
const WHITE = 'ansi:whiteBright'
interface SwitchPanelProps {
party: Creature[]
activeId: string
onSelect: (creatureId: string) => void
onCancel: () => void
}
export function SwitchPanel({ party, activeId, onSelect, onCancel }: SwitchPanelProps) {
return (
<Box flexDirection="column" borderStyle="round" paddingX={1}>
<Text bold color={CYAN}> </Text>
{party.map((creature, i) => {
const stats = calculateStats(creature)
const isActive = creature.id === activeId
const hpPct = 100 // No current HP tracking in v2, assume full
const hpColor = hpPct > 50 ? GREEN : hpPct > 25 ? YELLOW : RED
return (
<Box key={creature.id}>
<Text>{isActive ? ' ▶ ' : ' '}</Text>
<Text color={isActive ? GRAY : WHITE}>
[{i + 1}] {getCreatureName(creature)} (Lv.{creature.level}){' '}
</Text>
{isActive && <Text color={GRAY}> </Text>}
</Box>
)
})}
<Box marginTop={1}>
<Text color={GRAY}> [ESC] </Text>
</Box>
</Box>
)
}