mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-10-09 00:26:11 +00:00
提交上阵
This commit is contained in:
50
JisolGameCocos/assets/script/data/PlayerTacticalData.ts
Normal file
50
JisolGameCocos/assets/script/data/PlayerTacticalData.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
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]
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user