feat(评分系统): 添加游戏评分标准配置和结算逻辑

添加 ScoreSet.ts 配置文件定义评分权重和等级阈值
在 VictoryComp.ts 中实现总分计算逻辑,根据战斗行为、伤害、击杀等多项指标计算最终得分
This commit is contained in:
walkpan
2026-01-03 23:28:31 +08:00
parent 3ed0a2ebac
commit 190cbc4281
2 changed files with 94 additions and 0 deletions

View File

@@ -9,6 +9,7 @@ import { HeroAttrsComp } from "../hero/HeroAttrsComp";
import { HeroViewComp } from "../hero/HeroViewComp";
import { FacSet } from "../common/config/GameSet";
import { Attrs } from "../common/config/HeroAttrs";
import { ScoreWeights } from "../common/config/ScoreSet";
const { ccclass, property } = _decorator;
@@ -53,6 +54,51 @@ export class VictoryComp extends CCComp {
this.node.getChildByName("btns").getChildByName("next").active=!args.can_revive
this.node.getChildByName("btns").getChildByName("alive").active=args.can_revive
// 只有在不能复活(彻底结算)时才计算总分
if (!this.canRevive) {
this.calculateTotalScore();
}
}
/**
* 计算单局总分并更新到 smc.scores.score
*/
private calculateTotalScore() {
const s = smc.vmdata.scores;
let totalScore = 0;
// 1. 战斗行为分
totalScore += s.crt_count * ScoreWeights.CRT_KILL;
totalScore += s.wf_count * ScoreWeights.WF_TRIGGER;
totalScore += s.dod_count * ScoreWeights.DODGE_SUCCESS;
totalScore += s.back_count * ScoreWeights.BACK_SUCCESS;
totalScore += s.stun_count * ScoreWeights.STUN_SUCCESS;
totalScore += s.freeze_count * ScoreWeights.FREEZE_SUCCESS;
// 2. 伤害转化分
totalScore += s.total_dmg * ScoreWeights.DMG_FACTOR;
totalScore += s.avg_dmg * ScoreWeights.AVG_DMG_FACTOR;
totalScore += s.thorns_dmg * ScoreWeights.THORNS_DMG_FACTOR;
totalScore += s.crit_dmg_total * ScoreWeights.CRIT_DMG_FACTOR;
// 3. 击杀得分
totalScore += s.melee_kill_count * ScoreWeights.KILL_MELEE;
totalScore += s.remote_kill_count * ScoreWeights.KILL_REMOTE;
totalScore += s.elite_kill_count * ScoreWeights.KILL_ELITE;
totalScore += s.boss_kill_count * ScoreWeights.KILL_BOSS;
// 4. 生存得分
totalScore += s.heal_total * ScoreWeights.HEAL_FACTOR;
totalScore += s.lifesteal_total * ScoreWeights.LIFESTEAL_FACTOR;
// 5. 资源得分
totalScore += s.exp_total * ScoreWeights.EXP_FACTOR;
totalScore += s.gold_total * ScoreWeights.GOLD_FACTOR;
// 更新总分(向下取整)
s.score = Math.floor(totalScore);
console.log(`[VictoryComp] 结算总分: ${s.score}`);
}