refactor(game): 调整场上英雄数量机制为固定3人

1. 重构GameSet配置,移除HERO_MAX_NUM新增HERO_FIELD_NUM定义场上固定编制
2. 移除局内英雄上限相关的冗余数据与校验逻辑,玩家无法主动扩充英雄数量
3. 更新所有引用旧英雄上限配置的代码,统一使用新的固定编制常量
4. 调整抽卡、阵容计算等相关逻辑适配新的英雄数量规则
This commit is contained in:
panFD
2026-08-23 17:15:46 +08:00
parent fb2c67ccab
commit 8c81be7592
4 changed files with 13 additions and 50 deletions

View File

@@ -7,7 +7,8 @@
* 抽卡规则:从基础英雄卡池按权重抽取,同一次抽卡内英雄不重复;
* 过滤已上场英雄(卡池不足时自动回退,保证能抽满)。
* 2. **金币费用管理** —— 抽卡费用refreshCost的扣除。
* 3. **英雄数量上限校验** —— 在 UseHeroCard 事件的 guard 阶段判断是否允许再召唤英雄。
* 3. **英雄数量由机制固定** —— 开局 3 次免费三选一召唤满 3 个英雄,玩家无法扩充,
* UseHeroCard 事件的 guard 入口保留但不再做满员拦截。
* 4. **场上英雄信息面板HInfoComp 列表)同步** ——
* 英雄上场时实例化面板,死亡时移除,定时刷新属性显示。
* 5. **特殊卡执行** —— 处理英雄升级卡SpecialUpgrade按 UUID 精确升级)和
@@ -35,7 +36,7 @@
* - HInfoComp —— 英雄信息面板
* - CardSet 模块 —— 卡池配置、抽卡规则、特殊卡数据
* - HeroAttrsComp —— 英雄属性(升级)
* - smc.vmdata.mission_data —— 局内数据coin / hero_num / hero_max_num
* - smc.vmdata.mission_data —— 局内数据coin / hero_num
*/
import { mLogger } from "../common/Logger";
import { _decorator, instantiate, Label, Node, NodeEventType, Prefab, Tween, tween, Vec3, UITransform, Widget } from "cc";
@@ -324,8 +325,6 @@ export class MissionCardComp extends CCComp {
if (missionData) {
missionData.coin = Math.max(0, Math.floor(missionData.coin ?? 0));
missionData.hero_num = 0;
missionData.hero_max_num = FightSet.HERO_MAX_NUM;
missionData.hero_extend_max_num = FightSet.HERO_MAX_NUM + 1;
}
// 确保卡牌组件列表已被正确缓存
@@ -812,24 +811,13 @@ export class MissionCardComp extends CCComp {
/**
* 使用英雄卡的 guard 校验(由 CHeroComp 通过 UseHeroCard 事件调用):
* - 当前英雄数 < 上限 → 允许使用。
* - 已满 → 阻止使用cancel=true弹 toast
*
* 注意:英雄不再支持合成腾位,满员时一律阻止。
* 英雄数量由开局 3 次三选一固定,玩家无法主动扩充,此 guard 不再做满员拦截,
* 仅保留事件入口兼容 CHeroComp 的调用契约
*/
private onUseHeroCard(event: string, args: any) {
const payload = args ?? event;
if (!payload) return;
const current = this.getAliveHeroCount();
this.syncMissionHeroData(current);
const heroMax = this.getMissionHeroMaxNum();
if (current >= heroMax) {
payload.cancel = true;
payload.reason = "hero_limit";
this.showSmallTip("hero_full", "英雄队伍已满");
this.playHeroNumDeniedAnim();
}
this.syncMissionHeroData();
}
/**
@@ -2088,28 +2076,8 @@ export class MissionCardComp extends CCComp {
if (num && num.isValid) this.playHeroNumNodePop(num, peak);
}
public setHeroMaxCount(max: number) {
const missionData = this.getMissionData();
if (!missionData) return;
const min = FightSet.HERO_MAX_NUM;
const limit = Math.max(min, missionData.hero_extend_max_num ?? (FightSet.HERO_MAX_NUM + 1));
const next = Math.max(min, Math.min(limit, Math.floor(max || min)));
if (next === missionData.hero_max_num) return;
missionData.hero_max_num = next;
this.updateHeroNumUI(true, false);
}
public tryExpandHeroMax(add: number = 1): boolean {
const missionData = this.getMissionData();
if (!missionData) return false;
const before = this.getMissionHeroMaxNum();
const next = before + Math.max(0, Math.floor(add));
this.setHeroMaxCount(next);
return this.getMissionHeroMaxNum() > before;
}
public canUseHeroCard(): boolean {
return this.getAliveHeroCount() < this.getMissionHeroMaxNum();
return true;
}
private getAliveHeroCount(): number {
@@ -2300,10 +2268,6 @@ export class MissionCardComp extends CCComp {
return Math.max(0, Math.floor(missionData?.hero_num ?? 0));
}
private getMissionHeroMaxNum(): number {
return FightSet.HERO_MAX_NUM
}
private syncMissionHeroData(count?: number) {
const missionData = this.getMissionData();
if (!missionData) return;