pvp设置防守阵容
This commit is contained in:
@@ -256,6 +256,9 @@ export class PvpHandler {
|
|||||||
defHeros[defIndex].dataId = dataId;
|
defHeros[defIndex].dataId = dataId;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (heroes[index].order < 1 || heroes[index].order > 5) {
|
||||||
|
return resResult(STATUS.WRONG_PARMS);
|
||||||
|
}
|
||||||
let hero = await HeroModel.findByHidAndRole(heroes[index].actorId, roleId);
|
let hero = await HeroModel.findByHidAndRole(heroes[index].actorId, roleId);
|
||||||
if (!hero) {
|
if (!hero) {
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -240,7 +240,12 @@ export function getLvByScore(heroScores: HeroScores[]) {
|
|||||||
|
|
||||||
export async function defaultHeroes ( role:RoleType, challengeCnt?:number, challengeRefTime?:number,) {
|
export async function defaultHeroes ( role:RoleType, challengeCnt?:number, challengeRefTime?:number,) {
|
||||||
let { heroes } = await PvpDefenseModel.findByRoleId(role.roleId);
|
let { heroes } = await PvpDefenseModel.findByRoleId(role.roleId);
|
||||||
|
var orders = [1, 2, 3, 4, 5];
|
||||||
heroes.sort(function(a, b) {
|
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;
|
return b.ce - b.dataId - a.ce + a.dataId;
|
||||||
});
|
});
|
||||||
role.topFive.sort(function(a, b) {
|
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})) {
|
if (!!_.findWhere(role.topFive, {hid: hero.actorId})) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (!orders[0]) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
hero.actorId = item.hid;
|
hero.actorId = item.hid;
|
||||||
hero.hero = item.hero;
|
hero.hero = item.hero;
|
||||||
hero.ce = item.ce;
|
hero.ce = item.ce;
|
||||||
|
hero.order = orders[0];
|
||||||
num = j;
|
num = j;
|
||||||
|
orders.splice(0, 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
heroes[index].ce = item.ce;
|
heroes[index].ce = item.ce;
|
||||||
|
if (!heroes[index].order) {
|
||||||
|
heroes[index].order = orders[0];
|
||||||
|
orders.splice(0, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
defCe += item.ce;
|
defCe += item.ce;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user