pvp:修复赛季结束

This commit is contained in:
luying
2021-11-08 20:34:30 +08:00
parent c571737a3c
commit 43358d0d44
4 changed files with 17 additions and 20 deletions

View File

@@ -28,7 +28,6 @@ import { PVP } from '../pubUtils/dicParam';
const PER_SECOND = 1 * 1000;
const PER_DAY = 24 * 60 * 60;
const PER_HOUR = 1 * 60 * 60;
const SETTLE_DIFF_SECONDS = 29 * 60;
const PER_MINUTE = 1 * 60;
var seasonMakeRewardTimJobId: Job;
var warJobId: Job;
@@ -94,10 +93,10 @@ async function setPvpSeasonJob() {
await setPvpSeason();
}
async function setPvpSeason(isForce?: boolean, hour?: number) {
console.log(`******** setPvpSeason1 isForce-${isForce}, hour-${hour}`)
async function setPvpSeason(isForce?: boolean, minute?: number) {
console.log(`******** setPvpSeason1 isForce-${isForce}, minute-${minute}`)
let during = hour? hour * PER_HOUR: null; // 下一次重置赛季天数
let during = minute? minute * PER_MINUTE: null; // 下一次重置赛季天数
let oldPvpConfig = await PVPConfigModel.findCurPVPConfig();
let pvpConfig = oldPvpConfig;
console.log(`******** setPvpSeason2 during-${during}, seasonEndTime-${pvpConfig?.seasonEndTime}, now-${nowSeconds()}`)
@@ -112,7 +111,7 @@ async function setPvpSeason(isForce?: boolean, hour?: number) {
let newSeasonStartTime = lastSeasonEndTime + PER_MINUTE;
if(!during) during = getSeasonContinueDay(lastSeasonNum + 1) * PER_DAY;
let rewardTime = SETTLE_DIFF_SECONDS;
let rewardTime = PVP.PVP_SEASON_REWARD_TIME_BEFORE * PER_MINUTE;
if(nowSeconds() - newSeasonStartTime > during) {
newSeasonStartTime = <number>getTimeFun().getDayZeroPoint(0);
}
@@ -131,7 +130,7 @@ async function setPvpSeason(isForce?: boolean, hour?: number) {
let newSeasonNum = await CounterModel.getNewCounter(COUNTER.PVP_SEASON_NUM);
pvpConfig = await PVPConfigModel.createPVPConfig(newSeasonNum, newSeasonStartTime, newSeasonStartTime + during - rewardTime, newSeasonStartTime + during - PER_MINUTE);
}
await setPvpSeasonMakeRewardJob(oldPvpConfig);
await setPvpSeasonMakeRewardJob(pvpConfig);
await setNextSeasonJob(pvpConfig);
setPvpSeasonNum(pvpConfig);
return pvpConfig;
@@ -155,7 +154,8 @@ async function setPvpSeasonMakeRewardJob(pvpConfig: PVPConfigType) {
if(pvpConfig.seasonRewardTime < nowSeconds() && !pvpConfig.hasSettleReward) { // 未发奖励
await pvpSeasonEnd(pvpConfig.seasonNum);
} else {
seasonMakeRewardTimJobId = scheduleJob('seasonMakeRewardTimJobId', pvpConfig.seasonRewardTime, async () => {
seasonMakeRewardTimJobId = scheduleJob('seasonMakeRewardTimJobId', pvpConfig.seasonRewardTime * 1000, async () => {
console.log('************ seasonMakeRewardTimJobId *********');
await pvpSeasonEnd(pvpConfig.seasonNum);
});
}
@@ -166,15 +166,15 @@ async function setNextSeasonJob(pvpConfig: PVPConfigType) {
seasonRefreshTimeJobId.cancel();
}
//定时开启新赛季比seasonEndTime多定一分钟保证定时器时间没错
seasonRefreshTimeJobId = scheduleJob('seasonRefreshTimeJobId', pvpConfig.seasonEndTime + PER_MINUTE, setPvpSeasonJob);
seasonRefreshTimeJobId = scheduleJob('seasonRefreshTimeJobId', (pvpConfig.seasonEndTime + PER_MINUTE) * 1000, setPvpSeasonJob);
}
/**
* debug接口
* @param hour
*/
export async function resetPvpSeasonTime(hour: number) {
return await setPvpSeason(true, hour);
export async function resetPvpSeasonTime(minute: number) {
return await setPvpSeason(true, minute);
}
export async function reportOnlineSchedule() {