feat(评分系统): 添加游戏评分标准配置和结算逻辑
添加 ScoreSet.ts 配置文件定义评分权重和等级阈值 在 VictoryComp.ts 中实现总分计算逻辑,根据战斗行为、伤害、击杀等多项指标计算最终得分
This commit is contained in:
48
assets/script/game/common/config/ScoreSet.ts
Normal file
48
assets/script/game/common/config/ScoreSet.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* 游戏评分标准配置
|
||||
* 定义各统计指标的分数权重
|
||||
*/
|
||||
export const ScoreWeights = {
|
||||
// ========== 战斗行为权重 ==========
|
||||
CRT_KILL: 5, // 每次暴击得分
|
||||
WF_TRIGGER: 10, // 每次风怒得分
|
||||
DODGE_SUCCESS: 20, // 每次闪避得分
|
||||
BACK_SUCCESS: 5, // 每次击退得分
|
||||
STUN_SUCCESS: 8, // 每次击晕得分
|
||||
FREEZE_SUCCESS: 8, // 每次冰冻得分
|
||||
|
||||
// ========== 伤害权重 ==========
|
||||
// 总伤害转化分 (每 X 点伤害得 1 分)
|
||||
DMG_FACTOR: 0.01,
|
||||
// 平均伤害加成 (每点平均伤害得 X 分)
|
||||
AVG_DMG_FACTOR: 0.5,
|
||||
// 反伤伤害转化 (每点反伤得 X 分)
|
||||
THORNS_DMG_FACTOR: 0.02,
|
||||
// 暴击伤害转化 (每点暴击伤害得 X 分)
|
||||
CRIT_DMG_FACTOR: 0.015,
|
||||
|
||||
// ========== 击杀权重 ==========
|
||||
KILL_MELEE: 10, // 普通近战怪击杀
|
||||
KILL_REMOTE: 15, // 远程怪击杀
|
||||
KILL_ELITE: 100, // 精英怪击杀
|
||||
KILL_BOSS: 1000, // Boss击杀
|
||||
|
||||
// ========== 生存权重 ==========
|
||||
HEAL_FACTOR: 0.2, // 治疗量转化分
|
||||
LIFESTEAL_FACTOR: 0.3, // 吸血量转化分
|
||||
|
||||
// ========== 资源权重 ==========
|
||||
EXP_FACTOR: 0.1, // 经验值转化分
|
||||
GOLD_FACTOR: 0.5, // 金币转化分
|
||||
};
|
||||
|
||||
/**
|
||||
* 评分等级阈值
|
||||
*/
|
||||
export enum ScoreRank {
|
||||
S = 10000,
|
||||
A = 5000,
|
||||
B = 2000,
|
||||
C = 1000,
|
||||
D = 0
|
||||
}
|
||||
@@ -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}`);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user