// 时装表 import { decodeArrayListStr, readJsonFile, parseNumberList } from '../util'; import { FILENAME } from '../../consts/consts'; export interface DicFashions { // 时装id readonly id: number; // 增加的被动技能 readonly seid: Array; // 全局加成 readonly globalAttr: Array<{type: number, value: number}>; // 单体加成 readonly actorAttr: Array<{type: number, value: number}>; // 角色id readonly actorId: number; } const str = readJsonFile(FILENAME.DIC_FASHIONS); let arr = JSON.parse(str); export const dicFashions = new Map(); arr.forEach(o => { o.seid = parseNumberList(o.seid); o.globalAttr = parseAttr(o.globalAttr); o.actorAttr = parseAttr(o.actorAttr); dicFashions.set(o.id, o); }); function parseAttr(str: string) { let result = new Array<{type: number, value: number}>(); if(!str) return result; let decodeArr = decodeArrayListStr(str); for(let [type, value] of decodeArr) { if(isNaN(parseInt(type)) || isNaN(parseInt(value))) { throw new Error('data table format wrong'); } result.push({type: parseInt(type), value: parseInt(value)}); } return result }