mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-15 12:55:51 +00:00
feat: 支持随机特性选择,包括隐藏特性
- 新增 getAbilities() 返回所有可用特性(含隐藏) - 新增 randomAbility():80% 普通特性、20% 第二特性、5% 隐藏特性 - 保留 getDefaultAbility() 向后兼容 - 解决 #20 Ability 系统不完整 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -51,11 +51,33 @@ export async function getDefaultMoveset(speciesId: SpeciesId, level: number): Pr
|
||||
}
|
||||
|
||||
/** Get the default ability for a species (first non-hidden ability) */
|
||||
/** Get the first non-hidden ability for a species */
|
||||
export function getDefaultAbility(speciesId: SpeciesId): string {
|
||||
const species = Dex.species.get(speciesId)
|
||||
return species?.abilities?.['0']?.toLowerCase() ?? ''
|
||||
}
|
||||
|
||||
/** Get all available abilities for a species (including hidden) */
|
||||
export function getAbilities(speciesId: SpeciesId): { normal: string[]; hidden: string | null } {
|
||||
const species = Dex.species.get(speciesId)
|
||||
if (!species?.exists) return { normal: [], hidden: null }
|
||||
const normal: string[] = []
|
||||
if (species.abilities['0']) normal.push(species.abilities['0'].toLowerCase())
|
||||
if (species.abilities['1']) normal.push(species.abilities['1'].toLowerCase())
|
||||
const hidden = species.abilities['H']?.toLowerCase() ?? null
|
||||
return { normal, hidden }
|
||||
}
|
||||
|
||||
/** Randomly select an ability for a species. Hidden ability has ~5% chance. */
|
||||
export function randomAbility(speciesId: SpeciesId): string {
|
||||
const { normal, hidden } = getAbilities(speciesId)
|
||||
if (normal.length === 0 && !hidden) return ''
|
||||
// 5% chance for hidden ability
|
||||
if (hidden && Math.random() < 0.05) return hidden
|
||||
// Otherwise pick from normal abilities
|
||||
return normal[Math.floor(Math.random() * normal.length)] ?? hidden ?? ''
|
||||
}
|
||||
|
||||
/** Get newly learnable moves when leveling up */
|
||||
export async function getNewLearnableMoves(speciesId: SpeciesId, oldLevel: number, newLevel: number): Promise<{ id: string; name: string }[]> {
|
||||
const learnset = getLearnsetData(speciesId)
|
||||
|
||||
Reference in New Issue
Block a user