_TheStrongestSnail/TheStrongestSnail/Assets/Scripts/SnailKnight52/queryKnightRecord526.cs

77 lines
3.1 KiB
C#

using Newtonsoft.Json;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
//526查询用户战斗记录
public class queryKnightRecord526 : MonoBehaviour
{
KnightRecord knightRecord = new KnightRecord();
public async Task<KnightRecord> queryKnightBetResult(int orderByDesc) // 5.2.6
{
// 准备请求的头部信息,包含授权令牌
Dictionary<string, string> head526 = new Dictionary<string, string>
{
{ "Authorization", Global.global.serverResponse.data.token }
};
// 请求体
QueryKnightRecordBody queryKnightRecordBody = new QueryKnightRecordBody
{
userId = Global.global.serverResponse.data.userId,
orderByDesc = orderByDesc
};
// 异步发送请求
string response526 = await web.SendRequest(web.URL + "/snail/gameKnight/queryUserRecord", "POST", JsonUtility.ToJson(queryKnightRecordBody), head526);
// 调试输出接收到的响应
Debug.Log("5.2.6查询用户战斗记录 =====================" + response526);
// 将响应反序列化为 KnightRoomList 对象
KnightRecord knightRecord = JsonConvert.DeserializeObject<KnightRecord>(response526);
// 检查反序列化是否成功
if (knightRecord != null && knightRecord.data != null)
{
// 打印基本信息
Debug.Log("Code: " + knightRecord.code);
Debug.Log("Message: " + knightRecord.message);
Debug.Log("Total Beans Coin Bet: " + knightRecord.data.beansCoinBet);
Debug.Log("Total Beans Coin Win: " + knightRecord.data.beansCoinWin);
// 获取战斗记录列表
List<GameKnightModelRecord> gameList = knightRecord.data.gameKnightModelList;
if (gameList != null && gameList.Count > 0)
{
foreach (GameKnightModelRecord game in gameList)
{
Debug.Log("Game ID: " + game.id);
Debug.Log("Game No: " + game.gameNo);
Debug.Log("Game Session: " + game.gameSession);
Debug.Log("Start Time: " + game.startTime);
Debug.Log("Bet Time: " + game.betTime);
Debug.Log("Count Time: " + game.countTime);
Debug.Log("Settle Time: " + game.settleTime);
Debug.Log("Status: " + game.status);
Debug.Log("Horse No All: " + game.horseNoAll);
Debug.Log("Horse No Kill: " + game.horseNoKill);
Debug.Log("Horse No Remain: " + game.horseNoRemain);
Debug.Log("Beans Coin All: " + game.beansCoinAll);
Debug.Log("Beans Coin Kill: " + game.beansCoinKill);
Debug.Log("Beans Coin Remain: " + game.beansCoinRemain);
Debug.Log("Beans Coin Fee: " + game.beansCoinFee);
Debug.Log("Beans Coin Divide: " + game.beansCoinDivide);
}
}
}
else
{
Debug.LogError("KnightRecord or KnightRecord data is null");
}
return knightRecord;
}
}