战报排序

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;

View File

@@ -196,7 +196,7 @@ export async function resetPvpSeasonTime(hour: number) {
systemConfig = await SystemConfigModel.createSystemConfig( seasonEndTime, warId );
} else {
seasonEndTime = hour * 60 * 60 + getTodayZeroPoint();
seasonNum = systemConfig.seasonNum;
seasonNum = systemConfig.seasonNum + 1;
await SystemConfigModel.updateSystemConfig({ seasonEndTime, seasonNum});
}
let settleTime = (seasonEndTime - SETTLE_DIFF)* PER_SECOND;

View File

@@ -88,7 +88,7 @@ export default class PvpRecord extends BaseModel {
public static async getRecByRoleId( roleId: string, limit = 15, lean = true) {
await this.delPvpRecords();
const result: PvpRecord[] = await PvpRecordModel.find({ $or:[{roleId1: roleId}, {roleId2: roleId}] }).limit(limit).lean(lean);
const result: PvpRecord[] = await PvpRecordModel.find({ $or:[{roleId1: roleId}, {roleId2: roleId}] }).limit(limit).sort({lt: -1}).lean(lean);
return result;
}