战力:pvp远征战场显示

This commit is contained in:
luying
2021-03-10 16:07:47 +08:00
parent 901995b8ba
commit 1fe2d0f307
6 changed files with 27 additions and 21 deletions
+7 -7
View File
@@ -2,7 +2,7 @@
* 体力系统
*/
import { HERO_SYSTEM_TYPE, ABI_TYPE, HERO_CE_RATIO, HERO_SUB_ATTR_RATIO } from '../consts';
import { HERO_SYSTEM_TYPE, ABI_TYPE, HERO_CE_RATIO, HERO_SUB_ATTR_RATIO, LINEUP_NUM } from '../consts';
import { deepCopy, getAllAttrStage, reduceCe } from './util';
import { HeroModel, HeroType, HeroUpdate } from '../db/Hero';
@@ -188,29 +188,29 @@ export function calPlayerCe(hero: HeroType, update: HeroUpdate, type: number, ar
export async function calculatetopLineup(role: RoleType, hid?: number, ce?: number, heroId?: string) {
let topLineup = role?.topLineup || new Array();
if(!hid) { // 直接重新排
let heroes = await HeroModel.getTopHero(role.roleId, 6);
let heroes = await HeroModel.getTopHero(role.roleId, LINEUP_NUM);
topLineup = heroes.map(cur => { return { hid: cur.hid, ce: cur.ce, hero: cur._id } });
} else {
topLineup.sort((a, b) => { return b.ce - a.ce }); // 0-6,最大-最小
let index = topLineup.findIndex(cur => cur.hid == hid);
if(index != -1 && !heroId) {
let heroes = await HeroModel.getTopHero(role.roleId, 6);
let heroes = await HeroModel.getTopHero(role.roleId, LINEUP_NUM);
topLineup = heroes.map(cur => { return { hid: cur.hid, ce: cur.ce, hero: cur._id } });
} else {
if (index == -1) { // 不在最强列表
if (topLineup.length < 6) { // 不满6人
if (topLineup.length < LINEUP_NUM) { // 不满6人
topLineup.push({ hid, ce, hero: heroId });
} else if (topLineup.length == 6) {
} else if (topLineup.length == LINEUP_NUM) {
if (ce > topLineup[topLineup.length - 1].ce) { // 跻身最强6人
topLineup.pop();
topLineup.push({ hid, ce, hero: heroId });
}
} else {
topLineup.splice(6, topLineup.length - 6);
topLineup.splice(LINEUP_NUM, topLineup.length - LINEUP_NUM);
}
} else { // 原来就是最强6人
if (ce < topLineup[topLineup.length - 1].ce) { // 滑出最强
let heroes = await HeroModel.getTopHero(role.roleId, 6);
let heroes = await HeroModel.getTopHero(role.roleId, LINEUP_NUM);
topLineup = heroes.map(cur => { return { hid: cur.hid, ce: cur.ce, hero: cur._id } });
} else {
topLineup[index].ce = ce;