// 物品表
import { parseNumberList, readFileAndParse, } from '../util'
import { FILENAME, } from '../../consts'
const _ = require('lodash');

export interface DicArtifactQuality { 
    // 唯一id
    id: number;
    // 对应的se表的id
    seids: number[];
    // 解锁的品质
    quality: number;
    // 生效的职业，0表示全生效
    jobClass: number;
    // 生效的武将
    hids: number[];
}

type KeysEnum<T> = { [P in keyof Required<T>]: true };
const DicArtifactSeidKeys: KeysEnum<DicArtifactQuality> = {
    id: true,
    seids: true,
    quality: true,
    jobClass: true,
    hids: true,
}
export const dicArtifactSeid = new Map<number, DicArtifactQuality>(); // seid => dic

export function loadArtifactSeid() {
    dicArtifactSeid.clear();
    
    let arr = readFileAndParse(FILENAME.DIC_ARTIFACT_SEID);

    arr.forEach(o => {
        o.seids = parseNumberList(o.newId);
        o.hids = parseNumberList(o.hids);
        dicArtifactSeid.set(o.id, _.pick(o, Object.keys(DicArtifactSeidKeys)));
    });

    arr = undefined;
}