寻宝部分假数据改为读表
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import fs = require('fs');
|
||||
import path = require('path');
|
||||
import { ABI_TYPE } from '../consts/abilityConst';
|
||||
import { decodeIdCntArrayStr } from './util';
|
||||
|
||||
let gamedata = {};
|
||||
const wars = ['dic_zyz_gk_main', 'dic_zyz_gk_mainElite', 'dic_zyz_gk_daily', 'dic_zyz_gk_event', 'dic_zyz_gk_tower', 'dic_zyz_gk_expedition', 'dic_zyz_gk_dungeon','dic_zyz_gk_dungeonElite']; // 关卡相关的表
|
||||
@@ -15,6 +16,9 @@ const heroSkillInfo = new Map<number, any>()
|
||||
const seidInfo = new Map<number, any>();
|
||||
const olySeidInfo = new Map<number, any>();
|
||||
const expeditionInfo = new Map<number, any> ();
|
||||
const comBtlInfo = new Map<number, {quality: number, name: string, assistanceTime: number, assistanceLevel: number}>();
|
||||
const btlBossHp = new Map<number, number>();
|
||||
const blueprtBossHp = new Map<number, number>();
|
||||
|
||||
function parseWarData() {
|
||||
let result = null;
|
||||
@@ -176,6 +180,15 @@ function parseExpedition() {
|
||||
|
||||
}
|
||||
|
||||
function parseComBtlData() {
|
||||
const file = 'dic_zyz_xunbao';
|
||||
const data = gamedata['jsons'][file] || [];
|
||||
data.forEach(elem => {
|
||||
if (elem && elem.quality) {
|
||||
comBtlInfo.set(elem.quality, elem);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function initData (folder: string) {
|
||||
if(!gamedata.hasOwnProperty(folder)) {
|
||||
@@ -213,6 +226,7 @@ function parseData() {
|
||||
parseSeidList();
|
||||
parseOlySeidList();
|
||||
parseExpedition();
|
||||
parseComBtlData();
|
||||
}
|
||||
|
||||
initData('jsons'); // 加载一般json
|
||||
@@ -301,6 +315,42 @@ export function getExpeditionById(id: number) {
|
||||
return expeditionInfo.get(id);
|
||||
}
|
||||
|
||||
export function getComBtlSetByQuality(quality: number) {
|
||||
return comBtlInfo.get(quality);
|
||||
}
|
||||
|
||||
export function getBossHpByWarId(warId: number) {
|
||||
let bossHp = btlBossHp.get(warId) || 0;
|
||||
if (!bossHp) {
|
||||
const warInfo = getWarJsons(warId).json;
|
||||
if (warInfo && warInfo.length) {
|
||||
warInfo.forEach(hero => {
|
||||
if (hero.relation === 2) {
|
||||
let { attribute } = hero;
|
||||
let attriData = decodeIdCntArrayStr(attribute, 1);
|
||||
const hp = parseInt(attriData.get('1'));
|
||||
if (hp > 0) {
|
||||
bossHp += hp;
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
btlBossHp.set(warId, bossHp);
|
||||
}
|
||||
return bossHp;
|
||||
}
|
||||
|
||||
export function getBossHpByBlueprtId(blueprtId: number) {
|
||||
let bossHp = blueprtBossHp.get(blueprtId) || 0;
|
||||
if (!bossHp) {
|
||||
const { specialAttr } = getGoodById(blueprtId);
|
||||
const attrData = decodeIdCntArrayStr(specialAttr, 1);
|
||||
const warId = parseInt(attrData.get('1'));
|
||||
bossHp = getBossHpByWarId(warId);
|
||||
blueprtBossHp.set(blueprtId, bossHp);
|
||||
}
|
||||
return bossHp;
|
||||
}
|
||||
export function hasExpeditionById(id: number) {
|
||||
return expeditionInfo.has(id);
|
||||
}
|
||||
@@ -123,6 +123,7 @@ export function decodeArrayStr(str: string, splitForm='|') {
|
||||
*/
|
||||
export function decodeIdCntArrayStr(str: string, multi: number) {
|
||||
const strArr = decodeArrayStr(str);
|
||||
console.log('decodeIdCntArrayStr: ', strArr);
|
||||
const strMap = new Map();
|
||||
strArr.forEach(item => {
|
||||
const kv = item.split('&');
|
||||
|
||||
Reference in New Issue
Block a user