Некто'; public $email = 'неизвестно'; public $realname; public $borndate; public $info; public $level = 0; public $align = 0; public $clan = 0; public $money = 0; public $strength = 0; public $dexterity = 0; public $intuition = 0; public $endurance = 0; public $intelligence = 0; public $wisdom = 0; public $health; public $mana; public $ip; public $session_id; public $admin = 0; public $enter_game; public $room; public $block; public $shadow; // Удар кулаком всегда 1-2. public $minDamage = 1; public $maxDamage = 2; //Броня без предметов не существует. public $headArmor = 0; public $chestArmor = 0; public $legArmor = 0; public $free_stat_points = 0; public const STAT_MAXIMUM_AMOUNT = 40; private const ERROR_STAT_IS_MAXIMUM = 'Ошибка: Параметр достиг своего лимита!'; private const ERROR_STAT_UNKNOWN = 'Ошибка: Неизвестный параметр!'; // Пока несуществующие, для совместимости. public $married = 'Someone или нет.'; public $experience = 200; public $battle = 0; public $in_tower = 0; // Скорее башню похороним чем запустим... public $zayavka = 0; // Динамически рассчитываемые public $maxHealth = 5; public $maxMana = 5; //Статусы того, кто смотрит на информацию. public $watcher_id; protected $watcherIsAdmin; protected $watcherIsModerator; use Rooms; public function __construct($user) { $user_query = db::c()->query('SELECT * FROM users WHERE id = "?s" OR login = "?s"', $user, $user)->fetch_assoc(); foreach ($this as $key => $value) { if (isset($user_query[$key])) { $this->$key = $user_query[$key]; } } $this->maxHealth = round(($this->endurance * 3) + ($this->endurance / 2) * ($this->level - 1) + ($this->endurance / 5) * (($this->level - 1) * ($this->level - 2) / 2)); $this->maxMana = round(($this->wisdom * 3) + ($this->wisdom / 2) * ($this->level - 1) + ($this->wisdom / 5) * (($this->level - 1) * ($this->level - 2) / 2)); } /** * Отображает куклу персонажа (образ и слоты). * * @param int $isBattle - установить 1, если куклу нужно отобразить в поединке (показывает параметры при наведении * на образ). * @param int $isMain - установить 1, если куклу надо показать на странице игрока (по клику на предмет снимает * его). * * @throws \Krugozor\Database\Mysql\Exception */ private function UserInfoDoll($isBattle = 0, $isMain = 0) { //https://jsfiddle.net/ngx0yvhc //TODO переверстать grid, чтобы он касался только куклы. $di = new DressedItems($this->id); $dressedItems = $di->getItemsInSlots(); for ($i = 1; $i <= 12; $i++) { echo sprintf('
', $i); if (!empty($dressedItems[$i])) { if (!$isBattle && $isMain) { $itemString = '%s'; echo sprintf($itemString, $i, $dressedItems[$i]['image'], $dressedItems[$i]['name'], $dressedItems[$i]['name']); } else { $itemString = '%s%s'; echo sprintf($itemString, $dressedItems[$i]['image'], $dressedItems[$i]['name'], $dressedItems[$i]['name']); } } else { echo sprintf('Пустой слот [%s]', $i, $i); } echo sprintf('
', $i); } echo '
'; if ($isBattle) { $sh = '%s%sУровень: %s
Сила: %s
Ловкость: %s
Интуиция: %s
Выносливость: %s
Интеллект: %s
Мудрость: %s
'; echo sprintf($sh, $this->shadow, $this->login, $this->login, $this->level, $this->strength, $this->dexterity, $this->intuition, $this->endurance, $this->intelligence, $this->wisdom); unset($sh); } else { echo '' . $this->login . ''; } echo '
'; } private function UserInfoStats($isMainWindow = 0) { $captions = 'Уровень:
Сила:
Ловкость:
Интуиция:
Выносливость:
Интеллект:
Мудрость:
Местонахождение:'; $variables = $this->level . '
' . $this->getStrength() . '
' . $this->getDexterity() . '
' . $this->getIntuition() . '
' . $this->getEndurance() . '
' . $this->getIntelligence() . '
' . $this->getWisdom() . '
' . $this->getRoomName($this->room); if ($isMainWindow) { $this->Bank = new Bank($this->id); $captions = 'Уровень:
Здоровье:
Сила:
Ловкость:
Интуиция:
Выносливость:
Интеллект:
Мудрость:
Опыт:
Очки характеристик:
Деньги:
Деньги в банке:'; $variables = $this->level . '
' . $this->health . '
' . $this->getStrength(1) . '
' . $this->getDexterity(1) . '
' . $this->getIntuition(1) . '
' . $this->getEndurance(1) . '
' . $this->getIntelligence(1) . '
' . $this->getWisdom(1) . '
' . $this->experience . '
' . $this->free_stat_points . '
' . $this->money . '
' . $this->Bank->money; } if ($this->align) { $nameString = sprintf('', $this->align); } if ($this->block) { $nameString .= '' . $this->login . ''; } else { $nameString .= ' ' . $this->login . ' '; } if ($this->clan) { $nameString .= sprintf('', $this->clan); } echo '
'; echo '
'; echo '' . $nameString . ''; echo '
'; echo '
'; echo '
'; echo $captions; echo '
'; echo '
'; echo $variables; echo '
'; echo '
'; echo '
TODO: Сделать рассчёт модификаторов. Вывести полоску здоровья когда будет от чего отталкиваться.
'; echo '
'; } public function getStrength($isMainWindow = 0) { if ($this->free_stat_points && $isMainWindow && $this->strength < self::STAT_MAXIMUM_AMOUNT) { //main.php?edit=1&ups=sila return sprintf('%s [+]', $this->strength); } return $this->strength; } public function getDexterity($isMainWindow = 0) { if ($this->free_stat_points && $isMainWindow && $this->dexterity < self::STAT_MAXIMUM_AMOUNT) { //main.php?edit=1&ups=lovk return sprintf('%s [+]', $this->dexterity); } return $this->dexterity; } public function getIntuition($isMainWindow = 0) { if ($this->free_stat_points && $isMainWindow && $this->intuition < self::STAT_MAXIMUM_AMOUNT) { //main.php?edit=1&ups=inta... return sprintf('%s [+]', $this->intuition); } return $this->intuition; } public function getEndurance($isMainWindow = 0) { if ($this->free_stat_points && $isMainWindow && $this->endurance < self::STAT_MAXIMUM_AMOUNT) { return sprintf('%s [+]', $this->endurance); } return $this->endurance; } public function getIntelligence($isMainWindow = 0) { if ($this->free_stat_points && $isMainWindow && $this->intelligence < self::STAT_MAXIMUM_AMOUNT) { return sprintf('%s [+]', $this->intelligence); } return $this->intelligence; } public function getWisdom($isMainWindow = 0) { if ($this->free_stat_points && $isMainWindow && $this->wisdom < self::STAT_MAXIMUM_AMOUNT) { return sprintf('%s [+]', $this->wisdom); } return $this->wisdom; } public function setStrength() { if ($this->strength <= self::STAT_MAXIMUM_AMOUNT && $this->free_stat_points > 0) { db::c()->query('UPDATE users SET strength = strength + 1, free_stat_points = free_stat_points - 1 WHERE id = ?i', $this->id); } else { throw new Exception(self::ERROR_STAT_IS_MAXIMUM); } } public function setDexterity() { if ($this->dexterity <= self::STAT_MAXIMUM_AMOUNT && $this->free_stat_points > 0) { db::c()->query('UPDATE users SET dexterity = dexterity + 1, free_stat_points = free_stat_points - 1 WHERE id = ?i', $this->id); } else { throw new Exception(self::ERROR_STAT_IS_MAXIMUM); } } public function setIntuition() { if ($this->intuition <= self::STAT_MAXIMUM_AMOUNT && $this->free_stat_points > 0) { db::c()->query('UPDATE users SET intuition = intuition + 1, free_stat_points = free_stat_points - 1 WHERE id = ?i', $this->id); } else { throw new Exception(self::ERROR_STAT_IS_MAXIMUM); } } public function setEndurance() { if ($this->endurance <= self::STAT_MAXIMUM_AMOUNT && $this->free_stat_points > 0) { db::c()->query('UPDATE users SET endurance = endurance + 1, free_stat_points = free_stat_points - 1 WHERE id = ?i', $this->id); } else { throw new Exception(self::ERROR_STAT_IS_MAXIMUM); } } public function setIntelligence() { if ($this->intelligence <= self::STAT_MAXIMUM_AMOUNT && $this->free_stat_points > 0) { db::c()->query('UPDATE users SET intelligence = intelligence + 1, free_stat_points = free_stat_points - 1 WHERE id = ?i', $this->id); } else { throw new Exception(self::ERROR_STAT_IS_MAXIMUM); } } public function setWisdom() { if ($this->wisdom <= self::STAT_MAXIMUM_AMOUNT && $this->free_stat_points > 0) { db::c()->query('UPDATE users SET wisdom = wisdom + 1, free_stat_points = free_stat_points - 1 WHERE id = ?i', $this->id); } else { throw new Exception(self::ERROR_STAT_IS_MAXIMUM); } } public function addOnePointToStat($stat_name) { $allowed = ['strength', 'dexterity', 'intuition', 'endurance', 'intelligence', 'wisdom']; if (in_array($stat_name, $allowed)) { if ($this->free_stat_points > 0 && $this->$stat_name <= self::STAT_MAXIMUM_AMOUNT) { $query = 'UPDATE users SET ?f = ?f + 1, free_stat_points = free_stat_points - 1 WHERE id = ?i'; db::c()->query($query, $stat_name, $stat_name, $this->id); } else { throw new Exception(self::ERROR_STAT_IS_MAXIMUM); } } else { throw new Exception(self::ERROR_STAT_UNKNOWN); } } private function UserInfo() { echo '
'; $this->UserInfoDoll(); $this->UserInfoStats(); echo '
'; if ($this->married) { echo sprintf('В браке с %s', $this->married, $this->married, $this->married); } echo '
'; echo '
'; echo sprintf('Родовой знак', $this->showStarSign()); echo '
'; echo '
'; echo '
'; echo '
'; echo '

