feat(score): 新增亮点成就系统并集成至结算评分
- 添加亮点成就配置文件,定义九类成就及其等级阈值、奖励分数和称号 - 在游戏得分统计数据结构中增加已达成亮点记录字段 - 实现亮点成就判定逻辑,根据玩家表现计算达成的最高等级 - 将亮点成就奖励分数计入总分计算,并在结算界面展示前三个亮点 - 新增动画资源用于界面表现
This commit is contained in:
@@ -32,6 +32,7 @@ import { Attrs } from "../common/config/HeroAttrs";
|
||||
import { HeroInfo } from "../common/config/heroSet";
|
||||
import { CKind } from "../common/config/CardSet";
|
||||
import { ScoreWeights } from "../common/config/ScoreSet";
|
||||
import { HighlightSet, HighlightType, HighlightLevel } from "../common/config/HighlightSet";
|
||||
import { mLogger } from "../common/Logger";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
@@ -349,17 +350,60 @@ export class VictoryComp extends CCComp {
|
||||
});
|
||||
}
|
||||
|
||||
// ======================== 得分计算 ========================
|
||||
/**
|
||||
* 获取满足条件的最高等级的亮点成就
|
||||
* @param type 亮点类型
|
||||
* @param value 玩家实际达成的值
|
||||
* @returns 达成的最高等级配置,未达成返回 null
|
||||
*/
|
||||
private getHighestHighlightLevel(type: HighlightType, value: number): HighlightLevel | null {
|
||||
const config = HighlightSet[type];
|
||||
if (!config || !config.levels) return null;
|
||||
|
||||
let highest: HighlightLevel | null = null;
|
||||
for (const levelConfig of config.levels) {
|
||||
if (value >= levelConfig.threshold) {
|
||||
highest = levelConfig;
|
||||
}
|
||||
}
|
||||
return highest;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算并获取所有达成的最高亮点配置数组,用于加分和UI展示
|
||||
*/
|
||||
private getAchievedHighlights(s: any): { type: HighlightType, config: HighlightLevel, value: number }[] {
|
||||
const achieved: { type: HighlightType, config: HighlightLevel, value: number }[] = [];
|
||||
|
||||
// 计算辅助比例
|
||||
const refreshRatio = s.refresh_count > 0 ? (s.refresh_hit_count / s.refresh_count) : 0;
|
||||
const goldRatio = s.gold_earned > 0 ? (s.gold_spent / s.gold_earned) : 0;
|
||||
|
||||
// 判定表:每个维度对应的值
|
||||
const checkList: { type: HighlightType, value: number }[] = [
|
||||
{ type: HighlightType.CritMaster, value: s.crt_count },
|
||||
{ type: HighlightType.DeathExpert, value: s.dead_trigger_count },
|
||||
{ type: HighlightType.IronWall, value: s.shield_block_count },
|
||||
{ type: HighlightType.WindStorm, value: s.wf_count },
|
||||
{ type: HighlightType.OneHitKill, value: Math.floor(s.highest_dmg) },
|
||||
{ type: HighlightType.HealingLight, value: Math.floor(s.heal_total) },
|
||||
{ type: HighlightType.PerfectClear, value: (s.passed_wave_20 && s.wave_all_alive_count >= 20) ? 1 : 0 },
|
||||
{ type: HighlightType.LuckyKing, value: refreshRatio },
|
||||
{ type: HighlightType.ThriftyPlayer, value: goldRatio }
|
||||
];
|
||||
|
||||
for (const item of checkList) {
|
||||
const levelConfig = this.getHighestHighlightLevel(item.type, item.value);
|
||||
if (levelConfig) {
|
||||
achieved.push({ type: item.type, config: levelConfig, value: item.value });
|
||||
}
|
||||
}
|
||||
|
||||
return achieved;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算单局总分并更新到 smc.vmdata.scores.score。
|
||||
*
|
||||
* 得分维度:
|
||||
* 1. 战斗行为分 —— 暴击次数、连击触发、闪避、格挡、眩晕、冻结
|
||||
* 2. 伤害转化分 —— 总伤害、平均伤害、反伤、暴击伤害
|
||||
* 3. 击杀得分 —— 近战击杀、远程击杀、精英击杀、Boss 击杀
|
||||
* 4. 生存得分 —— 治疗量、吸血量
|
||||
* 5. 资源得分 —— 经验获取、金币获取
|
||||
*/
|
||||
private calculateTotalScore() {
|
||||
const s = smc.vmdata.scores;
|
||||
@@ -389,14 +433,25 @@ export class VictoryComp extends CCComp {
|
||||
const refreshRatio = s.refresh_count > 0 ? (s.refresh_hit_count / s.refresh_count) : 0;
|
||||
s.score_efficiency = Math.floor(goldRatio * 100) + Math.floor(refreshRatio * 50);
|
||||
|
||||
// 6. 亮点成就额外加分 (按等级叠加)
|
||||
const achieved = this.getAchievedHighlights(s);
|
||||
s.achieved_highlights = achieved; // 记录已达成的亮点信息
|
||||
|
||||
let highlightBonus = 0;
|
||||
for (const item of achieved) {
|
||||
highlightBonus += item.config.scoreBonus;
|
||||
}
|
||||
|
||||
// 取整并存储
|
||||
s.score = Math.floor(s.score_combat + s.score_output + s.score_defense + s.score_build + s.score_efficiency);
|
||||
s.score = Math.floor(s.score_combat + s.score_output + s.score_defense + s.score_build + s.score_efficiency + highlightBonus);
|
||||
mLogger.log(this.debugMode, 'VictoryComp', `[VictoryComp] 结算总分: ${s.score}`, {
|
||||
combat: s.score_combat,
|
||||
output: s.score_output,
|
||||
defense: s.score_defense,
|
||||
build: s.score_build,
|
||||
efficiency: s.score_efficiency
|
||||
efficiency: s.score_efficiency,
|
||||
highlightBonus: highlightBonus,
|
||||
achievedHighlights: achieved
|
||||
});
|
||||
}
|
||||
|
||||
@@ -446,40 +501,26 @@ export class VictoryComp extends CCComp {
|
||||
this.highlights_container.removeAllChildren();
|
||||
|
||||
const s = smc.vmdata.scores;
|
||||
const tags: { name: string, desc: string }[] = [];
|
||||
// 获取所有已达成的亮点(包含对应等级的信息)
|
||||
const achievedList = s.achieved_highlights || [];
|
||||
|
||||
// 按照 scoring-system.md 设计的触发条件判定
|
||||
if (s.crt_count >= 40) tags.push({ name: "🔥 暴击大师", desc: `暴击${s.crt_count}次` });
|
||||
if (s.dead_trigger_count >= 25) tags.push({ name: "💀 送死达人", desc: `死亡触发${s.dead_trigger_count}次` });
|
||||
if (s.shield_block_count >= 30) tags.push({ name: "🛡️ 铁壁铜墙", desc: `格挡${s.shield_block_count}次` });
|
||||
if (s.wf_count >= 20) tags.push({ name: "⚡ 风暴之王", desc: `风怒${s.wf_count}次` });
|
||||
if (s.highest_dmg >= 200) tags.push({ name: "🎯 一击必杀", desc: `单次伤害${Math.floor(s.highest_dmg)}` });
|
||||
if (s.heal_total >= 500) tags.push({ name: "💊 治愈之光", desc: `治疗总量${Math.floor(s.heal_total)}` });
|
||||
// 最多显示前3个亮点(如有优先级需求,可在截取前对 achievedList 进行排序)
|
||||
const displayTags = achievedList.slice(0, 3);
|
||||
|
||||
// 🏆 完美通关:通关且20回合全员存活
|
||||
if (s.passed_wave_20 && s.wave_all_alive_count >= 20) {
|
||||
tags.push({ name: "🏆 完美通关", desc: "20回合全胜" });
|
||||
}
|
||||
|
||||
// 效率类判定
|
||||
const refreshRatio = s.refresh_count > 0 ? (s.refresh_hit_count / s.refresh_count) : 0;
|
||||
if (refreshRatio >= 0.8) {
|
||||
tags.push({ name: "🎲 欧皇附体", desc: `刷新命中率${Math.floor(refreshRatio * 100)}%` });
|
||||
}
|
||||
|
||||
const goldRatio = s.gold_earned > 0 ? (s.gold_spent / s.gold_earned) : 0;
|
||||
if (goldRatio >= 0.95) {
|
||||
tags.push({ name: "💰 节俭玩家", desc: `金币使用率${Math.floor(goldRatio * 100)}%` });
|
||||
}
|
||||
|
||||
// 最多显示前3个亮点
|
||||
const displayTags = tags.slice(0, 3);
|
||||
displayTags.forEach(tag => {
|
||||
displayTags.forEach(item => {
|
||||
const tagNode = instantiate(this.highlight_prefab);
|
||||
// 尝试获取自身或者名为 "label" 的子节点上的 Label 组件
|
||||
const lab = tagNode.getComponent(Label) || tagNode.getChildByName("label")?.getComponent(Label);
|
||||
|
||||
if (lab) {
|
||||
lab.string = `${tag.name} (${tag.desc})`;
|
||||
// 获取主配置和等级配置
|
||||
const typeConfig = HighlightSet[item.type];
|
||||
const levelConfig = item.config;
|
||||
|
||||
// 格式化描述(替换占位符 {0} 为实际所需达成的阈值或当前值)
|
||||
let descStr = levelConfig.desc.replace("{0}", levelConfig.threshold.toString());
|
||||
|
||||
// 显示:[图标] 称号 (描述)
|
||||
lab.string = `${typeConfig.icon} ${levelConfig.title} (${descStr})`;
|
||||
}
|
||||
this.highlights_container.addChild(tagNode);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user