refactor(common prompt,hero box): 优化弹窗绑定逻辑与英雄出售限制
1. 重构CommonPrompt的编辑器属性绑定,添加按钮节点序列化引用并优化兜底查找逻辑 2. 为英雄出售操作添加存活数量校验,场上仅1个英雄时禁止出售 3. 新增统一的存活英雄统计工具方法 4. 补充Claude工具命令配置
This commit is contained in:
@@ -20,7 +20,7 @@ import { GameEvent } from "../common/config/GameEvent";
|
||||
import { HeroInfo } from "../common/config/heroSet";
|
||||
import { HeroAttrsComp } from "../hero/HeroAttrsComp";
|
||||
import { Hero } from "../hero/Hero";
|
||||
import { getLvColor } from "../common/config/GameSet";
|
||||
import { FacSet, getLvColor } from "../common/config/GameSet";
|
||||
import { buildSkillDescRich } from "../common/config/HeroSkillDesc";
|
||||
import { MissionEconomy } from "./MissionEconomy";
|
||||
import { UIID } from "../common/config/GameUIConfig";
|
||||
@@ -189,6 +189,11 @@ export class HeroBoxComp extends CCComp {
|
||||
*/
|
||||
private onSellHeroClick() {
|
||||
if (!this.eid || !this.model) return;
|
||||
// 场上仅剩 1 个英雄时不允许出售(至少保留一个作战单位)
|
||||
if (HeroBoxComp.getAliveHeroCount() <= 1) {
|
||||
oops.gui.toast("至少保留 1 个英雄");
|
||||
return;
|
||||
}
|
||||
oops.audio.playEffect("music/button");
|
||||
|
||||
const heroName = this.model.hero_name ?? "";
|
||||
@@ -453,6 +458,20 @@ export class HeroBoxComp extends CCComp {
|
||||
|
||||
// ======================== 内部工具 ========================
|
||||
|
||||
/**
|
||||
* 统计场上存活英雄数量(与 MissionCardComp.getAliveHeroCount 口径一致)。
|
||||
*/
|
||||
private static getAliveHeroCount(): number {
|
||||
let count = 0;
|
||||
ecs.query(ecs.allOf(HeroAttrsComp)).forEach((entity: ecs.Entity) => {
|
||||
const model = entity.get(HeroAttrsComp);
|
||||
if (model && model.fac === FacSet.HERO) {
|
||||
count++;
|
||||
}
|
||||
});
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* 写入一行战斗信息(总值 + 附加值)。
|
||||
* 总值始终显示(0 不隐藏);附加值为 0 时隐藏,正/负分别显示 (+x) / (x)。
|
||||
|
||||
Reference in New Issue
Block a user