战力:pvp远征战场显示
This commit is contained in:
@@ -7,7 +7,7 @@ import { ExpeditionPointModel } from '../../../db/ExpeditionPoint';
|
||||
import { RoleModel } from '../../../db/Role';
|
||||
import { calculateSumCE, genCode } from '../../../pubUtils/util';
|
||||
import { getPointRewardStatus, getResetRemainCnt, findOrCreateEnemies } from '../../../services/expeditionService';
|
||||
import { EXPEDITION_CONST, EXPEDITION_WAR_RECORD_STATUS } from '../../../consts';
|
||||
import { EXPEDITION_CONST, EXPEDITION_WAR_RECORD_STATUS, LINEUP_NUM } from '../../../consts';
|
||||
import { WarReward } from '../../../services/warRewardService';
|
||||
import { handleFixedReward } from '../../../services/rewardService';
|
||||
import { getAp, setAp } from '../../../services/actionPointService';
|
||||
@@ -35,7 +35,7 @@ export class ExpeditionBattleHandler {
|
||||
let expeditionRecord = await ExpeditionRecordModel.getCurRecord(roleId);
|
||||
if(!expeditionRecord) { // 首次新建一条记录
|
||||
// 我方战力
|
||||
let myCe = await calculateSumCE(roleId, 1, { num: 5 });
|
||||
let myCe = await calculateSumCE(roleId, 1, { num: LINEUP_NUM });
|
||||
expeditionRecord = await ExpeditionRecordModel.createRecord({
|
||||
roleId, roleName, heroes: [], myCe
|
||||
});
|
||||
@@ -85,7 +85,7 @@ export class ExpeditionBattleHandler {
|
||||
await ExpeditionRecordModel.hideRecord(roleId); // 刷掉旧关卡
|
||||
|
||||
// 我方战力(暂定)
|
||||
let myCe = await calculateSumCE(roleId, 1, { num: 5 });
|
||||
let myCe = await calculateSumCE(roleId, 1, { num: LINEUP_NUM });
|
||||
// 每一关的挑战状态
|
||||
let { expeditionCode, heroes } = await ExpeditionRecordModel.createRecord({
|
||||
roleId, roleName, heroes: [], myCe
|
||||
|
||||
@@ -103,7 +103,7 @@ export async function matchPlayers(roleId: string, scale: number, range: number,
|
||||
let hero = heroes[heroIndex];
|
||||
if(hero) {
|
||||
let h = <HeroType>hero.hero;
|
||||
let { star, lv, attr: heroAttrs } = h;
|
||||
let { star, lv, attr: heroAttrs, ce } = h;
|
||||
let dicHero = gameData.hero.get(hero.actorId);
|
||||
let newAttribute = getPlayerAttribute(heroAttrs, roleAttrs);
|
||||
let heroInfo = {
|
||||
@@ -114,7 +114,8 @@ export async function matchPlayers(roleId: string, scale: number, range: number,
|
||||
star,
|
||||
spine: 0,
|
||||
attribute: newAttribute,
|
||||
lv
|
||||
lv,
|
||||
ce
|
||||
};
|
||||
|
||||
enemyObj.enemies.push({...json, ...heroInfo});
|
||||
@@ -150,8 +151,8 @@ export async function matchRobots(scale: number, myCe: number, robotCe: number,
|
||||
const { attribute } = json;
|
||||
|
||||
let newAttribute = getRobotAttribute(attribute, myCe, robotCe, scale);
|
||||
let ce = newAttribute.calCe();
|
||||
enemyObj.enemies.push({...json, attribute: newAttribute, lv});
|
||||
let ce = newAttribute.ce;
|
||||
enemyObj.enemies.push({...json, attribute: newAttribute, lv, ce});
|
||||
allCe += ce;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -217,7 +217,7 @@ async function generPlayerOppHis(pvpdefense: PvpDefenseType, mapWarJson: DicWarJ
|
||||
heroInfo.setOutIndex(h.order);
|
||||
let attribute = getPlayerAttribute(dbHero.attr, role.attr);
|
||||
heroInfo.setAttribute(attribute);
|
||||
let enemy = new PvpEnemies(warJson, heroInfo, hs?hs.score: 0);
|
||||
let enemy = new PvpEnemies(warJson, heroInfo, hs?hs.score: 0, attribute.ce);
|
||||
heroes.push(enemy);
|
||||
}
|
||||
} else {
|
||||
@@ -260,9 +260,9 @@ async function matchRobot(oppPlayers: OppPlayers[], mapWarJson: DicWarJson[], ro
|
||||
let heroInfo = new PvpHeroInfo();
|
||||
heroInfo.setRobotInfo(h, myLv, dicHero.initialStars, dicHero.quality);
|
||||
let attribute = getRobotAttribute(h.attribute, myCe, PVP_CONST.ENEMY_CE, ratio);
|
||||
defCe += attribute.ce;
|
||||
defCe += attribute.ce
|
||||
heroInfo.setAttribute(attribute);
|
||||
let enemy = new PvpEnemies(warJson, heroInfo, 0);
|
||||
let enemy = new PvpEnemies(warJson, heroInfo, 0, attribute.ce);
|
||||
heroes.push(enemy);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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