// 时装表 import { decodeArrayListStr, readJsonFile } from '../util'; import { FILENAME } from '../../consts'; export interface DicFashions { // 时装id readonly id: number; // 指向heroSkill表 readonly skillId: number; // 全局加成 readonly globalAttr: Array<{id: number, number: number}>; // 单体加成 readonly actorAttr: Array<{id: number, number: 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.globalAttr = parseAttr(o.globalAttr); o.actorAttr = parseAttr(o.actorAttr); dicFashions.set(o.id, o); }); function parseAttr(str: string) { let result = new Array<{id: number, number: number}>(); if(!str) return result; let decodeArr = decodeArrayListStr(str); for(let [id, number] of decodeArr) { if(isNaN(parseInt(id)) || isNaN(parseInt(number))) { throw new Error('data table format wrong'); } result.push({id: parseInt(id), number: parseInt(number)}); } return result }