feature:
天梯派遣功能 fix: 天梯挂机等bug修复
This commit is contained in:
@@ -7,6 +7,8 @@ const allWarInfos = new Map<number, any>();
|
||||
const towerInfos = new Map<number, any>();
|
||||
const towerTaskInfos = new Map<number, any>();
|
||||
const towerTasksByQuality = new Map<number, Array<number>>();
|
||||
const heroInfos = new Map<number, any>();
|
||||
const jobInfos = new Map<number, any>();
|
||||
|
||||
function parseWarData() {
|
||||
let result = null;
|
||||
@@ -44,6 +46,26 @@ function parseTowerTaskData() {
|
||||
});
|
||||
}
|
||||
|
||||
function parseHeroData() {
|
||||
const heroFile = 'dic_zyz_hero';
|
||||
const heroesData = gamedata['jsons'][heroFile] || [];
|
||||
heroesData.forEach(elem => {
|
||||
if (elem && elem.heroId) {
|
||||
heroInfos.set(elem.heroId, elem);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function parseJobData() {
|
||||
const jobFile = 'dic_zyz_job';
|
||||
const jobsData = gamedata['jsons'][jobFile] || [];
|
||||
jobsData.forEach(elem => {
|
||||
if (elem && elem.jobid) {
|
||||
heroInfos.set(elem.jobid, elem);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function initData (folder) {
|
||||
if(!gamedata.hasOwnProperty(folder)) {
|
||||
gamedata[folder] = {};
|
||||
@@ -71,6 +93,8 @@ function parseData() {
|
||||
parseWarData();
|
||||
parseTowerData();
|
||||
parseTowerTaskData();
|
||||
parseHeroData();
|
||||
parseJobData();
|
||||
}
|
||||
|
||||
initData('jsons'); // 加载一般json
|
||||
@@ -116,4 +140,14 @@ export function getTaskById(tid: number) {
|
||||
export function getTaskIdByQuality(quality: number) {
|
||||
const taskIds = towerTasksByQuality.get(quality);
|
||||
return taskIds;
|
||||
}
|
||||
|
||||
export function getHeroInfoById(hid: number) {
|
||||
const heroInfo = heroInfos.get(hid);
|
||||
return heroInfo;
|
||||
}
|
||||
|
||||
export function getJobInfoById(jid: number) {
|
||||
const jobInfo = jobInfos.get(jid);
|
||||
return jobInfo;
|
||||
}
|
||||
@@ -174,7 +174,7 @@ export function getRandEelm(source: Array<any> = [], cnt = 1): Array<any> {
|
||||
if (cnt > source.length) return null;
|
||||
if (cnt === source.length) return source;
|
||||
let idxs = new Set();
|
||||
for (let i = 1; i < cnt; ++i) {
|
||||
for (let i = 0; i < cnt; ++i) {
|
||||
let rand = Math.floor(Math.random() * source.length);
|
||||
idxs.add(rand);
|
||||
if (idxs.size == cnt) {
|
||||
|
||||
Reference in New Issue
Block a user