diff --git a/game-server/app/servers/battle/handler/pvpHandler.ts b/game-server/app/servers/battle/handler/pvpHandler.ts index 996bdf2fe..703fd8815 100644 --- a/game-server/app/servers/battle/handler/pvpHandler.ts +++ b/game-server/app/servers/battle/handler/pvpHandler.ts @@ -256,6 +256,9 @@ export class PvpHandler { defHeros[defIndex].dataId = dataId; continue; } + if (heroes[index].order < 1 || heroes[index].order > 5) { + return resResult(STATUS.WRONG_PARMS); + } let hero = await HeroModel.findByHidAndRole(heroes[index].actorId, roleId); if (!hero) { continue; diff --git a/game-server/app/services/pvpService.ts b/game-server/app/services/pvpService.ts index 694407130..b2b585a30 100644 --- a/game-server/app/services/pvpService.ts +++ b/game-server/app/services/pvpService.ts @@ -240,7 +240,12 @@ export function getLvByScore(heroScores: HeroScores[]) { export async function defaultHeroes ( role:RoleType, challengeCnt?:number, challengeRefTime?:number,) { let { heroes } = await PvpDefenseModel.findByRoleId(role.roleId); + var orders = [1, 2, 3, 4, 5]; heroes.sort(function(a, b) { + if (!!a.order) { + let index = orders.indexOf(a.order); + orders.splice(index, 1); + } return b.ce - b.dataId - a.ce + a.dataId; }); role.topFive.sort(function(a, b) { @@ -260,14 +265,23 @@ export async function defaultHeroes ( role:RoleType, challengeCnt?:number, chall if (!!_.findWhere(role.topFive, {hid: hero.actorId})) { continue; } + if (!orders[0]) { + break; + } hero.actorId = item.hid; hero.hero = item.hero; hero.ce = item.ce; + hero.order = orders[0]; num = j; + orders.splice(0, 1); break; } } else { heroes[index].ce = item.ce; + if (!heroes[index].order) { + heroes[index].order = orders[0]; + orders.splice(0, 1); + } } defCe += item.ce; }