54 lines
1.2 KiB
C#
54 lines
1.2 KiB
C#
using UnityEngine;
|
|
|
|
public class PluralizeUtil
|
|
{
|
|
public static string Rubles(int n)
|
|
{
|
|
int lastDigit = n % 10;
|
|
int lastTwoDigits = n % 100;
|
|
|
|
if (lastTwoDigits >= 11 && lastTwoDigits <= 14)
|
|
return "рублей";
|
|
|
|
return lastDigit switch
|
|
{
|
|
1 => "рубль",
|
|
2 or 3 or 4 => "рубля",
|
|
_ => "рублей"
|
|
};
|
|
}
|
|
|
|
public static string Tokens(int n)
|
|
{
|
|
int lastDigit = n % 10;
|
|
int lastTwoDigits = n % 100;
|
|
|
|
if (lastTwoDigits >= 11 && lastTwoDigits <= 14)
|
|
return "жетонов";
|
|
|
|
return lastDigit switch
|
|
{
|
|
1 => "жетон",
|
|
2 or 3 or 4 => "жетона",
|
|
_ => "жетонов"
|
|
};
|
|
}
|
|
|
|
//Для настроек
|
|
public static int PlaytimeToMinutes(string playtime)
|
|
{
|
|
if (playtime == "Неограниченно") return 0;
|
|
|
|
try
|
|
{
|
|
string textNumber = playtime.Split(' ')[0];
|
|
int minutes = int.Parse(textNumber);
|
|
return minutes;
|
|
}
|
|
catch
|
|
{
|
|
Debug.Log($"Ошибка парсинга значения {playtime}");
|
|
return 0;
|
|
}
|
|
}
|
|
} |