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

export interface DicGVGLeagueLv {
    // 等级
    readonly lv: number;
    // 粮食
    readonly food: number;
    // 矿产
    readonly mineral: number;
    // 木材
    readonly wood: number;
    // 消耗后可获得的奖励
    readonly reward: RewardInter[];
}

export const dicGVGLeagueLv = new Map<number, DicGVGLeagueLv>();
export function loadGVGLeagueLv() {
    dicGVGLeagueLv.clear();
    
    let arr = readFileAndParse(FILENAME.DIC_GVG_LEAGUE_LV);
    let food = 0, mineral = 0, wood = 0;
    arr.forEach(o => {
        food += o.food;
        mineral += o.mineral;
        wood += o.wood;
        dicGVGLeagueLv.set(o.lv, {
            lv: o.lv, reward: parseGoodStr(o.reward), food, mineral, wood,
        });
    });
    arr = undefined;
}