mirror of
https://github.com/DrMboga/WotBlitzStatisticsBlazor.git
synced 2026-10-24 20:00:05 +02:00
feat: Search player component implemented. Plus Winrate color schale implementation
This commit is contained in:
1 parent
edfc9aa139
commit
4fb56c3b16
10 files changed
+160
-4
No files matched your search
@@ -24,13 +24,39 @@ namespace WotBlitzStatisticsPro.Blazor.Helpers
|
||||
return $"{difference.value} {ago}";
|
||||
}
|
||||
|
||||
public static string SinceTime(this DateTimeOffset time, IStringLocalizer<App> localizer)
|
||||
{
|
||||
var currentDate = DateTime.Now;
|
||||
|
||||
var difference = ParseTheDifference(currentDate - time);
|
||||
string ago = difference.interval switch
|
||||
{
|
||||
TimeInterval.Year => localizer.GetString("years ago"),
|
||||
TimeInterval.Month => localizer.GetString("months ago"),
|
||||
TimeInterval.Day => localizer.GetString("days ago"),
|
||||
TimeInterval.Hour => localizer.GetString("hours ago"),
|
||||
TimeInterval.Minute => localizer.GetString("minutes ago")
|
||||
};
|
||||
|
||||
return $"{difference.value} {ago}";
|
||||
}
|
||||
|
||||
public static (int value, TimeInterval interval) ParseTheDifference(TimeSpan difference)
|
||||
{
|
||||
// ToDo: Check hours and mins if Days is 0
|
||||
if (difference.TotalHours < 1)
|
||||
{
|
||||
return (Convert.ToInt32(difference.TotalMinutes), TimeInterval.Minute);
|
||||
}
|
||||
|
||||
if (difference.TotalDays < 1)
|
||||
{
|
||||
return (Convert.ToInt32(difference.TotalHours), TimeInterval.Hour);
|
||||
}
|
||||
|
||||
return difference.TotalDays switch
|
||||
{
|
||||
>= 365 => (CalculateYears(difference.TotalDays), TimeInterval.Year),
|
||||
(> 30) and (< 365) => (CalculateMonths(difference.TotalDays), TimeInterval.Month),
|
||||
(>= 30) and (< 365) => (CalculateMonths(difference.TotalDays), TimeInterval.Month),
|
||||
_ => (Convert.ToInt32(difference.TotalDays), TimeInterval.Day)
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
namespace WotBlitzStatisticsPro.Blazor.Helpers
|
||||
{
|
||||
public static class ScaleHelper
|
||||
{
|
||||
public static string ScaleColor(this int winRate)
|
||||
{
|
||||
return winRate switch
|
||||
{
|
||||
( > 0 ) and ( < 45) => Constants.ScaleVeryBadColor,
|
||||
( >= 45 ) and ( < 47 ) => Constants.ScaleBadColor,
|
||||
( >= 47 ) and ( < 49 ) => Constants.ScaleBelowAverageColor,
|
||||
( >= 49 ) and ( < 52 ) => Constants.ScaleAverageColor,
|
||||
( >= 52 ) and ( < 54 ) => Constants.ScaleGoodColor,
|
||||
( >= 54 ) and ( < 56 ) => Constants.ScaleVeryGoodColor,
|
||||
( >= 56 ) and ( < 60 ) => Constants.ScaleGreatColor,
|
||||
( >= 60 ) and ( < 65 ) => Constants.ScaleUnicumColor,
|
||||
_ => Constants.ScaleSuperUnicumColor
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user