// 武将特技表
import { readFileAndParse, parseNumberList } from '../util'
import { FILENAME } from '../../consts'

export interface DicRandomEffectPool {

    // 特技id
    readonly id: number;
    // 类型
    readonly type: number;
    // 包含的值
    readonly gainValueArr: Array<number>;
    // 随机值位置
    readonly index: number;
    // 随机最小值
    readonly Min: number;
    // 随机最大值
    readonly Max: number;
    // 分割
    readonly gap: number;
    // 分割
    readonly planId: number;
    // 组别
    readonly group: number;
    // 等级
    readonly level: number;

}

export const dicRandomEffectPool = new Map<number, DicRandomEffectPool>();
export const dicRandomEffectPoolByGroupAndLv = new Map<string, number>();
export function loadRandomEffectPool() {
    dicRandomEffectPool.clear();
    
    let arr = readFileAndParse(FILENAME.DIC_RANDOM_EFFECT_POOL);

    arr.forEach(o => {
        if(o.planId == '&') o.planId = 0;
        o.gainValueArr = parseNumberList(o.gainValue);
        dicRandomEffectPool.set(o.id, o);
        dicRandomEffectPoolByGroupAndLv.set(`${o.group}_${o.level}`, o.id);
    });
    arr = undefined;
}