mirror of
https://github.com/DrMboga/WotBlitzStatisticsBlazor.git
synced 2026-10-26 11:50:05 +01:00
feat: tanks table layout
This commit is contained in:
1 parent
8a5d286560
commit
8b2c0daa27
51 files changed
+201
-11
No files matched your search
@@ -1,4 +1,5 @@
|
||||
using System.Text.Encodings.Web;
|
||||
using System;
|
||||
using System.Text.Encodings.Web;
|
||||
using System.Text.Json;
|
||||
using System.Text.Unicode;
|
||||
|
||||
@@ -10,5 +11,32 @@ namespace WotBlitzStatisticsPro.Blazor.Helpers
|
||||
{
|
||||
return JsonSerializer.Serialize(data, new JsonSerializerOptions { WriteIndented = true, Encoder = JavaScriptEncoder.Create(UnicodeRanges.BasicLatin, UnicodeRanges.Cyrillic) });
|
||||
}
|
||||
|
||||
public static string RomanNumber(this int number)
|
||||
{
|
||||
var romanNumerals = new[] {"M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"};
|
||||
var numerals = new[] {1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1};
|
||||
|
||||
if (number <= 0)
|
||||
{
|
||||
return number.ToString();
|
||||
}
|
||||
|
||||
string result = "";
|
||||
|
||||
while (number > 0)
|
||||
{
|
||||
// find biggest numeral that is less than equal to number
|
||||
var index = Array.FindIndex(numerals, n => n <= number);
|
||||
|
||||
// subtract it's value from your number
|
||||
number -= numerals[index];
|
||||
|
||||
// tack it onto the end of your roman numeral
|
||||
result = string.Concat(result, romanNumerals[index]);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user