// 邮件内容
import {readFileAndParse} from '../util'
import { FILENAME } from '../../consts'

export interface DicMail {
    // id MAIL_TYPE
    readonly id: number;
    // 内容 %d 替换
    readonly content: string;
    readonly title: string;
    readonly sendName: string;
    readonly time: number;
}

export const dicMail = new Map<number, DicMail>();
export function loadMail() {
    dicMail.clear();
    
    let arr = readFileAndParse(FILENAME.DIC_MAIL);
    arr.forEach(o => {
        if(o.title == '&') o.title = '';
        if(o.sendName == '&') o.sendName = '';
        o.time = o.time * 60 * 60;
        dicMail.set(o.id, o);
    });
    arr = undefined;
}