巅峰演武:赛季优化修改

This commit is contained in:
luying
2022-10-17 16:04:45 +08:00
parent ddff18eb20
commit 08ca06d7ac
30 changed files with 590 additions and 272 deletions
+10 -3
View File
@@ -48,6 +48,7 @@ import { ComBattleTeamModel } from '../db/ComBattleTeam';
import { INFO_WINDOW } from '../pubUtils/dicParam';
import { getLadderData } from './ladderService';
import { dispatch } from '../pubUtils/dispatcher';
import { PvpDataReturn } from '../domain/battleField/pvp';
/**
* init: 初始的时候是否推送 true-推 false-不推
@@ -260,11 +261,17 @@ async function getPvpEntryData(roleId: string) {
pvpDefense = await sendLastSeasonRewardIfNotSent(pvpDefense);
let seasonNum: number = pinus.app.get('pvpSeasonNum');
let seasonEndTime: number = pinus.app.get('pvpSeasonEndTime');
let seasonStartTime: number = pinus.app.get('pvpSeasonStartTime');
let seasonRewardTime: number = pinus.app.get('pvpSeasonRewardTime');
let result = new PvpDataReturn(); // 返回对象
result.setPvpConfig(seasonNum, seasonStartTime, seasonEndTime, seasonRewardTime);
result.setPvpDefense(pvpDefense);
result.calHasSaveDefense();
let refChallengeObj = await refChallengeCnt(pvpDefense.challengeCnt, pvpDefense.challengeRefTime, seasonEndTime, roleId);
let { challengeCnt } = refChallengeObj;
let { receivedBox, score, seasonWinNum } = pvpDefense;
return { challengeCnt, score, seasonWinNum, receivedBox, seasonNum, seasonEndTime }
result.setChallengeCnt(challengeCnt);
return pick(result, ['challengeCnt', 'score', 'seasonWinNum', 'receivedBox', 'hasSaveDefense', 'seasonNum', 'seasonEndTime', 'seasonStartTime', 'seasonRewardTime'])
} else {
return null
}
-1
View File
@@ -5,7 +5,6 @@ import { STATUS, MAIL_TYPE, GUILD_AUTH, GUILD_JOB, REDIS_KEY, CHAT_SERVER, TASK_
import { RoleModel, RoleType } from "../db/Role";
import { UserGuildModel, UserGuildType, WishGood } from "../db/UserGuild";
import { UserGuildApplyModel } from "../db/UserGuildApply";
import { PVPConfigModel } from "../db/SystemConfig";
import { getZeroPointD, getZeroPointOfTime, getZeroPointOfTimeD, nowSeconds } from "../pubUtils/timeUtil";
import { pinus, BackendSession, FrontendOrBackendSession } from "pinus";
import { ARMY } from "../pubUtils/dicParam";
+48 -17
View File
@@ -2,23 +2,21 @@
import { PvpDefenseModel, PvpDefenseType, pvpUpdateInter } from '../db/PvpDefense';
import { Defense, Attack, LineupCe, OppPlayer, HeroScore, HeroReward, OppPlayerReturn, AttackHero, DefenseHero } from '../domain/battleField/pvp';
import { RoleType } from '../db/Role';
import { REDIS_KEY, TASK_TYPE, MAIL_TYPE, TA_EVENT, ITID, getHeadItid, getFrameItid, getSpineItid } from '../consts';
import { REDIS_KEY, TASK_TYPE, MAIL_TYPE, TA_EVENT, ITID, getHeadItid, getFrameItid, getSpineItid, PVP_SEASON_STATUS } from '../consts';
import { dicPvpOpponent, DicPvpOpponent } from "../pubUtils/dictionary/DicPvpOpponent";
import { getRandSingleIndex, genCode, shouldRefresh, getChineseName, makeRobotId, robotIdComBack, getRandSingleEelm } from '../pubUtils/util';
import { pvpEndParamInter, RewardInter } from '../pubUtils/interface';
import { gameData, getPLvByScore, getPvpHeroRewardsByScore, getPvpRankRewardsByRank, getPvpDifficultByScore, getPlvAndScore, getPvpBoxsBySeasonNum, getPvpRankMaxRewardsBySeasonNum, randomGoodsByItid } from "../pubUtils/data";
import { EXTERIOR, PVP } from '../pubUtils/dicParam';
import { PVPConfigModel, PVPConfigType } from '../db/SystemConfig'
import { PVPConfigModel } from '../db/PvpConfig'
import { nowSeconds, getTimeFun } from '../pubUtils/timeUtil';
import { HeroesRecord, PvpRecordPlayerInfo } from '../db/PvpRecord';
import { HeroModel, HeroType } from '../db/Hero';
import { AttributeCal } from '../domain/roleField/attribute';
import { PvpEnemies, PvpHeroInfo, PvpOtherHeroes } from '../domain/dbGeneral';
import { DicWarJson } from '../pubUtils/dictionary/DicWarJson';
import { pinus } from 'pinus';
import { PvpHistoryOppModel, PvpHistoryOppType, PvpOppCreateParam } from '../db/PvpHistoryOpp';
import { Rank } from './rankService';
import { CounterModel } from '../db/Counter';
import { DicRankRewads } from '../pubUtils/dictionary/DicPvpRankReward';
import { PvpSeasonResultModel, PvpSeasonResultType } from '../db/PvpSeasonResult';
import { checkTask } from './task/taskService';
@@ -27,6 +25,7 @@ import { RoleRankInfo } from '../domain/rank';
import { reportTAEvent } from './sdkService';
import { getVipPvpChallengeMaxCnt } from './activity/monthlyTicketService';
import { getHeroesAttributes } from './playerCeService';
import { setPvpSeasonNumToRemote, setPvpSettleSeasonNumToRemote } from './timeTaskService';
/**
* 返回对手三人信息
@@ -166,7 +165,7 @@ export async function matchPlayerByRank(seasonNum: number, chosenOpps: string[],
oppRoleId = result[0];
let pvpdefense = await PvpDefenseModel.findByRoleIdIncludeAll(oppRoleId);
if (!pvpdefense || pvpdefense.seasonNum != seasonNum) return null;
if (!pvpdefense || pvpdefense.seasonNum != seasonNum || !pvpdefense.hasDefense) return null;
let pvpHistoryOpp = await generPlayerOppHis(pvpdefense, roleId, pos);
if (!pvpHistoryOpp) return null;
@@ -367,15 +366,21 @@ export async function comsumeChallengeCnt(challengeCnt: number, challengeRefTime
}
export async function sendLastSeasonRewardIfNotSent(pvpDefense: PvpDefenseType) {
let seasonNum: number = pinus.app.get('pvpSeasonNum');
if(pvpDefense.seasonNum < seasonNum) {
let oldPvpCongig = await PVPConfigModel.findPVPConfig(pvpDefense.seasonNum);
let result = await sendPVPRewardToUser(pvpDefense, pvpDefense.seasonNum, oldPvpCongig.seasonEndTime);
let seasonSettleNum: number = pinus.app.get('pvpSettleSeasonNum');
console.log('##### sendLastSeasonRewardIfNotSent seasonSettleNum', seasonSettleNum)
if(seasonSettleNum && !await checkHasSettled(seasonSettleNum, pvpDefense.roleId)) {
let oldPvpCongig = await PVPConfigModel.findPVPConfig(seasonSettleNum);
let result = await sendPVPRewardToUser(pvpDefense, seasonSettleNum, oldPvpCongig.seasonEndTime);
pvpDefense = result.pvpDefense;
}
return pvpDefense;
}
async function checkHasSettled(seasonSettleNum: number, roleId: string) {
let hasData = await PvpSeasonResultModel.checkResultBySeasonNum(roleId, seasonSettleNum);
return hasData;
}
// 获取刷新对手次数及消耗
export function refreshRefOppCnt(pvpDefense: PvpDefenseType) {
let { refOppCnt = 0, setAttackCnt = 0, buyAttackCnt = 0, refDaily } = pvpDefense;
@@ -563,7 +568,8 @@ export async function generPVPOppRecInfo(isSuccess: boolean, curOpp: OppPlayer,
let { pvpSeasonResult } = await sendPVPRewardToUser(pvpDefense, pvpConfig.seasonNum, pvpConfig.seasonEndTime);
reportTAEvent(roleId, TA_EVENT.PVP_SEASON_END, { top_rank: rank, hero_score: pvpSeasonResult.heroScores })
}
await PVPConfigModel.setReward(pvpConfig.seasonNum);
let settledPvpConfig = await PVPConfigModel.setReward(pvpConfig.seasonNum);
await setPvpSettleSeasonNumToRemote(settledPvpConfig);
}
/**
@@ -593,7 +599,7 @@ export async function sendPVPRewardToUser(pvpDefense: PvpDefenseType, seasonNum:
return {
pvpSeasonResult,
pvpDefense: await resetPvpScores(pvpDefense, seasonNum + 1, pvpSeasonResult)
pvpDefense: await resetPvpScores(pvpDefense, pvpSeasonResult)
}
}
@@ -612,17 +618,16 @@ async function sendUnreceivedPvpBox(roleId: string, seasonNum: number, seasonWin
}
}
async function resetPvpScores(pvpDefense: PvpDefenseType, seasonNum: number, pvpSeasonResult: PvpSeasonResultType) {
let { roleId, attack, defense } = pvpDefense;
async function resetPvpScores(pvpDefense: PvpDefenseType, pvpSeasonResult: PvpSeasonResultType) {
let { roleId, attack } = pvpDefense;
let { newHeroScores, newScore } = pvpSeasonResult;
let initCount = await getVipPvpChallengeMaxCnt(roleId)
let newAttack = <Attack>calLineupScore(attack, newHeroScores);
let newDefense = <Defense>calLineupScore(defense, newHeroScores);
pvpDefense = await PvpDefenseModel.updateInfoAndInclude(roleId, {
heroScores: newHeroScores, score: newScore, attack: newAttack, defense: newDefense,
seasonNum, challengeCnt: initCount, challengeRefTime: 0, winStreakNum: 0, isFirstEntry: true,
heroScores: newHeroScores, score: newScore, attack: newAttack, defense: null, hasDefense: false,
challengeCnt: initCount, challengeRefTime: 0, winStreakNum: 0,
seasonWinNum: 0, receivedBox: []
});
return pvpDefense;
@@ -664,8 +669,9 @@ export async function savePvpSeasonResult(pvpDefense: PvpDefenseType, seasonNum:
}
//pvp锁定的信息存入赛季结算表中
let {receivedBox, score, seasonWinNum, heroScores } = pvpDefense;
let pvpSeasonResult = await PvpSeasonResultModel.updatePvpSeasonResult(pvpDefense.roleId, seasonNum, {
...pvpDefense, rankLv, heroGoods, rankGoods, show: true, newScore, newHeroScores, seasonEndTime
receivedBox, score, seasonWinNum, heroScores, rankLv, heroGoods, rankGoods, show: true, newScore, newHeroScores, seasonEndTime
});//结算修改玩家pvp信息
if(newScore > 0) {
let r = new Rank(REDIS_KEY.PVP_RANK, { seasonNum: seasonNum + 1 });
@@ -702,4 +708,29 @@ export async function generPvpLineupCe(roleId: string, lineupCe: LineupCe[], att
newLineupCe.push({ hid, ce });
}
return newLineupCe;
}
export function getPvpSeasonStatus() {
let seasonEndTime: number = pinus.app.get('pvpSeasonEndTime');
let seasonStartTime: number = pinus.app.get('pvpSeasonStartTime');
let seasonRewardTime: number = pinus.app.get('pvpSeasonRewardTime');
let now = nowSeconds();
if(now >= seasonStartTime && now < seasonEndTime) {
return PVP_SEASON_STATUS.START;
} else if (now >= seasonEndTime && now < seasonRewardTime) {
return PVP_SEASON_STATUS.SUMMIT;
} else {
return PVP_SEASON_STATUS.WAITING;
}
}
export function checkPvpSeasonIsStart() {
let status = getPvpSeasonStatus();
return status == PVP_SEASON_STATUS.START;
}
export function checkPvpSeasonIsSummit() {
let status = getPvpSeasonStatus();
return status == PVP_SEASON_STATUS.SUMMIT;
}
+9 -5
View File
@@ -9,13 +9,14 @@ import { UserShopTypeModel, UserShopTypeType } from "../db/UserShopType";
import { GuildModel } from "../db/Guild";
import { RoleModel } from "../db/Role";
import { DicShop } from "../pubUtils/dictionary/DicShop";
import { BackendSession } from "pinus";
import { BackendSession, pinus } from "pinus";
import { ActivityModelType } from "../db/Activity";
import { addItems } from "./role/rewardService";
import { LadderMatchModel } from "../db/LadderMatch";
export async function getAllShopList(roleId: string, serverId: number) {
let userShopRecs = await UserShopModel.findByRoleId(roleId);
let seasonNum = pinus.app.get('pvpSeasonNum');
let userShopRecs = await UserShopModel.findByRoleId(roleId, seasonNum);
let userShopTypeRecs = await UserShopTypeModel.findByRoleId(roleId);
let activities = await getShopActivityDatas(roleId, serverId);
@@ -30,7 +31,8 @@ export async function getAllShopList(roleId: string, serverId: number) {
}
export async function getShopListByType(shop: number, type: number, roleId: string, serverId: number) {
let userShopRecs = await UserShopModel.findByShopType(roleId, shop, type);
let seasonNum = pinus.app.get('pvpSeasonNum');
let userShopRecs = await UserShopModel.findByShopType(roleId, shop, type, seasonNum);
let activities = await getShopActivityDatas(roleId, serverId);
let activity = activities.find(cur => cur.shop == shop && cur.type == type);
let readRecord = await UserShopTypeModel.findByType(roleId, shop, type);
@@ -128,6 +130,7 @@ export async function checkShopInPurchase(session: BackendSession, activityId: n
}
export async function checkShopCanBuyInOrder(roleId: string, serverId: number, activity: ActivityModelType, productID: string) {
let seasonNum = pinus.app.get('pvpSeasonNum');
let role = await RoleModel.findByRoleId(roleId, 'guildCode createTime vipStartTime');
let { createTime, guildCode, vipStartTime } = role;
let serverTime = await getServerCreateTime(serverId);
@@ -136,7 +139,7 @@ export async function checkShopCanBuyInOrder(roleId: string, serverId: number, a
let dicItem = shopData.findByProductID(productID);
if(!dicItem) return false;
let userShop = await UserShopModel.findByRoleAndItem(roleId, activity.activityId, dicItem);
let userShop = await UserShopModel.findByRoleAndItem(roleId, activity.activityId, dicItem, seasonNum);
let result = await checkShopItemCanBuy(activity.activityId, dicItem.id, roleId, serverId, guildCode, vipStartTime, 1, userShop?.count||0, dicItem);
return result.code == STATUS.SUCCESS.code;
}
@@ -188,6 +191,7 @@ export async function checkShopItemCanBuy(activityId: number, shopItemId: number
*
*/
export async function makeShopOrder(roleId: string, roleName: string, sid: string, serverId: number, activityId: number, productID: string) {
let seasonNum = pinus.app.get('pvpSeasonNum');
let activityData: ActivityModelType = await getActivityById(activityId);
if (!activityData) {
return STATUS.ACTIVITY_MISSING;
@@ -206,7 +210,7 @@ export async function checkShopItemCanBuy(activityId: number, shopItemId: number
}];
await addItems(roleId, roleName, sid, reward, ITEM_CHANGE_REASON.SHOP_PURCHASE);
await UserShopModel.purchase(roleId, roleName, activityId, dicItem, 1);
await UserShopModel.purchase(roleId, roleName, activityId, dicItem, 1, seasonNum);
return {
code: 0,
data: Object.assign({}, { item: { shop: dicItem.shop, type: dicItem.type, shopItemId: dicItem.id }, activityId: activityId })
+90 -85
View File
@@ -1,6 +1,6 @@
import { scheduleJob, Job, scheduledJobs, } from 'node-schedule';
import { PVPConfigModel, PVPConfigType } from '../db/SystemConfig';
import { PVPConfigModel, PVPConfigType } from '../db/PvpConfig';
import { nowSeconds, getTimeFun, getSeconds } from '../pubUtils/timeUtil';
import { getTodayGuildActivity, gameData } from '../pubUtils/data';
import { pvpSeasonEnd } from './pvpService';
@@ -46,6 +46,7 @@ const PER_SECOND = 1 * 1000;
const PER_DAY = 24 * 60 * 60;
const PER_HOUR = 1 * 60 * 60;
const PER_MINUTE = 1 * 60;
var seasonEndJob: Job;
var seasonMakeRewardTimJobId: Job;
var seasonRefreshTimeJobId: Job;
let guildWeeklyJobId: Job;
@@ -61,7 +62,7 @@ export async function init() {
console.log('******* init systimer *******')
// pvp赛季
await setPvpSeason(true);
await setPvpSeasonSchedule();
// 周功勋结算任务
guildWeeklyJobId = scheduleJob('settleGuildWeekly', '0 0 0 * * 1', settleGuildWeekly);
@@ -115,111 +116,115 @@ export async function everydayRefresh() {
// —————————————— PVP 及赛季相关 —————————————— //
function getSeasonContinueDay(seasonNum: number) {
const pvpSeasonDuring = PVP.PVP_SEASON_DAYS.split('|').map(cur => {
let arr = cur.split('&');
let seasonNum = parseInt(arr[0]);
let day = parseInt(arr[1]);
if(isNaN(seasonNum) || isNaN(day)) return null;
return { seasonNum, day }
}).filter(cur => !!cur);
let maxDay = 0;
for(let {seasonNum: dicSeasonNum, day } of pvpSeasonDuring) {
if(seasonNum == dicSeasonNum) return day;
if(maxDay < day) maxDay = day;
export async function setPvpSeasonSchedule(fromBackend = false) {
let pvpConfig = await PVPConfigModel.setCurrentPvp();
await setSeasonEndJob(pvpConfig);
await setPvpSeasonMakeRewardJob(pvpConfig); // 发送奖励定时器
await setNextSeasonJob(pvpConfig); // 赛季开始定时器
if(fromBackend) {
setPvpSeasonNumToRemote(pvpConfig);
setPvpSettleSeasonNumToRemote();
} else {
setPvpSeasonNum(pvpConfig);
setPvpSettleSeasonNum();
}
return maxDay;
}
async function setPvpSeasonJob() {
await setPvpSeason(false);
}
async function setPvpSeason(isFirst: boolean, isForce?: boolean, minute?: number) {
console.log(`******** setPvpSeason1 isForce-${isForce}, minute-${minute}`)
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()}`)
if(!pvpConfig || pvpConfig.seasonEndTime - PER_MINUTE <= nowSeconds() || isForce) {
if(pvpConfig && !pvpConfig.hasSettleReward) {
await pvpSeasonEnd(pvpConfig.seasonNum);
}
let lastSeasonNum = pvpConfig? pvpConfig.seasonNum: 0;
let lastSeasonEndTime = pvpConfig? pvpConfig.seasonEndTime: 0;
console.log(`******** setPvpSeason3 lastSeasonNum-${lastSeasonNum}, lastSeasonEndTime-${lastSeasonEndTime}`)
let newSeasonStartTime = lastSeasonEndTime;
if(!during) during = getSeasonContinueDay(lastSeasonNum + 1) * PER_DAY;
let rewardTime = PVP.PVP_SEASON_REWARD_TIME_BEFORE * PER_MINUTE;
if(nowSeconds() - newSeasonStartTime > during) {
newSeasonStartTime = <number>getTimeFun().getDayZeroPoint(0);
}
console.log(`******** setPvpSeason4 newSeasonStartTime-${newSeasonStartTime}, during-${during}`)
if(isForce) { // debug使用,如果seasonEndTime是未来的,强行结束掉,新赛季从现在开始
newSeasonStartTime = nowSeconds();
} else { // 不是用debug的情况,如果(因为debugnewSeasonStartTime不是每天0点结算,那么改成lastSeasonEndTime之后的0点开始
let d = new Date(newSeasonStartTime * 1000);
if(d.getHours() != 0) {
d.setHours(0, 0, 0, 0);
newSeasonStartTime = getSeconds(d);
}
}
console.log(`******** setPvpSeason5 isForce-${isForce}, newSeasonStartTime-${newSeasonStartTime}`)
let newSeasonNum = await CounterModel.getNewCounter(COUNTER.PVP_SEASON_NUM);
pvpConfig = await PVPConfigModel.createPVPConfig(newSeasonNum, newSeasonStartTime, newSeasonStartTime + during - rewardTime, newSeasonStartTime + during);
async function setSeasonEndJob(pvpConfig: PVPConfigType) {
if (!!seasonEndJob) {
seasonEndJob.cancel();
}
await setPvpSeasonMakeRewardJob(pvpConfig);
await setNextSeasonJob(pvpConfig);
setPvpSeasonNum(pvpConfig, isFirst);
return pvpConfig;
}
function setPvpSeasonNum(pvpConfig: PVPConfigType, isFirst = false) {
if(pvpConfig) {
pinus.app.set('pvpSeasonNum', pvpConfig.seasonNum);
pinus.app.set('pvpSeasonEndTime', pvpConfig.seasonEndTime);
if(!isFirst) {
pinus.app.rpc.battle.battleRemote.setPvpSeasonNum.broadcast(pvpConfig);
pinus.app.rpc.role.roleRemote.setPvpSeasonNum.broadcast(pvpConfig);
pinus.app.rpc.connector.connectorRemote.setPvpSeasonNum.broadcast(pvpConfig);
}
if(!pvpConfig || pvpConfig.seasonEndTime < nowSeconds()) {
pvpConfig = await PVPConfigModel.findPVPConfig(pvpConfig? pvpConfig.seasonNum + 1: 1);
if(!pvpConfig) return;
}
console.log('####### setSeasonEndJob', JSON.stringify(pvpConfig))
seasonEndJob = scheduleJob('seasonEndJob', pvpConfig.seasonEndTime * 1000, async () => {
console.log('************ setSeasonEndJob *********');
setPvpSeasonNumToRemote(pvpConfig);
let nextPvpConfig = await PVPConfigModel.findPVPConfig(pvpConfig.seasonNum + 1);
await setSeasonEndJob(nextPvpConfig);
});
}
async function setPvpSeasonMakeRewardJob(pvpConfig: PVPConfigType) {
if (!!seasonMakeRewardTimJobId) {
seasonMakeRewardTimJobId.cancel();
}
if(!pvpConfig) return;
if(pvpConfig.seasonRewardTime < nowSeconds() && !pvpConfig.hasSettleReward) { // 未发奖励
await pvpSeasonEnd(pvpConfig.seasonNum);
} else {
seasonMakeRewardTimJobId = scheduleJob('seasonMakeRewardTimJobId', pvpConfig.seasonRewardTime * 1000, async () => {
console.log('************ seasonMakeRewardTimJobId *********');
await pvpSeasonEnd(pvpConfig.seasonNum);
});
if(!pvpConfig || pvpConfig.seasonRewardTime - 60 < nowSeconds()) {
pvpConfig = await PVPConfigModel.findPVPConfig(pvpConfig? pvpConfig.seasonNum + 1: 1);
if(!pvpConfig) return;
}
console.log('####### setPvpSeasonMakeRewardJob', JSON.stringify(pvpConfig))
seasonMakeRewardTimJobId = scheduleJob('seasonMakeRewardTimJobId', pvpConfig.seasonRewardTime * 1000 - 60 * 1000, async () => {
console.log('************ seasonMakeRewardTimJobId *********');
await pvpSeasonEnd(pvpConfig.seasonNum);
let nextPvpConfig = await PVPConfigModel.findPVPConfig(pvpConfig.seasonNum + 1);
await setPvpSeasonMakeRewardJob(nextPvpConfig);
});
}
async function setNextSeasonJob(pvpConfig: PVPConfigType) {
if (!!seasonRefreshTimeJobId) {
seasonRefreshTimeJobId.cancel();
}
//定时开启新赛季,比seasonEndTime多定一分钟,保证定时器时间没错
seasonRefreshTimeJobId = scheduleJob('seasonRefreshTimeJobId', (pvpConfig.seasonEndTime) * 1000, setPvpSeasonJob);
if(!pvpConfig || pvpConfig.seasonStartTime < nowSeconds()) {
pvpConfig = await PVPConfigModel.findPVPConfig(pvpConfig? pvpConfig.seasonNum + 1: 1);
if(!pvpConfig) return;
}
console.log('####### setNextSeasonJob', JSON.stringify(pvpConfig))
seasonRefreshTimeJobId = scheduleJob('seasonRefreshTimeJobId', pvpConfig.seasonStartTime * 1000, async () => {
console.log('************ setNextSeasonJob *********');
setPvpSeasonNumToRemote(pvpConfig);
await PVPConfigModel.setNextPvp(pvpConfig.seasonNum);
let nextPvpConfig = await PVPConfigModel.findPVPConfig(pvpConfig.seasonNum + 1);
await setNextSeasonJob(nextPvpConfig);
});
}
/**
* debug接口
* @param hour
*/
export async function resetPvpSeasonTime(minute: number) {
return await setPvpSeason(false, true, minute);
export async function setPvpSeasonNumToRemote(pvpConfig: PVPConfigType) {
await setPvpSeasonNum(pvpConfig);
await pinus.app.rpc.battle.battleRemote.setPvpSeasonNum.broadcast(pvpConfig);
await pinus.app.rpc.role.roleRemote.setPvpSeasonNum.broadcast(pvpConfig);
await pinus.app.rpc.connector.connectorRemote.setPvpSeasonNum.broadcast(pvpConfig);
}
export async function setPvpSeasonNum(pvpConfig?: PVPConfigType) {
if(!pvpConfig) {
pvpConfig = await PVPConfigModel.findCurPVPConfig();
if(!pvpConfig) return;
}
let now = nowSeconds();
pinus.app.set('pvpSeasonNum', pvpConfig.seasonNum);
pinus.app.set('pvpSeasonStartTime', pvpConfig.seasonStartTime);
pinus.app.set('pvpSeasonEndTime', pvpConfig.seasonEndTime);
pinus.app.set('pvpSeasonRewardTime', pvpConfig.seasonRewardTime);
if(pvpConfig.seasonEndTime <= now) { // 赛季结束,需要显示下一赛季的倒计时
let nextPvpConfig = await PVPConfigModel.findPVPConfig(pvpConfig.seasonNum + 1);
if(nextPvpConfig) {
pinus.app.set('pvpSeasonStartTime', nextPvpConfig.seasonStartTime);
}
}
}
export async function setPvpSettleSeasonNumToRemote(settledPvpConfig?: PVPConfigType) {
setPvpSettleSeasonNum(settledPvpConfig);
await pinus.app.rpc.battle.battleRemote.setPvpSettleSeasonNum.broadcast(settledPvpConfig);
await pinus.app.rpc.role.roleRemote.setPvpSettleSeasonNum.broadcast(settledPvpConfig);
await pinus.app.rpc.connector.connectorRemote.setPvpSettleSeasonNum.broadcast(settledPvpConfig);
}
export async function setPvpSettleSeasonNum(settledPvpConfig?: PVPConfigType) {
if(!settledPvpConfig) {
settledPvpConfig = await PVPConfigModel.getSettledConfig();
if(!settledPvpConfig) return;
}
pinus.app.set('pvpSettleSeasonNum', settledPvpConfig.seasonNum);
}
export async function reportOnlineSchedule() {