import { app } from "../App";
import GAttributeData, { GBattleDataInfo } from "../battle/base/values/GAttributeData";
import BaseData from "./BaseData";
import PetEquipData from "./PetEquipData";
import PlayerPetData from "./PlayerPetData";

export enum GBattleDataEnum{
    UPDARE_ATTRIBUTE = "GBattleDataEnum_UPDARE_ATTRIBUTE",     //更新属性
    UPDARE_ATTRIBUTE_SUCCESS = "GBattleDataEnum_UPDARE_ATTRIBUTE_SUCCESS",     //更新成功
}

//游戏战斗数据
export default class GBattleData extends BaseData{

    //自己的战斗数据
    data:GAttributeData = new GAttributeData();

    onInit() {
        this.onUpdateAttribute();
        app.event.on(GBattleDataEnum.UPDARE_ATTRIBUTE,this.onUpdateAttribute,this);
    }

    destroy(): void {
        app.event.off(GBattleDataEnum.UPDARE_ATTRIBUTE,this.onUpdateAttribute,this);
    }

    //刷新属性
    onUpdateAttribute(){
        this.data.assets({
            petEquips:PetEquipData.getIns().equips,
            pets:PlayerPetData.getIns().getTacticalData()
        })

        app.event.emit(GBattleDataEnum.UPDARE_ATTRIBUTE_SUCCESS)

    }

}

