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

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

@@ -21,7 +21,7 @@ import { dicXunbao } from "./dictionary/DicXunbao";
import { SPECIAL_ATTR } from "../consts/consts";
import { dicFashions } from "./dictionary/DicFashions";
import { friendShips, friendShipHidAandIds } from "./dictionary/DicFriendShip";
import { dicFriendShipLevel, dicFriendShipLevelMap } from "./dictionary/DicFriendShipLevel";
import { maxFriendShipLv, dicFriendShipLevelMap } from "./dictionary/DicFriendShipLevel";
import { dicHeroQualityUp } from "./dictionary/DicHeroQualityUp";
import { dicHeroStar } from "./dictionary/DicHeroStar";
import { dicHeroWake } from "./dictionary/DicHeroWake";
@@ -93,7 +93,7 @@ export const gameData = {
fashion: dicFashions,
friendShips: friendShips,
friendShipHidAandIds: friendShipHidAandIds,
friendShipLevel: dicFriendShipLevel,
maxFriendShipLv: maxFriendShipLv,
friendShipLevelMap: dicFriendShipLevelMap,
randomEffectPool: dicRandomEffectPool,
strengthenCost: dicStrengthenCost,
@@ -189,6 +189,20 @@ export function getHeroExpByLv(lv: number) {
return gameData.charexp.get(lv);
}
/**
* 根据武将当前好感获得好感等级
* @param exp 累积经验
*/
export function getFavourLvByExp(exp: number) {
let curLv = 0;
let entries = gameData.friendShipLevelMap.entries();
for (let [lv, { expSum: sum }] of entries) {
curLv = lv;
if(exp < sum) break;
}
return curLv;
}
export function getBossHpByWarId(warId: number) {
let bossHpSum = gameData.btlBossHpSum.get(warId) || 0;

View File

@@ -9,17 +9,19 @@ export interface DicFriendShipLevel {
readonly exp: number;
// 加成百分比
readonly add: number;
// 到这一级的总经验
readonly expSum: number;
}
const str = readJsonFile(FILENAME.DIC_FRIEND_SHIP_LEVEL);
let arr = JSON.parse(str);
export const dicFriendShipLevel = new Array<DicFriendShipLevel>();
export let maxFriendShipLv = 0;
export const dicFriendShipLevelMap = new Map<number, DicFriendShipLevel>();
let expSum = 0;
arr.forEach(o => {
dicFriendShipLevel.push(o);
expSum += o.exp;
o.expSum = expSum;
dicFriendShipLevelMap.set(o.level, o);
});
dicFriendShipLevel.sort(function(a, b) {
return a.level - b.level;
if(o.level > maxFriendShipLv) maxFriendShipLv = o.level;
});

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;