// GVG千机阁
import { FILENAME } from '../../consts'
import { decodeArrayListStr, parseNumberList, readFileAndParse } from '../util'

export interface DicGVGTech {
    // 唯一id
    readonly id: number;
    // 点名称
    readonly name: string
    // 激活后获得的内容
    readonly content: string;
    // 效果类型 1-资源产量上传 2-征战中原提升 3-激战期提升 4-复活cd减少 5-箭塔 6-攻城车
    readonly type: number;
    // 资源提升量啊，复活cd减少量啊之类的值
    readonly param: number[];
    // 点排序
    readonly nodeSort: number;
    // 联军等级限制
    readonly levelLimit: number;
    // 前置id
    readonly prepositionId: number[][];
    // 所需的战功
    readonly consume: number;
}

export const dicGVGTech = new Map<number, DicGVGTech>();
export function loadGVGTech() {
    dicGVGTech.clear();
    
    let arr = readFileAndParse(FILENAME.DIC_GVG_TECH);
    arr.forEach(o => {
        o.prepositionId = parsePrePositionId(o.prepositionId);
        o.param = parseNumberList(o.param)
        dicGVGTech.set(o.id, o);
    });
    arr = undefined;
}


function parsePrePositionId(str: string) {
    let arr = decodeArrayListStr(str);
    return arr.map(arr1 => {
        return arr1.map(str => parseInt(str));
    });
}