dev #41
@ -217,5 +217,18 @@ class UserStats extends User
|
|||||||
return $this->legArmor;
|
return $this->legArmor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getFullStats()
|
||||||
|
{
|
||||||
|
$query = "
|
||||||
|
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(dexterity + (ifnull((select sum(add_dexterity) from inventory where dressed_slot != 0 and owner_id = $this->id), 0)), 0)) as allDexterity,
|
||||||
|
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(endurance + (ifnull((select sum(add_endurance) from inventory where dressed_slot != 0 and owner_id = $this->id), 0)), 0)) as allEndurance,
|
||||||
|
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(wisdom + (ifnull((select sum(add_wisdom) from inventory where dressed_slot != 0 and owner_id = $this->id), 0)), 0)) as allWisdom
|
||||||
|
from users where id = $this->id";
|
||||||
|
return self::$db->ofetch($query);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
24
main.php
24
main.php
@ -138,7 +138,6 @@ function del_efs($id, $type)
|
|||||||
// одеть предмет
|
// одеть предмет
|
||||||
function dressitem($id)
|
function dressitem($id)
|
||||||
{
|
{
|
||||||
//bug #7
|
|
||||||
define('HELMET', 1);
|
define('HELMET', 1);
|
||||||
define('ARMOR', 2);
|
define('ARMOR', 2);
|
||||||
define('LEGS', 3);
|
define('LEGS', 3);
|
||||||
@ -153,11 +152,26 @@ function dressitem($id)
|
|||||||
'TOO_MANY_ITEMS_IN_SLOTS' => 'Критическая ошибка: Переполнение слота!',
|
'TOO_MANY_ITEMS_IN_SLOTS' => 'Критическая ошибка: Переполнение слота!',
|
||||||
'UNKNOWN_ITEM_TYPE' => 'Неизвестный тип предмета!',
|
'UNKNOWN_ITEM_TYPE' => 'Неизвестный тип предмета!',
|
||||||
'ITEM_NOT_FOUND' => 'Предмет не найден!',
|
'ITEM_NOT_FOUND' => 'Предмет не найден!',
|
||||||
|
'REQUIREMENTS_NOT_MET' => 'Персонаж не соответствует требованиям!',
|
||||||
]);
|
]);
|
||||||
|
$userStats = new UserStats($_SESSION['uid']);
|
||||||
$itemInSlot = [];
|
$itemInSlot = [];
|
||||||
$selectedItemRow = db::c()->query('SELECT item_type FROM `inventory` WHERE item_id = ?i AND owner_id = ?i AND `dressed_slot` = 0', $id, $_SESSION['uid']);
|
$selectedItemRow = db::c()->query('SELECT item_type,need_strength,need_dexterity,need_intuition,need_endurance,need_intelligence,need_wisdom FROM `inventory` WHERE item_id = ?i AND owner_id = ?i AND `dressed_slot` = 0 AND `durability` != 0', $id, $_SESSION['uid']);
|
||||||
if ($selectedItemRow->getNumRows()) {
|
|
||||||
|
//$userStats->getStrength()
|
||||||
|
if (!$selectedItemRow->getNumRows()) {
|
||||||
|
//с предметом что-то сильно не ок, ошибка.
|
||||||
|
$error = DRESSITEM_ERROR['ITEM_NOT_FOUND'];
|
||||||
|
} else {
|
||||||
$selectedItem = $selectedItemRow->fetch_object();
|
$selectedItem = $selectedItemRow->fetch_object();
|
||||||
|
if ($selectedItem->need_strength > $userStats->getFullStats()->allStrength
|
||||||
|
|| $selectedItem->need_dexterity > $userStats->getFullStats()->allDexterity
|
||||||
|
|| $selectedItem->need_intuition > $userStats->getFullStats()->allIntuition
|
||||||
|
|| $selectedItem->need_endurance > $userStats->getFullStats()->allEndurance
|
||||||
|
|| $selectedItem->need_intelligence > $userStats->getFullStats()->allIntelligence
|
||||||
|
|| $selectedItem->need_wisdom > $userStats->getFullStats()->allWisdom) {
|
||||||
|
$error = DRESSITEM_ERROR['REQUIREMENTS_NOT_MET'];
|
||||||
|
} 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);
|
||||||
$itemInSlotQuantity = $itemInSlotRow->getNumRows();
|
$itemInSlotQuantity = $itemInSlotRow->getNumRows();
|
||||||
if ($itemInSlotQuantity) {
|
if ($itemInSlotQuantity) {
|
||||||
@ -201,9 +215,7 @@ function dressitem($id)
|
|||||||
//предмет вообще не должен одеваться, ошибка
|
//предмет вообще не должен одеваться, ошибка
|
||||||
$error = DRESSITEM_ERROR['UNKNOWN_ITEM_TYPE'];
|
$error = DRESSITEM_ERROR['UNKNOWN_ITEM_TYPE'];
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
//с предметом что-то сильно не ок, ошибка.
|
|
||||||
$error = DRESSITEM_ERROR['ITEM_NOT_FOUND'];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($error)) {
|
if (isset($error)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user