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

export interface DicGVGItem {
    // 道具id
    readonly id: number;
    // 点名称
    readonly name: string
    // 1-种子 2-铲子 3-斧子 4-内政外政令 5-战功 6-激战期用的复活令&匕首
    readonly type: number;
    // 1-每日刷新 2-赛期内刷新 
    readonly refreshType: number;
    // 兑换物品表消耗
    readonly consume: RewardInter[];
    // 这个表里的兑换消耗
    readonly leagueConsume: RewardInter[];
    // 耐久度或者产量
    readonly value: number,
    // 消耗后可获得的奖励
    readonly reward: RewardInter[];
    // 消耗后可获得的这张表里的奖励
    readonly leagueReward: RewardInter[];
    // 成熟时间
    readonly ripeTime: number;
}

export const dicGVGItem = new Map<number, DicGVGItem>();
export function loadGVGItem() {
    dicGVGItem.clear();
    
    let arr = readFileAndParse(FILENAME.DIC_GVG_ITEM);
    arr.forEach(o => {
        o.consume = parseGoodStr(o.consume);
        o.leagueConsume = parseGoodStr(o.leagueConsume);
        o.reward = parseGoodStr(o.reward);
        o.leagueReward = parseGoodStr(o.leagueReward);
        dicGVGItem.set(o.id, o);
    });
    arr = undefined;
}