Now supports saving card groups, this is probably the ugliest code ive ever written but anything to avoid 20 cardgroup properties. we should see if there's a better way, it could probably be a lot cleaner
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Dynamic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using AutoMapper;
|
||||
using Newtonsoft.Json;
|
||||
using TOOHUCardAPI.Data.Models;
|
||||
@@ -9,30 +11,17 @@ namespace TOOHUCardAPI.DTO
|
||||
public class PlayerDataGetResponseObject
|
||||
{
|
||||
[JsonProperty("bo")]
|
||||
public Dictionary<string, PlayerDataGetResponseObjectPlayer> Players { get; set; }
|
||||
|
||||
public PlayerDataGetResponseObject(Dictionary<string, User> users, IMapper mapper)
|
||||
{
|
||||
this.Players = users.Aggregate(new Dictionary<string, PlayerDataGetResponseObjectPlayer>(),
|
||||
(players, pair) =>
|
||||
{
|
||||
User user = pair.Value;
|
||||
players[pair.Key] = mapper.Map<PlayerDataGetResponseObjectPlayer>(user);
|
||||
return players;
|
||||
});
|
||||
}
|
||||
public Dictionary<string, Dictionary<string, object>> Players { get; set; }
|
||||
|
||||
}
|
||||
/**
|
||||
* Fields pulled from the game code
|
||||
* Looking up Gamerules.Playerdata
|
||||
*/
|
||||
public class PlayerDataGetResponseObjectPlayer
|
||||
public class PlayerDataGetResponseObjectPlayer: AbstractResponse
|
||||
{
|
||||
[JsonProperty("code")] public string Code { get; set; } = "0000";
|
||||
|
||||
[JsonProperty("msg")] public string Message { get; set; } = string.Empty;
|
||||
//[JsonProperty("steamid")]
|
||||
//public string SteamId { get; set; }
|
||||
[JsonProperty("steamid")]
|
||||
public string SteamId { get; set; }
|
||||
[JsonProperty("max_wave")] public int MaxWave { get; set; } = 0;
|
||||
[JsonProperty("max_team_wave")] public int MaxTeamWave { get; set; } = 0;
|
||||
[JsonProperty("pet_level")] public int PetLevel { get; set; } = 1;
|
||||
@@ -42,5 +31,16 @@ namespace TOOHUCardAPI.DTO
|
||||
[JsonProperty("vip")] public int Vip { get; set; } = 1;
|
||||
[JsonProperty("point")] public int Point { get; set; } = 10000;
|
||||
[JsonProperty("level_list")] public string LevelList { get; set; } = string.Empty;
|
||||
|
||||
public Dictionary<string, object> ToDynamicProperties()
|
||||
{
|
||||
return GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public)
|
||||
.ToDictionary(prop => prop.Name, prop => prop.GetValue(this));
|
||||
}
|
||||
}
|
||||
|
||||
public class PlayerDataSaveCardGroupResponseObject : AbstractResponse
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user