// GVG遗迹
import { FILENAME } from '../../consts'
import { parseNumberList, readFileAndParse } from '../util'

export interface DicGVGVestigeType {
    // 唯一id
    readonly id: number;
    // 遗迹id
    readonly vestigeId: number;
    // 地图类型，1-单服 2-跨服
    readonly mapType: number[];
    // 位置
    readonly position: string;
}

export const dicGVGVestigeByType = new Map<number, DicGVGVestigeType[]>(); // 地图类型 => 遗迹id
export const dicGVGVestigeName = new Map<number, string>(); // 遗迹地图名
export function loadGVGVestigeType() {
    dicGVGVestigeByType.clear();
    
    let arr = readFileAndParse(FILENAME.DIC_GVG_VESTIGE_TYPE);
    arr.forEach(o => {
        o.mapType = parseNumberList(o.mapType);
        for(let type of o.mapType) {
            if(!dicGVGVestigeByType.has(type)) {
                dicGVGVestigeByType.set(type, []);
            }
            dicGVGVestigeByType.get(type)?.push(o);
        }
        dicGVGVestigeName.set(o.vestigeId, o.name);
    });
    arr = undefined;
}