时间:整理时间方法

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
+7 -6
View File
@@ -1,11 +1,11 @@
import { HeroModel } from './../db/Hero';
import { HangUpRecordModel } from './../db/HangUpRecord';
import { pinus } from 'pinus';
import { HANG_UP_CONSTS, TOWER_TASK_CONST, REDIS_KEY, TASK_TYPE } from './../consts';
import { HANG_UP_CONSTS, TOWER_TASK_CONST, REDIS_KEY, TASK_TYPE, TIME_OUTPUT_TYPE } from './../consts';
import { BattleRecordModel } from './../db/BattleRecord';
import { TowerRecordModel } from './../db/TowerRecord';
import { RoleModel } from './../db/Role';
import { shouldRefresh, resResult, cal, getRandEelmWithWeight, getRefTime } from '../pubUtils/util';
import { shouldRefresh, resResult, cal, getRandEelmWithWeight } from '../pubUtils/util';
import { STATUS } from '../consts/statusCode';
import { HangUpSpdUpRecModel } from '../db/HangUpSpdUpRec';
import { TowerTaskRecModel } from '../db/TowerTaskRec';
@@ -14,6 +14,7 @@ import { Rank } from './rankService';
import { checkTask } from './taskService';
import { getRandExpedition, gameData } from '../pubUtils/data';
import { ItemInter, RewardInter } from '../pubUtils/interface';
import { getTimeFunM } from '../pubUtils/timeUtil';
export async function checkTowerWar(roleId: string, battleId: number, heroes: Array<number>) {
let { towerLv } = await RoleModel.findByRoleId(roleId);
@@ -113,7 +114,7 @@ async function startHangUp(roleId: string, roleName: string) {
export async function checkHangUpSpdUpCnt(roleId: string, cnt: number, curTime: Date) {
const role = await RoleModel.findByRoleId(roleId);
let {hangUpSpdUpCnt, gold, lastSpdUpTime} = role;
if (!lastSpdUpTime || (shouldRefresh(lastSpdUpTime, curTime, HANG_UP_CONSTS.REFRESH_TIME, 1) && hangUpSpdUpCnt <= HANG_UP_CONSTS.MAX_SPD_UP_CNT)) {
if (!lastSpdUpTime || (shouldRefresh(lastSpdUpTime, curTime) && hangUpSpdUpCnt <= HANG_UP_CONSTS.MAX_SPD_UP_CNT)) {
hangUpSpdUpCnt = HANG_UP_CONSTS.MAX_SPD_UP_CNT;
}
if (cnt > hangUpSpdUpCnt) {
@@ -145,7 +146,7 @@ export async function calcuHangUpReward(roleId: string, speedUp = false, speedUp
}
if (speedUp) { // 加速,直接收取6小时收益,小数的累积和普通收取独立
if (hangUpSpdUpCnt >= speedUpCnt || !lastSpdUpTime || shouldRefresh(lastSpdUpTime, new Date, HANG_UP_CONSTS.REFRESH_TIME, 1)) { // 可加速
if (hangUpSpdUpCnt >= speedUpCnt || !lastSpdUpTime || shouldRefresh(lastSpdUpTime, new Date)) { // 可加速
let multi = Math.floor(HANG_UP_CONSTS.SPD_UP_REC_TIME / HANG_UP_CONSTS.UNIT_TIME);
let spdUpRec = await HangUpSpdUpRecModel.getSpdUpRec(roleId, towerLv - 1);
let goods = [];
@@ -293,8 +294,8 @@ export async function createCurTasks(towerLv: number, batchCode: string, roleId:
}
export function getRemainTime(curTime: Date) {
let nextTime = getRefTime(curTime, TOWER_TASK_CONST.REFRESH_TIME, 1);
return Math.floor((nextTime.getTime() - curTime.getTime())/1000);
let nextTime = <number>getTimeFunM(curTime).getAfterDayWithHour(1);
return Math.floor((nextTime - curTime.getTime())/1000);
}
export function treatTask(recs: Array<any>, curTime: Date) {