mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-22 08:15:53 +00:00
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:
46
packages/pokemon/src/ui/SwitchPanel.tsx
Normal file
46
packages/pokemon/src/ui/SwitchPanel.tsx
Normal 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>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user