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

This commit is contained in:
luying
2023-04-28 20:09:40 +08:00
parent 50a24cb4b8
commit a362a397b5
39 changed files with 676 additions and 622 deletions

View File

@@ -1,5 +1,8 @@
import * as crc from 'crc';
import { md5 } from './sdkUtil';
import { gameData } from './data';
import moment = require('moment');
import { cloneDeep } from 'lodash';
const BATTLE_CLASS_MOD = 100; // 存档分类模数
const CDN_URL_PREFIX_SQ = 'https://download-sgzzyz.yev242.com'; // sq cdn 服务器地址前缀
@@ -79,4 +82,32 @@ export function getLocalImgUrl(curEnv: string, type: string) {
export function getRemoteImgUrl(curEnv: string, fileName: string, type: string) {
const rplUrl = `${getPrefixByEnv(curEnv)}/img/${type}/` + fileName;
return rplUrl;
}
/**
* 寻宝当前是否是有加成的特殊时间
*/
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;
}
/**
* 拷贝敌军数组并添加当前血量字段
* @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);
}