战报排序

This commit is contained in:
mamengke01
2021-01-15 11:36:17 +08:00
parent 03357a7bcd
commit fb10eb8623
3 changed files with 18 additions and 15 deletions

View File

@@ -33,19 +33,22 @@ export class PvpHandler {
async addRoleScore(msg: {heroScores: Array<{hid: number, score:number}>}, session: BackendSession) {
let { heroScores: addHeroScores } = msg;
let roleId = session.get('roleId');
let {heroScores, hisScore, score} = await PvpDefenseModel.findByRoleId(roleId);
for (let {hid, score: heroScore} of addHeroScores) {
let {heroScores, hisScore} = await PvpDefenseModel.findByRoleId(roleId);
let score = 0;
for (let {hid, score: heroScore} of heroScores) {
if (heroScore < 0) continue;
let index = findIndex(heroScores, {hid});
if (index!= -1) {
let oldScore = heroScores[index].score;
let index = findIndex(addHeroScores, {hid});
if (index != -1) {
heroScores[index].score = heroScore;
score = score - oldScore + heroScore;
} else {
heroScores.push({hid, score :heroScore});
score = score + heroScore;
}
}
for (let heroScore of heroScores) {
score += heroScore.score;
}
if (score < 0) {
score = 0;
}
@@ -102,12 +105,12 @@ export class PvpHandler {
if (!!pvpSeasonResult) {
var { oldSeasonData, show, heroGoods, rankGoods} = pvpSeasonResult;
if ( oldSeasonData.seasonEndTime > nowSeconds()) {//结算中锁定玩家信息
seasonEndTime = oldSeasonData.seasonEndTime;
heroScores = oldSeasonData.heroScores;
score = oldSeasonData.score;
refOppCnt = oldSeasonData.refOppCnt;
challengeCnt = oldSeasonData.challengeCnt;
challengeRefTime = oldSeasonData.challengeRefTime;
// seasonEndTime = oldSeasonData.seasonEndTime;
// heroScores = oldSeasonData.heroScores;
// score = oldSeasonData.score;
// refOppCnt = oldSeasonData.refOppCnt;
// challengeCnt = oldSeasonData.challengeCnt;
// challengeRefTime = oldSeasonData.challengeRefTime;
} else if(show) {
await PvpSeasonResultModel.updatePvpSeasonResult(roleId, {show: false});
flag = true;