战报排序
This commit is contained in:
@@ -33,19 +33,22 @@ export class PvpHandler {
|
|||||||
async addRoleScore(msg: {heroScores: Array<{hid: number, score:number}>}, session: BackendSession) {
|
async addRoleScore(msg: {heroScores: Array<{hid: number, score:number}>}, session: BackendSession) {
|
||||||
let { heroScores: addHeroScores } = msg;
|
let { heroScores: addHeroScores } = msg;
|
||||||
let roleId = session.get('roleId');
|
let roleId = session.get('roleId');
|
||||||
let {heroScores, hisScore, score} = await PvpDefenseModel.findByRoleId(roleId);
|
let {heroScores, hisScore} = await PvpDefenseModel.findByRoleId(roleId);
|
||||||
for (let {hid, score: heroScore} of addHeroScores) {
|
let score = 0;
|
||||||
|
for (let {hid, score: heroScore} of heroScores) {
|
||||||
if (heroScore < 0) continue;
|
if (heroScore < 0) continue;
|
||||||
let index = findIndex(heroScores, {hid});
|
let index = findIndex(addHeroScores, {hid});
|
||||||
if (index!= -1) {
|
if (index != -1) {
|
||||||
let oldScore = heroScores[index].score;
|
|
||||||
heroScores[index].score = heroScore;
|
heroScores[index].score = heroScore;
|
||||||
score = score - oldScore + heroScore;
|
|
||||||
} else {
|
} else {
|
||||||
heroScores.push({hid, score :heroScore});
|
heroScores.push({hid, score :heroScore});
|
||||||
score = score + heroScore;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (let heroScore of heroScores) {
|
||||||
|
score += heroScore.score;
|
||||||
|
}
|
||||||
|
|
||||||
if (score < 0) {
|
if (score < 0) {
|
||||||
score = 0;
|
score = 0;
|
||||||
}
|
}
|
||||||
@@ -102,12 +105,12 @@ export class PvpHandler {
|
|||||||
if (!!pvpSeasonResult) {
|
if (!!pvpSeasonResult) {
|
||||||
var { oldSeasonData, show, heroGoods, rankGoods} = pvpSeasonResult;
|
var { oldSeasonData, show, heroGoods, rankGoods} = pvpSeasonResult;
|
||||||
if ( oldSeasonData.seasonEndTime > nowSeconds()) {//结算中锁定玩家信息
|
if ( oldSeasonData.seasonEndTime > nowSeconds()) {//结算中锁定玩家信息
|
||||||
seasonEndTime = oldSeasonData.seasonEndTime;
|
// seasonEndTime = oldSeasonData.seasonEndTime;
|
||||||
heroScores = oldSeasonData.heroScores;
|
// heroScores = oldSeasonData.heroScores;
|
||||||
score = oldSeasonData.score;
|
// score = oldSeasonData.score;
|
||||||
refOppCnt = oldSeasonData.refOppCnt;
|
// refOppCnt = oldSeasonData.refOppCnt;
|
||||||
challengeCnt = oldSeasonData.challengeCnt;
|
// challengeCnt = oldSeasonData.challengeCnt;
|
||||||
challengeRefTime = oldSeasonData.challengeRefTime;
|
// challengeRefTime = oldSeasonData.challengeRefTime;
|
||||||
} else if(show) {
|
} else if(show) {
|
||||||
await PvpSeasonResultModel.updatePvpSeasonResult(roleId, {show: false});
|
await PvpSeasonResultModel.updatePvpSeasonResult(roleId, {show: false});
|
||||||
flag = true;
|
flag = true;
|
||||||
|
|||||||
@@ -196,7 +196,7 @@ export async function resetPvpSeasonTime(hour: number) {
|
|||||||
systemConfig = await SystemConfigModel.createSystemConfig( seasonEndTime, warId );
|
systemConfig = await SystemConfigModel.createSystemConfig( seasonEndTime, warId );
|
||||||
} else {
|
} else {
|
||||||
seasonEndTime = hour * 60 * 60 + getTodayZeroPoint();
|
seasonEndTime = hour * 60 * 60 + getTodayZeroPoint();
|
||||||
seasonNum = systemConfig.seasonNum;
|
seasonNum = systemConfig.seasonNum + 1;
|
||||||
await SystemConfigModel.updateSystemConfig({ seasonEndTime, seasonNum});
|
await SystemConfigModel.updateSystemConfig({ seasonEndTime, seasonNum});
|
||||||
}
|
}
|
||||||
let settleTime = (seasonEndTime - SETTLE_DIFF)* PER_SECOND;
|
let settleTime = (seasonEndTime - SETTLE_DIFF)* PER_SECOND;
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ export default class PvpRecord extends BaseModel {
|
|||||||
|
|
||||||
public static async getRecByRoleId( roleId: string, limit = 15, lean = true) {
|
public static async getRecByRoleId( roleId: string, limit = 15, lean = true) {
|
||||||
await this.delPvpRecords();
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user