时间:整理时间方法
This commit is contained in:
@@ -4,7 +4,7 @@ import { LOT_CODE_LEN, AUCTION_STAGE, AUCTION_TIME, DIVIDEND_CODE_LEN, DIVIDEND_
|
||||
import { DividendRec, ItemReward } from "../domain/dbGeneral";
|
||||
import { genCode, resResult } from '../pubUtils/util';
|
||||
import { LotModel, LotParam } from '../db/Lot';
|
||||
import { getNextTime, getTodayZeroDate, getZeroDateByDeltaDay } from '../pubUtils/timeUtil';
|
||||
import { getZeroPointD, getTimeFunD } from '../pubUtils/timeUtil';
|
||||
import { gameData, getGoodById } from '../pubUtils/data';
|
||||
import { DividendParam, DividendType } from '../db/Dividend';
|
||||
import { pushMail } from '../pubUtils/interface';
|
||||
@@ -53,31 +53,31 @@ export async function officialAuctionLots(session: BackendSession, begin: Date)
|
||||
}
|
||||
|
||||
export function auctionBegin() {
|
||||
return getNextTime(new Date(), AUCTION_TIME.GUILD_BEGIN_HOUR, AUCTION_TIME.GUILD_BEGIN_MIN);
|
||||
return <Date>getTimeFunD().getAfterDayWithHour(0, AUCTION_TIME.GUILD_BEGIN_HOUR, AUCTION_TIME.GUILD_BEGIN_MIN);
|
||||
}
|
||||
|
||||
export function guildAuctionEnd() {
|
||||
return getNextTime(new Date(), AUCTION_TIME.GUILD_END_HOUR, AUCTION_TIME.GUILD_END_MIN);
|
||||
return <Date>getTimeFunD().getAfterDayWithHour(0, AUCTION_TIME.GUILD_END_HOUR, AUCTION_TIME.GUILD_END_MIN);
|
||||
}
|
||||
|
||||
export function auctionEnd() {
|
||||
return getNextTime(new Date(), AUCTION_TIME.WORLD_END_HOUR, AUCTION_TIME.WORLD_END_MIN);
|
||||
export function auctionEnd() {
|
||||
return <Date>getTimeFunD().getAfterDayWithHour(0, AUCTION_TIME.WORLD_END_HOUR, AUCTION_TIME.WORLD_END_MIN);
|
||||
}
|
||||
|
||||
export function todayGuildBegin() {
|
||||
return getNextTime(getTodayZeroDate(), AUCTION_TIME.GUILD_BEGIN_HOUR, AUCTION_TIME.GUILD_BEGIN_MIN);
|
||||
return <Date>getTimeFunD(getZeroPointD()).getAfterDayWithHour(0, AUCTION_TIME.GUILD_BEGIN_HOUR, AUCTION_TIME.GUILD_BEGIN_MIN);
|
||||
}
|
||||
|
||||
export function yestodayGuildBegin() {
|
||||
return getNextTime(getZeroDateByDeltaDay(-1), AUCTION_TIME.GUILD_BEGIN_HOUR, AUCTION_TIME.GUILD_BEGIN_MIN);
|
||||
export function yestodayGuildBegin() {
|
||||
return <Date>getTimeFunD(getZeroPointD()).getAfterDayWithHour(-1, AUCTION_TIME.GUILD_BEGIN_HOUR, AUCTION_TIME.GUILD_BEGIN_MIN);
|
||||
}
|
||||
|
||||
export function todayWorldBegin() {
|
||||
return getNextTime(getTodayZeroDate(), AUCTION_TIME.WORLD_BEGIN_HOUR, AUCTION_TIME.WORLD_BEGIN_MIN);
|
||||
return <Date>getTimeFunD(getZeroPointD()).getAfterDayWithHour(0, AUCTION_TIME.WORLD_BEGIN_HOUR, AUCTION_TIME.WORLD_BEGIN_MIN);
|
||||
}
|
||||
|
||||
export function todayWorldEnd() {
|
||||
return getNextTime(getTodayZeroDate(), AUCTION_TIME.WORLD_END_HOUR, AUCTION_TIME.WORLD_END_MIN);
|
||||
return <Date>getTimeFunD(getZeroPointD()).getAfterDayWithHour(0, AUCTION_TIME.WORLD_END_HOUR, AUCTION_TIME.WORLD_END_MIN);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -24,6 +24,7 @@ import { checkTaskInComBattleEnd } from './taskService';
|
||||
import { getRewardByBlueprtId, gameData, comBtlRangeByLv, getBossHpByBlueprtId } from '../pubUtils/data';
|
||||
import { getFriendPointObject } from '../pubUtils/itemUtils';
|
||||
import { DicWar } from '../pubUtils/dictionary/DicWar';
|
||||
import { getZeroPointD } from '../pubUtils/timeUtil';
|
||||
|
||||
/**
|
||||
* 在给定的品质列表中随机返回一定数量的藏宝图Id
|
||||
@@ -170,7 +171,7 @@ export async function getRealReward(blueprtId: number, roleSt: RoleStatus) {
|
||||
}
|
||||
|
||||
export async function getAssistTimesByQuality(roleId: string, qualityArr?: number[]) {
|
||||
let teams = await ComBattleTeamModel.getAssistTeamsByTime(roleId, qualityArr, new Date(new Date().setHours(0, 0, 0, 0)), true);
|
||||
let teams = await ComBattleTeamModel.getAssistTeamsByTime(roleId, qualityArr, getZeroPointD(), true);
|
||||
let cntMap = new Map<number, number>();
|
||||
teams.forEach(team => {
|
||||
if (team && team.quality && team.roleStatus) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
import { DonationModel } from '../db/Donation';
|
||||
import { getTodayZeroPoint, nowSeconds } from '../pubUtils/timeUtil';
|
||||
import { getZeroPoint, nowSeconds } from '../pubUtils/timeUtil';
|
||||
import { GuildModel } from '../db/Guild';
|
||||
import { findWhere } from 'underscore';
|
||||
import { GUILD_STRUCTURE } from '../consts/constModules/guildConst';
|
||||
@@ -14,7 +14,7 @@ export async function getDonation(code: string, serverId: number) {
|
||||
if (!donation) {
|
||||
donation = await createDonation(code, serverId);
|
||||
}
|
||||
if (donation.refTime < getTodayZeroPoint()) {
|
||||
if (donation.refTime < getZeroPoint()) {
|
||||
let { structure } = await GuildModel.findGuild(code, serverId, 'structure');
|
||||
let { lv } = findWhere(structure, {id: GUILD_STRUCTURE.DONATE});
|
||||
donation = await DonationModel.updateDonation(code, { donateFund:0, reports:[], refTime: nowSeconds(), donationLv: lv});
|
||||
|
||||
@@ -11,7 +11,7 @@ import { DUNGEON_CONST } from '../consts';
|
||||
export async function checkDungeonNum(roleId: string, inc: number) {
|
||||
let { dungeonCnt = 0, dungeonBuyCnt = 0, dungeonRefTime } = await RoleModel.findByRoleId(roleId);
|
||||
let curTime = new Date();
|
||||
let needRefresh = shouldRefresh(dungeonRefTime, curTime, DUNGEON_CONST.REFRESH_TIME);
|
||||
let needRefresh = shouldRefresh(dungeonRefTime, curTime);
|
||||
if(needRefresh) {
|
||||
dungeonCnt = 0; dungeonBuyCnt = 0;
|
||||
}
|
||||
@@ -38,7 +38,7 @@ export async function checkDungeonAndIncrease(roleId: string, inc: number, isRef
|
||||
let { dungeonCnt = 0, dungeonBuyCnt = 0, dungeonRefTime } = await RoleModel.findByRoleId(roleId);
|
||||
let curTime = new Date();
|
||||
|
||||
let needRefresh = isRef && shouldRefresh(dungeonRefTime, curTime, DUNGEON_CONST.REFRESH_TIME);
|
||||
let needRefresh = isRef && shouldRefresh(dungeonRefTime, curTime);
|
||||
if(needRefresh) {
|
||||
dungeonCnt = 0; dungeonBuyCnt = 0;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ import { ActivityModel } from "../db/Activity";
|
||||
import { DicGacha } from "../pubUtils/dictionary/DicGacha";
|
||||
import { UserGachaType, UserGachaModel } from "../db/UserGacha";
|
||||
import { shouldRefresh, getRandEelm, getRandEelmWithWeight } from "../pubUtils/util";
|
||||
import { REFRESH_HOUR, GACHA_TO_FLOOR, GACHA_FLOOR_TYPE, GACHA_CONTENT_TYPE, HERO_QUALITY_TYPE, GACHA_OCCUPY_HID, IT_TYPE, ITID, CONSUME_TYPE, SPECIAL_ATTR } from "../consts";
|
||||
import { getNextDayByGap, getTodayZeroDate } from "../pubUtils/timeUtil";
|
||||
import { REFRESH_TIME, GACHA_TO_FLOOR, GACHA_FLOOR_TYPE, GACHA_CONTENT_TYPE, HERO_QUALITY_TYPE, GACHA_OCCUPY_HID, IT_TYPE, ITID, CONSUME_TYPE, SPECIAL_ATTR, TIME_OUTPUT_TYPE } from "../consts";
|
||||
import { getTimeFunD, getZeroPointD } from "../pubUtils/timeUtil";
|
||||
import { gameData, getDicGachaFloor } from "../pubUtils/data";
|
||||
|
||||
/**
|
||||
@@ -38,13 +38,13 @@ export async function refreshGacha(dicGacha: DicGacha, userGacha: UserGachaType)
|
||||
}
|
||||
|
||||
let { roleId, gachaId, refFreeTime, refHopeTime, hope } = userGacha;
|
||||
if(shouldRefresh(refFreeTime, new Date(), REFRESH_HOUR, day)) {
|
||||
let ref = getNextDayByGap(refFreeTime, new Date(), day);
|
||||
if(shouldRefresh(refFreeTime, new Date(), REFRESH_TIME, day)) {
|
||||
let ref = <Date>getTimeFunD().getAfterDayByGap(refFreeTime, day);
|
||||
userGacha = await UserGachaModel.refreshFreeCount(roleId, gachaId, 0, ref);
|
||||
}
|
||||
if(shouldRefresh(refHopeTime, new Date(), REFRESH_HOUR)) {
|
||||
if(shouldRefresh(refHopeTime, new Date(), REFRESH_TIME)) {
|
||||
hope = hope.map(cur => { return { ...cur, hasGet: false}});
|
||||
let ref = getTodayZeroDate(REFRESH_HOUR);
|
||||
let ref = getZeroPointD();
|
||||
userGacha = await UserGachaModel.refreshHopeCount(roleId, gachaId, 0, hope, ref);
|
||||
}
|
||||
return userGacha
|
||||
|
||||
@@ -12,7 +12,7 @@ import { getGuildChannelSid } from "./chatService";
|
||||
import { pinus } from "pinus";
|
||||
import { getRandEelm, sortArrRandom, resResult } from "../pubUtils/util";
|
||||
import { Rank } from "./rankService";
|
||||
import { getNextHourPoint } from "../pubUtils/timeUtil";
|
||||
import { getTimeFun } from "../pubUtils/timeUtil";
|
||||
|
||||
export class GateActivityObject {
|
||||
private gateHp: Map<string, number> = new Map(); // 城门血条,每个军团有一条血条 guildCode => hp
|
||||
@@ -268,7 +268,8 @@ export class RaceActivityObject {
|
||||
if(woodenHorse.status == 1 || woodenHorse.status == 2) { // 更新距离 // TODO 写进const表
|
||||
let r = new Rank(REDIS_KEY.RACE_ACTIVITY, { serverId }, true, 5);
|
||||
await r.setRank({guildCode}, Math.floor(woodenHorse.distance * 1000), woodenHorse.time - woodenHorse.startTime, false);
|
||||
await r.setExpire(getNextHourPoint(5));
|
||||
let tomorrow = <number>getTimeFun().getAfterDayWithHour();
|
||||
await r.setExpire(tomorrow);
|
||||
if (needSendEnd) { // 抵达后发送奖励,发送消息,结算
|
||||
await sendSingleRaceActEndMsg(guildCode, woodenHorse);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import { RoleModel } from "../db/Role";
|
||||
import { reduceCe } from "../pubUtils/util";
|
||||
import { GUILDACTIVITY } from "../pubUtils/dicParam";
|
||||
import { gameData, getGuildAuctionRewards, getCityActivityRewards } from "../pubUtils/data";
|
||||
import { getCurHourPoint, getCurDay, nowSeconds } from "../pubUtils/timeUtil";
|
||||
import { getCurDay, nowSeconds, getTimeFun } from "../pubUtils/timeUtil";
|
||||
import { GUILD_ACTIVITY_STATUS, GET_POINT_WAYS, GUILD_ACTIVITY_TYPE, REDIS_KEY, AUCTION_SOURCE, MAIL_TYPE, CITY_STATUS } from "../consts";
|
||||
import { Record, UserGuildActivityRecModel } from "../db/UserGuildActivityRec";
|
||||
import { GateMembersRec, CityParam, Member, WoodenHorse } from "../domain/battleField/guildActivity";
|
||||
@@ -92,8 +92,9 @@ export function getGuildActivityStatus(id: number) {
|
||||
}
|
||||
|
||||
export function getGuildActivityByDic(dicGuildActivity: DicGuildActivity) {
|
||||
let startTime = getCurHourPoint(dicGuildActivity.startTime, dicGuildActivity.startMinute, dicGuildActivity.startSeconds);
|
||||
let countdownTime = getCurHourPoint(dicGuildActivity.countDown);
|
||||
let t = getTimeFun();
|
||||
let startTime = <number>t.getTimeWithHour(dicGuildActivity.startTime, dicGuildActivity.startMinute, dicGuildActivity.startSeconds);
|
||||
let countdownTime = <number>t.getTimeWithHour(dicGuildActivity.countDown);
|
||||
let { duringTime, openDay } = dicGuildActivity;
|
||||
let endTime = startTime + duringTime;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { BossInstanceType, BossInstanceModel } from '../db/BossInstance';
|
||||
import { getTodayZeroPoint } from '../pubUtils/timeUtil';
|
||||
import { getZeroPoint } from '../pubUtils/timeUtil';
|
||||
import { lockData } from '../services/redLockService';
|
||||
import { findIndex } from 'underscore';
|
||||
import { MailModel, MailType } from '../db/Mail';
|
||||
@@ -25,14 +25,14 @@ export async function getBossInstanceInfo(bossInstance: BossInstanceType, roleId
|
||||
return b.score - a.score + a.time - b.time;
|
||||
});
|
||||
let result:any = {};
|
||||
if (!!winWarId && winTime > getTodayZeroPoint() && roleIdRecords.indexOf(roleId) == -1) {
|
||||
if (!!winWarId && winTime > getZeroPoint() && roleIdRecords.indexOf(roleId) == -1) {
|
||||
//今日通关过,且首次点开boss界面,提示某某boss已通关
|
||||
result = { showParam: { winWarId, winBossLv } };
|
||||
await BossInstanceModel.recordRoleIdWhenCheck(guildCode, roleId);
|
||||
}
|
||||
if ( bossHp <= 0 ) {
|
||||
result = { warId };
|
||||
if (startTime < getTodayZeroPoint()) {
|
||||
if (startTime < getZeroPoint()) {
|
||||
//今日未开启过boss,等待开启
|
||||
result.status = GUILD_BOSS_STATUS.WAIT_OPEN;
|
||||
return result;
|
||||
@@ -47,7 +47,7 @@ export async function getBossInstanceInfo(bossInstance: BossInstanceType, roleId
|
||||
let lastRanks = ranks.map(({roleId: battleRoleId, score, time}, index) => {
|
||||
if (roleId == battleRoleId) {
|
||||
myRank = { roleId, score, rankLv: index + 1 };
|
||||
if (time >= getTodayZeroPoint())
|
||||
if (time >= getZeroPoint())
|
||||
isBattled = true;
|
||||
}
|
||||
return {roleId, score, rankLv: index + 1};
|
||||
@@ -80,7 +80,7 @@ export async function getBossInstanceWhenEnd(bossInstance: BossInstanceType, rol
|
||||
pushRanks.forEach(({roleId: battleRoleId, score, time}, index) => {
|
||||
if (roleId == battleRoleId) {
|
||||
myRank = {roleId, score, rankLv: index + 1};
|
||||
if (time >= getTodayZeroPoint())
|
||||
if (time >= getZeroPoint())
|
||||
isBattled = true;
|
||||
}
|
||||
return {roleId, score, rankLv: index + 1};
|
||||
|
||||
@@ -119,7 +119,7 @@ export async function getGuildWithRefActive(guildCode: string, serverId: number)
|
||||
const now = new Date();
|
||||
let { activeDaily, refTimeDaily } = guild;
|
||||
|
||||
let isRefDaily = shouldRefresh(refTimeDaily, now, 0);
|
||||
let isRefDaily = shouldRefresh(refTimeDaily, now);
|
||||
if (isRefDaily) {
|
||||
activeDaily = 0; refTimeDaily = now;
|
||||
guild = await GuildModel.updateInfoWithLeader(guildCode, { activeDaily, refTimeDaily }, {});
|
||||
@@ -198,7 +198,7 @@ export async function getUserGuildWithRefActive(roleId: string, select: string,
|
||||
let { receivedActive, refTimeDaily, activeDaily, activeRecord, wishGoods } = userGuild;
|
||||
|
||||
const now = new Date();
|
||||
let isRefDaily = shouldRefresh(refTimeDaily, now, 0);
|
||||
let isRefDaily = shouldRefresh(refTimeDaily, now);
|
||||
if (isRefDaily) {
|
||||
let mails = new Array<MailType>();
|
||||
let pushMessage = new Array<pushMail>();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { UserGuildModel } from '../db/UserGuild';
|
||||
import { getArmyTrainJuDian, getTrainBaseByLv } from '../pubUtils/data';
|
||||
import { nowSeconds, getHourPoint } from '../pubUtils/timeUtil';
|
||||
import { REFRESH_HOUR, GUILD_STRUCTURE } from '../consts/constModules/guildConst';
|
||||
import { nowSeconds, getZeroPoint } from '../pubUtils/timeUtil';
|
||||
import { GUILD_STRUCTURE } from '../consts';
|
||||
import { GuildTrainType, GuildTrainModel, TrainInstance } from '../db/GuildTrain';
|
||||
import { GuildModel } from '../db/Guild';
|
||||
import { findWhere } from 'underscore';
|
||||
@@ -26,7 +26,7 @@ export async function getUserGuild(roleId: string, serverId: number) {
|
||||
return;
|
||||
let { trainCount, trainTime, buyTrainCount, guildCode} = userGuild;
|
||||
await resetTrain(guildCode, serverId);//检查重置练兵场
|
||||
if (trainTime < getHourPoint(REFRESH_HOUR)) {//重置挑战次数和购买次数
|
||||
if (trainTime < getZeroPoint()) {//重置挑战次数和购买次数
|
||||
trainCount = ARMY.ARMY_TRAIN_BUYTIMES;
|
||||
buyTrainCount = 0;
|
||||
userGuild = await UserGuildModel.updateInfo(roleId, {trainCount, trainTime: nowSeconds(), buyTrainCount}, {});
|
||||
|
||||
@@ -4,12 +4,12 @@ import { RoleType } from '../db/Role';
|
||||
import { PVP_HERO_POS, REDIS_KEY, PVP_CONST } from '../consts';
|
||||
import { setPvpDefResult } from '../services/timeTaskService';
|
||||
import { dicPvpOpponent, DicPvpOpponent } from "../pubUtils/dictionary/DicPvpOpponent";
|
||||
import { getRandSingleIndex, genCode, shouldRefresh, reduceCe, getChineseName } from '../pubUtils/util';
|
||||
import { getRandSingleIndex, genCode, shouldRefresh, getChineseName } from '../pubUtils/util';
|
||||
import { oppPlayersInter, pvpEndParamInter } from '../pubUtils/interface';
|
||||
import { gameData, getPLvByScore } from "../pubUtils/data";
|
||||
import { PVP } from '../pubUtils/dicParam';
|
||||
import { SystemConfigModel } from '../db/SystemConfig'
|
||||
import { nowSeconds, checkTodayTime } from '../pubUtils/timeUtil';
|
||||
import { nowSeconds, getTimeFun } from '../pubUtils/timeUtil';
|
||||
import { HeroesRecord } from '../db/PvpRecord';
|
||||
import { HeroModel } from '../db/Hero';
|
||||
import { MainAttrNumber, Attribute, CeAttrData, CeAttrDataRole } from '../domain/roleField/attribute';
|
||||
@@ -405,7 +405,7 @@ export function refresh(challengeCnt: number, challengeRefTime: number, seasonEn
|
||||
return {challengeCnt, challengeRefTime};
|
||||
}
|
||||
let period = PVP.PVP_CHALLENGE_NORMALTIMES * 60;
|
||||
if (checkTodayTime(seasonEndTime)) {
|
||||
if (getTimeFun(seasonEndTime).checkDay()) {
|
||||
period = PVP.PVP_CHALLENGE_FINALTIMES * 60;
|
||||
}
|
||||
let time = nowSeconds();
|
||||
@@ -452,7 +452,7 @@ export async function findPvpDefByRoleId(roleId: string) {
|
||||
// 获取刷新对手次数及消耗
|
||||
export function getRefOppCnt(refOppCnt: number, refOppTime: Date) {
|
||||
let curTime = new Date();
|
||||
let shouldRefOpp = shouldRefresh(refOppTime, curTime, PVP_CONST.REFRESH_TIME);
|
||||
let shouldRefOpp = shouldRefresh(refOppTime, curTime);
|
||||
if(shouldRefOpp) {
|
||||
refOppCnt = 0; refOppTime = curTime;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import { resResult, shouldRefresh, shouldRefreshWeek } from '../pubUtils/util';
|
||||
import { nowSeconds } from "../pubUtils/timeUtil";
|
||||
import { RoleModel } from '../db/Role';
|
||||
import { refDailyTask, refDailyTaskBox } from './taskService'
|
||||
import { REFRESH_HOUR } from "../consts";
|
||||
|
||||
/**
|
||||
* 刷新
|
||||
@@ -37,14 +36,14 @@ export async function refreshDaily(session: FrontendOrBackendSession) {
|
||||
if(session.get('roleId')) {
|
||||
let refDaily: number = session.get('refDaily'); // 10位时间戳,每天每人更新一次
|
||||
let refWeekly: number = session.get('refWeekly'); // 10位时间戳,每天每人更新一次
|
||||
if(!refDaily || shouldRefresh(new Date(refDaily * 1000), new Date(), REFRESH_HOUR)) {
|
||||
if(!refDaily || shouldRefresh(new Date(refDaily * 1000), new Date())) {
|
||||
refDaily = nowSeconds();
|
||||
session.set('refDaily', refDaily);
|
||||
session.push('refDaily', () => {});
|
||||
await refDailyTask(session.get('roleId'), session.get('sid'));
|
||||
}
|
||||
|
||||
if(!refWeekly || shouldRefreshWeek(new Date(refWeekly * 1000), new Date(), 1, REFRESH_HOUR)) {
|
||||
if(!refWeekly || shouldRefreshWeek(new Date(refWeekly * 1000), new Date())) {
|
||||
refWeekly = nowSeconds();
|
||||
session.set('refWeekly', refWeekly);
|
||||
session.push('refWeekly', () => {});
|
||||
|
||||
@@ -2,7 +2,7 @@ import * as taskUtil from '../pubUtils/taskUtil';
|
||||
import { RoleType } from '../db/Role';
|
||||
import { pinus, FrontendOrBackendSession } from 'pinus';
|
||||
import { resResult, shouldRefresh } from '../pubUtils/util';
|
||||
import { STATUS, TASK_TYPE, TASK_FUN_TYPE } from '../consts';
|
||||
import { STATUS, TASK_TYPE, TASK_FUN_TYPE, SHOP_REFRESH_TYPE } from '../consts';
|
||||
import { TaskParam, TaskListReturn } from '../domain/roleField/task';
|
||||
import { HeroType } from '../db/Hero';
|
||||
import { EquipType } from '../db/Equip';
|
||||
@@ -13,7 +13,7 @@ import { UserTaskModel, UserTaskType } from '../db/UserTask';
|
||||
import { UserTaskRecModel } from '../db/UserTaskRec';
|
||||
import { UserTaskHistoryModel } from '../db/UserTaskHistory';
|
||||
import { gameData, getGoodById } from '../pubUtils/data';
|
||||
import { getCurWeekDate, getSeconds } from '../pubUtils/timeUtil';
|
||||
import { getSeconds, getZeroPointD } from '../pubUtils/timeUtil';
|
||||
import { RoleStatus } from '../db/ComBattleTeam';
|
||||
|
||||
export async function checkTaskWithRoles(roleId: string, sid: string, funcs: number[], taskType: number, roles: RoleType[]) {
|
||||
@@ -125,14 +125,14 @@ export async function getCurTask(roleId: string, session: FrontendOrBackendSessi
|
||||
let userTask = await UserTaskModel.findByRole(roleId);
|
||||
|
||||
let { dailyTaskRefWeekly, dailyTaskRef } = userTask;
|
||||
let curWeekStart = getCurWeekDate(1, 5);
|
||||
let curWeekStart = getZeroPointD(SHOP_REFRESH_TYPE.WEEKLY);
|
||||
if (dailyTaskRefWeekly < curWeekStart) { // 刷新周宝箱
|
||||
dailyTaskRefWeekly = curWeekStart;
|
||||
}
|
||||
session.set('refWeekly', getSeconds(dailyTaskRefWeekly));
|
||||
session.push('refWeekly', () => { });
|
||||
|
||||
if (shouldRefresh(dailyTaskRef, new Date(), 5)) {
|
||||
if (shouldRefresh(dailyTaskRef, new Date())) {
|
||||
dailyTaskRef = new Date();
|
||||
userTask = await UserTaskModel.updateInfo(roleId, { dailyTaskRef });
|
||||
await removeHistoryTask(roleId, TASK_FUN_TYPE.DAILY);
|
||||
@@ -168,7 +168,7 @@ export async function getMainTask(roleId: string, userTask: UserTaskType) {
|
||||
export async function getDailyTask(roleId: string, userTask: UserTaskType) {
|
||||
let type = TASK_FUN_TYPE.DAILY;
|
||||
let { dailyTaskPoint: point, dailyTaskRefWeekly, dailyTaskPointWeekly: weeklyPoint, dailyTaskBox: box } = userTask;
|
||||
let curWeekStart = getCurWeekDate(1, 5);
|
||||
let curWeekStart = getZeroPointD(SHOP_REFRESH_TYPE.WEEKLY);
|
||||
if (dailyTaskRefWeekly < curWeekStart) { // 刷新
|
||||
dailyTaskRefWeekly = curWeekStart;
|
||||
weeklyPoint = 0;
|
||||
|
||||
@@ -3,12 +3,12 @@ import { scheduleJob, Job } from 'node-schedule';
|
||||
import { SystemConfigModel } from '../db/SystemConfig';
|
||||
import PvpDefenseType,{ PvpDefenseModel } from '../db/PvpDefense';
|
||||
import { PVP } from '../pubUtils/dicParam';
|
||||
import { nowSeconds, getTodayZeroPoint, getAge } from '../pubUtils/timeUtil';
|
||||
import { nowSeconds, getAge, getTimeFun } from '../pubUtils/timeUtil';
|
||||
import { getPvpGkWarIds, getPvpRankRewards, getPvpHeroRewards, getResultMaxRank, getTodayGuildActivity } from '../pubUtils/data';
|
||||
import { deepCopy, resResult, getRandSingleEelm } from '../pubUtils/util';
|
||||
import { getLvByScore } from './pvpService';
|
||||
import { getAllOnlineRoles, getAllServers, initSingleRank, delGuildActivityRank } from './redisService';
|
||||
import { MAIL_TYPE, REDIS_KEY, ADULT_AGE, GUEST_MAX_TIME, ADDICTION_PREVENTION_CODE, GUILD_ACTIVITY_STATUS, GUILD_ACTIVITY_TYPE, TASK_TYPE } from '../consts';
|
||||
import { MAIL_TYPE, REDIS_KEY, ADULT_AGE, GUEST_MAX_TIME, ADDICTION_PREVENTION_CODE, GUILD_ACTIVITY_STATUS, GUILD_ACTIVITY_TYPE, TASK_TYPE, TIME_OUTPUT_TYPE, REFRESH_TIME } from '../consts';
|
||||
import { RoleModel } from '../db/Role';
|
||||
import { MailModel, MailType } from '../db/Mail';
|
||||
import { pinus } from 'pinus';
|
||||
@@ -48,12 +48,12 @@ export async function init() {
|
||||
console.log('create season seasonNum = '+ systemConfig?.seasonNum);
|
||||
let warIds = getPvpGkWarIds();
|
||||
let warId = warIds[0];
|
||||
seasonEndTime = PVP.PVP_SEASON_DAYS * PER_DAY + getTodayZeroPoint();
|
||||
seasonEndTime = <number>getTimeFun().getAfterDay(PVP.PVP_SEASON_DAYS);
|
||||
systemConfig = await SystemConfigModel.createSystemConfig( seasonEndTime, warId );
|
||||
} else {
|
||||
seasonEndTime = systemConfig.seasonEndTime;
|
||||
if (systemConfig.seasonEndTime - SETTLE_DIFF <= nowSeconds()) {//服务器启动时,检查当前时间是否大于实际结算的时间,若大于则重新开启定时任务,若小于则按照结束时间开启定时任务
|
||||
seasonEndTime = PVP.PVP_SEASON_DAYS * PER_DAY + getTodayZeroPoint();
|
||||
seasonEndTime = <number>getTimeFun().getAfterDay(PVP.PVP_SEASON_DAYS);
|
||||
console.log('update season seasonNum = '+ systemConfig.seasonNum);
|
||||
systemConfig.seasonNum++;//赛季值增加1
|
||||
await SystemConfigModel.updateSystemConfig({ seasonEndTime, seasonNum: systemConfig.seasonNum, oldSeasonEndTime: systemConfig.seasonEndTime});
|
||||
@@ -241,7 +241,7 @@ async function setNextPvpTime(notSetNext: boolean) {
|
||||
return { seasonEndTime, seasonNum , oldSeasonEndTime: 0};
|
||||
}
|
||||
let oldSeasonEndTime = seasonEndTime;
|
||||
seasonEndTime = (PVP.PVP_SEASON_DAYS + 1) * PER_DAY + getTodayZeroPoint();
|
||||
seasonEndTime = <number>getTimeFun().getAfterDay(PVP.PVP_SEASON_DAYS + 1);
|
||||
await SystemConfigModel.updateSeason(seasonEndTime, oldSeasonEndTime);
|
||||
let settleTime = (seasonEndTime - SETTLE_DIFF)* PER_SECOND;
|
||||
seasonJobId = scheduleJob('setPvpSeasonResult', settleTime, setPvpSeasonSchdule);
|
||||
@@ -273,10 +273,10 @@ export async function resetPvpSeasonTime(hour: number) {
|
||||
if (!systemConfig) {
|
||||
let warIds = getPvpGkWarIds();
|
||||
let warId = warIds[0];
|
||||
seasonEndTime = hour * 60 * 60 + getTodayZeroPoint();
|
||||
seasonEndTime = <number>getTimeFun().getTimeWithHour(REFRESH_TIME - hour);
|
||||
systemConfig = await SystemConfigModel.createSystemConfig( seasonEndTime, warId );
|
||||
} else {
|
||||
seasonEndTime = hour * 60 * 60 + getTodayZeroPoint();
|
||||
seasonEndTime = <number>getTimeFun().getTimeWithHour(REFRESH_TIME - hour);
|
||||
seasonNum = systemConfig.seasonNum + 1;
|
||||
await SystemConfigModel.updateSystemConfig({ seasonEndTime, seasonNum, oldSeasonEndTime: 0});
|
||||
await setPvpSeasonResult({name: 'simpleJobExample' + systemConfig.seasonNum, notSetNext: true });
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
import { BattleDropModel } from '../db/BattleDrop';
|
||||
import { getRefTime, getRandEelmWithWeight, getRandSingleEelm } from '../pubUtils/util';
|
||||
import { getRandEelmWithWeight, getRandSingleEelm } from '../pubUtils/util';
|
||||
import { BATTLE_REWARD_TYPE, BLUEPRT_CONST } from '../consts';
|
||||
import { addItems } from './rewardService';
|
||||
import { BattleBlueprtDropModel } from '../db/BattleBlueprtDrop'
|
||||
@@ -12,6 +12,7 @@ import { RoleModel } from '../db/Role';
|
||||
import { gameData } from '../pubUtils/data';
|
||||
import { DicWar } from '../pubUtils/dictionary/DicWar';
|
||||
import { RewardInter } from '../pubUtils/interface';
|
||||
import { getZeroPointD } from '../pubUtils/timeUtil';
|
||||
|
||||
export class WarReward {
|
||||
private roleId: string;
|
||||
@@ -117,7 +118,7 @@ export class WarReward {
|
||||
}
|
||||
|
||||
private async handlerBlueprtReward(num: number) {
|
||||
const refTime = getRefTime(new Date(), BLUEPRT_CONST.REFRESH_TIME);
|
||||
const refTime = getZeroPointD();
|
||||
const battleBlueprtDrop = await BattleBlueprtDropModel.findByTime(this.roleId, refTime);
|
||||
if(battleBlueprtDrop) {
|
||||
let { getNum = 0, curCostAp = 0, getSum = 0, costAp = 0 } = battleBlueprtDrop;
|
||||
|
||||
Reference in New Issue
Block a user