2020-07-03 13:23:08 +00:00
< ? php
class User
{
public $id ;
public $login ;
public $email ;
public $realname ;
public $borndate ;
public $info ;
public $level ;
public $align ;
public $clan ;
public $money ;
public $strength ;
public $dexterity ;
public $intuition ;
public $endurance ;
public $intelligence ;
public $wisdom ;
public $ip ;
public $session_id ;
public $admin ;
public $enter_game ;
public $room ;
public $block ;
2020-07-03 13:49:39 +00:00
// Пока несуществующие, для совместимости.
public $married ;
public $stats ;
2020-07-04 20:37:47 +00:00
public $shadow ;
2020-07-05 21:16:22 +00:00
public $experience ;
public $stat_points ;
2020-07-03 13:49:39 +00:00
2020-07-05 18:38:13 +00:00
//Статусы того, кто смотрит на информацию.
2020-07-06 05:56:25 +00:00
public $watcher_id ;
2020-07-05 18:38:13 +00:00
protected $watcherIsAdmin ;
protected $watcherIsModerator ;
2020-07-04 23:25:14 +00:00
2020-07-04 10:49:43 +00:00
use Rooms ;
2020-07-03 13:33:34 +00:00
public function __construct ( $user )
2020-07-03 13:23:08 +00:00
{
2020-07-03 16:21:57 +00:00
$user_query = db :: c () -> query ( 'SELECT * FROM users WHERE id = "?s" OR login = "?s"' , $user , $user ) -> fetch_assoc ();
2020-07-03 13:23:08 +00:00
foreach ( $this as $key => $value ) {
if ( isset ( $user_query [ $key ])) {
$this -> $key = $user_query [ $key ];
}
}
}
2020-07-03 16:37:24 +00:00
2020-07-06 09:23:56 +00:00
protected function showItem ( $item )
2020-07-04 20:00:47 +00:00
{
2020-07-04 22:05:37 +00:00
$itemSlot = $item [ 'dressed_slot' ] ? ? 0 ;
$itemName = $item [ 'name' ] ? ? '' ;
$itemImage = $item [ 'image' ] ? ? '' ;
if ( $itemSlot ) {
echo <<< SLOT
2020-07-06 09:23:56 +00:00
< img src = " /i/sh/ { $itemImage } " class = " item-wrap-normal tip " alt = " { $itemName } " >
2020-07-04 22:05:37 +00:00
< span class = " tiptext " >< strong > { $itemName } </ strong ></ span >
SLOT ;
2020-07-04 20:00:47 +00:00
} else {
2020-07-04 22:05:37 +00:00
echo <<< EMPTY_SLOT
2020-07-04 23:29:32 +00:00
< img src = " /i/sh/noitem.png " class = " item-wrap-normal " title = " Пустой слот [ { $item } ] " alt = " Пустой слот [ { $item } ] " >
2020-07-04 22:05:37 +00:00
EMPTY_SLOT ;
2020-07-04 20:00:47 +00:00
}
2020-07-04 18:37:01 +00:00
}
2020-07-06 09:09:47 +00:00
private function UserInfoDoll () {
$dressed_items = db :: c () -> query ( 'SELECT * FROM inventory WHERE owner_id = ?i AND dressed_slot > 0' , $this -> id );
while ( $row = $dressed_items -> fetch_assoc ()) {
$dressed_item [ $row [ 'dressed_slot' ]] = $row ;
}
echo '<div class="user-info-container">' ;
for ( $i = 1 ; $i <= 12 ; $i ++ ) {
echo sprintf ( '<div class="slot-%s">' , $i );
if ( isset ( $dressed_item [ $i ])) {
2020-07-06 09:23:56 +00:00
//$this->showItem($dressed_item[$i]);
$itemString = '<img src="/i/sh/%s" class="item-wrap-normal tip" alt="%s"><span class="tiptext"><strong>%s</strong></span>' ;
echo sprintf ( $itemString , $dressed_item [ $i ][ 'image' ], $dressed_item [ $i ][ 'name' ], $dressed_item [ $i ][ 'name' ]);
2020-07-06 09:09:47 +00:00
} else {
2020-07-06 09:23:56 +00:00
echo sprintf ( '<img src="/i/sh/noitem.png" class="item-wrap-normal" title="Пустой слот [%s]" alt="Пустой слот [%s]">' , $i , $i );
2020-07-06 09:09:47 +00:00
}
echo sprintf ( '</div><!-- slot-%s -->' , $i );
}
echo '<div class="slot-image">' ;
echo sprintf ( '<img src="/i/shadow/%s" alt="%s">' , $this -> shadow , $this -> login );
echo '</div><!-- slot-image -->' ;
echo '</div><!-- user-info-container -->' ;
}
private function UserInfo ()
2020-07-05 15:09:55 +00:00
{
$dressed_items = db :: c () -> query ( 'SELECT * FROM inventory WHERE owner_id = ?i AND dressed_slot > 0' , $this -> id );
while ( $row = $dressed_items -> fetch_assoc ()) {
$dressed_item [ $row [ 'dressed_slot' ]] = $row ;
}
echo '<div class="user-info-container">' ;
echo '<div class="slot-1">' ;
if ( isset ( $dressed_item [ 1 ])) {
$this -> showItem ( $dressed_item [ 1 ]);
} else {
$this -> showItem ( 1 );
}
2020-07-05 16:43:15 +00:00
echo '</div><!-- slot-1 -->' ;
2020-07-05 15:09:55 +00:00
echo '<div class="slot-2">' ;
if ( isset ( $dressed_item [ 2 ])) {
$this -> showItem ( $dressed_item [ 2 ]);
} else {
$this -> showItem ( 2 );
}
2020-07-05 16:43:15 +00:00
echo '</div><!-- slot-2 -->' ;
2020-07-05 15:09:55 +00:00
echo '<div class="slot-3">' ;
if ( isset ( $dressed_item [ 3 ])) {
$this -> showItem ( $dressed_item [ 3 ]);
} else {
$this -> showItem ( 3 );
}
2020-07-05 16:43:15 +00:00
echo '</div><!-- slot-3 -->' ;
2020-07-05 15:09:55 +00:00
echo '<div class="slot-4">' ;
if ( isset ( $dressed_item [ 4 ])) {
$this -> showItem ( $dressed_item [ 4 ]);
} else {
$this -> showItem ( 4 );
}
2020-07-05 16:43:15 +00:00
echo '</div><!-- slot-4 -->' ;
2020-07-05 15:09:55 +00:00
echo '<div class="slot-5">' ;
if ( isset ( $dressed_item [ 5 ])) {
$this -> showItem ( $dressed_item [ 5 ]);
} else {
$this -> showItem ( 5 );
}
2020-07-05 16:43:15 +00:00
echo '</div><!-- slot-5 -->' ;
2020-07-05 15:09:55 +00:00
echo '<div class="slot-6">' ;
if ( isset ( $dressed_item [ 6 ])) {
$this -> showItem ( $dressed_item [ 6 ]);
} else {
$this -> showItem ( 6 );
}
2020-07-05 16:43:15 +00:00
echo '</div><!-- slot-6 -->' ;
2020-07-05 15:09:55 +00:00
echo '<div class="slot-7">' ;
if ( isset ( $dressed_item [ 7 ])) {
$this -> showItem ( $dressed_item [ 7 ]);
} else {
2020-07-05 15:17:25 +00:00
$this -> showItem ( 7 );
2020-07-05 15:09:55 +00:00
}
2020-07-05 16:43:15 +00:00
echo '</div><!-- slot-7 -->' ;
2020-07-05 15:09:55 +00:00
echo '<div class="slot-8">' ;
if ( isset ( $dressed_item [ 8 ])) {
$this -> showItem ( $dressed_item [ 8 ]);
} else {
$this -> showItem ( 8 );
}
2020-07-05 16:43:15 +00:00
echo '</div><!-- slot-8 -->' ;
2020-07-05 15:09:55 +00:00
echo '<div class="slot-lower">' ;
if ( isset ( $dressed_item [ 9 ])) {
$this -> showItem ( $dressed_item [ 9 ]);
} else {
$this -> showItem ( 9 );
}
if ( isset ( $dressed_item [ 10 ])) {
$this -> showItem ( $dressed_item [ 10 ]);
} else {
$this -> showItem ( 10 );
}
if ( isset ( $dressed_item [ 11 ])) {
$this -> showItem ( $dressed_item [ 11 ]);
} else {
$this -> showItem ( 11 );
}
2020-07-05 16:43:15 +00:00
echo '</div><!-- slot-lower -->' ;
2020-07-05 15:09:55 +00:00
echo '<div class="slot-image">' ;
2020-07-05 16:58:57 +00:00
echo sprintf ( '<img src="/i/shadow/%s" alt="%s">' , $this -> shadow , $this -> login );
2020-07-05 16:43:15 +00:00
echo '</div><!-- slot-image -->' ;
2020-07-05 15:09:55 +00:00
echo '<div class="user-signs">' ;
2020-07-05 17:29:30 +00:00
echo sprintf ( '<img src="i/zodiac/%s.png" alt="Родовой знак">' , $this -> showStarSign ());
2020-07-05 16:43:15 +00:00
echo '</div><!-- user-signs -->' ;
2020-07-05 15:09:55 +00:00
echo '<div class="user-info">' ;
2020-07-05 15:45:59 +00:00
echo '<div class="stats-container">' ;
echo '<div class="column">' ;
2020-07-05 16:54:57 +00:00
echo 'Уровень:<br>Сила:<br>Ловкость:<br>Интуиция:<br>Выносливость:<br>Интеллект:<br>Мудрость:<br>Местонахождение:' ;
2020-07-05 16:43:15 +00:00
echo '</div><!-- column -->' ;
2020-07-05 15:45:59 +00:00
echo '<div class="column">' ;
2020-07-05 16:12:53 +00:00
echo $this -> level . '<br>' . $this -> strength . '<br>' . $this -> dexterity . '<br>' . $this -> intuition . '<br>' . $this -> endurance . '<br>' . $this -> intelligence . '<br>' . $this -> wisdom . '<br>' . $this -> getRoomName ( $this -> room );
2020-07-05 16:43:15 +00:00
echo '</div><!-- column -->' ;
echo '</div><!-- stats-container -->' ;
2020-07-05 16:12:53 +00:00
if ( $this -> married ) {
echo sprintf ( '<a href = "inf.php?%s" target = _blank ><img alt = "В браке с %s" src = "i/married.gif" title = "В браке с %s"></a >' , $this -> married , $this -> married , $this -> married );
}
2020-07-05 16:54:57 +00:00
echo '<div class="debug">TODO: Сделать отображение имени. Сделать рассчёт здоровья и модификаторов. Вывести полоску здоровья когда будет от чего отталкиваться.</div>' ;
2020-07-05 16:43:15 +00:00
echo '</div><!-- user-info -->' ;
echo '</div><!-- user-info-container -->' ;
echo '<hr><!-- Нижняя часть -->' ;
echo '<div class="user-info-container-lower">' ;
echo '<h2>О б игроке</h2>' ;
if ( $this -> realname ) {
echo sprintf ( 'Имя: %s<br>' , $this -> realname );
}
if ( $this -> info ) {
echo nl2br ( $this -> info );
}
echo '</div><!-- user-info-container-lower -->' ;
2020-07-05 17:59:52 +00:00
2020-07-05 18:38:13 +00:00
if ( $this -> watcherIsAdmin || $this -> watcherIsModerator ) {
2020-07-05 21:35:25 +00:00
echo '<div class="secret-info">' ;
2020-07-06 05:56:25 +00:00
$infoString = '<b>Личное дело</b><br>E-Mail: %s<br> ДР Игрока: %s<br> IP Регистрации: %s' ;
echo sprintf ( $infoString , $this -> email , date ( 'd.m.Y' , strtotime ( $this -> borndate )), $this -> ip );
2020-07-05 18:38:13 +00:00
if ( $this -> watcherIsAdmin ) {
$this -> Bank = new Bank ( $this -> id );
2020-07-06 05:56:25 +00:00
$infoString = '<br><span>ИД Игрока: %s<br> ИД Комнаты: %s<br> Деньги: %s<br> Деньги в банке: %s<br> Опыт: %s<br> Нераспределённые очки: %s<br> Текущая сессия: %s</span>' ;
echo sprintf ( $infoString , $this -> id , $this -> room , $this -> money , $this -> Bank -> money , $this -> experience , $this -> stat_points , $this -> email , $this -> session_id );
2020-07-05 21:16:22 +00:00
}
$this -> UserLogs = new UserLogModel ( $this -> id );
2020-07-05 21:35:25 +00:00
echo '<div class="secret-info-user-log">' ;
2020-07-05 21:16:22 +00:00
while ( $userLogRow = $this -> UserLogs -> getUserLog () -> fetch_object ()) {
echo sprintf ( '<code>%s</code><br>' , date ( " d.m.Y H:i " , strtotime ( $userLogRow -> date )) . $userLogRow -> text );
2020-07-05 18:38:13 +00:00
}
2020-07-05 21:35:25 +00:00
echo '</div><!-- secret-info-user-log -->' ;
echo '</div><!-- secret-info -->' ;
2020-07-05 18:38:13 +00:00
}
2020-07-04 10:49:43 +00:00
}
2020-07-06 05:56:25 +00:00
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 ( '<span class="error">Персонаж ' . $this -> login . ' заблокирован!</span>' );
} 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 ( '<span class="error">Персонаж ' . $this -> login . ' обезличен ' . $date . '.</span>' );
} else {
2020-07-06 09:09:47 +00:00
$this -> UserInfoDoll ();
2020-07-06 05:56:25 +00:00
}
}
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
*/
2020-07-05 17:29:30 +00:00
$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 )); //Высокосный?
2020-07-06 05:56:25 +00:00
if ( $isLeapYear && $dayOfYear > 59 ) {
2020-07-05 17:29:30 +00:00
-- $dayOfYear ;
}
foreach ( $zodiac as $day => $sign ) {
if ( $dayOfYear > $day ) {
break ;
}
}
return $sign ? ? null ;
}
2020-07-05 18:38:13 +00:00
2020-07-03 13:23:08 +00:00
}