pvp最强五人和刷新挑战次数
This commit is contained in:
@@ -241,37 +241,41 @@ export function getLvByScore(heroScores: HeroScores[]) {
|
||||
export async function defaultHeroes ( role:RoleType, challengeCnt?:number, challengeRefTime?:number,) {
|
||||
let { heroes } = await PvpDefenseModel.findByRoleId(role.roleId);
|
||||
heroes.sort(function(a, b) {
|
||||
return a.ce + a.dataId - b.ce + b.dataId;
|
||||
return b.ce - b.dataId - a.ce + a.dataId;
|
||||
});
|
||||
role.topFive.sort(function(a, b) {
|
||||
return a.ce - b.ce;
|
||||
return b.ce - a.ce;
|
||||
});
|
||||
let defCe = 0;
|
||||
for (let i = 1; i < role.topFive.length; i++) {
|
||||
let num = 0;
|
||||
for (let i = 0; i < role.topFive.length; i++) {
|
||||
let item = role.topFive[i];
|
||||
if (!_.findWhere(heroes, {actorId: item.hid})) {
|
||||
for (let j = 0; j < heroes.length; j++) {
|
||||
let index = _.findIndex(heroes, {actorId: item.hid});
|
||||
if (index == -1) {
|
||||
for (let j = num; j < heroes.length; j++) {
|
||||
let hero = heroes[j];
|
||||
if (heroes.length >= 5 && !hero.actorId) {
|
||||
if (num >= 5) {
|
||||
break;
|
||||
}
|
||||
if (!!_.findWhere(role.topFive, {hid: hero.actorId})) {
|
||||
continue;
|
||||
}
|
||||
let index = _.findIndex(role.topFive,{hid: hero.actorId});
|
||||
if (index == -1) {
|
||||
hero.actorId = item.hid;
|
||||
hero.hero = item.hero||'';
|
||||
hero.ce = item.ce||0;
|
||||
} else {
|
||||
heroes[index].ce = item.ce||0;
|
||||
}
|
||||
}
|
||||
hero.actorId = item.hid;
|
||||
hero.hero = item.hero;
|
||||
hero.ce = item.ce;
|
||||
num = j;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
heroes[index].ce = item.ce;
|
||||
}
|
||||
defCe += item.ce;
|
||||
}
|
||||
if (!!challengeCnt && !!challengeRefTime) {
|
||||
let { heroes: resHeroes} = await PvpDefenseModel.updateInfo(role.roleId, {defCe, heroes, challengeCnt, challengeRefTime});
|
||||
let { heroes: resHeroes} = await PvpDefenseModel.updateInfo(role.roleId, {defCe, heroes, challengeCnt, challengeRefTime, isDefaultHero:true});
|
||||
return { resHeroes};
|
||||
} else {
|
||||
let { heroes: resHeroes} = await PvpDefenseModel.updateInfo(role.roleId, {defCe, heroes});
|
||||
let { heroes: resHeroes} = await PvpDefenseModel.updateInfo(role.roleId, {defCe, heroes, isDefaultHero:true});
|
||||
return { resHeroes};
|
||||
}
|
||||
}
|
||||
@@ -280,9 +284,9 @@ export function refresh(challengeCnt: number, challengeRefTime: number, seasonEn
|
||||
if (challengeCnt >= PVP.PVP_CHALLENGE_COUNTS) {
|
||||
return {challengeCnt, challengeRefTime};
|
||||
}
|
||||
let period = PVP.PVP_CHALLENGE_NORMALTIMES;
|
||||
let period = PVP.PVP_CHALLENGE_NORMALTIMES * 60;
|
||||
if (checkTodayTime(seasonEndTime)) {
|
||||
period = PVP.PVP_CHALLENGE_FINALTIMES;
|
||||
period = PVP.PVP_CHALLENGE_FINALTIMES * 60;
|
||||
}
|
||||
let time = nowSeconds();
|
||||
let num = Math.floor(( time - challengeRefTime)/period);
|
||||
|
||||
Reference in New Issue
Block a user