47 lines
1.5 KiB
TypeScript
47 lines
1.5 KiB
TypeScript
import { COM_TEAM_STATUS } from '../../consts';
|
|
import { getBossHpByBlueprtId, getDicBlueprtById } from '../../pubUtils/data';
|
|
import ComBattleTeam from './../../db/ComBattleTeam';
|
|
import { cloneDeep } from 'lodash'
|
|
|
|
/**
|
|
* 拷贝敌军数组并添加当前血量字段
|
|
* @param source 原敌军数组,不包含当前血量字段
|
|
*/
|
|
export function transBossHpArr(source: Array<{ dataId: number, hp: number, actorId: number }>): Array<{ dataId: number, hp: number, curHp: number, actorId: number }> {
|
|
let desArr = [];
|
|
source.forEach(elem => {
|
|
let { hp } = elem;
|
|
desArr.push(Object.assign(elem, { curHp: hp }));
|
|
});
|
|
return cloneDeep(desArr);
|
|
}
|
|
|
|
|
|
export class MemComBtlTeam extends ComBattleTeam {
|
|
bossCurHp: number;
|
|
curRnd: number;
|
|
bossHp: number;
|
|
sid: string;
|
|
|
|
constructor(teamCode: string, pub: boolean, blueprtId: number, capId: string, ceLimit: number, sid: string) {
|
|
super();
|
|
const { lv } = getDicBlueprtById(blueprtId);
|
|
this.lv = lv;
|
|
const { bossHpSum, bossHpArr } = getBossHpByBlueprtId(blueprtId);
|
|
this.bossHpArr = transBossHpArr(bossHpArr);
|
|
this.teamCode = teamCode;
|
|
this.pub = pub;
|
|
this.blueprtId = blueprtId;
|
|
this.status = COM_TEAM_STATUS.DEFAULT;
|
|
this.capId = capId;
|
|
this.ceLimit = ceLimit;
|
|
this.curRnd = 0;
|
|
this.roleCnt = 1;
|
|
this.timeout = false;
|
|
this.bossCurHp = bossHpSum;
|
|
this.bossHp = bossHpSum;
|
|
this.blacklist = [];
|
|
this.sid = sid;
|
|
}
|
|
};
|