CombatProgressBarHelper.cs
1 namespace GUNRPG.WebClient.Helpers; 2 3 public static class CombatProgressBarHelper 4 { 5 public static int GetPercent(double current, double maximum) 6 { 7 if (maximum <= 0 || double.IsNaN(current) || double.IsNaN(maximum)) 8 return 0; 9 10 var percent = current / maximum * 100d; 11 return (int)Math.Round(Math.Clamp(percent, 0d, 100d), MidpointRounding.AwayFromZero); 12 } 13 14 public static int? GetAriaValue(double current, double maximum) 15 { 16 if (double.IsNaN(current) || double.IsNaN(maximum) || maximum <= 0d) 17 return null; 18 19 var clamped = Math.Clamp(current, 0d, maximum); 20 return (int)Math.Round(clamped, MidpointRounding.AwayFromZero); 21 } 22 23 public static int? GetAriaMax(double maximum) 24 { 25 if (maximum <= 0 || double.IsNaN(maximum)) 26 return null; 27 28 return (int)Math.Round(maximum, MidpointRounding.AwayFromZero); 29 } 30 }