// 主公经验
import {readFileAndParse} from '../util'
import { FILENAME } from '../../consts'

export interface DicKingExp {
    // 等级
    readonly level: number;
    // 经验
    readonly exp: number;
}

export const dicKingExp = new Map<number, {sum: number, cur: number}>();
export const maxPlayerLv = { max: 0 };

export function loadKingExp() {
    dicKingExp.clear();
    maxPlayerLv.max = 0;
    let arr = readFileAndParse(FILENAME.DIC_KING_EXP);
    let exp = 0;
    arr.forEach(o => {
        exp += o.exp;
        if(o.level > maxPlayerLv.max) maxPlayerLv.max = o.level;
        dicKingExp.set(o.level, { sum: exp, cur: o.exp });
    });
    arr = null;
}