This commit is contained in:
PC-20230316NUNE\Administrator
2024-01-15 18:45:45 +08:00
parent 94832afecb
commit 68e0f81616
14 changed files with 65 additions and 47 deletions

View File

@@ -3,6 +3,7 @@ import { API, PlayerInfoOV, PlayerPetOV } from "../consts/API";
import BaseData from "./BaseData";
import { GBattleDataEnum } from "./GBattleData";
import GOnHookData from "./GOnHookData";
import PetEquipData, { PetEquipDataEnum } from "./PetEquipData";
import PlayerTacticalData from "./PlayerTacticalData";
import { ResourceUpdateType } from "./ResourceData";
@@ -23,6 +24,16 @@ export default class PlayerPetData extends BaseData{
//更新玩家宠物
await this.UpdatePlayerPet();
app.event.on(PetEquipDataEnum.UPDATE_FORGING_INFO,this.onUpdateForgingInfo,this);
}
//更新锻造等级 (宠物等级)
onUpdateForgingInfo(){
this.datas.forEach(item => item.petLevel = PetEquipData.getIns().getForgingBenchPetLevel(item.petId));
app.event.emit(PlayerPetEvent.UPDATE)
}
@@ -49,7 +60,10 @@ export default class PlayerPetData extends BaseData{
//更新玩家宠物
async UpdatePlayerPet(){
//获取全部宠物
this.datas = await API.GetPlayerPets();
let datas = await API.GetPlayerPets();
datas.forEach(item => item.petLevel = PetEquipData.getIns().getForgingBenchPetLevel(item.petId));
this.datas = datas;
app.event.emit(GBattleDataEnum.UPDARE_ATTRIBUTE); //刷新属性
}
@@ -68,12 +82,15 @@ export default class PlayerPetData extends BaseData{
//添加宠物
addPet(pet:PlayerPetOV){
pet.petLevel = PetEquipData.getIns().getForgingBenchPetLevel(pet.petId);
this.datas.push(pet);
}
//刷新返回宠物
onUpdateOV(operation:number,resource:PlayerPetOV){
resource.petLevel = PetEquipData.getIns().getForgingBenchPetLevel(resource.petId);
//如果没有刷新的宠物 则 返回
if(!resource) return;