mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-06-26 03:14:47 +00:00
50 lines
1.2 KiB
TypeScript
50 lines
1.2 KiB
TypeScript
import { API, PlayerTacticalOV } from "../consts/API";
|
|
import BaseData from "./BaseData";
|
|
|
|
interface PlayerTacticalInfo extends PlayerTacticalOV{
|
|
roles:number[], //上阵的宠物顺序
|
|
}
|
|
|
|
//玩家阵法数据 (玩家最多上阵 9 个宠物)
|
|
export default class PlayerTacticalData extends BaseData{
|
|
|
|
//阵法信息
|
|
info:PlayerTacticalInfo;
|
|
|
|
async onInit() {
|
|
|
|
await this.onUpdateInfo();
|
|
|
|
}
|
|
|
|
//更新阵法信息
|
|
async onUpdateInfo(){
|
|
let ov = await API.GetPlayerTactical();
|
|
if(!ov.tacticalData){
|
|
ov.tacticalData = JSON.stringify(this.getTacticalInfo());
|
|
}
|
|
this.info = {
|
|
...ov,
|
|
roles: JSON.parse(ov.tacticalData),
|
|
}
|
|
}
|
|
|
|
//更新上阵
|
|
async UpdateTactical(roles:number[]){
|
|
this.info.roles = roles;
|
|
this.info.tacticalData = JSON.stringify(this.info.roles);
|
|
//上传到服务器
|
|
await API.SetPlayerTactical(this.info);
|
|
}
|
|
|
|
//获取指定位置
|
|
getItem(index:number){
|
|
return this.info.roles[index];
|
|
}
|
|
|
|
//获取初始化上阵信息
|
|
getTacticalInfo():number[]{
|
|
return [0,0,0,0,0,0,0,0,0]
|
|
}
|
|
|
|
} |