🦄 refactor(热更新): 分割状态代码和功能代码

This commit is contained in:
luying
2023-05-05 15:42:00 +08:00
parent 50a24cb4b8
commit a362a397b5
39 changed files with 676 additions and 622 deletions
@@ -1,23 +1,8 @@
import { COM_BTL_CONST, COM_TEAM_STATUS } from '../../consts';
import { gameData, getBossHpByBlueprtId, getDicBlueprtById } from '../../pubUtils/data';
import { COM_TEAM_STATUS } from '../../consts';
import { getBossHpByBlueprtId, getDicBlueprtById } from '../../pubUtils/data';
import ComBattleTeam from './../../db/ComBattleTeam';
import { cloneDeep } from 'lodash'
import { FriendParams } from '../roleField/friend';
import { nowSeconds } from '../../pubUtils/timeUtil';
import moment = require('moment');
/**
* 拷贝敌军数组并添加当前血量字段
* @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);
}
import { transBossHpArr } from '../../pubUtils/battleUtils';
export class MemComBtlTeam extends ComBattleTeam {
@@ -50,13 +35,6 @@ export class MemComBtlTeam extends ComBattleTeam {
findMemberByRoleId(roleId: string) {
return this.roleStatus.find(cur => cur.roleId == roleId);
}
startTeam() {
this.status = COM_TEAM_STATUS.FIGHTING;
this.startTime = nowSeconds();
this.endTime = nowSeconds() + COM_BTL_CONST.BTL_TIME_LMT/1000;
this.hasTimeExtraReward = isComBattleTimeLimit();
}
};
@@ -75,18 +53,3 @@ export class MemComBtlTeam extends ComBattleTeam {
this.status = comBattle.status;
}
}
/**
* 当前是否是有加成的特殊时间
*/
export function isComBattleTimeLimit() {
let arr = gameData.comBattleRewardTime;
for(let { from, to } of arr) {
let fromTime = moment(moment().format(`YYYY-MM-DD ${from}`)).valueOf();
let toTime = moment(moment().format(`YYYY-MM-DD ${to}`)).valueOf();
let now = moment().valueOf();
if(fromTime <= now && toTime >= now) return true;
}
return false;
}