battles/classes/User.php

81 lines
2.4 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
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;
// Пока несуществующие, для совместимости.
public $married;
public $exp;
public $stats;
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];
}
}
}
public function showUserInfo() {
$dressed_items_array = [];
$dressed_items = db::c()->query('SELECT * FROM inventory WHERE owner_id = ?i AND dressed_slot > 0', $this->id)->fetch_object();
foreach ($dressed_items as $key=>$value) {
$dressed_items_array[$dressed_items['dressed_slot']][$key] = $value;
$dressed_items_object[$dressed_items['dressed_slot']]->$key = $value;
}
echo <<<USERINFO
Имя {$this->login} <br>
Сила {$this->strength} <br>
Ловкость {$this->dexterity} <br>
Интуиция {$this->intuition} <br>
Выносливость {$this->endurance} <br>
Интеллект {$this->intelligence} <br>
Мудрость {$this->wisdom} <br>
Находится в {$this->getRoomName($this->room)}<br>
Предметы на тушке: <br>
USERINFO;
if (isset($dressed_items_array[1])) {
echo "В руке — " .$dressed_items_array[1]['name'].PHP_EOL;
}
if (isset($dressed_items_array[4])) {
echo "На пузе — " .$dressed_items_array[4]['name'].PHP_EOL;
}
if (isset($dressed_items_object[1])) {
echo "!В руке — " .$dressed_items_array[1]->name.PHP_EOL;
}
if (isset($dressed_items_object[4])) {
echo "!На пузе — " .$dressed_items_array[4]->name.PHP_EOL;
}
var_dump($dressed_items_array).PHP_EOL;
var_dump($dressed_items_object).PHP_EOL;
}
}