Files
ZYZ/shared/pubUtils/dictionary/DicWarJson.ts
2021-03-04 15:33:24 +08:00

75 lines
2.0 KiB
TypeScript

// 关卡表
import {decodeArrayListStr, readWarJsonFileList} from '../util'
export interface DicWarJson {
// 关卡id
readonly warId: number;
// 武将编号
readonly actorId: number;
// 武将名字
readonly actorName: string;
// 战场中指向该角色的唯一代码
readonly dataId: number;
// 角色属于我方/敌方/友军
readonly relation: number;
// 上阵时的方向
readonly direction: number;
// 客户端存入数组的顺序
readonly outIndex: number;
// x坐标
readonly x: number;
// y坐标
readonly y: number;
// 剧本中调用角色时的变量
readonly var: number;
// 角色等级
readonly lv: number;
// 是否隐藏
readonly hide: number;
// 角色使用的AI类型
readonly initial_ai: number;
// 属性
readonly attribute: {id: number, val: number}[];
// 武将技能
readonly skill: string;
// 武将被动技能
readonly seid: string;
// 角色星级
readonly star: number;
// s动画
readonly spine: string;
// boss阶段
readonly bossStage: number;
// 召唤技能的召唤物
readonly callSkillData: string;
}
export const dicWarJson = new Map<number, Array<DicWarJson>>();
readWarJsonFileList().forEach(str => {
let arr = JSON.parse(str);
let warjson = new Array<DicWarJson>();
let warid = 0;
arr.forEach(o => {
o.attribute = parseAttribute(o.attribute);
warid = o.warId;
warjson.push(o);
});
dicWarJson.set(warid, warjson);
})
export function parseAttribute(str: string) {
let result = new Array<{ id: number, val: number }>();
if (!str) return result;
let decodeArr = decodeArrayListStr(str);
for (let [id, val] of decodeArr) {
if (isNaN(parseInt(id)) || isNaN(parseInt(val))) {
throw new Error('data table format wrong');
}
result.push({ id: parseInt(id), val: parseInt(val) });
}
return result
}