Files
LeagueARAMTracker/ARAMUtility/ViewModel/ChampionViewModel.cs
2026-03-13 01:22:28 +01:00

71 lines
2.5 KiB
C#

using System.Text;
using CommunityToolkit.Mvvm.ComponentModel;
using LeagueAPI.Models.DDragon.Champions;
namespace ARAMUtility.ViewModel;
public partial class ChampionViewModel(ChampionData data) : ObservableObject
{
[ObservableProperty]
public partial int Id { get; set; } = data.Id;
[ObservableProperty]
public partial string? Name { get; set; } = data.Name;
[ObservableProperty]
public required partial string ImagePath { get; set; }
public string AramBalanceText { get; } = GetAramBalanceText(data);
[ObservableProperty]
public required partial bool IsNeededForChallenge { get; set; }
private static string GetAramBalanceText(ChampionData data)
{
StringBuilder sb = new();
sb.AppendLine(data.Name);
foreach (KeyValuePair<string, double> kv in data.AramBalance)
{
switch (kv.Key)
{
case "dmg_dealt":
if (kv.Value == 1) { continue; }
sb.AppendFormat("Dmg Dealt: {0:+#0%;-#0%}", kv.Value - 1);
break;
case "dmg_taken":
if (kv.Value == 1) { continue; }
sb.AppendFormat("Dmg Taken: {0:+#0%;-#0%}", kv.Value - 1);
break;
case "healing":
if (kv.Value == 1) { continue; }
sb.AppendFormat("Healing: {0:+#0%;-#0%}", kv.Value - 1);
break;
case "energyregen_mod":
if (kv.Value == 1) { continue; }
sb.AppendFormat("Energy Regen: {0:+#0%;-#0%}", kv.Value - 1);
break;
case "tenacity":
if (kv.Value == 1) { continue; }
sb.AppendFormat("Tenacity: {0:+#0%;-#0%}", kv.Value - 1);
break;
case "shielding":
if (kv.Value == 1) { continue; }
sb.AppendFormat("Shielding: {0:+#0%;-#0%}", kv.Value - 1);
break;
case "ability_haste":
sb.AppendFormat("Ability Haste: {0}", kv.Value);
break;
case "total_as":
if (kv.Value == 1) { continue; }
sb.AppendFormat("Total AS: {0}", kv.Value);
break;
default:
sb.AppendFormat("{0}: {1}", kv.Key, kv.Value);
break;
}
sb.AppendLine();
}
return sb.ToString();
}
}