战力:pvp远征战场显示
This commit is contained in:
@@ -420,4 +420,6 @@ export enum GET_SMS_TYPE {
|
||||
|
||||
export enum DEFAULT_DEVICE_ID {
|
||||
PC = 'pc'
|
||||
}
|
||||
}
|
||||
|
||||
export const LINEUP_NUM = 6;
|
||||
@@ -77,10 +77,12 @@ export class Enemies extends PvpHeroInfo {
|
||||
hide: number; // 是否隐藏
|
||||
@prop({ required: false })
|
||||
initial_ai: number; // AI类型
|
||||
@prop({ required: false })
|
||||
ce: number; // 战力
|
||||
|
||||
// warjson 出兵表
|
||||
// heroInfo 覆盖掉出兵表的相应参数
|
||||
constructor(warjson: DicWarJson, heroInfo: PvpHeroInfo) {
|
||||
constructor(warjson: DicWarJson, heroInfo: PvpHeroInfo, ce: number) {
|
||||
super();
|
||||
this.actorId = heroInfo.actorId != undefined ? heroInfo.actorId : warjson.actorId;
|
||||
this.actorName = heroInfo.actorName != undefined ? heroInfo.actorName : warjson.actorName;
|
||||
@@ -99,6 +101,7 @@ export class Enemies extends PvpHeroInfo {
|
||||
this.seid = heroInfo.seid != undefined ? heroInfo.seid : warjson.seid;
|
||||
this.star = heroInfo.star != undefined ? heroInfo.star : warjson.star;
|
||||
this.spine = heroInfo.spine != undefined ? heroInfo.spine : warjson.spine;
|
||||
this.ce = ce;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -116,8 +119,8 @@ export class PvpEnemies extends Enemies {
|
||||
score: number;
|
||||
|
||||
// score: 这个武将的军功
|
||||
constructor(warjson: DicWarJson, heroInfo: PvpHeroInfo, score: number) {
|
||||
super(warjson, heroInfo);
|
||||
constructor(warjson: DicWarJson, heroInfo: PvpHeroInfo, score: number, ce: number) {
|
||||
super(warjson, heroInfo, ce);
|
||||
this.star = heroInfo.star;
|
||||
this.colorStar = heroInfo.colorStar;
|
||||
this.quality = heroInfo.quality;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user