diff --git a/assets/script/game/common/SingletonModuleComp.ts b/assets/script/game/common/SingletonModuleComp.ts index c50dabb2..9476f73c 100644 --- a/assets/script/game/common/SingletonModuleComp.ts +++ b/assets/script/game/common/SingletonModuleComp.ts @@ -509,7 +509,7 @@ export class SingletonModuleComp extends ecs.Comp { if (curLv >= cfg.max_lv) return false; // 阶位解锁:二/三阶天赋要求前一阶累计投入点数达标(一阶恒解锁) if (!isTalentTierUnlocked(this.data.talents, cfg.tier)) return false; - const cost = getTalentUpgradeCost(curLv); + const cost = getTalentUpgradeCost(cfg.tier); if (cost < 0 || this.getTalentPoints() < cost) return false; this.data.talent_points -= cost; this.data.talents[uuid] = curLv + 1; diff --git a/assets/script/game/common/config/TalentSet.ts b/assets/script/game/common/config/TalentSet.ts index 5170b09a..eaf15e5e 100644 --- a/assets/script/game/common/config/TalentSet.ts +++ b/assets/script/game/common/config/TalentSet.ts @@ -272,17 +272,20 @@ export const TalentSet: Record = { }, }; -/** 天赋升级消耗:索引为当前等级(0 表示升到 1 级),返回所需天赋点数 */ -export const TALENT_UPGRADE_COST: number[] = [1, 1, 2, 2, 3]; +/** 天赋升级消耗:按阶位统一消耗,同一阶内每级消耗相同 */ +export const TALENT_UPGRADE_COST: Record = { + [TalentTier.Basic]: 1, // 基础天赋:1 点升 1 级 + [TalentTier.Specialized]: 2, // 专精天赋:2 点升 1 级 + [TalentTier.Super]: 2, // 传说天赋:2 点升 1 级 +}; /** * 查询升级所需天赋点数 - * @param curLv 当前等级 - * @returns 升到下一级所需点数;已满级返回 -1 + * @param tier 天赋所属阶位 + * @returns 升 1 级所需点数;非法阶位返回 -1 */ -export function getTalentUpgradeCost(curLv: number): number { - if (curLv < 0 || curLv >= TALENT_UPGRADE_COST.length) return -1; - return TALENT_UPGRADE_COST[curLv]; +export function getTalentUpgradeCost(tier: TalentTier): number { + return TALENT_UPGRADE_COST[tier] ?? -1; } /** 天赋等级上限(不含):等级从 0 起步,区间 0~29,共 30 级;每升 1 级产出 1 点天赋点 */ @@ -309,7 +312,7 @@ export function getTalentLevelExp(curLv: number): number { export const TALENT_TIER_UNLOCK_THRESHOLD = 10; /** - * 计算指定阶位已投入的天赋点数(按升级消耗表逐级累加)。 + * 计算指定阶位已投入的天赋点数(按该阶统一消耗 × 等级累加)。 * Why: 阶位解锁按"实际消耗点数"而非"等级总和"口径——与玩家直觉(投入了多少点) * 及重置退款口径(resetTalents 同表对账)保持一致。 * @param levels 天赋等级表(key 为天赋 uuid,value 为当前等级) @@ -318,14 +321,13 @@ export const TALENT_TIER_UNLOCK_THRESHOLD = 10; */ export function getTalentTierInvestedPoints(levels: Record, tier: TalentTier): number { if (!levels) return 0; + const cost = getTalentUpgradeCost(tier); + if (cost <= 0) return 0; let invested = 0; for (const key in levels) { const cfg = TalentSet[key]; if (!cfg || cfg.tier !== tier) continue; - for (let i = 0; i < levels[key]; i++) { - const c = getTalentUpgradeCost(i); - if (c > 0) invested += c; - } + invested += levels[key] * cost; } return invested; } diff --git a/assets/script/game/map/TalentsComp.ts b/assets/script/game/map/TalentsComp.ts index fac607a2..f6b3cf18 100644 --- a/assets/script/game/map/TalentsComp.ts +++ b/assets/script/game/map/TalentsComp.ts @@ -260,7 +260,7 @@ export class TalentsComp extends CCComp { this.showSmallTip(tab?.node ?? null, "该天赋已满级"); return; } - const cost = getTalentUpgradeCost(lv); + const cost = getTalentUpgradeCost(cfg.tier); if (cost <= 0) return; if (smc.getTalentPoints() < cost) { this.showSmallTip(tab?.node ?? null, "天赋点不足");