mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-27 02:36:14 +00:00
宠物上阵
This commit is contained in:
@@ -16,7 +16,7 @@ export default class PlayerPetData extends BaseData{
|
||||
}
|
||||
|
||||
//获取全部宠物
|
||||
getData(){
|
||||
getData():PlayerPetOV[]{
|
||||
return this.datas;
|
||||
}
|
||||
|
||||
@@ -33,6 +33,11 @@ export default class PlayerPetData extends BaseData{
|
||||
await this.UpdatePlayerPet();
|
||||
}
|
||||
|
||||
//通过宠物Id找到宠物
|
||||
petIdQueryPetInfo(petId:number):PlayerPetOV{
|
||||
return this.datas.filter(item => item.petId == petId)[0]
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@@ -1,6 +1,12 @@
|
||||
import { app } from "../App";
|
||||
import { API, PlayerTacticalOV } from "../consts/API";
|
||||
import BaseData from "./BaseData";
|
||||
|
||||
export enum PlayerTacticalEvent{
|
||||
//更新上阵信息
|
||||
UPDATE_TACTICAL = "PlayerTacticalEvent_UPDATE_TACTICAL"
|
||||
}
|
||||
|
||||
interface PlayerTacticalInfo extends PlayerTacticalOV{
|
||||
roles:number[], //上阵的宠物顺序
|
||||
}
|
||||
@@ -17,9 +23,9 @@ export default class PlayerTacticalData extends BaseData{
|
||||
|
||||
}
|
||||
|
||||
//更新阵法信息
|
||||
async onUpdateInfo(){
|
||||
let ov = await API.GetPlayerTactical();
|
||||
//保存阵法信息
|
||||
onSaveTacticalInfo(ov:PlayerTacticalOV){
|
||||
|
||||
if(!ov.tacticalData){
|
||||
ov.tacticalData = JSON.stringify(this.getTacticalInfo());
|
||||
}
|
||||
@@ -27,14 +33,28 @@ export default class PlayerTacticalData extends BaseData{
|
||||
...ov,
|
||||
roles: JSON.parse(ov.tacticalData),
|
||||
}
|
||||
|
||||
//通知阵法信息已更新
|
||||
app.event.emit(PlayerTacticalEvent.UPDATE_TACTICAL);
|
||||
}
|
||||
|
||||
//更新阵法信息
|
||||
async onUpdateInfo(){
|
||||
this.onSaveTacticalInfo(await API.GetPlayerTactical());
|
||||
}
|
||||
|
||||
//更新上阵
|
||||
async UpdateTactical(roles:number[]){
|
||||
this.info.roles = roles;
|
||||
this.info.tacticalData = JSON.stringify(this.info.roles);
|
||||
//上传到服务器
|
||||
await API.SetPlayerTactical(this.info);
|
||||
//上传到服务器 并且保存
|
||||
this.onSaveTacticalInfo(await API.SetPlayerTactical(this.info));
|
||||
}
|
||||
|
||||
//修改指定位置的上阵 上阵下标,上阵的宠物Id
|
||||
async UpdateIndexTactical(index:number,petId:number){
|
||||
this.info.roles[index] = petId;
|
||||
await this.UpdateTactical(this.info.roles);
|
||||
}
|
||||
|
||||
//获取指定位置
|
||||
|
Reference in New Issue
Block a user