Некто'; 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 $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 const STAT_MAXIMUM_AMOUNT = 40; private const ERROR_STAT_IS_MAXIMUM = 'Ошибка: Параметр достиг своего лимита!'; private const ERROR_STAT_UNKNOWN = 'Ошибка: Неизвестный параметр!'; // Пока несуществующие, для совместимости. public $married = 'Someone или нет.'; public $experience = 200; public $stat_points = 1; // Динамически рассчитываемые public $health; //Статусы того, кто смотрит на информацию. 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->health = round(($this->endurance * 3) + ($this->endurance / 2) * ($this->level - 1) + ($this->endurance / 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 $di = new DressedItems($this->id); $dressedItems = $di->getItemsInSlots(); for ($i = 1; $i <= 12; $i++) { echo sprintf('
', $i, $i);
}
echo sprintf('
', $this->align);
}
if ($this->block) {
$nameString .= '
', ClanImage($this->clan));
}
echo '';
}
public function getStrength($isMainWindow = 0)
{
if ($this->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->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->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->stat_points && $isMainWindow && $this->endurance < self::STAT_MAXIMUM_AMOUNT) {
return sprintf('%s [+]', $this->endurance);
}
return $this->endurance;
}
public function getIntelligence($isMainWindow = 0)
{
if ($this->stat_points && $isMainWindow && $this->intelligence < self::STAT_MAXIMUM_AMOUNT) {
return sprintf('%s [+]', $this->intelligence);
}
return $this->intelligence;
}
public function getWisdom($isMainWindow = 0)
{
if ($this->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->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->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->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->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->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->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->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 '';
echo '%s