pvp创建获取
This commit is contained in:
@@ -106,7 +106,7 @@ export async function calPlayerCeAndSave(roleId: string, heros: Array<HeroType>,
|
||||
let incHeroCe = calPlayerCe(role.globalCeAttr, hero, type, args);
|
||||
|
||||
incPlayerCe += incHeroCe;
|
||||
await calculateTopFive(role, hero.hid, hero.ce); // 计算更新最强五人战力
|
||||
await calculateTopFive(role, hero.hid, hero.ce, hero._id); // 计算更新最强五人战力
|
||||
await HeroModel.updateHeroInfo(roleId, hero.hid, hero);
|
||||
await PvpDefenseModel.updateCe(roleId, hero.hid, hero.ce); // 更新pvp防守阵最强五人战力
|
||||
pushHeros.push({
|
||||
@@ -121,18 +121,18 @@ export async function calPlayerCeAndSave(roleId: string, heros: Array<HeroType>,
|
||||
return { pushHeros, role, topFiveCe }
|
||||
}
|
||||
|
||||
async function calculateTopFive(role: RoleType, hid: number, ce: number) {
|
||||
async function calculateTopFive(role: RoleType, hid: number, ce: number, heroId: string) {
|
||||
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 });
|
||||
topFive.push({ hid, ce, hero: heroId });
|
||||
} else if (topFive.length == 5) {
|
||||
if (ce > topFive[topFive.length - 1].ce) { // 跻身最强5人
|
||||
topFive.pop();
|
||||
topFive.push({ hid, ce });
|
||||
topFive.push({ hid, ce, hero: heroId });
|
||||
}
|
||||
} else {
|
||||
topFive.splice(5, topFive.length - 5);
|
||||
|
||||
Reference in New Issue
Block a user