2020-07-05 21:16:22 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Author: lopiu
|
|
|
|
* Date: 05.07.2020
|
|
|
|
* Time: 23:32
|
|
|
|
*/
|
2021-01-28 21:05:34 +00:00
|
|
|
|
2020-10-28 20:21:08 +00:00
|
|
|
namespace Battles\Models;
|
2021-01-28 21:05:34 +00:00
|
|
|
|
2022-01-26 23:15:33 +00:00
|
|
|
use Battles\Database\Db;
|
2021-01-28 21:05:34 +00:00
|
|
|
|
2020-07-05 21:16:22 +00:00
|
|
|
class EffectsModel
|
|
|
|
{
|
|
|
|
protected $DB;
|
2020-07-06 18:41:32 +00:00
|
|
|
const EFFECT_HIDEUSERINFO = 5; // Обезлик
|
2020-07-05 21:16:22 +00:00
|
|
|
|
2021-01-28 21:05:34 +00:00
|
|
|
public function __construct(int $user_id)
|
2020-07-07 13:15:58 +00:00
|
|
|
{
|
2022-01-26 23:15:33 +00:00
|
|
|
$this->DB = Db::getInstance()->ofetchAll('SELECT * FROM users_effects WHERE owner_id = ?', $user_id);
|
2020-07-07 13:15:58 +00:00
|
|
|
}
|
|
|
|
|
2020-07-05 21:16:22 +00:00
|
|
|
/**
|
|
|
|
* Проверка обезличен ли персонаж.
|
|
|
|
* @return int date() до конца эффекта или 0.
|
|
|
|
*/
|
2021-01-28 21:05:34 +00:00
|
|
|
public function getHideUserInfoStatus(): int
|
2020-07-05 21:16:22 +00:00
|
|
|
{
|
2020-07-05 21:31:50 +00:00
|
|
|
if ($this->DB) {
|
2021-01-28 21:05:34 +00:00
|
|
|
$i = 0;
|
|
|
|
while ($i < count($this->DB)) {
|
2021-01-31 23:48:53 +00:00
|
|
|
if ($this->DB[$i]->type == self::EFFECT_HIDEUSERINFO) {
|
|
|
|
return $this->DB[$i]->remaining_time;
|
2020-07-05 21:31:50 +00:00
|
|
|
}
|
2021-01-28 21:05:34 +00:00
|
|
|
$i++;
|
2020-07-05 21:16:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|