Об игроке

'; if ($this->realname) { echo sprintf('Имя: %s
', $this->realname); } if ($this->info) { echo nl2br($this->info); } echo '
'; if ($this->watcherIsAdmin || $this->watcherIsModerator) { echo '
'; $infoString = 'E-Mail: %s
ДР Игрока: %s
IP Регистрации: %s'; echo sprintf($infoString, $this->email, date('d.m.Y', strtotime($this->borndate)), $this->ip); if ($this->watcherIsAdmin) { $this->Bank = new Bank($this->id); $infoString = '
ИД Игрока: %s
ИД Комнаты: %s
Деньги: %s
Деньги в банке: %s
Опыт: %s
Нераспределённые очки: %s
Текущая сессия: %s
'; echo sprintf($infoString, $this->id, $this->room, $this->money, $this->Bank->money, $this->experience, $this->free_stat_points, $this->session_id); } $this->UserLogs = new UserLogModel($this->id); echo '
Личное дело
'; while ($userLogRow = $this->UserLogs->getUserLog()->fetch_object()) { echo sprintf('%s
', date("d.m.Y H:i ", strtotime($userLogRow->date)) . $userLogRow->text); } echo '
'; echo '
'; } } private function WatcherStatus() { $query = db::c()->query('SELECT `align`,`admin` FROM `users` WHERE `id` = ?i', $this->watcher_id)->fetch_assoc(); if ($query['admin']) { $this->watcherIsAdmin = 1; } if ($query['align'] == 1) { $this->watcherIsModerator = 1; } } public function showUserInfo() { $this->effects = new EffectsModel($this->id); $this->WatcherStatus(); if ($this->block && (!$this->watcherIsAdmin || !$this->watcherIsModerator)) { throw new Exception('Персонаж ' . $this->login . ' заблокирован!'); } elseif ($this->effects->getHideUserInfoStatus() && (!$this->watcherIsAdmin || !$this->watcherIsModerator)) { if ($this->effects->getHideUserInfoStatus() == -1) { $date = 'навсегда'; } else { $date = 'до' . date('d.m.Y', strtotime($this->effects->getHideUserInfoStatus())); } throw new Exception('Персонаж ' . $this->login . ' обезличен ' . $date . '.'); } else { $this->UserInfo(); } } public function showUserDoll($isBattle = 0, $isMain = 0) { echo '
'; $this->UserInfoDoll($isBattle, $isMain); echo '
'; } public function showUserInfoMain() { echo '
'; $this->UserInfoDoll(); $this->userInfoStats(1); echo '
'; } public function showStarSign() { /* * 1 aries * 2 taurus * 3 gemini * 4 cancer * 5 leo * 6 virgo * 7 libra * 8 scorpio * 9 sagittarios * 10 capricorn * 11 aquarius * 12 pisches */ $zodiac[356] = "10"; $zodiac[326] = "09"; $zodiac[296] = "08"; $zodiac[266] = "07"; $zodiac[235] = "06"; $zodiac[203] = "05"; $zodiac[172] = "04"; $zodiac[140] = "03"; $zodiac[111] = "02"; $zodiac[78] = "01"; $zodiac[51] = "12"; $zodiac[20] = "11"; $zodiac[0] = "10"; $dayOfYear = date("z", strtotime($this->borndate)); $isLeapYear = date("L", strtotime($this->borndate)); //Высокосный? if ($isLeapYear && $dayOfYear > 59) { --$dayOfYear; } foreach ($zodiac as $day => $sign) { if ($dayOfYear > $day) { break; } } return $sign ?? null; } public function getHealth(): string { return $this->health.'/'.$this->maxHealth; } public function getMana(): string { return $this->mana.'/'.$this->maxMana; } public function setRoom() { } }