import { BattleBuffFunctionType } from '../../manager/battleBuff/BattleBuffTypes'; import { isBattleBuffPassiveGoldMine } from '../../manager/battleBuff/BattleBuffPassiveSkillUtil'; import type { ProjectBattleHandle } from '../../battle/runtime/BattleRuntime'; import type { BattleGamePassiveSkillHost } from './BattleGamePassiveSkillHost'; /** * 局内被动 buff CD 结束触发(按 functiontype 扩展具体逻辑)。 * 无 CD 的被动为携带即生效,不在此处理。 */ export class BattleGamePassiveSkillRuntime { /** * 被动 buff CD 结束 * @param row Battlebuff 表行 * @param battle 战斗句柄 * @param host 被动 UI / 棋盘上下文 * @param slotIndex ui_selfskill2List 槽位 * @returns 是否已受理本次触发 */ static onPassiveCdReady( row: ITableBattlebuff, battle: ProjectBattleHandle | null, host: BattleGamePassiveSkillHost | null, slotIndex: number, ): boolean { const ft = Math.floor(Number(row.functiontype) || 0); const id = Math.floor(Number(row.id) || 0); if (ft <= 0 || id <= 0) return false; if (!host) { console.log('[PassiveSkill] CD 结束缺少 host', ft, 'id=', id); return false; } if (isBattleBuffPassiveGoldMine(row) || ft === BattleBuffFunctionType.GoldMine) { return BattleGamePassiveSkillRuntime._onGoldMineReady(battle, host, slotIndex); } console.log('[PassiveSkill] CD 结束未实现 functiontype', ft, 'id=', id); return false; } /** * 金矿:本机 +1 金币、飞币表现并重开 CD。 * @param battle 战斗 * @param host 被动 host * @param slotIndex 槽位 */ private static _onGoldMineReady( battle: ProjectBattleHandle | null, host: BattleGamePassiveSkillHost, slotIndex: number, ): boolean { if (!battle) { console.log('[PassiveSkill] 金矿缺少 battle'); return false; } battle.addPlayerGold(battle.localPlayerId, 1); host.notifyGoldMineCoinFly(slotIndex); host.restartPassiveCd(slotIndex); return true; } }