import { readFileAndParse, parseGoodStr } from '../util'
import { FILENAME } from '../../consts'
import { RewardInter } from '../interface';

export interface DicQuenchConsume {
    // id
    readonly id: number;
    // 等级
    readonly equipLvl: number;
    // 品质
    readonly quality: number;
    // 淬火一次的消耗
    readonly unitConsume: RewardInter[];
}

export const dicQuenchConsume = new Map<string, RewardInter[]>(); // equipLvl&quality => dic
export function loadQuenchConsume() {
    dicQuenchConsume.clear();
    
    let arr = readFileAndParse(FILENAME.DIC_QUENCH_CONSUME);

    arr.forEach(o => {
        o.unitConsume = parseGoodStr(o.unitconsume);
        dicQuenchConsume.set(`${o.equipLvl}_${o.quality}`, o.unitConsume);
    });
    arr = undefined;
}