diff --git a/EDPlayerJournal/PowerPlay/Powers.cs b/EDPlayerJournal/PowerPlay/Powers.cs new file mode 100644 index 0000000..d84419e --- /dev/null +++ b/EDPlayerJournal/PowerPlay/Powers.cs @@ -0,0 +1,101 @@ +namespace EDPlayerJournal.PowerPlay; + +/// +/// Holds a list of all available powers in E:D, and helps +/// to translate commonly used short-hands and aliases to +/// journal approved power names. +/// +public class Powers { + public static readonly string + // Basking + ALavignyDuval = "A. Lavigny-Duval", + AislingDuval = "Aisling Duval", + DentonPatreus = "Denton Patreus", + ZeminaTorval = "Zemina Torval", + // Feds + JeromeArcher = "Jerome Archer", + FeliciaWinters = "Felicia Winters", + // Alliance + EdmunMahon = "Edmund Mahon", + NakatoKaine = "Nakato Kaine", + // Independents + YuriGrom = "Yuri Grom", + ArchonDelaine = "Archon Delaine", + LiYongRui = "Li Yong-Rui", + PranavAntal = "Pranav Antal" + ; + + public static readonly Dictionary aliases = new() { + // ALD + { Powers.ALavignyDuval, Powers.ALavignyDuval }, + { "ALD", Powers.ALavignyDuval }, + { "Arissa", Powers.ALavignyDuval }, + { "Emperor", Powers.ALavignyDuval }, + { "Kaiser", Powers.ALavignyDuval }, + // AD + { Powers.AislingDuval, Powers.AislingDuval }, + { "AD", Powers.AislingDuval }, + { "Aisling", Powers.AislingDuval }, + // DP + { Powers.DentonPatreus, Powers.DentonPatreus }, + { "DP", Powers.DentonPatreus }, + { "Denton", Powers.DentonPatreus }, + // ZT + { Powers.ZeminaTorval, Powers.ZeminaTorval }, + { "ZT", Powers.ZeminaTorval }, + { "Torval", Powers.ZeminaTorval }, + // Archer + { Powers.JeromeArcher, Powers.JeromeArcher }, + { "JA", Powers.JeromeArcher }, + { "Archer", Powers.JeromeArcher }, + // Winters + { Powers.FeliciaWinters, Powers.FeliciaWinters }, + { "FW", Powers.FeliciaWinters }, + { "Winters", Powers.FeliciaWinters }, + // Mahon + { Powers.EdmunMahon, Powers.EdmunMahon }, + { "EM", Powers.EdmunMahon }, + { "Mahon", Powers.EdmunMahon }, + // Kaine + { Powers.NakatoKaine, Powers.NakatoKaine }, + { "NK", Powers.NakatoKaine }, + { "Kaine", Powers.NakatoKaine }, + // Grom + { Powers.YuriGrom, Powers.YuriGrom }, + { "YG", Powers.YuriGrom }, + { "Grom", Powers.YuriGrom }, + // Archon + { Powers.ArchonDelaine, Powers.ArchonDelaine }, + { "Archon", Powers.ArchonDelaine }, + { "Kumo", Powers.ArchonDelaine }, + { "KumoBurger", Powers.ArchonDelaine }, + // LYR + { Powers.LiYongRui, Powers.LiYongRui }, + { "LYR", Powers.LiYongRui }, + // Pranav + { Powers.PranavAntal, Powers.PranavAntal }, + { "PA", Powers.PranavAntal }, + { "Pranav", Powers.PranavAntal }, + }; + + public static bool IsValidPower(string power) { + try { + string p = GetPower(power); + return true; + } catch (Exception) { + return false; + } + } + + public static string GetPower(string nameOrAlias) { + string? val = aliases + .Where(x => string.Compare(x.Key, nameOrAlias, StringComparison.InvariantCultureIgnoreCase) == 0) + .Select(x => x.Value) + .FirstOrDefault() + ; + if (string.IsNullOrEmpty(val)) { + throw new ApplicationException($"not a valid power: {nameOrAlias}"); + } + return val; + } +} \ No newline at end of file