refactor(MissionHeroComp): 移除闲置的驻场技能总加成计算方法
This commit is contained in:
33
assets/script/game/hero/FieldSkillHelper.ts
Normal file
33
assets/script/game/hero/FieldSkillHelper.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||
import { FacSet } from "../common/config/GameSet";
|
||||
import { HeroInfo } from "../common/config/heroSet";
|
||||
import { FieldSkillSet, FieldSkillType } from "../common/config/SkillSet";
|
||||
import { HeroAttrsComp } from "./HeroAttrsComp";
|
||||
|
||||
/**
|
||||
* 驻场技能(光环属性)计算辅助类
|
||||
*
|
||||
* 核心职责:
|
||||
* 统一管理全场存活英雄带来的全局加成属性计算。
|
||||
* 解耦原先写在 HeroAttrsComp 中的静态计算逻辑,符合单一职责原则。
|
||||
*/
|
||||
export class FieldSkillHelper {
|
||||
/** 获取指定驻场技能类型的总加成值(只计算存活的友方英雄) */
|
||||
public static getFieldSkillTotalValue(type: FieldSkillType): number {
|
||||
let total = 0;
|
||||
ecs.query(ecs.allOf(HeroAttrsComp)).forEach((entity: ecs.Entity) => {
|
||||
const model = entity.get(HeroAttrsComp);
|
||||
if (!model || model.is_dead || model.fac !== FacSet.HERO) return;
|
||||
const heroConfig = HeroInfo[model.hero_uuid];
|
||||
if (heroConfig && heroConfig.field) {
|
||||
for (const skillUuid of heroConfig.field) {
|
||||
const skillConfig = FieldSkillSet[skillUuid];
|
||||
if (skillConfig && skillConfig.type === type) {
|
||||
total += skillConfig.value;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return total;
|
||||
}
|
||||
}
|
||||
9
assets/script/game/hero/FieldSkillHelper.ts.meta
Normal file
9
assets/script/game/hero/FieldSkillHelper.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "140c8aaf-42b4-4f1c-880a-dd43af7588a2",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import { FacSet, FightSet } from "../common/config/GameSet";
|
||||
import { FieldSkillSet, FieldSkillType } from "../common/config/SkillSet";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
import { TalentConfig, TalentType } from "../common/config/TalentSet";
|
||||
import { FieldSkillHelper } from "./FieldSkillHelper";
|
||||
@ecs.register('HeroAttrs')
|
||||
export class HeroAttrsComp extends ecs.Comp {
|
||||
public debugMode: boolean = false;
|
||||
@@ -203,7 +204,7 @@ export class HeroAttrsComp extends ecs.Comp {
|
||||
|
||||
/** 将驻场配置值统一换算成百分比数值,兼容 0.2 和 20 两种写法。 */
|
||||
private getFieldPercentValue(type: FieldSkillType): number {
|
||||
const rawValue = HeroAttrsComp.getFieldSkillTotalValue(type);
|
||||
const rawValue = FieldSkillHelper.getFieldSkillTotalValue(type);
|
||||
if (Math.abs(rawValue) <= HeroAttrsComp.percentRateThreshold) {
|
||||
return rawValue * 100;
|
||||
}
|
||||
@@ -340,24 +341,7 @@ export class HeroAttrsComp extends ecs.Comp {
|
||||
this.dirty_shield = false;
|
||||
}
|
||||
|
||||
/** 获取指定驻场技能类型的总加成值(只计算存活的英雄) */
|
||||
public static getFieldSkillTotalValue(type: FieldSkillType): number {
|
||||
let total = 0;
|
||||
ecs.query(ecs.allOf(HeroAttrsComp)).forEach((entity: ecs.Entity) => {
|
||||
const model = entity.get(HeroAttrsComp);
|
||||
if (!model || model.is_dead || model.fac !== FacSet.HERO) return;
|
||||
const heroConfig = HeroInfo[model.hero_uuid];
|
||||
if (heroConfig && heroConfig.field) {
|
||||
for (const skillUuid of heroConfig.field) {
|
||||
const skillConfig = FieldSkillSet[skillUuid];
|
||||
if (skillConfig && skillConfig.type === type) {
|
||||
total += skillConfig.value;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return total;
|
||||
}
|
||||
|
||||
|
||||
/** 获取指定天赋的加成数值 */
|
||||
public static getTalentValue(talentId: TalentType): number {
|
||||
|
||||
@@ -6,6 +6,7 @@ import { FacSet } from "../common/config/GameSet";
|
||||
import { FieldSkillType } from "../common/config/SkillSet";
|
||||
import { TalentType } from "../common/config/TalentSet";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
import { FieldSkillHelper } from "./FieldSkillHelper";
|
||||
|
||||
|
||||
/**
|
||||
@@ -65,7 +66,7 @@ export class SkillTriggerHelper {
|
||||
let triggerCount = 1;
|
||||
// 仅英雄享受加成,怪物始终只触发 1 次
|
||||
if (model.fac === FacSet.HERO) {
|
||||
triggerCount += HeroAttrsComp.getFieldSkillTotalValue(FieldSkillType.SummonCount);
|
||||
triggerCount += FieldSkillHelper.getFieldSkillTotalValue(FieldSkillType.SummonCount);
|
||||
triggerCount += HeroAttrsComp.getTalentValue(TalentType.Summon);
|
||||
}
|
||||
triggerCount = Math.max(1, Math.floor(triggerCount)); // 确保最少触发 1 次
|
||||
@@ -84,7 +85,7 @@ export class SkillTriggerHelper {
|
||||
|
||||
let triggerCount = 1;
|
||||
if (model.fac === FacSet.HERO) {
|
||||
triggerCount += HeroAttrsComp.getFieldSkillTotalValue(FieldSkillType.DeadCount);
|
||||
triggerCount += FieldSkillHelper.getFieldSkillTotalValue(FieldSkillType.DeadCount);
|
||||
// 【局内战绩评分系统】统计死亡触发技能生效次数(用于局后防守评分结算)
|
||||
smc.vmdata.scores.dead_trigger_count += model.dead.length;
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ import { Tooltip } from "../skill/Tooltip";
|
||||
import { CardInitCoins } from "../common/config/CardSet";
|
||||
import { Timer } from "db://oops-framework/core/common/timer/Timer";
|
||||
import { FieldSkillType } from "../common/config/SkillSet";
|
||||
import { FieldSkillHelper } from "../hero/FieldSkillHelper";
|
||||
import { spawningEngine } from "./RogueConfig";
|
||||
import { MissionEconomy } from "./MissionEconomy";
|
||||
const { ccclass, property } = _decorator;
|
||||
@@ -579,9 +580,9 @@ export class MissionComp extends CCComp {
|
||||
private triggerHeroBattleSkills(isStart: boolean) {
|
||||
let triggerCount = 1;
|
||||
if (isStart) {
|
||||
triggerCount += HeroAttrsComp.getFieldSkillTotalValue(FieldSkillType.StartCount);
|
||||
triggerCount += FieldSkillHelper.getFieldSkillTotalValue(FieldSkillType.StartCount);
|
||||
} else {
|
||||
triggerCount += HeroAttrsComp.getFieldSkillTotalValue(FieldSkillType.EndCount);
|
||||
triggerCount += FieldSkillHelper.getFieldSkillTotalValue(FieldSkillType.EndCount);
|
||||
}
|
||||
triggerCount = Math.max(1, Math.floor(triggerCount));
|
||||
|
||||
@@ -600,7 +601,7 @@ export class MissionComp extends CCComp {
|
||||
* 战斗结束阶段治疗所有英雄(包括墓地英雄),恢复70%最大生命值
|
||||
*/
|
||||
private healAllHeroes() {
|
||||
const healRateBoost = HeroAttrsComp.getFieldSkillTotalValue(FieldSkillType.WaveHeal);
|
||||
const healRateBoost = FieldSkillHelper.getFieldSkillTotalValue(FieldSkillType.WaveHeal);
|
||||
const finalHealRate = Math.min(1, FightSet.WAVE_HEAL_RATE + healRateBoost);
|
||||
|
||||
ecs.query(this.heroAttrsMatcher).forEach(entity => {
|
||||
|
||||
@@ -5,6 +5,7 @@ import { HeroAttrsComp } from "../hero/HeroAttrsComp";
|
||||
import { FieldSkillType } from "../common/config/SkillSet";
|
||||
import { TalentType } from "../common/config/TalentSet";
|
||||
import { FightSet } from "../common/config/GameSet";
|
||||
import { FieldSkillHelper } from "../hero/FieldSkillHelper";
|
||||
|
||||
/**
|
||||
* 局内经济统一管理类
|
||||
@@ -70,7 +71,7 @@ export class MissionEconomy {
|
||||
*/
|
||||
static getSellGold(): number {
|
||||
const baseSellGold = 1; // 基础卖出金币
|
||||
const goldBoost = HeroAttrsComp.getFieldSkillTotalValue(FieldSkillType.SellGold);
|
||||
const goldBoost = FieldSkillHelper.getFieldSkillTotalValue(FieldSkillType.SellGold);
|
||||
let totalSellGold = baseSellGold + goldBoost;
|
||||
// 应用天赋 SellBonus (增加数值)
|
||||
const bonusGold = HeroAttrsComp.getTalentValue(TalentType.SellBonus);
|
||||
@@ -94,7 +95,7 @@ export class MissionEconomy {
|
||||
*/
|
||||
static getWaveGold(baseReward: number): number {
|
||||
let reward = Math.max(0, Math.floor(baseReward));
|
||||
const goldBoost = HeroAttrsComp.getFieldSkillTotalValue(FieldSkillType.WaveGold);
|
||||
const goldBoost = FieldSkillHelper.getFieldSkillTotalValue(FieldSkillType.WaveGold);
|
||||
reward += goldBoost;
|
||||
return reward;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user