mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-22 16:25:51 +00:00
refactor: 提取共享 getStatColor、移除 deprecated EVOLUTION_CHAINS
- 新增 ui/shared.ts 统一 getStatColor 函数 - CompanionCard/SpeciesDetail 改用共享函数,消除重复 - 移除 data/evolution.ts 中已废弃的 EVOLUTION_CHAINS 常量 - 清理 index.ts 导出 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -2,6 +2,8 @@ import { Dex } from '@pkmn/sim'
|
|||||||
import type { SpeciesId } from '../types'
|
import type { SpeciesId } from '../types'
|
||||||
import { ALL_SPECIES_IDS } from '../types'
|
import { ALL_SPECIES_IDS } from '../types'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export interface EvolutionChainStep {
|
export interface EvolutionChainStep {
|
||||||
from: SpeciesId
|
from: SpeciesId
|
||||||
to: SpeciesId
|
to: SpeciesId
|
||||||
@@ -33,13 +35,3 @@ export function getNextEvolution(speciesId: SpeciesId): EvolutionChainStep | und
|
|||||||
minLevel: targetDex.evoLevel ?? undefined,
|
minLevel: targetDex.evoLevel ?? undefined,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @deprecated Use getNextEvolution() instead. Kept for backward compat. */
|
|
||||||
export const EVOLUTION_CHAINS: EvolutionChainStep[] = (() => {
|
|
||||||
const chains: EvolutionChainStep[] = []
|
|
||||||
for (const id of ALL_SPECIES_IDS) {
|
|
||||||
const evo = getNextEvolution(id)
|
|
||||||
if (evo) chains.push(evo)
|
|
||||||
}
|
|
||||||
return chains
|
|
||||||
})()
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ export { DEFAULT_EV_MAPPING, getEVForTool, MAX_EV_PER_STAT, MAX_EV_TOTAL } from
|
|||||||
export { xpForLevel, levelFromXp, xpToNextLevel } from './data/xpTable'
|
export { xpForLevel, levelFromXp, xpToNextLevel } from './data/xpTable'
|
||||||
export { SPECIES_NAMES, SPECIES_I18N, SPECIES_PERSONALITY } from './data/names'
|
export { SPECIES_NAMES, SPECIES_I18N, SPECIES_PERSONALITY } from './data/names'
|
||||||
export { getAllNatureNames, randomNature, getNatureEffect } from './data/nature'
|
export { getAllNatureNames, randomNature, getNatureEffect } from './data/nature'
|
||||||
export { getNextEvolution, EVOLUTION_CHAINS } from './data/evolution'
|
export { getNextEvolution } from './data/evolution'
|
||||||
export { getDefaultMoveset, getDefaultAbility, getNewLearnableMoves } from './data/learnsets'
|
export { getDefaultMoveset, getDefaultAbility, getNewLearnableMoves } from './data/learnsets'
|
||||||
export { FROM_DEX_STAT, TO_DEX_STAT } from './data/pkmn'
|
export { FROM_DEX_STAT, TO_DEX_STAT } from './data/pkmn'
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import { calculateStats, getCreatureName, getTotalEV } from '../core/creature'
|
|||||||
import { getXpProgress } from '../core/experience'
|
import { getXpProgress } from '../core/experience'
|
||||||
import { getEVSummary } from '../core/effort'
|
import { getEVSummary } from '../core/effort'
|
||||||
import { getGenderSymbol } from '../core/gender'
|
import { getGenderSymbol } from '../core/gender'
|
||||||
|
import { getStatColor } from './shared'
|
||||||
import { getNextEvolution } from '../data/evolution'
|
import { getNextEvolution } from '../data/evolution'
|
||||||
import { StatBar } from './StatBar'
|
import { StatBar } from './StatBar'
|
||||||
|
|
||||||
@@ -156,15 +157,3 @@ export function CompanionCard({ creature, buddyData, spriteLines }: CompanionCar
|
|||||||
</Box>
|
</Box>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function getStatColor(stat: string): Color {
|
|
||||||
const colors: Record<string, Color> = {
|
|
||||||
hp: 'ansi:green',
|
|
||||||
attack: 'ansi:red',
|
|
||||||
defense: 'ansi:yellow',
|
|
||||||
spAtk: 'ansi:blue',
|
|
||||||
spDef: 'ansi:magenta',
|
|
||||||
speed: 'ansi:cyan',
|
|
||||||
}
|
|
||||||
return colors[stat] ?? 'ansi:white'
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { getSpeciesData } from '../data/species'
|
|||||||
import { SPECIES_PERSONALITY } from '../data/names'
|
import { SPECIES_PERSONALITY } from '../data/names'
|
||||||
import { getNextEvolution } from '../data/evolution'
|
import { getNextEvolution } from '../data/evolution'
|
||||||
import { StatBar } from './StatBar'
|
import { StatBar } from './StatBar'
|
||||||
|
import { getStatColor } from './shared'
|
||||||
|
|
||||||
const CYAN: Color = 'ansi:cyan'
|
const CYAN: Color = 'ansi:cyan'
|
||||||
const GRAY: Color = 'ansi:white'
|
const GRAY: Color = 'ansi:white'
|
||||||
@@ -184,10 +185,3 @@ function isInChain(target: SpeciesId, head: SpeciesId): boolean {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
function getStatColor(stat: string): Color {
|
|
||||||
const colors: Record<string, Color> = {
|
|
||||||
hp: 'ansi:green', attack: 'ansi:red', defense: 'ansi:yellow',
|
|
||||||
spAtk: 'ansi:blue', spDef: 'ansi:magenta', speed: 'ansi:cyan',
|
|
||||||
}
|
|
||||||
return colors[stat] ?? 'ansi:white'
|
|
||||||
}
|
|
||||||
|
|||||||
14
packages/pokemon/src/ui/shared.ts
Normal file
14
packages/pokemon/src/ui/shared.ts
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
import type { Color } from '@anthropic/ink'
|
||||||
|
|
||||||
|
const STAT_COLORS: Record<string, Color> = {
|
||||||
|
hp: 'ansi:green',
|
||||||
|
attack: 'ansi:red',
|
||||||
|
defense: 'ansi:yellow',
|
||||||
|
spAtk: 'ansi:blue',
|
||||||
|
spDef: 'ansi:magenta',
|
||||||
|
speed: 'ansi:cyan',
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getStatColor(stat: string): Color {
|
||||||
|
return STAT_COLORS[stat] ?? 'ansi:white'
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user