// GVG周期表

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

export interface DicGVGPeriod {
    // 1-组建期 2-备战期 3-激战期
    readonly periodType: number; 
    // 星期几 1-7
    readonly day: number[]; 
    // 星期几 1-7
    readonly startDay: number; 
    // HH:mm, 组建期备战期填05:00。激战期填20:40
    readonly startHour: number;
    readonly startMinute: number;
    readonly startSecond: number;
    // HH:mm，组建期填截止创建联军时间，备战期填22:00，激战期填21:40
    readonly endHour: number;
    readonly endMinute: number;
    readonly endSecond: number;
}

export const dicGVGPeriod = new Map<number, DicGVGPeriod>();
export function loadGVGPeriod() {
    dicGVGPeriod.clear();
    
    let arr = readFileAndParse(FILENAME.DIC_GVG_PERIOD);
    arr.forEach(o => {
        o.day = parseNumberList(o.day);
        o.startDay = o.day[0];
        let startTime = o.startTime.split(':');
        o.startHour = parseInt(startTime[0]);
        o.startMinute = parseInt(startTime[1]);
        o.startSecond = parseInt(startTime[2]);
        let endTime = o.endTime.split(':');
        o.endHour = parseInt(endTime[0]);
        o.endMinute = parseInt(endTime[1]);
        o.endSecond = parseInt(endTime[2]);
        dicGVGPeriod.set(o.periodType, o);
    });
    arr = undefined;
}
