属性: 修改好感度添加方法

This commit is contained in:
luying
2021-02-24 11:36:28 +08:00
parent dd995e67eb
commit b14f751d92
9 changed files with 9754 additions and 111 deletions

View File

@@ -127,26 +127,26 @@ export async function calPlayerCeAndSave(roleId: string, heros: Array<HeroType>,
export async function calculateTopFive(role: RoleType, hid: number, ce: number, heroId: string) {
let topFive = role?.topFive || new Array();
topFive.sort((a, b) => { return b.ce - a.ce }); // 0-5,最大-最小
topFive.sort((a, b) => { return b.ce - a.ce }); // 0-6,最大-最小
let index = topFive.findIndex(cur => cur.hid == hid);
if(index != -1 && !heroId) {
let heroes = await HeroModel.getTopHero(role.roleId, 5);
let heroes = await HeroModel.getTopHero(role.roleId, 6);
topFive = heroes.map(cur => { return { hid: cur.hid, ce: cur.ce, hero: cur._id } });
} else {
if (index == -1) { // 不在最强列表
if (topFive.length < 5) { // 不满5
if (topFive.length < 6) { // 不满6
topFive.push({ hid, ce, hero: heroId });
} else if (topFive.length == 5) {
if (ce > topFive[topFive.length - 1].ce) { // 跻身最强5
} else if (topFive.length == 6) {
if (ce > topFive[topFive.length - 1].ce) { // 跻身最强6
topFive.pop();
topFive.push({ hid, ce, hero: heroId });
}
} else {
topFive.splice(5, topFive.length - 5);
topFive.splice(6, topFive.length - 6);
}
} else { // 原来就是最强5
} else { // 原来就是最强6
if (ce < topFive[topFive.length - 1].ce) { // 滑出最强
let heroes = await HeroModel.getTopHero(role.roleId, 5);
let heroes = await HeroModel.getTopHero(role.roleId, 6);
topFive = heroes.map(cur => { return { hid: cur.hid, ce: cur.ce, hero: cur._id } });
} else {
topFive[index].ce = ce;