I'm an idiot, they store encoded data for towers, we dont need a separate object unless we want to

This commit is contained in:
2021-11-06 22:18:12 -04:00
parent 7ef9c0d498
commit f23d108fe7
9 changed files with 135 additions and 50 deletions

View File

@@ -11,13 +11,12 @@ namespace TOOHUCardAPI.Data.JsonConverters
{
public override void WriteJson(JsonWriter writer, RankEntryDTO value, JsonSerializer serializer)
{
List<RankCardDTO> cards = value.Cards;
Dictionary<string, string> cards = value.Cards;
value.Cards = null;
JObject jo = JObject.FromObject(value);
for (int i = 0; i < cards.Count; i++)
foreach (var kv in cards)
{
jo[$"card{i}"] = JObject.FromObject(cards[i]);
jo[kv.Key] = kv.Value;
}
jo.WriteTo(writer);
}
@@ -29,7 +28,8 @@ namespace TOOHUCardAPI.Data.JsonConverters
RankEntryDTO dto = new RankEntryDTO();
serializer.Populate(reader, dto);
dto.Cards = jo.Properties().Where(prop => prop.Name.Contains("card"))
.Select(i => i.Value.ToObject<RankCardDTO>()).ToList();
.Select(i => KeyValuePair.Create(i.Name, i.Value))
.ToDictionary(kv => kv.Key, kv => kv.Value.ToObject<string>());
return dto;
}
}