import { BattleBuffFunctionType, BattleBuffSlotType } from '../BattleBuffTypes'; import type { IBattleBuffEffectContext, IBattleBuffEffectHandler, IBattleBuffInstantResult } from '../BattleBuffEffectTypes'; import { parseBattleBuffVigourDelta } from '../BattleBuffParamParse'; import { BattleBuffVigourFloatView } from '../BattleBuffVigourFloatView'; /** functiontype=1 + type=3:抽中即加体力 */ export class BattleBuffVigourEffectHandler implements IBattleBuffEffectHandler { /** @inheritdoc */ readonly functionType = BattleBuffFunctionType.Vigour; /** @inheritdoc */ isInstant(row: ITableBattlebuff): boolean { if (Number(row.functiontype) !== BattleBuffFunctionType.Vigour) return false; return Math.floor(Number(row.type) || 0) === BattleBuffSlotType.Auto; } /** @inheritdoc */ applyInstant(row: ITableBattlebuff, ctx: IBattleBuffEffectContext): IBattleBuffInstantResult { const delta = parseBattleBuffVigourDelta(row.functionpar); if (delta <= 0) { console.log('[BattleBuff] 体力 buff 参数无效', row.id, row.functionpar); return { applied: false }; } gg.data.addVigour(delta); gg.data.saveLocal(); BattleBuffVigourFloatView.play(delta, ctx.floatParent, ctx.floatWorldPos ?? null); console.log(`[BattleBuff] 即时体力 +${delta} id=${row.id} source=${ctx.source}`); return { applied: true }; } }