资源刷新 以及 出售

This commit is contained in:
DESKTOP-5RP3AKU\Jisol
2023-11-20 03:47:00 +08:00
parent cb64a6c25f
commit 98b7a52b45
41 changed files with 1483 additions and 263 deletions

View File

@@ -1,9 +1,17 @@
import { app } from "../App";
import ResourceData from "../data/ResourceData";
import { GUI } from "../ui/UIConfig";
//接受到JSON消息
export const RData = (data:any,isTips:boolean = true) => {
if(data.data.state == 200){
//如果有 Resource 字段 表示要刷新资源
if(data.data['resources']){
//刷新资源
data.data['resources'].forEach(res => {
ResourceData.getIns().onUpdateOV(res.operation,res.resource);
})
}
return data.data.data;
}else{
//弹出提示
@@ -68,6 +76,13 @@ export interface PlayerTacticalOV{
playerId:number, //玩家Id
tacticalData:string, //阵法数据
}
//玩家资源
export interface ResourceOV{
resourceId:number; //资源Id
playerId:number; //玩家Id
resourceTbId:number; //资源配置表Id
resourceValue:number; //资源数量
}
export const API = {
@@ -86,5 +101,9 @@ export const API = {
/********** 阵法接口 ******************/
GetPlayerTactical: async () => RData(await app.api.get(`/game/tactical/get`),false) as PlayerTacticalOV, //获取玩家阵法
SetPlayerTactical: async (data:PlayerTacticalOV) => RData(await app.api.post(`/game/tactical/set`,data),false) as PlayerTacticalOV, //更新玩家阵法
/********** 资源接口 ******************/
GetPlayerResource: async () => RData(await app.api.get(`/game/resource/get`),false) as ResourceOV[], //获取玩家资源
}

View File

@@ -10,5 +10,7 @@ export const GAPI = {
GOnHookSpawnCreeps : async () => RProto(await app.api.get(`/game/mode/onHook/onSpawnCreeps`,{responseType:'arraybuffer'}),GActionType.GOnHookPets) as GOnHookPets,
//捕捉野怪
GOnHookCatchCreeps : async (creepId) => RData(await app.api.post(`/game/mode/onHook/onCatchCreeps/${creepId}`)) as PlayerPetOV,
//出售野怪
GOnHookSellCreeps : async (creepId) => RData(await app.api.post(`/game/mode/onHook/onSellCreeps/${creepId}`)),
}