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

export interface DicRankRewads {
    readonly id: number;
    readonly min: number;
    readonly max: number;
    readonly reward:  Array<RewardInter>;

}


export const dicRankRewads = new Array<DicRankRewads>();
export const dicRankMax: { max: DicRankRewads } = { max: undefined };
export function loadPvpRankReward() {
    dicRankRewads.splice(0, dicRankRewads.length);
    let arr = readFileAndParse(FILENAME.DIC_PVP_RANK_REWARD);

    arr.forEach(o => {
        o.reward = parseGoodStr(o.reward);
        if (!dicRankMax.max||o.min > dicRankMax.max.min) {
            dicRankMax.max = o;
        }
        dicRankRewads.push(o);
    });
    arr = undefined;
}