羁绊:修改武将羁绊格式
This commit is contained in:
+16
-16
@@ -15,8 +15,7 @@ import { dicWar, dicWarPvp, dicDailyWarByType, loadWar, dicHeroIdByWar } from ".
|
||||
import { dicWarJson, loadWarJson } from "./dictionary/DicWarJson";
|
||||
import { AUCTION_TIME } from "../consts";
|
||||
import { dicFashions, dicFashionsByHeroId, loadFashions } from "./dictionary/DicFashions";
|
||||
import { friendShips, friendShipHidAandIds, loadFriendShip } from "./dictionary/DicFriendShip";
|
||||
import { maxFriendShipLv, dicFriendShipLevelMap, loadFriendShipLevel } from "./dictionary/DicFriendShipLevel";
|
||||
import { friendShips, friendShipsByLv, loadFriendShip } from "./dictionary/DicFriendShip";
|
||||
import { dicHeroQualityUp, loadHeroQualityUp } from "./dictionary/DicHeroQualityUp";
|
||||
import { dicHeroStar, loadHeroStar } from "./dictionary/DicHeroStar";
|
||||
import { dicHeroWake, loadHeroWake } from "./dictionary/DicHeroWake";
|
||||
@@ -139,9 +138,7 @@ export const gameData = {
|
||||
fashion: dicFashions,
|
||||
fashionBySkinId: dicFashionsByHeroId,
|
||||
friendShips: friendShips,
|
||||
friendShipHidAandIds: friendShipHidAandIds,
|
||||
maxFriendShipLv: maxFriendShipLv,
|
||||
friendShipLevelMap: dicFriendShipLevelMap,
|
||||
friendShipsByLv: friendShipsByLv,
|
||||
randomEffectPool: dicRandomEffectPool,
|
||||
randomEffectPoolByGroupAndLv: dicRandomEffectPoolByGroupAndLv,
|
||||
title: dicTitle,
|
||||
@@ -321,19 +318,23 @@ export function getHeroExpByLv(lv: number) {
|
||||
return gameData.charexp.get(lv);
|
||||
}
|
||||
|
||||
export function hasCurConnect(actorId: number, shipId: number) {
|
||||
return gameData.friendShips.has(`${actorId}_${shipId}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据武将当前好感获得好感等级
|
||||
* @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;
|
||||
export function getConnectLvByExp(actorId: number, shipId: number, newExp: number) {
|
||||
let exps = gameData.friendShips.get(`${actorId}_${shipId}`)||[];
|
||||
exps.sort((a, b) => a.level - b.level);
|
||||
let newLv = 0, maxLv = 0;
|
||||
for(let { level, shipValue } of exps) {
|
||||
if(newExp >= shipValue) newLv = level;
|
||||
if(maxLv < level) maxLv = level
|
||||
}
|
||||
|
||||
return curLv;
|
||||
return { newLv, maxLv }
|
||||
}
|
||||
|
||||
export function getBossHpByWarId(warId: number) {
|
||||
@@ -408,8 +409,8 @@ export function getJobByGradeAndClass(jobClass: number, grade: number) {
|
||||
return gameData.jobClassAndgrades.get(jobClass + '_' + grade);
|
||||
}
|
||||
|
||||
export function getFriendShipById(shipId: number, level: number) {
|
||||
return gameData.friendShips.get(shipId + '_' + level);
|
||||
export function getFriendShipByIdAndLv(actorId: number, shipId: number, level: number) {
|
||||
return gameData.friendShipsByLv.get(`${actorId}_${shipId}_${level}`);
|
||||
}
|
||||
|
||||
export function getGoodById(gid: number) {
|
||||
@@ -1057,7 +1058,6 @@ function loadDatas() {
|
||||
loadWarJson();
|
||||
loadFashions();
|
||||
loadFriendShip();
|
||||
loadFriendShipLevel();
|
||||
loadHeroQualityUp();
|
||||
loadHeroStar();
|
||||
loadHeroWake();
|
||||
|
||||
@@ -17,24 +17,30 @@ export interface DicFriendShip {
|
||||
readonly hids: Array<number>;
|
||||
// 属性加成
|
||||
readonly attributes: Array<{id: number, number: number}>
|
||||
// 消耗铜币
|
||||
readonly costCoin: number;
|
||||
// 升到这一级所需的羁绊值
|
||||
readonly shipValue: number;
|
||||
}
|
||||
|
||||
export const friendShips = new Map<string, DicFriendShip>();
|
||||
export const friendShipHidAandIds = new Map<number, {actorId: number, level:number}>();
|
||||
export const friendShips = new Map<string, { level: number, shipValue: number }[]>();
|
||||
export const friendShipsByLv = new Map<string, DicFriendShip>();
|
||||
export function loadFriendShip() {
|
||||
friendShips.clear();
|
||||
friendShipHidAandIds.clear();
|
||||
let arr = readFileAndParse(FILENAME.DIC_FRIEND_SHIP);
|
||||
|
||||
arr.forEach(o => {
|
||||
o.attributes = parseAttribute(o.attribute);
|
||||
o.hids = parseNumberList(o.memberId);
|
||||
friendShips.set(o.shipId + '_' + o.level, o);
|
||||
let fiendShipHidAandId = friendShipHidAandIds.get(o.shipId);
|
||||
if (!fiendShipHidAandId || fiendShipHidAandId.level < o.level)
|
||||
friendShipHidAandIds.set(o.shipId, {actorId: o.actorId, level: o.level});
|
||||
let key1 = `${o.actorId}_${o.shipId}`;
|
||||
let shipSumValue = 0;
|
||||
if(!friendShips.has(key1)) {
|
||||
friendShips.set(key1, []);
|
||||
shipSumValue = 0;
|
||||
}
|
||||
shipSumValue += o.shipValue;
|
||||
friendShips.get(key1).push({ level: o.level, shipValue: shipSumValue });
|
||||
|
||||
let key2 = `${o.actorId}_${o.shipId}_${o.level}`;
|
||||
friendShipsByLv.set(key2, o);
|
||||
});
|
||||
arr = undefined;
|
||||
}
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
// 武将羁绊好感等级表
|
||||
import { readFileAndParse } from '../util';
|
||||
import { FILENAME } from '../../consts';
|
||||
|
||||
export interface DicFriendShipLevel {
|
||||
// 等级
|
||||
readonly level: number;
|
||||
// 下一级经验
|
||||
readonly exp: number;
|
||||
// 加成百分比
|
||||
readonly add: number;
|
||||
// 到这一级的总经验
|
||||
readonly expSum: number;
|
||||
}
|
||||
|
||||
export const maxFriendShipLv = { max: 0 };
|
||||
export const dicFriendShipLevelMap = new Map<number, DicFriendShipLevel>();
|
||||
export function loadFriendShipLevel() {
|
||||
maxFriendShipLv.max = 0;
|
||||
dicFriendShipLevelMap.clear();
|
||||
let arr = readFileAndParse(FILENAME.DIC_FRIEND_SHIP_LEVEL);
|
||||
let expSum = 0;
|
||||
arr.forEach(o => {
|
||||
expSum += o.exp;
|
||||
o.expSum = expSum;
|
||||
dicFriendShipLevelMap.set(o.level, o);
|
||||
if(o.level > maxFriendShipLv.max) maxFriendShipLv.max = o.level;
|
||||
});
|
||||
arr = undefined;
|
||||
}
|
||||
Reference in New Issue
Block a user