You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
AdLike2048/assets/script/manager/battleBuff/handlers/BattleBuffVigourEffectHandl...

31 lines
1.4 KiB

import { BattleBuffFunctionType, BattleBuffSlotType } from '../BattleBuffTypes';
import type { IBattleBuffEffectContext, IBattleBuffEffectHandler, IBattleBuffInstantResult } from '../BattleBuffEffectTypes';
import { parseBattleBuffVigourDelta } from '../BattleBuffParamParse';
import { BattleBuffVigourFloatView } from '../BattleBuffVigourFloatView';
/** functiontype=15 + 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 };
}
}