🐞 fix(gvg): 投石车定时任务
This commit is contained in:
@@ -5,7 +5,7 @@ import { nowSeconds, getTimeFun, getSeconds } from '../pubUtils/timeUtil';
|
||||
import { getTodayGuildActivity, gameData } from '../pubUtils/data';
|
||||
import { pvpSeasonEnd } from './pvpService';
|
||||
import { getAllOnlineRoles, getAllServers, delGuildActivityRank, getServerCreateTime } from './redisService';
|
||||
import { GUILD_ACTIVITY_TYPE, REFRESH_TIME, COUNTER, AUCTION_TIME, GM_MAIL_TYPE, SERVER_TIMER, ACTIVITY_TYPE, PUSH_ROUTE, STATUS, LADDER_STATUS, LADDER_SERVER_GAP_TIME } from '../consts';
|
||||
import { GUILD_ACTIVITY_TYPE, REFRESH_TIME, COUNTER, AUCTION_TIME, GM_MAIL_TYPE, SERVER_TIMER, ACTIVITY_TYPE, PUSH_ROUTE, STATUS, LADDER_STATUS, LADDER_SERVER_GAP_TIME, GVG_PERIOD } from '../consts';
|
||||
import { pinus } from 'pinus';
|
||||
import { settleGuildWeekly } from './guildService';
|
||||
import { SendMailFun, sendMailsByGmMail, } from './mailService';
|
||||
@@ -16,7 +16,7 @@ import { dispatch } from '../pubUtils/dispatcher';
|
||||
import { createNewServer, initMarquee, setServerMainten } from './gmService';
|
||||
import moment = require('moment');
|
||||
import { reportOneOnline } from './authenticateService';
|
||||
import { LADDER, PVP } from '../pubUtils/dicParam';
|
||||
import { GVG, LADDER, PVP } from '../pubUtils/dicParam';
|
||||
import { fetch37Words } from './sdkService';
|
||||
import { GMMailModel, GMMailType } from '../db/GMMail';
|
||||
import { Maintenance, ServerlistModel, ServerlistType } from '../db/Serverlist';
|
||||
@@ -44,7 +44,7 @@ import { HiddenDataModel, HiddenDataModelType } from '../db/HiddenData';
|
||||
import { setHiddenData, setHiddenDataToMemory } from './dataService';
|
||||
import { GVGConfigModel } from '../db/GVGConfig';
|
||||
import { createNewGVGConfig, initLeaguePrepare } from './gvg/gvgService';
|
||||
import { saveVestigeRankSchedule } from './gvg/gvgFightService';
|
||||
import { getFightTimeByPeriod, saveVestigeRankSchedule } from './gvg/gvgFightService';
|
||||
|
||||
const PER_SECOND = 1 * 1000;
|
||||
const PER_DAY = 24 * 60 * 60;
|
||||
@@ -913,5 +913,54 @@ export async function initGVGConfigSchedule() {
|
||||
}
|
||||
|
||||
scheduleJob('gvgFightSchedule', '0 0 22 * * ?', saveVestigeRankSchedule);
|
||||
|
||||
let { startFightTime, endFightTime } = getFightTimeByPeriod(GVG_PERIOD.BATTLE, config.battleTime);
|
||||
|
||||
scheduleJob(`gvgBattleStartSchedule`, startFightTime * 1000, gvgBattleStartSchedule);
|
||||
scheduleJob(`gvgBattleEndSchedule`, endFightTime * 1000, gvgBattleEndSchedule);
|
||||
}
|
||||
|
||||
let gvgBattleSecondJob: Job; // gvg每5秒的定时器
|
||||
let gvgBattleCatapultJob: Job; // gvg投石车定时器
|
||||
|
||||
// gvg激战期开始定时器
|
||||
export async function gvgBattleStartSchedule() {
|
||||
// 初始化投石车
|
||||
let guildServers = pinus.app.getServersByType('guild');
|
||||
if(guildServers.length > 0) {
|
||||
pinus.app.rpc.guild.guildRemote.gvgBattleStart.toServer(guildServers[0].id);
|
||||
}
|
||||
// 发放道具
|
||||
if(gvgBattleSecondJob) gvgBattleSecondJob.cancel();
|
||||
gvgBattleSecondJob = scheduleJob('gvgBattleSecondJob', '*/5 * * * * *', gvgBattleSecondSchedule);
|
||||
if(gvgBattleCatapultJob) gvgBattleCatapultJob.cancel();
|
||||
gvgBattleCatapultJob = scheduleJob('gvgBattleCatapultJob', `*/${GVG.GVG_CATAPULT_TIME} * * * * *`, gvgBattleCatapult);
|
||||
}
|
||||
|
||||
// 每隔5秒的积分计算定时器
|
||||
async function gvgBattleSecondSchedule() {
|
||||
// console.log('********** gvgBattleSecondJob *************');
|
||||
}
|
||||
|
||||
// 每隔10秒的投石车投机定时器
|
||||
async function gvgBattleCatapult() {
|
||||
console.log('********** gvgBattleCatapultJob *************');
|
||||
pinus.app.rpc.guild.guildRemote.catapultHurt.broadcast();
|
||||
}
|
||||
|
||||
// gvg激战期结束定时器
|
||||
async function gvgBattleEndSchedule() {
|
||||
// 排行榜发放奖励
|
||||
// 城池占领情况
|
||||
// 定时器关闭
|
||||
if(gvgBattleSecondJob) {
|
||||
gvgBattleSecondJob.cancel();
|
||||
gvgBattleSecondJob = undefined;
|
||||
}
|
||||
if(gvgBattleCatapultJob) {
|
||||
gvgBattleCatapultJob.cancel();
|
||||
gvgBattleCatapultJob = undefined;
|
||||
}
|
||||
|
||||
}
|
||||
// —————————————— gvg end —————————————— //
|
||||
Reference in New Issue
Block a user