秘境本挑战次数

This commit is contained in:
luying
2020-11-13 18:06:53 +08:00
parent 9574bada4f
commit ada3cfe849
18 changed files with 439 additions and 82 deletions

View File

@@ -3,7 +3,7 @@ import path = require('path');
import { ABI_TYPE } from '../consts/abilityConst';
let gamedata = {};
const wars = ['dic_zyz_gk_main', 'dic_zyz_gk_mainElite', 'dic_zyz_gk_daily', 'dic_zyz_gk_event', 'dic_zyz_gk_tower', 'dic_zyz_gk_expedition']; // 关卡相关的表
const wars = ['dic_zyz_gk_main', 'dic_zyz_gk_mainElite', 'dic_zyz_gk_daily', 'dic_zyz_gk_event', 'dic_zyz_gk_tower', 'dic_zyz_gk_expedition', 'dic_zyz_gk_dungeon','dic_zyz_gk_dungeonElite']; // 关卡相关的表
const allWarInfos = new Map<number, any>();
const towerInfos = new Map<number, any>();
const towerTaskInfos = new Map<number, any>();

View File

@@ -333,38 +333,10 @@ export async function updateCe(roleId: string, hero: any ) {
let ce = actor.calculateCE();
if(ce != oldCe) {
// 更新总战力&最强五人战力
let role = await RoleModel.findByRoleId(roleId);
let distance = ce - oldCe;
let historyDistance = ce > historyCe ?ce - historyCe: 0;
let topFive = role?.topFive||new Array();
topFive.sort((a, b) => {return b.ce - a.ce}); // 0-5最大-最小
let index = topFive.findIndex(cur => cur.hid == hid);
if(index == -1) { // 不在最强列表
if(topFive.length < 5) { // 不满5人
topFive.push({hid, ce});
} else if(topFive.length == 5){
if(ce > topFive[topFive.length - 1].ce) { // 跻身最强6人
topFive.pop();
topFive.push({hid, ce});
} else {
topFive[index].ce = ce;
}
} else {
topFive.splice(5, topFive.length - 5);
}
} else { // 原来就是最强5人
if(ce < topFive[topFive.length - 1].ce) { // 滑出最强
let heroes = await HeroModel.getTopHero(roleId, 5);
topFive = heroes.map(cur => {return {hid: cur.hid, ce: cur.ce}});
} else {
topFive[index].ce = ce;
}
}
let topFiveCe = topFive.reduce((pre, cur) => {
return pre + cur.ce
}, 0);
await RoleModel.findOneAndUpdate({roleId}, { topFive, topFiveCe, $inc: {ce: distance} });
await PvpDefenseModel.findOneAndUpdate({roleId, 'heroes.actorId': hid}, {$inc: {ce: distance}});
await HeroModel.findOneAndUpdate({roleId, hid}, {$inc:{ce: distance, historyCe: historyDistance}})
await RoleModel.updateSumCe(roleId, hid, ce, oldCe);
// 更新pvp防守阵容战力
await PvpDefenseModel.updateCe(roleId, hid, ce, oldCe);
// 更新武将战力,历史最高战力
await HeroModel.updateCe(roleId, hid, ce, oldCe, historyCe);
}
}