战力:pvp远征战场显示

This commit is contained in:
luying
2021-03-10 16:07:39 +08:00
parent 901995b8ba
commit 1fe2d0f307
6 changed files with 27 additions and 21 deletions

View File

@@ -7,7 +7,7 @@ import { ExpeditionPointModel } from '../../../db/ExpeditionPoint';
import { RoleModel } from '../../../db/Role'; import { RoleModel } from '../../../db/Role';
import { calculateSumCE, genCode } from '../../../pubUtils/util'; import { calculateSumCE, genCode } from '../../../pubUtils/util';
import { getPointRewardStatus, getResetRemainCnt, findOrCreateEnemies } from '../../../services/expeditionService'; 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 { WarReward } from '../../../services/warRewardService';
import { handleFixedReward } from '../../../services/rewardService'; import { handleFixedReward } from '../../../services/rewardService';
import { getAp, setAp } from '../../../services/actionPointService'; import { getAp, setAp } from '../../../services/actionPointService';
@@ -35,7 +35,7 @@ export class ExpeditionBattleHandler {
let expeditionRecord = await ExpeditionRecordModel.getCurRecord(roleId); let expeditionRecord = await ExpeditionRecordModel.getCurRecord(roleId);
if(!expeditionRecord) { // 首次新建一条记录 if(!expeditionRecord) { // 首次新建一条记录
// 我方战力 // 我方战力
let myCe = await calculateSumCE(roleId, 1, { num: 5 }); let myCe = await calculateSumCE(roleId, 1, { num: LINEUP_NUM });
expeditionRecord = await ExpeditionRecordModel.createRecord({ expeditionRecord = await ExpeditionRecordModel.createRecord({
roleId, roleName, heroes: [], myCe roleId, roleName, heroes: [], myCe
}); });
@@ -85,7 +85,7 @@ export class ExpeditionBattleHandler {
await ExpeditionRecordModel.hideRecord(roleId); // 刷掉旧关卡 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({ let { expeditionCode, heroes } = await ExpeditionRecordModel.createRecord({
roleId, roleName, heroes: [], myCe roleId, roleName, heroes: [], myCe

View File

@@ -103,7 +103,7 @@ export async function matchPlayers(roleId: string, scale: number, range: number,
let hero = heroes[heroIndex]; let hero = heroes[heroIndex];
if(hero) { if(hero) {
let h = <HeroType>hero.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 dicHero = gameData.hero.get(hero.actorId);
let newAttribute = getPlayerAttribute(heroAttrs, roleAttrs); let newAttribute = getPlayerAttribute(heroAttrs, roleAttrs);
let heroInfo = { let heroInfo = {
@@ -114,7 +114,8 @@ export async function matchPlayers(roleId: string, scale: number, range: number,
star, star,
spine: 0, spine: 0,
attribute: newAttribute, attribute: newAttribute,
lv lv,
ce
}; };
enemyObj.enemies.push({...json, ...heroInfo}); enemyObj.enemies.push({...json, ...heroInfo});
@@ -150,8 +151,8 @@ export async function matchRobots(scale: number, myCe: number, robotCe: number,
const { attribute } = json; const { attribute } = json;
let newAttribute = getRobotAttribute(attribute, myCe, robotCe, scale); let newAttribute = getRobotAttribute(attribute, myCe, robotCe, scale);
let ce = newAttribute.calCe(); let ce = newAttribute.ce;
enemyObj.enemies.push({...json, attribute: newAttribute, lv}); enemyObj.enemies.push({...json, attribute: newAttribute, lv, ce});
allCe += ce; allCe += ce;
} }
} }

View File

@@ -217,7 +217,7 @@ async function generPlayerOppHis(pvpdefense: PvpDefenseType, mapWarJson: DicWarJ
heroInfo.setOutIndex(h.order); heroInfo.setOutIndex(h.order);
let attribute = getPlayerAttribute(dbHero.attr, role.attr); let attribute = getPlayerAttribute(dbHero.attr, role.attr);
heroInfo.setAttribute(attribute); 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); heroes.push(enemy);
} }
} else { } else {
@@ -260,9 +260,9 @@ async function matchRobot(oppPlayers: OppPlayers[], mapWarJson: DicWarJson[], ro
let heroInfo = new PvpHeroInfo(); let heroInfo = new PvpHeroInfo();
heroInfo.setRobotInfo(h, myLv, dicHero.initialStars, dicHero.quality); heroInfo.setRobotInfo(h, myLv, dicHero.initialStars, dicHero.quality);
let attribute = getRobotAttribute(h.attribute, myCe, PVP_CONST.ENEMY_CE, ratio); let attribute = getRobotAttribute(h.attribute, myCe, PVP_CONST.ENEMY_CE, ratio);
defCe += attribute.ce; defCe += attribute.ce
heroInfo.setAttribute(attribute); heroInfo.setAttribute(attribute);
let enemy = new PvpEnemies(warJson, heroInfo, 0); let enemy = new PvpEnemies(warJson, heroInfo, 0, attribute.ce);
heroes.push(enemy); heroes.push(enemy);
} }
} }

