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/BattleBuffActiveSkillUtil.ts

214 lines
9.7 KiB

import { BattleBuffFunctionType } from './BattleBuffTypes';
import {
parseBattleBuffAttackSpeedConfig,
parseBattleBuffBindNetDuration,
parseBattleBuffConfuseHeroDuration,
parseBattleBuffFireTrapConfig,
parseBattleBuffRandomLevelConfig,
parseBattleBuffRecyclePeachCount,
parseBattleBuffUnitLevelDelta,
type BattleBuffAttackSpeedConfig,
type BattleBuffFireTrapConfig,
type BattleBuffRandomLevelConfig,
} from './BattleBuffParamParse';
/** 战斗 skill 拖拽施放类型 */
export enum BattleGameSkillDragKind {
/** 拖到己方单位升级 */
UnitLevelUp = 1,
/** 拖到怪物行走格布置缚仙网 */
BindNet = 2,
/** 拖到字块/单格武将回收换蟠桃 */
RecycleToPeach = 3,
/** 拖到字块随机升/降级(授仙箓) */
RandomLevel = 4,
/** 拖到单字改字(文昌笔) */
RewriteGlyph = 5,
/** 拖到单字/组合字,提升对应攻击单位攻速(攻速符) */
AttackSpeedGlobal = 6,
/** 拖到单字/组合字,提升对应远程攻击单位射程(千里眼) */
AttackRangeGlobal = 7,
/** 拖到怪物行走格布置火焰陷阱(三昧真火) */
FireTrap = 8,
/** 拖到我方出怪口额外召唤 Boss(万神幡) */
ExtraBoss = 9,
/** 拖到敌方神将迷惑停攻(幻魂镜) */
ConfuseHero = 10,
/** 拖到敌方未合成武将散字或普通单字偷取(妙手神偷;不可偷合成武将/空地/武器字/背包) */
StealGlyph = 11,
}
/** 战斗 skill 点击施放类型 */
export enum BattleGameSkillClickKind {
}
/** 是否为主动「拖到单位升级」buff(functiontype=2;已部署合成武将补剩余升级经验) */
export function isBattleBuffDragUnitLevelUp(row: ITableBattlebuff | null | undefined): boolean {
if (!row) return false;
return Number(row.functiontype) === BattleBuffFunctionType.UnitLevelUp;
}
/** 是否为主动「缚仙网」buff(functiontype=4) */
export function isBattleBuffDragBindNet(row: ITableBattlebuff | null | undefined): boolean {
if (!row) return false;
return Number(row.functiontype) === BattleBuffFunctionType.BindNet;
}
/** 是否为主动「乾坤袋」buff(functiontype=5) */
export function isBattleBuffDragRecycleToPeach(row: ITableBattlebuff | null | undefined): boolean {
if (!row) return false;
return Number(row.functiontype) === BattleBuffFunctionType.RecycleToPeach;
}
/** 是否为主动「授仙箓」buff(functiontype=7;已部署合成武将升级补剩余经验) */
export function isBattleBuffDragRandomLevel(row: ITableBattlebuff | null | undefined): boolean {
if (!row) return false;
return Number(row.functiontype) === BattleBuffFunctionType.RandomLevel;
}
/** 是否为主动「文昌笔」buff(functiontype=11) */
export function isBattleBuffDragRewriteGlyph(row: ITableBattlebuff | null | undefined): boolean {
if (!row) return false;
return Number(row.functiontype) === BattleBuffFunctionType.RewriteGlyph;
}
/** 是否为主动「攻速符」buff(functiontype=17,type=1 主动槽) */
export function isBattleBuffDragAttackSpeedGlobal(row: ITableBattlebuff | null | undefined): boolean {
if (!row) return false;
if (Number(row.functiontype) !== BattleBuffFunctionType.AttackSpeed) return false;
return Number(row.type) === 1;
}
/** 是否为主动「千里眼」buff(functiontype=18,type=1 主动槽) */
export function isBattleBuffDragRangeGlobal(row: ITableBattlebuff | null | undefined): boolean {
if (!row) return false;
if (Number(row.functiontype) !== BattleBuffFunctionType.Range) return false;
return Number(row.type) === 1;
}
/** 是否为主动「三昧真火」buff(functiontype=24,type=1 主动槽) */
export function isBattleBuffDragFireTrap(row: ITableBattlebuff | null | undefined): boolean {
if (!row) return false;
if (Number(row.functiontype) !== BattleBuffFunctionType.FireTrap) return false;
return Number(row.type) === 1;
}
/** 是否为主动「七十二变」buff(functiontype=19) */
export function isBattleBuffRandomActive(row: ITableBattlebuff | null | undefined): boolean {
if (!row) return false;
return Number(row.type) === 1 && Number(row.functiontype) === BattleBuffFunctionType.RandomActive;
}
/** 是否为主动「万神幡」buff(functiontype=13,拖到己方出怪口召唤 Boss) */
export function isBattleBuffDragExtraBoss(row: ITableBattlebuff | null | undefined): boolean {
if (!row) return false;
return Number(row.functiontype) === BattleBuffFunctionType.ExtraHero;
}
/** 是否为主动「幻魂镜」buff(functiontype=22,拖到敌方神将迷惑停攻) */
export function isBattleBuffDragConfuseHero(row: ITableBattlebuff | null | undefined): boolean {
if (!row) return false;
return Number(row.functiontype) === BattleBuffFunctionType.ConfuseHero;
}
/** 是否为主动「妙手神偷」buff(functiontype=16,拖到敌方未合成武将散字或普通单字偷取) */
export function isBattleBuffDragStealGlyph(row: ITableBattlebuff | null | undefined): boolean {
if (!row) return false;
return Number(row.functiontype) === BattleBuffFunctionType.StealGlyph;
}
/** 解析 skill 点击类型;不可点击则 null */
export function resolveBattleGameSkillClickKind(_row: ITableBattlebuff | null | undefined): BattleGameSkillClickKind | null {
return null;
}
/** 解析 skill 拖拽类型;不可拖拽则 null */
export function resolveBattleGameSkillDragKind(row: ITableBattlebuff | null | undefined): BattleGameSkillDragKind | null {
if (isBattleBuffDragBindNet(row)) return BattleGameSkillDragKind.BindNet;
if (isBattleBuffDragRecycleToPeach(row)) return BattleGameSkillDragKind.RecycleToPeach;
if (isBattleBuffDragRandomLevel(row)) return BattleGameSkillDragKind.RandomLevel;
if (isBattleBuffDragRewriteGlyph(row)) return BattleGameSkillDragKind.RewriteGlyph;
if (isBattleBuffDragAttackSpeedGlobal(row)) return BattleGameSkillDragKind.AttackSpeedGlobal;
if (isBattleBuffDragRangeGlobal(row)) return BattleGameSkillDragKind.AttackRangeGlobal;
if (isBattleBuffDragFireTrap(row)) return BattleGameSkillDragKind.FireTrap;
if (isBattleBuffDragExtraBoss(row)) return BattleGameSkillDragKind.ExtraBoss;
if (isBattleBuffDragConfuseHero(row)) return BattleGameSkillDragKind.ConfuseHero;
if (isBattleBuffDragStealGlyph(row)) return BattleGameSkillDragKind.StealGlyph;
if (isBattleBuffDragUnitLevelUp(row)) return BattleGameSkillDragKind.UnitLevelUp;
return null;
}
/** 读取主动升级 buff 的等级增量(functionpar 第二段) */
export function readBattleBuffUnitLevelDelta(row: ITableBattlebuff | null | undefined): number {
if (!row) return 0;
const delta = parseBattleBuffUnitLevelDelta(row.functionpar);
if (delta <= 0) {
console.log('[BattleBuff] 主动升级 buff functionpar 缺少等级值', row.id, row.functionpar);
}
return delta;
}
/** 读取授仙箓 buff 随机等级配置 */
export function readBattleBuffRandomLevelConfig(row: ITableBattlebuff | null | undefined): BattleBuffRandomLevelConfig | null {
if (!row) return null;
return parseBattleBuffRandomLevelConfig(row.functionpar);
}
/** 读取缚仙网 buff 网住时长(functionpar 第二段,秒) */
export function readBattleBuffBindNetDuration(row: ITableBattlebuff | null | undefined): number {
if (!row) return 0;
const sec = parseBattleBuffBindNetDuration(row.functionpar);
if (sec <= 0) {
console.log('[BattleBuff] 缚仙网 buff functionpar 缺少网住时长', row.id, row.functionpar);
}
return sec;
}
/** 读取攻速符 buff 配置(functionpar:CD,加成万分比) */
export function readBattleBuffAttackSpeedConfig(row: ITableBattlebuff | null | undefined): BattleBuffAttackSpeedConfig | null {
if (!row) return null;
return parseBattleBuffAttackSpeedConfig(row.functionpar);
}
/** 读取三昧真火 buff 配置(functionpar:CD,伤害上限,陷阱持续时间) */
export function readBattleBuffFireTrapConfig(row: ITableBattlebuff | null | undefined): BattleBuffFireTrapConfig | null {
if (!row) return null;
return parseBattleBuffFireTrapConfig(row.functionpar);
}
/** 读取乾坤袋 buff 回收蟠桃数量(functionpar 第二段) */
export function readBattleBuffRecyclePeachCount(row: ITableBattlebuff | null | undefined): number {
if (!row) return 0;
const count = parseBattleBuffRecyclePeachCount(row.functionpar);
if (count <= 0) {
console.log('[BattleBuff] 乾坤袋 buff functionpar 缺少蟠桃数量', row.id, row.functionpar);
}
return count;
}
/** functionpar 首段为冷却秒数的局内主动 buff functiontype */
export function activeBuffUsesFunctionParCd(functiontype: number): boolean {
const ft = Number(functiontype) || 0;
return ft === BattleBuffFunctionType.UnitLevelUp
|| ft === BattleBuffFunctionType.BindNet
|| ft === BattleBuffFunctionType.RecycleToPeach
|| ft === BattleBuffFunctionType.RandomLevel
|| ft === BattleBuffFunctionType.RewriteGlyph
|| ft === BattleBuffFunctionType.AttackSpeed
|| ft === BattleBuffFunctionType.Range
|| ft === BattleBuffFunctionType.FireTrap
|| ft === BattleBuffFunctionType.ExtraHero
|| ft === BattleBuffFunctionType.ConfuseHero
|| ft === BattleBuffFunctionType.StealGlyph
|| ft === BattleBuffFunctionType.RandomActive;
}
/** 读取幻魂镜 buff 迷幻时长(functionpar 第二段,秒) */
export function readBattleBuffConfuseHeroDuration(row: ITableBattlebuff | null | undefined): number {
if (!row) return 0;
const sec = parseBattleBuffConfuseHeroDuration(row.functionpar);
if (sec <= 0) {
console.log('[BattleBuff] 幻魂镜 buff functionpar 缺少迷幻时长', row.id, row.functionpar);
}
return sec;
}