属性: 修改好感度添加方法
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user