pvp:修复赛季相关

This commit is contained in:
luying
2021-11-02 10:16:50 +08:00
parent 15ed1f71fe
commit 4c80a22ccf
15 changed files with 178 additions and 91 deletions

View File

@@ -149,7 +149,10 @@ export default class PvpDefense extends BaseModel {
}
public static async resetScores(roleId: string, newSeasonNum: number, newScore: number, newHeroScores: HeroScore[]) {
let result: PvpDefenseType = await PvpDefenseModel.findOneAndUpdate({roleId}, {$set: { seasonNum: newSeasonNum, score: newScore, heroScores: newHeroScores, challengeCnt: PVP.PVP_CHALLENGE_COUNTS, challengeRefTime: 0, winStreakNum: 0 }}, {new: true}).lean();
let result: PvpDefenseType = await PvpDefenseModel.findOneAndUpdate({roleId}, {$set: { seasonNum: newSeasonNum, score: newScore, heroScores: newHeroScores, challengeCnt: PVP.PVP_CHALLENGE_COUNTS, challengeRefTime: 0, winStreakNum: 0 }}, {new: true})
.populate('role', 'roleId roleName head frame spine heads frames spines title lv vLv')
.populate('oppPlayers.oppDef', 'oppRoleId pos roleName head frame spine heads frames spines rankLv pLv title lv defCe heroes warId buff').lean({ getters: true, virtuals: true })
.lean();
return result;
}

View File

@@ -39,11 +39,12 @@ export default class PvpSeasonResult extends BaseModel {
newHeroScores: HeroScore[];
public static async updatePvpSeasonResult(roleId: string, seasonNum: number, update: PvpSeasonResultUpdate , lean = true) {
delete update._id;
let result: PvpSeasonResultType = await PvpSeasonResultModel.findOneAndUpdate({roleId, seasonNum}, {$set: update}, {upsert: true, new: true}).lean(lean);
return result;
}
public static async getPvpSeasonResult(roleId: string, seasonNum: number, lean = true) {
let result: PvpSeasonResultType = await PvpSeasonResultModel.findOne({ roleId, seasonNum }).lean(lean);
public static async getPvpSeasonResult(roleId: string) {
let result: PvpSeasonResultType = await PvpSeasonResultModel.findOne({ roleId, show: true }).lean();
return result;
}
}