mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-27 02:36:14 +00:00
资源刷新 以及 出售
This commit is contained in:
@@ -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[], //获取玩家资源
|
||||
|
||||
}
|
||||
|
||||
|
@@ -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}`)),
|
||||
|
||||
}
|
Reference in New Issue
Block a user