This commit is contained in:
2023-11-02 15:57:39 +02:00
parent a14232a899
commit def933dca4
51 changed files with 8866 additions and 12429 deletions
+145
View File
@@ -0,0 +1,145 @@
<?php
namespace Inf;
use Core\Config;
use Core\Db;
class Awards
{
private const KNIGHT = [
1 => 'Рыцарь первого круга',
2 => 'Рыцарь второго круга',
3 => 'Рыцарь третьего круга',
];
private const SCHOLAR = [
1 => 'Посвящённый первого круга',
2 => 'Посвящённый второго круга',
3 => 'Посвящённый третьего круга',
];
private const IZLOM = [
1 => 'Аттестованный боец',
2 => 'Опытный боец',
3 => 'Ветеран',
4 => 'Генерал',
];
private const DUNGEON_NAME = [
'repdreamscity' => 'Водосток',
'repizlom' => 'Излом Хаоса',
'rep1' => 'Храм Знаний',
];
private array $awards = [];
public function __construct(int $userid)
{
$reputations = Db::getRow('select * from rep where id = ?', [$userid]) ?: [];
$customAwards = Db::getRows('select text, img from users_ico where uid = ? and (endTime = 0 or endTime > unix_timestamp())', [$userid]);
foreach ($customAwards as $award) {
$this->awards[] = ['', $award['text'], $award['img']];
}
if (!empty($reputations)) {
$this->addDungeonAwards($reputations);
}
}
private function addDungeonAwards(mixed $reputations): void
{
match (true) {
$reputations['repdreamscity'] > 9999 => $this->awards[] = [self::DUNGEON_NAME['repdreamscity'], self::KNIGHT[3], 'i/ico/ric_kanal3.gif'],
$reputations['repdreamscity'] > 4999 => $this->awards[] = [self::DUNGEON_NAME['repdreamscity'], self::KNIGHT[2], 'i/ico/ric_kanal2.gif'],
$reputations['repdreamscity'] > 999 => $this->awards[] = [self::DUNGEON_NAME['repdreamscity'], self::KNIGHT[1], 'i/ico/ric_kanal1.gif'],
default => '',
};
match (true) {
$reputations['rep1'] > 9999 => $this->awards[] = [self::DUNGEON_NAME['rep1'], self::SCHOLAR[3], 'znrune_3.gif'],
$reputations['rep1'] > 999 => $this->awards[] = [self::DUNGEON_NAME['rep1'], self::SCHOLAR[2], 'znrune_2.gif'],
$reputations['rep1'] > 99 => $this->awards[] = [self::DUNGEON_NAME['rep1'], self::SCHOLAR[1], 'znrune_1.gif'],
default => '',
};
match (true) {
$reputations['repizlom'] > 24999 => $this->awards[] = [self::DUNGEON_NAME['repizlom'], self::IZLOM[4], 'iz_zn_ver10_4.gif'],
$reputations['repizlom'] > 9999 => $this->awards[] = [self::DUNGEON_NAME['repizlom'], self::IZLOM[3], 'iz_zn_ver10_3.gif'],
$reputations['repizlom'] > 999 => $this->awards[] = [self::DUNGEON_NAME['repizlom'], self::IZLOM[2], 'iz_zn_ver10_2.gif'],
$reputations['repizlom'] > 99 => $this->awards[] = [self::DUNGEON_NAME['repizlom'], self::IZLOM[1], 'iz_zn_ver10_1.gif'],
default => '',
};
match (true) {
$reputations['repcapitalcity'] > 24999 => $this->awards[] = ['Capital city', self::KNIGHT[2], 'zn1_2.gif'],
$reputations['repcapitalcity'] > 9999 => $this->awards[] = ['Capital city', self::KNIGHT[1], 'zn1_1.gif'],
default => '',
};
match (true) {
$reputations['repangelscity'] > 24999 => $this->awards[] = ['Angels city', self::KNIGHT[2], 'zn2_2.gif'],
$reputations['repangelscity'] > 9999 => $this->awards[] = ['Angels city', self::KNIGHT[1], 'zn2_1.gif'],
default => '',
};
match (true) {
$reputations['repdemonscity'] > 24999 => $this->awards[] = ['Demons city', self::KNIGHT[2], 'zn3_2.gif'],
$reputations['repdemonscity'] > 9999 => $this->awards[] = ['Demons city', self::KNIGHT[1], 'zn3_1.gif'],
default => '',
};
match (true) {
$reputations['repdevilscity'] > 24999 => $this->awards[] = ['Devils city', self::KNIGHT[2], 'zn4_2.gif'],
$reputations['repdevilscity'] > 9999 => $this->awards[] = ['Devils city', self::KNIGHT[1], 'zn4_1.gif'],
default => '',
};
match (true) {
$reputations['repsuncity'] > 24999 => $this->awards[] = ['Sun city', self::KNIGHT[2], 'zn5_2.gif'],
$reputations['repsuncity'] > 9999 => $this->awards[] = ['Sun city', self::KNIGHT[1], 'zn5_1.gif'],
default => '',
};
match (true) {
$reputations['repsandcity'] > 24999 => $this->awards[] = ['Sand city', self::KNIGHT[2], 'zn7_2.gif'],
$reputations['repsandcity'] > 9999 => $this->awards[] = ['Sand city', self::KNIGHT[1], 'zn7_1.gif'],
default => '',
};
match (true) {
$reputations['repemeraldscity'] > 24999 => $this->awards[] = ['Emeralds city', self::KNIGHT[2], 'zn6_2.gif'],
$reputations['repemeraldscity'] > 9999 => $this->awards[] = ['Emeralds city', self::KNIGHT[1], 'zn6_1.gif'],
default => '',
};
match (true) {
$reputations['repmooncity'] > 24999 => $this->awards[] = ['Moon city', self::KNIGHT[2], 'zn9_2.gif'],
$reputations['repmooncity'] > 9999 => $this->awards[] = ['Moon city', self::KNIGHT[1], 'zn9_1.gif'],
default => '',
};
match (true) {
$reputations['repabandonedplain'] > 9999 => $this->awards[] = ['Гора Легиона', self::KNIGHT[2], '1_gora.gif'],
$reputations['repabandonedplain'] > 999 => $this->awards[] = ['Гора Легиона', self::KNIGHT[1], '2_gora.gif'],
default => '',
};
}
public function addCustom(string $name, string $description, string $image): void
{
$this->awards[] = [$name, $description, $image];
}
public function print(): void
{
foreach ($this->awards as $award) {
$img = Config::img() . DIRECTORY_SEPARATOR . $award[2];
if (!empty($award[0])) {
$award[1] = "<b>$award[0]</b><br>$award[1]";
}
echo <<<HTML
<img src="$img" alt="" onmouseover="top.hi(this,'$award[1]',event,0,0,1,0);" onmouseout="top.hic();" onmousedown="top.hic();" style="cursor: pointer;">
HTML;
}
}
}
+38
View File
@@ -0,0 +1,38 @@
<?php
namespace Inf;
use Core\Db;
use DateTimeImmutable;
class LastNames
{
private array $lastnames = [];
/** История имён
* @param int $userid
*/
public function __construct(int $userid)
{
$names = Db::getRows('select * from lastnames where uid = ? order by time desc', [$userid]);
$dt = new DateTimeImmutable();
foreach ($names as $name) {
$dt->setTimestamp($name['time']);
$this->lastnames[] = "«{$name['login']}» до " . $dt->format('d.m.Y H:i');
}
}
public function print(): void
{
echo $this->get();
}
private function get(): string
{
if (empty($this->lastnames)) {
return '';
}
return 'История имен:<br>' . implode('<br>', $this->lastnames);
}
}
+38
View File
@@ -0,0 +1,38 @@
<?php
namespace Inf;
use Core\Config;
use Helper\Conversion;
class Status
{
private array $statuses;
public function add(bool $condition, string $text, int|string|null $timeout = 0, ?string $img = ''): void
{
if (!$condition) {
return;
}
if (!empty($timeout)) {
$text .= ' ещё ' . Conversion::secondsToTimeout($timeout - time());
}
$text = "<span style='vertical-align:middle;'>$text</span>";
if (!empty($img)) {
$text = '<span><img src="' . Config::img() . DIRECTORY_SEPARATOR . $img . '" alt="' . $text . '" style="vertical-align:middle;"></span> ' . $text;
}
$this->statuses[] = "<div>$text</div>"; // обёртка для центрирования картинки с текстом
}
public function print(): void
{
if (empty($this->statuses)) {
return;
}
echo '<br><div style="font-size: smaller;">' . implode('<br>', $this->statuses) . '</div>';
}
}
+39
View File
@@ -0,0 +1,39 @@
<?php
namespace Inf;
use Core\Db;
class Twinks
{
private array $twinks = [];
/** Мульты персонажа
* @param int $userid
* @param int $twinkid
*/
public function __construct(int $userid, int $twinkid)
{
$twinks = Db::getRows('select login, level, twink from users_twink where uid = ? and twink != 0', [$userid]);
foreach ($twinks as $twink) {
$str = $twink['login'] . ' [' . $twink['level'] . ']';
if ($twinkid === $twink['twink']) {
$str = '<b style="color:#ff9900;">' . $str . '</b>';
}
$this->twinks[] = $str;
}
}
public function print(): void
{
echo $this->get();
}
private function get(): string
{
if (empty($this->twinks)) {
return '';
}
return 'Другие образы: ' . implode(', ', $this->twinks) . '<br>';
}
}
+68
View File
@@ -0,0 +1,68 @@
<?php
namespace Inf;
use Core\Config;
class Zodiac
{
private const ZODIAC = [
1 => 'Овен',
2 => 'Телец',
3 => 'Близнецы',
4 => 'Рак',
5 => 'Лев',
6 => 'Дева',
7 => 'Весы',
8 => 'Скорпион',
9 => 'Стрелец',
10 => 'Козерог',
11 => 'Водолей',
12 => 'Рыбы',
];
private int $day = 0;
private int $month = 0;
public function __construct(string $date)
{
[$d, $m, $y] = explode('.', $date);
if (!checkdate($d, $m, $y)) {
return;
}
$this->day = (int)$d;
$this->month = (int)$m;
}
public function getImageLink(): string
{
if (empty($this->getName())) {
return '#';
}
$id = array_flip(self::ZODIAC);
return Config::img() . '/i/zodiac/' . $id[$this->getName()] . '.gif';
}
public function getName(): string
{
if (empty($this->day) || empty($this->month)) {
return '';
}
$z = [
1 => self::ZODIAC[10],
self::ZODIAC[11],
self::ZODIAC[12],
self::ZODIAC[1],
self::ZODIAC[2],
self::ZODIAC[3],
self::ZODIAC[4],
self::ZODIAC[5],
self::ZODIAC[6],
self::ZODIAC[7],
self::ZODIAC[8],
self::ZODIAC[9],
self::ZODIAC[10],
];
$lastDay = [1 => 19, 18, 20, 20, 21, 21, 22, 22, 21, 22, 21, 20, 19];
return $this->day > $lastDay[$this->month] ? $z[$this->month + 1] : $z[$this->month];
}
}