View File

@@ -420,4 +420,6 @@ export enum GET_SMS_TYPE {
export enum DEFAULT_DEVICE_ID { export enum DEFAULT_DEVICE_ID {
PC = 'pc' PC = 'pc'
} }
export const LINEUP_NUM = 6;

View File

@@ -77,10 +77,12 @@ export class Enemies extends PvpHeroInfo {
hide: number; // 是否隐藏 hide: number; // 是否隐藏
@prop({ required: false }) @prop({ required: false })
initial_ai: number; // AI类型 initial_ai: number; // AI类型
@prop({ required: false })
ce: number; // 战力
// warjson 出兵表 // warjson 出兵表
// heroInfo 覆盖掉出兵表的相应参数 // heroInfo 覆盖掉出兵表的相应参数
constructor(warjson: DicWarJson, heroInfo: PvpHeroInfo) { constructor(warjson: DicWarJson, heroInfo: PvpHeroInfo, ce: number) {
super(); super();
this.actorId = heroInfo.actorId != undefined ? heroInfo.actorId : warjson.actorId; this.actorId = heroInfo.actorId != undefined ? heroInfo.actorId : warjson.actorId;
this.actorName = heroInfo.actorName != undefined ? heroInfo.actorName : warjson.actorName; 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.seid = heroInfo.seid != undefined ? heroInfo.seid : warjson.seid;
this.star = heroInfo.star != undefined ? heroInfo.star : warjson.star; this.star = heroInfo.star != undefined ? heroInfo.star : warjson.star;
this.spine = heroInfo.spine != undefined ? heroInfo.spine : warjson.spine; this.spine = heroInfo.spine != undefined ? heroInfo.spine : warjson.spine;
this.ce = ce;
} }
} }
@@ -116,8 +119,8 @@ export class PvpEnemies extends Enemies {
score: number; score: number;
// score: 这个武将的军功 // score: 这个武将的军功
constructor(warjson: DicWarJson, heroInfo: PvpHeroInfo, score: number) { constructor(warjson: DicWarJson, heroInfo: PvpHeroInfo, score: number, ce: number) {
super(warjson, heroInfo); super(warjson, heroInfo, ce);
this.star = heroInfo.star; this.star = heroInfo.star;
this.colorStar = heroInfo.colorStar; this.colorStar = heroInfo.colorStar;
this.quality = heroInfo.quality; this.quality = heroInfo.quality;

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 { deepCopy, getAllAttrStage, reduceCe } from './util';
import { HeroModel, HeroType, HeroUpdate } from '../db/Hero'; 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) { export async function calculatetopLineup(role: RoleType, hid?: number, ce?: number, heroId?: string) {
let topLineup = role?.topLineup || new Array(); let topLineup = role?.topLineup || new Array();
if(!hid) { // 直接重新排 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 } }); topLineup = heroes.map(cur => { return { hid: cur.hid, ce: cur.ce, hero: cur._id } });
} else { } else {
topLineup.sort((a, b) => { return b.ce - a.ce }); // 0-6最大-最小 topLineup.sort((a, b) => { return b.ce - a.ce }); // 0-6最大-最小
let index = topLineup.findIndex(cur => cur.hid == hid); let index = topLineup.findIndex(cur => cur.hid == hid);
if(index != -1 && !heroId) { 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 } }); topLineup = heroes.map(cur => { return { hid: cur.hid, ce: cur.ce, hero: cur._id } });
} else { } else {
if (index == -1) { // 不在最强列表 if (index == -1) { // 不在最强列表
if (topLineup.length < 6) { // 不满6人 if (topLineup.length < LINEUP_NUM) { // 不满6人
topLineup.push({ hid, ce, hero: heroId }); 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人 if (ce > topLineup[topLineup.length - 1].ce) { // 跻身最强6人
topLineup.pop(); topLineup.pop();
topLineup.push({ hid, ce, hero: heroId }); topLineup.push({ hid, ce, hero: heroId });
} }
} else { } else {
topLineup.splice(6, topLineup.length - 6); topLineup.splice(LINEUP_NUM, topLineup.length - LINEUP_NUM);
} }
} else { // 原来就是最强6人 } else { // 原来就是最强6人
if (ce < topLineup[topLineup.length - 1].ce) { // 滑出最强 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 } }); topLineup = heroes.map(cur => { return { hid: cur.hid, ce: cur.ce, hero: cur._id } });
} else { } else {
topLineup[index].ce = ce; topLineup[index].ce = ce;