refactor(talents): 重构天赋数值与消耗配置结构
- 将 TalentInfo 中的 `valuePerLevel` 和 `getValue` 方法替换为显式的 `values` 数组 - 将全局的 `costPerLevel` 数组替换为每个天赋独立的 `costs` 数组 - 更新 TalentsComp 逻辑以使用新的配置结构
This commit is contained in:
@@ -172,14 +172,14 @@ export class TalentsComp extends CCComp {
|
||||
}
|
||||
|
||||
if (lblDesc) {
|
||||
let currentVal = talentInfo.getValue(currentLevel);
|
||||
let currentVal = currentLevel === 0 ? 0 : talentInfo.values[currentLevel - 1];
|
||||
lblDesc.string = talentInfo.desc.replace('{value}', currentVal.toString());
|
||||
}
|
||||
|
||||
if (lblLevel) lblLevel.string = `Lv.${currentLevel}`;
|
||||
|
||||
let isMax = currentLevel >= talentInfo.maxLevel;
|
||||
let cost = isMax ? 0 : TalentConfig.costPerLevel[currentLevel];
|
||||
let cost = isMax ? 0 : talentInfo.costs[currentLevel];
|
||||
let points = smc.collection.talent_points || 0;
|
||||
|
||||
if (lblCost) {
|
||||
@@ -229,8 +229,11 @@ export class TalentsComp extends CCComp {
|
||||
let refundedPoints = 0;
|
||||
for (let id in collection.talents) {
|
||||
let level = collection.talents[id];
|
||||
for (let i = 0; i < level; i++) {
|
||||
refundedPoints += TalentConfig.costPerLevel[i];
|
||||
let talentInfo = TalentConfig.talents.find(t => t.id === Number(id));
|
||||
if (talentInfo) {
|
||||
for (let i = 0; i < level; i++) {
|
||||
refundedPoints += talentInfo.costs[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user