diff --git a/game-server/app/servers/battle/handler/expeditionBattleHandler.ts b/game-server/app/servers/battle/handler/expeditionBattleHandler.ts index a342da2db..c1f8ace6a 100644 --- a/game-server/app/servers/battle/handler/expeditionBattleHandler.ts +++ b/game-server/app/servers/battle/handler/expeditionBattleHandler.ts @@ -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 diff --git a/game-server/app/services/expeditionService.ts b/game-server/app/services/expeditionService.ts index cff12f2fa..844c5a254 100644 --- a/game-server/app/services/expeditionService.ts +++ b/game-server/app/services/expeditionService.ts @@ -103,7 +103,7 @@ export async function matchPlayers(roleId: string, scale: number, range: number, let hero = heroes[heroIndex]; if(hero) { let h = 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; } } diff --git a/game-server/app/services/pvpService.ts b/game-server/app/services/pvpService.ts index b4367fb0c..ca00dfea5 100644 --- a/game-server/app/services/pvpService.ts +++ b/game-server/app/services/pvpService.ts @@ -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); } } diff --git a/shared/consts/constModules/sysConst.ts b/shared/consts/constModules/sysConst.ts index cf18925a7..d67cf2f56 100644 --- a/shared/consts/constModules/sysConst.ts +++ b/shared/consts/constModules/sysConst.ts @@ -420,4 +420,6 @@ export enum GET_SMS_TYPE { export enum DEFAULT_DEVICE_ID { PC = 'pc' -} \ No newline at end of file +} + +export const LINEUP_NUM = 6; \ No newline at end of file diff --git a/shared/domain/dbGeneral.ts b/shared/domain/dbGeneral.ts index c621ea44d..035d63f86 100644 --- a/shared/domain/dbGeneral.ts +++ b/shared/domain/dbGeneral.ts @@ -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; diff --git a/shared/pubUtils/playerCe.ts b/shared/pubUtils/playerCe.ts index aea959889..0ec87a918 100644 --- a/shared/pubUtils/playerCe.ts +++ b/shared/pubUtils/playerCe.ts @@ -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;