pvp设置防守阵容

This commit is contained in:
mamengke01
2021-01-11 16:31:34 +08:00
parent 17a6ddb04b
commit 5ca63c00ae
2 changed files with 17 additions and 0 deletions

View File

@@ -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;

View File

@@ -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;
}