优化:初始角色时,不初始pvpdefense

This commit is contained in:
luying
2021-09-06 20:09:56 +08:00
parent 62fb04a2ee
commit d1e97590fb
5 changed files with 21 additions and 12 deletions
@@ -1,5 +1,5 @@
import { checkPvp, findPvpDefByRoleId } from '../services/pvpService'
import { findPvpDefByRoleId } from '../services/pvpService'
import { getFuncsSwitch, gameData } from '../pubUtils/data';
import { FUNCS_ID, FUNC_OPT_TYPE } from '../consts/constModules/sysConst';
import { RoleModel } from '../db/Role';
@@ -19,10 +19,6 @@ export async function eventOnPlayerLvUp(roleId: string, lv: number, addFuncs: Ar
if (dicFunSwitch && lv >= dicFunSwitch.param) {
addFuncs.push(id);
if(id == FUNCS_ID.PVP) {
let role = await RoleModel.findByRoleId(roleId, null, true);
await checkPvp(role);
}
}
}
+3 -1
View File
@@ -46,7 +46,7 @@ export async function initPvpInfo(role: RoleType) {
let oppPlayers: Array<OppPlayers> = await refreshEnemies(role, 0, 1);
let { seasonNum } = await PVPConfigModel.findCurPVPConfig();
let challengeCnt = PVP.PVP_CHALLENGE_COUNTS;
let result = await PvpDefenseModel.createPvpDefense({ roleId: role.roleId, roleName: role.roleName, role: role._id, heroes, oppPlayers, defCe, seasonNum, challengeCnt });
let result = await PvpDefenseModel.createPvpDefenseAndPopulate({ roleId: role.roleId, roleName: role.roleName, role: role._id, heroes, oppPlayers, defCe, seasonNum, challengeCnt });
//加入排行榜
let r = new Rank(REDIS_KEY.PVP_RANK, {});
@@ -428,6 +428,7 @@ export function comsumeChallengeCnt(challengeCnt: number, challengeRefTime: numb
export async function findPvpDefByRoleId(roleId: string) {
let pvpDefense = await PvpDefenseModel.findByRoleIdIncludeAll(roleId);
let { warId, seasonNum, seasonEndTime } = await PVPConfigModel.findCurPVPConfig();
if(!pvpDefense) return { pvpDefense, warId }
let oldSeasonNum = await CounterModel.getCounter(COUNTER.PVP_SEASON_NUM);
let { seasonEndTime: oldSeasonEndTime } = await PVPConfigModel.findPVPConfig(oldSeasonNum);
if (pvpDefense.seasonNum !== seasonNum && oldSeasonEndTime < nowSeconds()) {
@@ -467,6 +468,7 @@ export function getRefOppCnt(refOppCnt: number, refOppTime: Date) {
export async function findPvpDefAllByRoleId(roleId: string) {
let pvpDefense = await PvpDefenseModel.findByRoleIdIncludeAll(roleId);
let { warId, seasonNum, seasonEndTime } = await PVPConfigModel.findCurPVPConfig();
if(!pvpDefense) return { pvpDefense, warId }
let oldSeasonNum = await CounterModel.getCounter(COUNTER.PVP_SEASON_NUM);
let { seasonEndTime: oldSeasonEndTime } = await PVPConfigModel.findPVPConfig(oldSeasonNum);