import Gamecfg from "../../../../common/gameCfg";
import { gameMethod } from "../../../../common/gameMethod";
import { UserEvent } from "../../../../data/const/EventConst";
import GameDataCenter from "../../../../data/GameDataCenter";
import EventMng from "../../../../manager/EventMng";

export default class HomeEpsCom {
    private _vm: fairygui.GComponent;
    public constructor(vm: fgui.GComponent) {
        this._vm = vm;
        //请求eps属性
        GameDataCenter.user.sendEpsInfo();
    }

    public onEnable(): void {
        EventMng.on(UserEvent.UP_USER_EPS, this.onUpUser, this);
    }

    onUpUser() {
        //基础四维属性
        let epsInfo = GameDataCenter.user.epsInfo;
        for (const key in epsInfo) {
            if (!gameMethod.isEmpty(this._vm.getChild("TxtEps_" + key))) {
                let epsCfg = Gamecfg.attrAttr.getItem(key);
                if (epsCfg) {
                    this._vm.getChild("TxtEps_" + key).asRichTextField.text = `[color=#b7b7d3]${epsCfg.showName}:[/color]${epsInfo[key]}`;
                }
            }
        }
    }

    public onDisable(): void {
        
    }
}
