// 列传的进度节点 import {decodeArrayListStr, readFileAndParse} from '../util' import { FILENAME } from '../../consts' export interface DicAuthorsBookPoint { // 列传 readonly bookId: number; // 进度节点 readonly value: number; // 到这个节点可得的属性 readonly attr: { id: number, val: number }[] } export const dicAuthorsBookPoint = new Map(); export function loadAuthorsBookPoint() { dicAuthorsBookPoint.clear(); let arr = readFileAndParse(FILENAME.DIC_AUTHORS_BOOK_POINT); arr.forEach(o => { o.attr = parseAttribute(o.attr); if(!dicAuthorsBookPoint.has(o.bookId)) dicAuthorsBookPoint.set(o.bookId, []); dicAuthorsBookPoint.get(o.bookId)?.push(o); }); arr = undefined; } 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 }