pvp保存阵容
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
* 体力系统
|
||||
*/
|
||||
|
||||
import { scheduleJob } from 'pinus-scheduler';
|
||||
import { scheduleJob } from 'node-schedule';
|
||||
import { SystemConfigModel } from '../db/SystemConfig';
|
||||
import PvpDefenseType,{ PvpDefenseModel } from '../db/PvpDefense';
|
||||
import { PVP } from '../pubUtils/dicParam';
|
||||
@@ -21,23 +21,23 @@ export async function init() {
|
||||
let warIds = getPvpGkWarIds();
|
||||
let warId = warIds[0];//TODO随机地图
|
||||
seasonEndTime = PVP.PVP_SEASON_DAYS * PER_DAY + getTodayZeroPoint();
|
||||
await SystemConfigModel.createSystemConfig( seasonEndTime, warId );
|
||||
systemConfig = await SystemConfigModel.createSystemConfig( seasonEndTime, warId );
|
||||
} else {
|
||||
seasonEndTime = systemConfig.seasonEndTime;
|
||||
if (systemConfig.seasonEndTime - SETTLE_DIFF <= nowSeconds()) {
|
||||
await setPvpSeasonResult();
|
||||
await setPvpSeasonResult({name: 'simpleJobExample' + systemConfig.seasonNum});
|
||||
seasonEndTime = PVP.PVP_SEASON_DAYS * PER_DAY + getTodayZeroPoint();
|
||||
systemConfig.seasonNum++;
|
||||
await SystemConfigModel.updateSystemConfig({ seasonEndTime, seasonNum: systemConfig.seasonNum});
|
||||
}
|
||||
}
|
||||
let settleTime = seasonEndTime - SETTLE_DIFF - nowSeconds();
|
||||
// setTimeout(setPvpSeasonResult, settleTime * PER_SECOND);
|
||||
let settleTime = (seasonEndTime - SETTLE_DIFF)* PER_SECOND;
|
||||
scheduleJob(settleTime, setPvpSeasonResult)
|
||||
scheduleJob("0 0 0 * * 1", resetPvpWarId)
|
||||
}
|
||||
|
||||
export async function setPvpSeasonResult() {
|
||||
console.log('setPvpSeasonResult');
|
||||
export async function setPvpSeasonResult(obj:{ name:string }) {
|
||||
console.log('exce setPvpSeasonResult'+ obj.name);
|
||||
let pvpDefenses = await PvpDefenseModel.getPvpDef(LIMIT_NUM);
|
||||
for (let pvpDefense of pvpDefenses) {
|
||||
await setPvpDefResult(pvpDefense);
|
||||
@@ -47,7 +47,6 @@ export async function setPvpSeasonResult() {
|
||||
|
||||
async function setPvpDefResult(pvpDefense: PvpDefenseType) {
|
||||
await PvpDefenseModel.updateInfo(pvpDefense.roleId, {score:100, pLv: 1});
|
||||
|
||||
}
|
||||
|
||||
export async function resetPvpWarId() {
|
||||
@@ -65,7 +64,7 @@ export async function resetPvpWarId() {
|
||||
|
||||
async function setNextPvpTime() {
|
||||
let seasonEndTime = PVP.PVP_SEASON_DAYS * PER_DAY + getTodayZeroPoint();
|
||||
await SystemConfigModel.updateSeason(seasonEndTime);
|
||||
let settleTime = seasonEndTime - SETTLE_DIFF - nowSeconds();
|
||||
setTimeout(setPvpSeasonResult, settleTime * PER_SECOND);
|
||||
let systemConfig = await SystemConfigModel.updateSeason(seasonEndTime);
|
||||
let settleTime = (seasonEndTime - SETTLE_DIFF)* PER_SECOND;
|
||||
scheduleJob(settleTime, setPvpSeasonResult);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user