This commit is contained in:
Igor Barkov (iwork)
2020-07-22 17:04:15 +03:00
parent f0bf7069de
commit 35031f1296
5 changed files with 135 additions and 135 deletions
+16 -16
View File
@@ -32,13 +32,13 @@ class User
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 $stat_points = 1;
// Динамически рассчитываемые
public $health;
//Статусы того, кто смотрит на информацию.
@@ -109,7 +109,7 @@ class User
if ($isMainWindow) {
$this->Bank = new Bank($this->id);
$captions = 'Уровень:<br>Здоровье:<br>Сила:<br>Ловкость:<br>Интуиция:<br>Выносливость:<br>Интеллект:<br>Мудрость:<br>Опыт:<br>Очки характеристик:<br>Деньги:<br>Деньги в банке:';
$variables = $this->level . '<br>' . $this->health . '<br>' . $this->getStrength(1) . '<br>' . $this->getDexterity(1) . '<br>' . $this->getIntuition(1) . '<br>' . $this->getEndurance(1) . '<br>' . $this->getIntelligence(1) . '<br>' . $this->getWisdom(1) . '<br>' . $this->experience . '<br>' . $this->stat_points . '<br>' . $this->money . '<br>' . $this->Bank->money;
$variables = $this->level . '<br>' . $this->health . '<br>' . $this->getStrength(1) . '<br>' . $this->getDexterity(1) . '<br>' . $this->getIntuition(1) . '<br>' . $this->getEndurance(1) . '<br>' . $this->getIntelligence(1) . '<br>' . $this->getWisdom(1) . '<br>' . $this->experience . '<br>' . $this->free_stat_points . '<br>' . $this->money . '<br>' . $this->Bank->money;
}
if ($this->align) {
@@ -141,7 +141,7 @@ class User
public function getStrength($isMainWindow = 0)
{
if ($this->stat_points && $isMainWindow && $this->strength < self::STAT_MAXIMUM_AMOUNT) {
if ($this->free_stat_points && $isMainWindow && $this->strength < self::STAT_MAXIMUM_AMOUNT) {
//main.php?edit=1&ups=sila
return sprintf('%s <a href="#">[+]</a>', $this->strength);
}
@@ -150,7 +150,7 @@ class User
public function getDexterity($isMainWindow = 0)
{
if ($this->stat_points && $isMainWindow && $this->dexterity < self::STAT_MAXIMUM_AMOUNT) {
if ($this->free_stat_points && $isMainWindow && $this->dexterity < self::STAT_MAXIMUM_AMOUNT) {
//main.php?edit=1&ups=lovk
return sprintf('%s <a href="#">[+]</a>', $this->dexterity);
}
@@ -159,7 +159,7 @@ class User
public function getIntuition($isMainWindow = 0)
{
if ($this->stat_points && $isMainWindow && $this->intuition < self::STAT_MAXIMUM_AMOUNT) {
if ($this->free_stat_points && $isMainWindow && $this->intuition < self::STAT_MAXIMUM_AMOUNT) {
//main.php?edit=1&ups=inta...
return sprintf('%s <a href="#">[+]</a>', $this->intuition);
}
@@ -168,7 +168,7 @@ class User
public function getEndurance($isMainWindow = 0)
{
if ($this->stat_points && $isMainWindow && $this->endurance < self::STAT_MAXIMUM_AMOUNT) {
if ($this->free_stat_points && $isMainWindow && $this->endurance < self::STAT_MAXIMUM_AMOUNT) {
return sprintf('%s <a href="#">[+]</a>', $this->endurance);
}
return $this->endurance;
@@ -176,7 +176,7 @@ class User
public function getIntelligence($isMainWindow = 0)
{
if ($this->stat_points && $isMainWindow && $this->intelligence < self::STAT_MAXIMUM_AMOUNT) {
if ($this->free_stat_points && $isMainWindow && $this->intelligence < self::STAT_MAXIMUM_AMOUNT) {
return sprintf('%s <a href="#">[+]</a>', $this->intelligence);
}
return $this->intelligence;
@@ -184,7 +184,7 @@ class User
public function getWisdom($isMainWindow = 0)
{
if ($this->stat_points && $isMainWindow && $this->wisdom < self::STAT_MAXIMUM_AMOUNT) {
if ($this->free_stat_points && $isMainWindow && $this->wisdom < self::STAT_MAXIMUM_AMOUNT) {
return sprintf('%s <a href="#">[+]</a>', $this->wisdom);
}
return $this->wisdom;
@@ -192,7 +192,7 @@ class User
public function setStrength()
{
if ($this->strength <= self::STAT_MAXIMUM_AMOUNT && $this->stat_points > 0) {
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);
@@ -201,7 +201,7 @@ class User
public function setDexterity()
{
if ($this->dexterity <= self::STAT_MAXIMUM_AMOUNT && $this->stat_points > 0) {
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);
@@ -210,7 +210,7 @@ class User
public function setIntuition()
{
if ($this->intuition <= self::STAT_MAXIMUM_AMOUNT && $this->stat_points > 0) {
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);
@@ -219,7 +219,7 @@ class User
public function setEndurance()
{
if ($this->endurance <= self::STAT_MAXIMUM_AMOUNT && $this->stat_points > 0) {
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);
@@ -228,7 +228,7 @@ class User
public function setIntelligence()
{
if ($this->intelligence <= self::STAT_MAXIMUM_AMOUNT && $this->stat_points > 0) {
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);
@@ -237,7 +237,7 @@ class User
public function setWisdom()
{
if ($this->wisdom <= self::STAT_MAXIMUM_AMOUNT && $this->stat_points > 0) {
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);
@@ -248,7 +248,7 @@ class User
{
$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) {
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 {
@@ -292,7 +292,7 @@ class User
if ($this->watcherIsAdmin) {
$this->Bank = new Bank($this->id);
$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->session_id);
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 '<div class="secret-info-user-log"><b>Личное дело</b><br>';