2020-07-06 19:54:50 +00:00
|
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* Author: lopiu
|
|
|
|
|
* Date: 06.07.2020
|
|
|
|
|
* Time: 22:41
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
class DressedItems
|
|
|
|
|
{
|
2020-07-20 14:22:51 +00:00
|
|
|
|
protected static $DB;
|
2020-07-20 14:25:02 +00:00
|
|
|
|
protected static $DBSUM;
|
2020-07-20 14:22:51 +00:00
|
|
|
|
protected static $USERID;
|
2020-07-06 19:54:50 +00:00
|
|
|
|
private $dressedItem;
|
|
|
|
|
|
2020-07-07 09:52:54 +00:00
|
|
|
|
/**
|
|
|
|
|
* DressedItems constructor.
|
2020-07-20 13:27:32 +00:00
|
|
|
|
*
|
|
|
|
|
* @param $user_id - ID игрока.
|
2020-07-07 09:52:54 +00:00
|
|
|
|
*/
|
2020-07-20 12:07:49 +00:00
|
|
|
|
public function __construct($user_id)
|
|
|
|
|
{
|
2020-07-20 14:22:51 +00:00
|
|
|
|
//$this->USERID = $user_id;
|
|
|
|
|
self::$USERID = $user_id;
|
2020-07-20 12:07:49 +00:00
|
|
|
|
}
|
2020-07-06 20:34:34 +00:00
|
|
|
|
|
2020-07-20 14:22:51 +00:00
|
|
|
|
private static function getDressedItems()
|
2020-07-06 19:54:50 +00:00
|
|
|
|
{
|
|
|
|
|
try {
|
2020-07-20 14:22:51 +00:00
|
|
|
|
self::$DB = db::c()->query('SELECT * FROM inventory WHERE owner_id = ?i AND dressed_slot > 0', self::$USERID);
|
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-20 12:07:49 +00:00
|
|
|
|
protected function getBonusesFromDressedItems()
|
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,
|
2020-07-20 13:51:23 +00:00
|
|
|
|
SUM(add_dexterity) as sum_dexterity,
|
2020-07-07 13:01:46 +00:00
|
|
|
|
SUM(add_intuition) as sum_intuition,
|
|
|
|
|
SUM(add_endurance) as sum_endurance,
|
|
|
|
|
SUM(add_intelligence) as sum_intelligence,
|
2020-07-20 10:22:29 +00:00
|
|
|
|
SUM(add_wisdom) as sum_wisdom,
|
|
|
|
|
SUM(add_accuracy) as sum_accuracy,
|
2020-07-20 13:27:32 +00:00
|
|
|
|
SUM(add_evasion) as sum_evasion,
|
|
|
|
|
SUM(add_criticals) as sum_criticals,
|
2020-07-20 13:44:31 +00:00
|
|
|
|
SUM(add_min_physical_damage) as sum_min_phys_damage,
|
2020-07-20 14:48:09 +00:00
|
|
|
|
SUM(add_max_physical_damage) as sum_max_phys_damage,
|
|
|
|
|
SUM(weight) as sum_weight
|
2020-07-20 14:01:59 +00:00
|
|
|
|
FROM inventory WHERE owner_id = ?i AND dressed_slot > 0
|
2020-07-07 13:01:46 +00:00
|
|
|
|
SQL;
|
2020-07-20 14:25:02 +00:00
|
|
|
|
self::$DBSUM = db::c()->query($query, self::$USERID)->fetch_assoc();
|
2020-07-07 09:50:45 +00:00
|
|
|
|
} catch (Exception $e) {
|
2020-07-20 12:07:49 +00:00
|
|
|
|
echo '<div class="debug">Не прогрузилась таблица inventory (SUM) для класса DressedItems:' . $e . '</div>';
|
2020-07-07 09:50:45 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-07-07 13:01:46 +00:00
|
|
|
|
|
2020-07-20 12:07:49 +00:00
|
|
|
|
public function getItemsInSlots()
|
2020-07-07 09:50:45 +00:00
|
|
|
|
{
|
2020-07-20 14:22:51 +00:00
|
|
|
|
if (!self::$DB) {
|
2020-07-20 13:51:23 +00:00
|
|
|
|
//$this->getDressedItems();
|
|
|
|
|
self::getDressedItems();
|
2020-07-07 09:50:45 +00:00
|
|
|
|
}
|
2020-07-20 14:22:51 +00:00
|
|
|
|
while ($row = self::$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-20 12:07:49 +00:00
|
|
|
|
protected function getBonuses()
|
2020-07-07 13:01:46 +00:00
|
|
|
|
{
|
2020-07-20 14:25:02 +00:00
|
|
|
|
if (!self::$DBSUM) {
|
2020-07-20 13:51:23 +00:00
|
|
|
|
self::getBonusesFromDressedItems();
|
2020-07-07 13:01:46 +00:00
|
|
|
|
}
|
2020-07-20 14:25:02 +00:00
|
|
|
|
return self::$DBSUM;
|
2020-07-07 13:01:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-07-20 12:07:49 +00:00
|
|
|
|
public function getStrengthBonus()
|
|
|
|
|
{
|
2020-07-20 13:51:23 +00:00
|
|
|
|
//return $this->getBonuses()['sum_strength'];
|
|
|
|
|
return self::getBonuses()['sum_strength'];
|
2020-07-20 12:07:49 +00:00
|
|
|
|
}
|
|
|
|
|
public function getDexterityBonus()
|
|
|
|
|
{
|
|
|
|
|
return $this->getBonuses()['sum_dexterity'];
|
|
|
|
|
}
|
|
|
|
|
public function getIntuitionBonus()
|
|
|
|
|
{
|
|
|
|
|
return $this->getBonuses()['sum_intuition'];
|
|
|
|
|
}
|
|
|
|
|
public function getEnduranceBonus()
|
|
|
|
|
{
|
|
|
|
|
return $this->getBonuses()['sum_endurance'];
|
|
|
|
|
}
|
|
|
|
|
public function getIntelliganceBonus()
|
|
|
|
|
{
|
|
|
|
|
return $this->getBonuses()['sum_intelligence'];
|
|
|
|
|
}
|
|
|
|
|
public function getWisdomBonus()
|
|
|
|
|
{
|
|
|
|
|
return $this->getBonuses()['sum_wisdom'];
|
|
|
|
|
}
|
|
|
|
|
public function getAccuracyBonus()
|
|
|
|
|
{
|
|
|
|
|
return $this->getBonuses()['sum_accuracy'];
|
|
|
|
|
}
|
2020-07-20 13:27:32 +00:00
|
|
|
|
public function getEvasionBonus()
|
2020-07-20 12:07:49 +00:00
|
|
|
|
{
|
2020-07-20 13:27:32 +00:00
|
|
|
|
return $this->getBonuses()['sum_evasion'];
|
2020-07-20 12:07:49 +00:00
|
|
|
|
}
|
|
|
|
|
public function getCriticalsBonus()
|
|
|
|
|
{
|
|
|
|
|
return $this->getBonuses()['sum_criticals'];
|
|
|
|
|
}
|
2020-07-20 14:48:09 +00:00
|
|
|
|
public function getItemsWeight()
|
|
|
|
|
{
|
|
|
|
|
return self::getBonuses()['sum_weight'];
|
|
|
|
|
}
|
2020-07-20 12:07:49 +00:00
|
|
|
|
|
2020-07-06 19:54:50 +00:00
|
|
|
|
}
|