重置时间
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import {Application, BackendSession} from 'pinus';
|
||||
import {Application, BackendSession, pinus} from 'pinus';
|
||||
import { uniq, findWhere, findIndex } from 'underscore';
|
||||
import { gameData, getPvpBoxs } from '../../../pubUtils/data';
|
||||
import { refreshEnemies, getEnemies, getLvByScore, defaultHeroes, comsumeChallengeCnt, refresh, findPvpDefByRoleId, checkRoleIsRobot, getRefOppCnt, findPvpDefAllByRoleId, generPVPOppRecInfo, generMyRecInfo, getRobotLineup, getPlayerLineup } from '../../../services/pvpService';
|
||||
@@ -71,7 +71,7 @@ export class PvpHandler {
|
||||
|
||||
async debugPvpSeasonResetTime(msg: {day: number}, session: BackendSession) {
|
||||
let { day } = msg;
|
||||
let { seasonNum, seasonEndTime } = await resetPvpSeasonTime(day);
|
||||
let { seasonNum, seasonEndTime } = await pinus.app.rpc.systimer.systimerRemote.resetPvpSeasonTime.toServer('systimer-server-1', day);
|
||||
return resResult(STATUS.SUCCESS, { seasonNum, seasonEndTime });
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import { ChatRemote } from './chat/remote/chatRemote';
|
||||
import { ComBattleRemote } from './battle/remote/comBattleRemote';
|
||||
import { BattleRemote } from './battle/remote/battleRemote';
|
||||
import { ConnectorRemote } from './connector/remote/connectorRemote';
|
||||
import { SystimerRemote } from './systimer/remote/systimerRemote';
|
||||
|
||||
declare global {
|
||||
interface UserRpc {
|
||||
@@ -19,6 +20,9 @@ declare global {
|
||||
};
|
||||
connector: {
|
||||
connectorRemote: RemoterClass<FrontendSession, ConnectorRemote>;
|
||||
};
|
||||
systimer: {
|
||||
systimerRemote: RemoterClass<FrontendSession, SystimerRemote>;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ import { HeroModel, HeroType } from '../db/Hero';
|
||||
import { CeAttrNumber, CeAttr, CeAttrRole } from '../db/generalField';
|
||||
import { DicWarJson } from '../pubUtils/dictionary/DicWarJson';
|
||||
import { findWhere, findIndex } from 'underscore';
|
||||
import { pinus } from 'pinus';
|
||||
|
||||
|
||||
export async function initPvpInfo(role: RoleType) {
|
||||
@@ -364,7 +365,7 @@ export async function findPvpDefAllByRoleId(roleId: string) {
|
||||
let pvpDefense = await PvpDefenseModel.findByRoleIdIncludeAll(roleId);
|
||||
let {warId, seasonNum, seasonEndTime} = await SystemConfigModel.findSystemConfig();
|
||||
if (pvpDefense.seasonNum !== seasonNum) {
|
||||
let { score, pLv, winStreakNum, heroScores, challengeCnt, challengeRefTime } = await setPvpDefResult(pvpDefense, seasonNum, seasonEndTime);
|
||||
let { score, pLv, winStreakNum, heroScores, challengeCnt, challengeRefTime } = await pinus.app.rpc.systimer.systimerRemote.setPvpDefResult.toServer('systimer-server-1', pvpDefense, seasonNum, seasonEndTime);
|
||||
pvpDefense.score = score;
|
||||
pvpDefense.pLv = pLv;
|
||||
pvpDefense.winStreakNum = winStreakNum;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* 体力系统
|
||||
*/
|
||||
|
||||
import { scheduleJob, } from 'node-schedule';
|
||||
import { scheduleJob, Job } from 'node-schedule';
|
||||
import { SystemConfigModel } from '../db/SystemConfig';
|
||||
import PvpDefenseType,{ PvpDefenseModel } from '../db/PvpDefense';
|
||||
import { PVP } from '../pubUtils/dicParam';
|
||||
@@ -17,12 +17,13 @@ import { RoleModel } from '../db/Role';
|
||||
import { MailModel, MailType } from '../db/Mail';
|
||||
import { pinus } from 'pinus';
|
||||
import { indexOf } from 'underscore';
|
||||
import { JsxEmit } from 'typescript';
|
||||
const PER_SECOND = 1 * 1000;
|
||||
const PER_DAY = 24 * 60 * 60;
|
||||
const SETTLE_DIFF = 29 * 60;
|
||||
const LIMIT_NUM = 1000;
|
||||
let seasonJobId;
|
||||
let warJobId;
|
||||
var seasonJobId;
|
||||
var warJobId;
|
||||
export async function init() {
|
||||
let seasonEndTime = 0;
|
||||
let systemConfig = await SystemConfigModel.findSystemConfig();
|
||||
@@ -34,7 +35,7 @@ export async function init() {
|
||||
} else {
|
||||
seasonEndTime = systemConfig.seasonEndTime;
|
||||
if (systemConfig.seasonEndTime - SETTLE_DIFF <= nowSeconds()) {
|
||||
await setPvpSeasonResult({name: 'simpleJobExample' + systemConfig.seasonNum});
|
||||
await setPvpSeasonResult({name: 'simpleJobExample' + systemConfig.seasonNum, notSetNext: true });
|
||||
seasonEndTime = PVP.PVP_SEASON_DAYS * PER_DAY + getTodayZeroPoint();
|
||||
systemConfig.seasonNum++;
|
||||
await SystemConfigModel.updateSystemConfig({ seasonEndTime, seasonNum: systemConfig.seasonNum});
|
||||
@@ -43,19 +44,18 @@ export async function init() {
|
||||
let settleTime = (seasonEndTime - SETTLE_DIFF)* PER_SECOND;
|
||||
seasonJobId = scheduleJob(settleTime, setPvpSeasonResult);
|
||||
warJobId = scheduleJob("0 0 0 * * 1", resetPvpWarId);
|
||||
console.log ('seasonJobId = = = = = = = = =' + seasonJobId);
|
||||
}
|
||||
|
||||
export async function setPvpSeasonResult(obj:{ name:string }) {
|
||||
export async function setPvpSeasonResult(obj:{ name:string, notSetNext?: boolean }) {
|
||||
console.log('exce setPvpSeasonResult'+ obj.name);
|
||||
let { seasonNum, seasonEndTime } = await setNextPvpTime();
|
||||
let { seasonNum, seasonEndTime } = await setNextPvpTime(obj.notSetNext);
|
||||
for (let page = 0; page < 3; page++) {
|
||||
let pvpDefenses = await PvpDefenseModel.getPvpDef(500, page);
|
||||
let addMails = new Array<MailType>();
|
||||
let pushMessage = new Array<any>();
|
||||
for (let pvpDefense of pvpDefenses) {
|
||||
if (pvpDefense.seasonNum !== seasonNum) {
|
||||
await setPvpDefResultOnTime(pvpDefense, seasonNum, seasonEndTime, addMails,pushMessage);
|
||||
await setPvpDefResultOnTime(pvpDefense, seasonNum, seasonEndTime, addMails, pushMessage);
|
||||
}
|
||||
}
|
||||
await MailModel.addMails(addMails);
|
||||
@@ -145,7 +145,11 @@ export async function resetPvpWarId() {
|
||||
return await SystemConfigModel.updateSystemConfig({ warId });
|
||||
}
|
||||
|
||||
async function setNextPvpTime() {
|
||||
async function setNextPvpTime(notSetNext: boolean) {
|
||||
if (!!notSetNext) {
|
||||
let systemConfig = await SystemConfigModel.findSystemConfig();
|
||||
return systemConfig;
|
||||
}
|
||||
let seasonEndTime = PVP.PVP_SEASON_DAYS * PER_DAY + getTodayZeroPoint();
|
||||
let systemConfig = await SystemConfigModel.updateSeason(seasonEndTime);
|
||||
let settleTime = (seasonEndTime - SETTLE_DIFF)* PER_SECOND;
|
||||
@@ -171,12 +175,12 @@ export async function resetPvpSeasonTime(day: number) {
|
||||
let warId = warIds[0];//TODO随机地图
|
||||
seasonEndTime = day * PER_DAY + getTodayZeroPoint();
|
||||
systemConfig = await SystemConfigModel.createSystemConfig( seasonEndTime, warId );
|
||||
} else {
|
||||
} else {
|
||||
seasonEndTime = day * PER_DAY + getTodayZeroPoint();
|
||||
seasonNum = systemConfig.seasonNum + 1;
|
||||
await SystemConfigModel.updateSystemConfig({ seasonEndTime, seasonNum: seasonNum});
|
||||
}
|
||||
let settleTime = (seasonEndTime - SETTLE_DIFF)* PER_SECOND;
|
||||
seasonJobId = scheduleJob(settleTime, setPvpSeasonResult)
|
||||
seasonJobId = scheduleJob(settleTime, setPvpSeasonResult);
|
||||
return { seasonEndTime, seasonNum };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user