pvp:修改接口

This commit is contained in:
luying
2021-10-26 19:10:25 +08:00
parent e39b120af4
commit 7fb13da627
10 changed files with 359 additions and 214 deletions

View File

@@ -1,7 +1,7 @@
import { scheduleJob, Job, } from 'node-schedule';
import { PVPConfigModel, PVPConfigType } from '../db/SystemConfig';
import { nowSeconds, getTimeFun, getZeroPoint } from '../pubUtils/timeUtil';
import { nowSeconds, getTimeFun } from '../pubUtils/timeUtil';
import { getTodayGuildActivity, gameData } from '../pubUtils/data';
import { pvpSeasonEnd } from './pvpService';
import { getAllOnlineRoles, getAllServers, delGuildActivityRank } from './redisService';
@@ -83,7 +83,7 @@ function getSeasonContinueDay(seasonNum: number) {
async function setPvpSeason() {
let pvpConfig = await PVPConfigModel.findCurPVPConfig();
if(!pvpConfig || pvpConfig.seasonEndTime <= nowSeconds() ) {
if(!pvpConfig.hasSettleReward) {
if(pvpConfig && !pvpConfig.hasSettleReward) {
await pvpSeasonEnd(pvpConfig);
}
@@ -94,9 +94,10 @@ async function setPvpSeason() {
let during = getSeasonContinueDay(lastSeasonNum + 1) * PER_DAY;
let rewardTime = SETTLE_DIFF_SECONDS;
if(nowSeconds() - lastSeasonEndTime > during) {
newSeasonStartTime = getZeroPoint();
newSeasonStartTime = <number>getTimeFun().getDayZeroPoint(0);
}
pvpConfig = await PVPConfigModel.createPVPConfig(lastSeasonNum + 1, newSeasonStartTime, newSeasonStartTime + during - rewardTime, newSeasonStartTime + during - PER_MINUTE);
let newSeasonNum = await CounterModel.getNewCounter(COUNTER.PVP_SEASON_NUM);
pvpConfig = await PVPConfigModel.createPVPConfig(newSeasonNum, newSeasonStartTime, newSeasonStartTime + during - rewardTime, newSeasonStartTime + during - PER_MINUTE);
}
await setPvpSeasonMakeRewardJob(pvpConfig);
await setNextSeasonJob(pvpConfig);
@@ -128,7 +129,7 @@ async function setNextSeasonJob(pvpConfig: PVPConfigType) {
* @param hour
*/
export async function resetPvpSeasonTime(hour: number) {
await PVPConfigModel.setCurPvpConfig({ seasonEndTime: getZeroPoint() });
await PVPConfigModel.setCurPvpConfig({ seasonEndTime: <number>getTimeFun().getDayZeroPoint(0) });
return await setPvpSeason();
}