217 lines
6.9 KiB
TypeScript
217 lines
6.9 KiB
TypeScript
import { dicHero } from "./dictionary/DicHero";
|
||
import { dicGoods, blueprt, dicJewel } from "./dictionary/DicGoods";
|
||
import { dicBlueprtCompose } from "./dictionary/DicBlueprtCompose";
|
||
import { dicBlueprtPossibility } from "./dictionary/DicBlueprtPossibility";
|
||
import { dicDaily } from "./dictionary/DicDaily";
|
||
import { dicEvent } from "./dictionary/DicEvent";
|
||
import { dicExpedition } from "./dictionary/DicExpedition";
|
||
import { dicExpeditionPoint } from "./dictionary/DicExpeditionPoint";
|
||
import { dicFuncSwitch } from "./dictionary/DicFuncSwitch";
|
||
import { dicHeroSkill } from "./dictionary/DicHeroSkill";
|
||
import { dicJob, jobClassAndgrades, jobClassMaxGrades } from "./dictionary/DicJob";
|
||
import { dicKingExp } from "./dictionary/DicKingExp";
|
||
import { dicCharExp } from "./dictionary/DicCharExp";
|
||
import { dicQuestion } from "./dictionary/DicQuestion";
|
||
import { dicSe } from "./dictionary/DicSe";
|
||
import { dicTower } from "./dictionary/DicTower";
|
||
import { dicTowerTask } from "./dictionary/DicTowerTask";
|
||
import { dicWar } from "./dictionary/DicWar";
|
||
import { dicWarJson } from "./dictionary/DicWarJson";
|
||
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 { dicHeroQualityUp } from "./dictionary/DicHeroQualityUp";
|
||
import { dicHeroStar } from "./dictionary/DicHeroStar";
|
||
import { dicHeroWake } from "./dictionary/DicHeroWake";
|
||
import { dicRandomEffectPool } from './dictionary/DicRandomEffectPool';
|
||
import { dicStrengthenCost } from './dictionary/DicStrengthenCost';
|
||
import { dicRefine } from './dictionary/DicRefine';
|
||
import { dicHeroEquip } from './dictionary/DicHeroEquip';
|
||
import { dicSuit } from './dictionary/DicSuit';
|
||
import { dicTitle } from './dictionary/DicTitle';
|
||
import { dicTeraph } from './dictionary/DicTeraph';
|
||
import { dicSchool } from './dictionary/DicSchool';
|
||
|
||
export const gameData = {
|
||
blurprtCompose: dicBlueprtCompose,
|
||
blueprtPossibility: dicBlueprtPossibility,
|
||
daily: dicDaily,
|
||
event: dicEvent,
|
||
expedition: dicExpedition,
|
||
expeditionPoint: dicExpeditionPoint,
|
||
funcsSwitch: dicFuncSwitch,
|
||
goods: dicGoods,
|
||
hero: dicHero,
|
||
heroQualityUp: dicHeroQualityUp,
|
||
heroSkill: dicHeroSkill,
|
||
heroStar: dicHeroStar,
|
||
heroWake: dicHeroWake,
|
||
job: dicJob,
|
||
jobClassMaxGrades: jobClassMaxGrades,
|
||
jobClassAndgrades: jobClassAndgrades,
|
||
kingexp: dicKingExp,
|
||
charexp: dicCharExp,
|
||
question: dicQuestion,
|
||
se: dicSe,
|
||
tower: dicTower,
|
||
towerTask: dicTowerTask,
|
||
war: dicWar,
|
||
warJson: dicWarJson,
|
||
xunbao: dicXunbao,
|
||
btlBossHpSum: new Map<number, number>(),
|
||
btlBossHp: new Map<number, Array<{dataId: number, hp: number, actorId: number}>>(),
|
||
blueprtToWar: new Map<number, number>(),
|
||
blueprt: blueprt,
|
||
fashion: dicFashions,
|
||
friendShips: friendShips,
|
||
friendShipHidAandIds: friendShipHidAandIds,
|
||
friendShipLevel: dicFriendShipLevel,
|
||
friendShipLevelMap: dicFriendShipLevelMap,
|
||
randomEffectPool: dicRandomEffectPool,
|
||
strengthenCost: dicStrengthenCost,
|
||
refine: dicRefine,
|
||
jewels: dicJewel,
|
||
dicHeroEquip: dicHeroEquip,
|
||
suit: dicSuit,
|
||
title: dicTitle,
|
||
teraphs: dicTeraph,
|
||
school: dicSchool
|
||
};
|
||
|
||
// 在此提供一些原先在gamedata中提供的方法,以便更方便获取gameData数据
|
||
|
||
/**
|
||
* 根据主公当前经验获得当前等级
|
||
* @param exp 累积经验
|
||
*/
|
||
export function getLvByExp(exp: number) {
|
||
let curLv = 0;
|
||
let entries = gameData.kingexp.entries();
|
||
for (let [lv, {sum}] of entries) {
|
||
curLv = lv;
|
||
if(exp < sum) break;
|
||
}
|
||
|
||
return curLv;
|
||
}
|
||
|
||
/**
|
||
* 根据主公当前等级,获得累积经验,1=> 1级满经验
|
||
* @param lv 等级
|
||
*/
|
||
export function getExpByLv(lv: number) {
|
||
return gameData.kingexp.get(lv);
|
||
}
|
||
|
||
/**
|
||
* 根据武将当前经验获得当前等级
|
||
* @param exp 累积经验
|
||
*/
|
||
export function getHeroLvByExp(exp: number) {
|
||
let curLv = 0;
|
||
let entries = gameData.charexp.entries();
|
||
for (let [lv, sum] of entries) {
|
||
curLv = lv;
|
||
if(exp < sum) break;
|
||
}
|
||
|
||
return curLv;
|
||
}
|
||
|
||
/**
|
||
* 根据武将当前等级,获得累积经验,1=> 1级满经验
|
||
* @param lv
|
||
*/
|
||
export function getHeroExpByLv(lv: number) {
|
||
return gameData.charexp.get(lv);
|
||
}
|
||
|
||
|
||
export function getBossHpByWarId(warId: number) {
|
||
let bossHpSum = gameData.btlBossHpSum.get(warId) || 0;
|
||
let bossHpArr = gameData.btlBossHp.get(warId) || [];
|
||
if (!bossHpSum || !bossHpArr) {
|
||
const warInfo = dicWarJson.get(warId);
|
||
if (warInfo && warInfo.length) {
|
||
warInfo.forEach(hero => {
|
||
let { attribute, dataId, relation, actorId } = hero;
|
||
if (relation === 2) {
|
||
const hp = attribute.hp||0;
|
||
if (hp > 0) {
|
||
bossHpArr.push({dataId, hp, actorId});
|
||
bossHpSum += hp;
|
||
}
|
||
}
|
||
})
|
||
gameData.btlBossHp.set(warId, bossHpArr);
|
||
gameData.btlBossHpSum.set(warId, bossHpSum);
|
||
}
|
||
}
|
||
return { bossHpSum, bossHpArr };
|
||
}
|
||
|
||
|
||
export function getWarIdByBlueprtId(blueprtId: number) {
|
||
let warId = gameData.blueprtToWar.get(blueprtId);
|
||
if (!warId) {
|
||
let blueprt = gameData.goods.get(blueprtId);
|
||
if(blueprt) {
|
||
const { specialAttr } = blueprt;
|
||
warId = specialAttr.get(SPECIAL_ATTR.WAR_ID);
|
||
if(warId)
|
||
gameData.blueprtToWar.set(blueprtId, warId);
|
||
}
|
||
}
|
||
return warId;
|
||
}
|
||
|
||
export function getHeroStarByQuality(quality: number, star: number) {
|
||
return gameData.heroStar.get(`${quality}_${star}`);
|
||
}
|
||
|
||
export function getHeroWakeByQuality(quality: number, star: number) {
|
||
return gameData.heroWake.get(`${quality}_${star}`);
|
||
}
|
||
|
||
export function getMaxGradeByjobClass(jobClass: number) {
|
||
const job = gameData.jobClassMaxGrades.get(jobClass);
|
||
return job?.jobid;
|
||
}
|
||
|
||
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 getGoodById(gid:number) {
|
||
return gameData.goods.get(gid);
|
||
}
|
||
|
||
export function getJewelById(gid:number) {
|
||
return gameData.jewels.get(gid);
|
||
}
|
||
|
||
export function getHeroEquipByClassId(classId:number) {
|
||
return gameData.dicHeroEquip.get(classId);
|
||
}
|
||
|
||
export function getHeroJob(jobId: number) {
|
||
const job = gameData.job.get(jobId);
|
||
return job;
|
||
}
|
||
|
||
export function getTitle(titleLv: number) {
|
||
const titleInfo = gameData.title.get(titleLv);
|
||
return titleInfo;
|
||
}
|
||
|
||
export function getTeraph(id: number, grade: number) {
|
||
const teraphInfo = gameData.teraphs.get(id +'_'+ grade);
|
||
return teraphInfo;
|
||
}
|