Added controller for gameconfig, easiest one to stub out more or less

This commit is contained in:
2021-10-24 21:26:13 -04:00
parent 627ebab716
commit cd55d95ba9
2 changed files with 65 additions and 0 deletions

View File

@@ -4,6 +4,7 @@ using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using TOOHUCardAPI.Models;
namespace TOOHUCardAPI.Controllers
{
@@ -11,5 +12,10 @@ namespace TOOHUCardAPI.Controllers
[ApiController]
public class GameConfigController : ControllerBase
{
[HttpGet]
public async Task<GameConfigResponse> GetGameConfig()
{
return GameConfigResponse.Default();
}
}
}

View File

@@ -0,0 +1,59 @@
using System.Text.Json.Serialization;
using Newtonsoft.Json;
namespace TOOHUCardAPI.Models
{
/**
* GameRules.GameData.code = data.code // "0000" for success
GameRules.GameData.msg = data.msg // error message if any
GameRules.GameData.game_code = data.game_code or ""
GameRules.GameData.game_msg = data.game_msg or ""
GameRules.GameData.luck_card = data.luck_card or ""
GameRules.GameData.luck_crit = data.luck_crit or 0
GameRules.GameData.new_card_list = data.new_card_list or ""
GameRules.GameData.open_day_list = data.open_day_list or ""
GameRules.GameData.is_open_day = data.is_open_day or 0
GameRules.GameData.server_time = data.server_time
*/
public class GameConfigResponse
{
private static string SUCCESS_CODE = "0000";
[JsonPropertyName("code")]
public string Code { get; set; }
[JsonPropertyName("msg")]
public string Message { get; set; }
[JsonPropertyName("game_code")]
public string GameCode { get; set; }
[JsonPropertyName("game_msg")]
public string GameMessage { get; set; }
[JsonPropertyName("luck_card")]
public string LuckCard { get; set; }
[JsonPropertyName("luck_crit")]
public float LuckCrit { get; set; }
[JsonPropertyName("new_card_list")]
public string NewCardList { get; set; }
[JsonPropertyName("open_day_list")]
public string OpenDayList { get; set; }
[JsonPropertyName("is_open_day")]
public int IsOpenDay { get; set; }
[JsonPropertyName("server_time")]
public string ServerTime { get; set; }
public static GameConfigResponse Default()
{
return new GameConfigResponse
{
Code = SUCCESS_CODE,
Message = string.Empty,
GameCode = string.Empty,
GameMessage = string.Empty,
LuckCard = string.Empty,
LuckCrit = 0,
NewCardList = string.Empty,
OpenDayList = string.Empty,
IsOpenDay = 0,
ServerTime = string.Empty,
};
}
}
}