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

@@ -1,14 +0,0 @@
using System.Collections.Generic;
namespace TOOHUCardAPI.DTO.RankData
{
public class RankCardDTO
{
public string ItemName { get; set; }
public int Star { get; set; }
public long Damage { get; set; }
public int Power { get; set; }
public int Attack { get; set; }
public Dictionary<int, string> Equip { get; set; }
}
}

View File

@@ -1,4 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using TOOHUCardAPI.Data.Models;
namespace TOOHUCardAPI.DTO.RankData
{
@@ -11,7 +13,25 @@ namespace TOOHUCardAPI.DTO.RankData
public string Version { get; set; }
public int Wave { get; set; }
public long Damage { get; set; }
// need cards here
public List<RankCardDTO> Cards { get; set; }
public Dictionary<string, string> Cards { get; set; }
}
public static class RankEntryDTOExtensions
{
public static RankEntryDTO ToRankEntryDTO(this RankEntry rankEntry)
{
return new RankEntryDTO
{
RankType = ((char) rankEntry.RankType).ToString(),
SteamId = rankEntry.User.SteamId,
UserId = 0, // temporary
Username = rankEntry.Username,
Version = rankEntry.Version,
Wave = rankEntry.Wave,
Damage = rankEntry.Damage,
Cards = rankEntry.TowersUsed.Select(tower => KeyValuePair.Create(tower.TowerKey, tower.EncodedData))
.ToDictionary(kv => kv.Key, kv => kv.Value)
};
}
}
}