import { readFileAndParse, parseGoodStr } from '../util'
import { FILENAME } from '../../consts'
import { RewardInter } from '../interface';
export interface DicPvpBox {
    readonly id: number;
    readonly seasonNum: number;
    readonly index: number;
    readonly winTimes: number;
    readonly reward:  Array<RewardInter>;

}

export const dicPvpBoxs = new Map<string, DicPvpBox>();
export const dicPvpBoxesBySeasonNum = new Map<number, Map<number, string>>();
export function loadPvpBox() {
    dicPvpBoxs.clear();
    dicPvpBoxesBySeasonNum.clear();
    let arr = readFileAndParse(FILENAME.DIC_PVP_BOX);

    arr.forEach(o => {
        o.reward = parseGoodStr(o.reward);
        let key = `${o.seasonNum}_${o.index}`;
        dicPvpBoxs.set(key, o);
        if(!dicPvpBoxesBySeasonNum.has(o.seasonNum)) {
            dicPvpBoxesBySeasonNum.set(o.seasonNum, new Map());
        }
        dicPvpBoxesBySeasonNum.get(o.seasonNum).set(o.index, key);
    });
    arr = undefined;
}
