mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-06-26 11:24:46 +00:00
50 lines
981 B
TypeScript
50 lines
981 B
TypeScript
import { API, PlayerInfoOV, PlayerPetOV } from "../consts/API";
|
|
import BaseData from "./BaseData";
|
|
|
|
|
|
//玩家宠物数据
|
|
export default class PlayerPetData extends BaseData{
|
|
|
|
//玩家宠物列表
|
|
datas:PlayerPetOV[] = [];
|
|
|
|
async onInit() {
|
|
|
|
//更新玩家宠物
|
|
await this.UpdatePlayerPet();
|
|
|
|
}
|
|
|
|
//获取全部宠物
|
|
getData():PlayerPetOV[]{
|
|
return this.datas;
|
|
}
|
|
|
|
//更新玩家宠物
|
|
async UpdatePlayerPet(){
|
|
//获取全部宠物
|
|
this.datas = await API.GetPlayerPets();
|
|
}
|
|
|
|
//选择宠物
|
|
async SelectNovicePet(petId:number){
|
|
await API.SelectNovicePet(petId);
|
|
//更新玩家宠物列表
|
|
await this.UpdatePlayerPet();
|
|
}
|
|
|
|
//通过宠物Id找到宠物
|
|
petIdQueryPetInfo(petId:number):PlayerPetOV{
|
|
return this.datas.filter(item => item.petId == petId)[0]
|
|
}
|
|
|
|
//添加宠物
|
|
addPet(pet:PlayerPetOV){
|
|
this.datas.push(pet);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|