2020-07-06 19:54:50 +00:00
|
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* Author: lopiu
|
|
|
|
|
* Date: 06.07.2020
|
|
|
|
|
* Time: 22:41
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
class DressedItems
|
|
|
|
|
{
|
|
|
|
|
protected $DB;
|
2020-07-07 13:01:46 +00:00
|
|
|
|
protected $DBSUM;
|
2020-07-06 19:54:50 +00:00
|
|
|
|
private $dressedItem;
|
|
|
|
|
|
2020-07-07 09:52:54 +00:00
|
|
|
|
/**
|
|
|
|
|
* DressedItems constructor.
|
|
|
|
|
*/
|
|
|
|
|
public function __construct() {}
|
2020-07-06 20:34:34 +00:00
|
|
|
|
|
2020-07-07 13:01:46 +00:00
|
|
|
|
private function getDressedItems($user_id)
|
2020-07-06 19:54:50 +00:00
|
|
|
|
{
|
|
|
|
|
try {
|
2020-07-07 13:01:46 +00:00
|
|
|
|
$this->DB = db::c()->query('SELECT * FROM inventory WHERE owner_id = ?i AND dressed_slot > 0', $user_id);
|
2020-07-06 20:10:24 +00:00
|
|
|
|
} catch (Exception $e) {
|
2020-07-07 13:01:46 +00:00
|
|
|
|
echo '<div class="debug">Не прогрузилась таблица inventory (*) для класса DressedItems.</div>';
|
2020-07-06 19:54:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-07 13:01:46 +00:00
|
|
|
|
private function getBonusesFromDressedItems($user_id)
|
2020-07-07 09:50:45 +00:00
|
|
|
|
{
|
|
|
|
|
try {
|
2020-07-07 13:01:46 +00:00
|
|
|
|
$query = <<<SQL
|
|
|
|
|
SELECT SUM(add_strength) as sum_strength,
|
|
|
|
|
SUM(add_dexterity)as sum_dexterity,
|
|
|
|
|
SUM(add_intuition) as sum_intuition,
|
|
|
|
|
SUM(add_endurance) as sum_endurance,
|
|
|
|
|
SUM(add_intelligence) as sum_intelligence,
|
|
|
|
|
SUM(add_wisdom) as sum_wisdom
|
|
|
|
|
FROM inventory WHERE owner_id = ?i AND dressed_slot > 0'
|
|
|
|
|
SQL;
|
|
|
|
|
$this->DBSUM = db::c()->query($query, $user_id)->fetch_assoc();
|
2020-07-07 09:50:45 +00:00
|
|
|
|
} catch (Exception $e) {
|
2020-07-07 13:01:46 +00:00
|
|
|
|
echo '<div class="debug">Не прогрузилась таблица inventory (SUM) для класса DressedItems.</div>';
|
2020-07-07 09:50:45 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-07-07 13:01:46 +00:00
|
|
|
|
|
|
|
|
|
public function getItemsInSlots($user_id)
|
2020-07-07 09:50:45 +00:00
|
|
|
|
{
|
|
|
|
|
if (!$this->DB) {
|
2020-07-07 13:01:46 +00:00
|
|
|
|
$this->getDressedItems($user_id);
|
2020-07-07 09:50:45 +00:00
|
|
|
|
}
|
|
|
|
|
while ($row = $this->DB->fetch_assoc()) {
|
2020-07-06 19:54:50 +00:00
|
|
|
|
$dressed_item[$row['dressed_slot']] = $row;
|
|
|
|
|
$this->dressedItem[$row['dressed_slot']] = $row;
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-07-07 09:50:45 +00:00
|
|
|
|
|
2020-07-07 13:01:46 +00:00
|
|
|
|
public function getBonusesAmount($user_id)
|
|
|
|
|
{
|
|
|
|
|
if (!$this->DBSUM) {
|
|
|
|
|
$this->getBonusesFromDressedItems($user_id);
|
|
|
|
|
}
|
|
|
|
|
return $this->DBSUM;
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-06 19:54:50 +00:00
|
|
|
|
}
|