Files
moonwell-web/app/Support/WowData.php
T
2026-03-13 23:33:35 +04:00

91 lines
2.3 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
namespace App\Support;
class WowData
{
/**
* @return array<int, string>
*/
public static function securityLevels(): array
{
return [
0 => 'Игрок',
1 => 'Модератор',
2 => 'Гейммастер',
3 => 'Администратор',
];
}
public static function securityLevelName(int $level): string
{
return self::securityLevels()[$level] ?? 'Неизвестно';
}
public static function raceName(int $race): string
{
return [
1 => 'Человек',
2 => 'Орк',
3 => 'Дворф',
4 => 'Ночной эльф',
5 => 'Нежить',
6 => 'Таурен',
7 => 'Гном',
8 => 'Тролль',
10 => 'Эльф крови',
11 => 'Дреней',
][$race] ?? 'Неизвестно';
}
public static function className(int $class): string
{
return [
1 => 'Воин',
2 => 'Паладин',
3 => 'Охотник',
4 => 'Разбойник',
5 => 'Жрец',
6 => 'Рыцарь смерти',
7 => 'Шаман',
8 => 'Маг',
9 => 'Чернокнижник',
11 => 'Друид',
][$class] ?? 'Неизвестно';
}
public static function genderName(int $gender): string
{
return [
0 => 'Мужской',
1 => 'Женский',
][$gender] ?? 'Неизвестно';
}
public static function formatMoney(int $copper): string
{
$gold = intdiv($copper, 10000);
$silver = intdiv($copper % 10000, 100);
$bronze = $copper % 100;
return sprintf('%dз %dс %dм', $gold, $silver, $bronze);
}
public static function formatPlayedTime(int $seconds): string
{
$days = intdiv($seconds, 86400);
$hours = intdiv($seconds % 86400, 3600);
$minutes = intdiv($seconds % 3600, 60);
if ($days > 0) {
return sprintf('%dд %dч', $days, $hours);
}
if ($hours > 0) {
return sprintf('%dч %dм', $hours, $minutes);
}
return sprintf('%dм', $minutes);
}
}