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

export interface DicGVGVestige {
    // 唯一id
    readonly id: number;
    // 遗迹id
    readonly vestigeId: number;
    // 排行
    readonly rank: number;
    // 驻扎分
    readonly score: number;
    // 显示在详情的头像
    readonly head: number;
    // 显示在上面的形象
    readonly spine: number;
    // 显示的机器人的等级
    readonly level: number;
    // 显示战力
    readonly ce: number;
    // 突破奖励
    readonly onceReward: RewardInter[];
    // 突破时得到的gvg相关的奖励
    readonly onceLeagueReward: RewardInter[];
    // 机器人的出兵表使用
    readonly warId: number;
    // 消耗征战令得到的奖励
    readonly battleReward: RewardInter[];
    // 消耗征战令得到的gvg相关的奖励
    readonly battleLeagueReward: RewardInter[];
}

export const dicGVGVestige = new Map<number, Map<number, DicGVGVestige>>(); // 遗迹id => 排行 => dic
export function loadGVGVestige() {
    dicGVGVestige.clear();
    
    let arr = readFileAndParse(FILENAME.DIC_GVG_VESTIGE);
    arr.forEach(o => {
        o.onceReward = parseGoodStr(o.onceReward);
        o.onceLeagueReward = parseGoodStr(o.onceLeagueReward);
        o.battleReward = parseGoodStr(o.battleReward);
        o.battleLeagueReward = parseGoodStr(o.battleLeagueReward);
        o.warId = parseInt(o.warId);
        if(!dicGVGVestige.has(o.vestigeId)) {
            dicGVGVestige.set(o.vestigeId, new Map());
        }
        dicGVGVestige.get(o.vestigeId)?.set(o.rank, o);
    });
    arr = undefined;
}