Отображение стат+бонус вместо чистого стата там, где это необходимо. Унификация запроса переменной. #18

This commit is contained in:
lopar 2021-03-11 20:14:41 +02:00
parent f5b2b23582
commit 484695af10
4 changed files with 25 additions and 55 deletions

View File

@ -60,36 +60,6 @@ SQL;
return self::$db->fetch($query, $this->USERID); return self::$db->fetch($query, $this->USERID);
} }
public function getStrengthBonus(): ?int
{
return self::getBonuses()['sum_strength'];
}
public function getDexterityBonus(): ?int
{
return self::getBonuses()['sum_dexterity'];
}
public function getIntuitionBonus(): ?int
{
return self::getBonuses()['sum_intuition'];
}
public function getEnduranceBonus(): ?int
{
return self::getBonuses()['sum_endurance'];
}
public function getIntelliganceBonus(): ?int
{
return self::getBonuses()['sum_intelligence'];
}
public function getWisdomBonus(): ?int
{
return self::getBonuses()['sum_wisdom'];
}
public function getAccuracyBonus(): ?int public function getAccuracyBonus(): ?int
{ {
return self::getBonuses()['sum_accuracy'] ?? 0; return self::getBonuses()['sum_accuracy'] ?? 0;

View File

@ -53,12 +53,12 @@ class UserInfo extends UserStats
$captions = 'Уровень:<br>Сила:<br>Ловкость:<br>Интуиция:<br>Выносливость:<br>Интеллект:<br>Мудрость:<br>Местонахождение:'; $captions = 'Уровень:<br>Сила:<br>Ловкость:<br>Интуиция:<br>Выносливость:<br>Интеллект:<br>Мудрость:<br>Местонахождение:';
$variables = $variables =
$this->level . '<br>' . $this->level . '<br>' .
parent::getStat('strength') . '<br>' . parent::getFullStats()->strength . '<br>' .
parent::getStat('dexterity') . '<br>' . parent::getFullStats()->dexterity . '<br>' .
parent::getStat('intuition') . '<br>' . parent::getFullStats()->intuition . '<br>' .
parent::getStat('endurance') . '<br>' . parent::getFullStats()->endurance . '<br>' .
parent::getStat('intelligence') . '<br>' . parent::getFullStats()->intelligence . '<br>' .
parent::getStat('wisdom') . '<br>' . parent::getFullStats()->wisdom . '<br>' .
Rooms::$roomNames[$this->room]; Rooms::$roomNames[$this->room];
if ($isMainWindow) { if ($isMainWindow) {
$this->Bank = new Bank($this->id); $this->Bank = new Bank($this->id);

View File

@ -221,12 +221,12 @@ class UserStats extends User
{ {
$query = " $query = "
select select
sum(greatest(strength + (ifnull((select sum(add_strength) from inventory where dressed_slot != 0 and owner_id = $this->id), 0)), 0)) as allStrength, sum(greatest(strength + (ifnull((select sum(add_strength) from inventory where dressed_slot != 0 and owner_id = $this->id), 0)), 0)) as strength,
sum(greatest(dexterity + (ifnull((select sum(add_dexterity) from inventory where dressed_slot != 0 and owner_id = $this->id), 0)), 0)) as allDexterity, sum(greatest(dexterity + (ifnull((select sum(add_dexterity) from inventory where dressed_slot != 0 and owner_id = $this->id), 0)), 0)) as dexterity,
sum(greatest(intuition + (ifnull((select sum(add_intuition) from inventory where dressed_slot != 0 and owner_id = $this->id), 0)), 0)) as allIntuition, sum(greatest(intuition + (ifnull((select sum(add_intuition) from inventory where dressed_slot != 0 and owner_id = $this->id), 0)), 0)) as intuition,
sum(greatest(endurance + (ifnull((select sum(add_endurance) from inventory where dressed_slot != 0 and owner_id = $this->id), 0)), 0)) as allEndurance, sum(greatest(endurance + (ifnull((select sum(add_endurance) from inventory where dressed_slot != 0 and owner_id = $this->id), 0)), 0)) as endurance,
sum(greatest(intelligence + (ifnull((select sum(add_intelligence) from inventory where dressed_slot != 0 and owner_id = $this->id), 0)), 0)) as allIntelligence, sum(greatest(intelligence + (ifnull((select sum(add_intelligence) from inventory where dressed_slot != 0 and owner_id = $this->id), 0)), 0)) as intelligence,
sum(greatest(wisdom + (ifnull((select sum(add_wisdom) from inventory where dressed_slot != 0 and owner_id = $this->id), 0)), 0)) as allWisdom sum(greatest(wisdom + (ifnull((select sum(add_wisdom) from inventory where dressed_slot != 0 and owner_id = $this->id), 0)), 0)) as wisdom
from users where id = $this->id"; from users where id = $this->id";
return self::$db->ofetch($query); return self::$db->ofetch($query);
} }

View File

@ -164,12 +164,12 @@ function dressitem($id)
$error = DRESSITEM_ERROR['ITEM_NOT_FOUND']; $error = DRESSITEM_ERROR['ITEM_NOT_FOUND'];
} else { } else {
$selectedItem = $selectedItemRow->fetch_object(); $selectedItem = $selectedItemRow->fetch_object();
if ($selectedItem->need_strength > $userStats->getFullStats()->allStrength if ($selectedItem->need_strength > $userStats->getFullStats()->strength
|| $selectedItem->need_dexterity > $userStats->getFullStats()->allDexterity || $selectedItem->need_dexterity > $userStats->getFullStats()->dexterity
|| $selectedItem->need_intuition > $userStats->getFullStats()->allIntuition || $selectedItem->need_intuition > $userStats->getFullStats()->intuition
|| $selectedItem->need_endurance > $userStats->getFullStats()->allEndurance || $selectedItem->need_endurance > $userStats->getFullStats()->endurance
|| $selectedItem->need_intelligence > $userStats->getFullStats()->allIntelligence || $selectedItem->need_intelligence > $userStats->getFullStats()->intelligence
|| $selectedItem->need_wisdom > $userStats->getFullStats()->allWisdom) { || $selectedItem->need_wisdom > $userStats->getFullStats()->wisdom) {
$error = DRESSITEM_ERROR['REQUIREMENTS_NOT_MET']; $error = DRESSITEM_ERROR['REQUIREMENTS_NOT_MET'];
} else { } else {
$itemInSlotRow = db::c()->query('SELECT dressed_slot FROM inventory WHERE owner_id = ?i AND dressed_slot > 0 AND item_type = ?i', $_SESSION['uid'], $selectedItem->item_type); $itemInSlotRow = db::c()->query('SELECT dressed_slot FROM inventory WHERE owner_id = ?i AND dressed_slot > 0 AND item_type = ?i', $_SESSION['uid'], $selectedItem->item_type);
@ -381,17 +381,17 @@ Template::header('Игра');
<!--Параметры--> <!--Параметры-->
<div> <div>
<div class="container"> <div class="container">
Сила: <?= ($userStats->getFreeStatPoints() ? $userStats->getStat('strength', 1) . '(' . strval($userStats->getStrength() + $getItemsBonuses->getStrengthBonus()) . ')' : $userStats->getStrength() + $getItemsBonuses->getStrengthBonus()) ?> Сила: <?= ($userStats->getFreeStatPoints() ? $userStats->getStat('strength', 1) . '(' . strval($userStats->getFullStats()->strength) . ')' : $userStats->getFullStats()->strength) ?>
<br> <br>
Ловкость: <?= ($userStats->getFreeStatPoints() ? $userStats->getStat('dexterity', 1) . '(' . strval($userStats->getDexterity() + $getItemsBonuses->getDexterityBonus()) . ')' : $userStats->getDexterity() + $getItemsBonuses->getDexterityBonus()) ?> Ловкость: <?= ($userStats->getFreeStatPoints() ? $userStats->getStat('dexterity', 1) . '(' . strval($userStats->getFullStats()->dexterity) . ')' : $userStats->getFullStats()->dexterity) ?>
<br> <br>
Интуиция: <?= ($userStats->getFreeStatPoints() ? $userStats->getStat('intuition', 1) . '(' . strval($userStats->getIntuition() + $getItemsBonuses->getIntuitionBonus()) . ')' : $userStats->getIntuition() + $getItemsBonuses->getIntuitionBonus()) ?> Интуиция: <?= ($userStats->getFreeStatPoints() ? $userStats->getStat('intuition', 1) . '(' . strval($userStats->getFullStats()->intuition) . ')' : $userStats->getFullStats()->intuition) ?>
<br> <br>
Выносливость: <?= ($userStats->getFreeStatPoints() ? $userStats->getStat('endurance', 1) . '(' . strval($userStats->getEndurance() + $getItemsBonuses->getEnduranceBonus()) . ')' : $userStats->getEndurance() + $getItemsBonuses->getEnduranceBonus()) ?> Выносливость: <?= ($userStats->getFreeStatPoints() ? $userStats->getStat('endurance', 1) . '(' . strval($userStats->getFullStats()->endurance) . ')' : $userStats->getFullStats()->endurance) ?>
<br> <br>
Интеллект: <?= ($userStats->getFreeStatPoints() ? $userStats->getStat('intelligence', 1) . '(' . strval($userStats->getIntelligence() + $getItemsBonuses->getIntelliganceBonus()) . ')' : $userStats->getIntelligence() + $getItemsBonuses->getIntelliganceBonus()) ?> Интеллект: <?= ($userStats->getFreeStatPoints() ? $userStats->getStat('intelligence', 1) . '(' . strval($userStats->getFullStats()->intelligence) . ')' : $userStats->getFullStats()->intelligence) ?>
<br> <br>
Мудрость: <?= ($userStats->getFreeStatPoints() ? $userStats->getStat('wisdom', 1) . '(' . strval($userStats->getWisdom() + $getItemsBonuses->getWisdomBonus()) . ')' : $userStats->getWisdom() + $getItemsBonuses->getWisdomBonus()) ?> Мудрость: <?= ($userStats->getFreeStatPoints() ? $userStats->getStat('wisdom', 1) . '(' . strval($userStats->getFullStats()->wisdom) . ')' : $userStats->getFullStats()->wisdom) ?>
<br> <br>
<?php if ($userStats->getFreeStatPoints()): ?> <?php if ($userStats->getFreeStatPoints()): ?>
<small style="color: darkgreen;">Возможных <small style="color: darkgreen;">Возможных
@ -438,7 +438,7 @@ Template::header('Игра');
<div> <!--рюкзак--> <div> <!--рюкзак-->
<table style="border: 0; padding: 2px; border-spacing: 1px; width: 100%; background-color: #a5a5a5"> <table style="border: 0; padding: 2px; border-spacing: 1px; width: 100%; background-color: #a5a5a5">
<caption>Рюкзак <caption>Рюкзак
(масса: <?= '?? /' . $userStats->getStrength() * 4 ?>) (масса: <?= '?? /' . (int)$userStats->getStrength() * 4 ?>)
</caption> </caption>
<?php <?php
foreach ($iteminfo as $ii) { foreach ($iteminfo as $ii) {