时间:整理时间方法

This commit is contained in:
luying
2021-05-08 19:13:44 +08:00
parent 6f03a96c51
commit 78e3c26a7a
51 changed files with 662 additions and 411 deletions
@@ -9,6 +9,7 @@ import { ExpeditionWarRecordModel } from '../db/ExpeditionWarRecord';
import { HeroType } from '../db/Hero';
import { gameData } from '../pubUtils/data';
import { getPlayerAttribute, getRobotAttribute } from './pvpService';
import { getTimeFunD } from '../pubUtils/timeUtil';
/**
* 根据存下的战力获取当前远征关卡的对手
@@ -167,9 +168,8 @@ export async function matchRobots(scale: number, myCe: number, robotCe: number,
export async function getCEScaleAndRange(roleId: string, curDicExpedition: any) {
// 匹配,判断是不是新手期
const role = await RoleModel.findByRoleId(roleId);
let now = new Date();
let today = now.setHours(0, 0, 0, 0);;
let isNew = today - role.createdAt.getTime() <= 3*24*60*60*1000;
let timef = getTimeFunD(role.createdAt)
let isNew = timef.getDayGap() <= 3;
let scale = isNew?curDicExpedition.CEScaleNew:curDicExpedition.CEScale;
let range = isNew?curDicExpedition.CERangeNew:curDicExpedition.CERange;
return {scale, range, lv: role.lv}
@@ -206,7 +206,7 @@ export async function getResetRemainCnt(curTime: Date, roleId: string, role?: Ro
}
let { expeditionResetCnt, expeditionResetRefTime } = role;
let needRefresh = !expeditionResetRefTime || shouldRefresh(expeditionResetRefTime, curTime, EXPEDITION_CONST.REFRESH_TIME);
let needRefresh = !expeditionResetRefTime || shouldRefresh(expeditionResetRefTime, curTime);
if(needRefresh) {
expeditionResetCnt = 0; expeditionResetRefTime = curTime;
}