// GVG城池
import { FILENAME } from '../../consts'
import { readFileAndParse } from '../util'

export interface DicGVGAreaPoint {
    // 积分点id
    readonly pointId: number;
    // 区域id
    readonly areaId: number;
    // 类型 1-守卫者 2-投石车
    readonly type: number;
    // 积分
    readonly score: number;
    // 位置
    readonly pointPosition: string;
    // 守卫名
    readonly name: string;
    // 守卫头像
    readonly head: number;
    // 守卫形象
    readonly spine: number;
    // 守卫战力
    readonly ce: number;
    // 守卫耐久
    readonly durability: number;
}

export const dicGVGAreaPoint = new Map<number, DicGVGAreaPoint>();
export const dicGVGPointsByAreaId = new Map<number, number[]>();
export function loadGVGAreaPoint() {
    dicGVGAreaPoint.clear();
    dicGVGPointsByAreaId.clear();
    
    let arr = readFileAndParse(FILENAME.DIC_GVG_AREA_POINT);
    arr.forEach(o => {
        dicGVGAreaPoint.set(o.pointId, o);
        if(!dicGVGPointsByAreaId.has(o.areaId)) {
            dicGVGPointsByAreaId.set(o.areaId, []);
        }
        dicGVGPointsByAreaId.get(o.areaId).push(o.pointId);
    });
    arr = undefined;
}