battles/classes/DressedItems.php
Igor Barkov (iwork) b358d19893 class errors
2020-07-20 17:25:02 +03:00

117 lines
3.2 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
* Author: lopiu
* Date: 06.07.2020
* Time: 22:41
*/
class DressedItems
{
protected static $DB;
protected static $DBSUM;
protected static $USERID;
private $dressedItem;
/**
* DressedItems constructor.
*
* @param $user_id - ID игрока.
*/
public function __construct($user_id)
{
//$this->USERID = $user_id;
self::$USERID = $user_id;
}
private static function getDressedItems()
{
try {
self::$DB = db::c()->query('SELECT * FROM inventory WHERE owner_id = ?i AND dressed_slot > 0', self::$USERID);
} catch (Exception $e) {
echo '<div class="debug">Не прогрузилась таблица inventory (*) для класса DressedItems.</div>';
}
}
protected function getBonusesFromDressedItems()
{
try {
$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,
SUM(add_accuracy) as sum_accuracy,
SUM(add_evasion) as sum_evasion,
SUM(add_criticals) as sum_criticals,
SUM(add_min_physical_damage) as sum_min_phys_damage,
SUM(add_max_physical_damage) as sum_max_phys_damage
FROM inventory WHERE owner_id = ?i AND dressed_slot > 0
SQL;
self::$DBSUM = db::c()->query($query, self::$USERID)->fetch_assoc();
} catch (Exception $e) {
echo '<div class="debug">Не прогрузилась таблица inventory (SUM) для класса DressedItems:' . $e . '</div>';
}
}
public function getItemsInSlots()
{
if (!self::$DB) {
//$this->getDressedItems();
self::getDressedItems();
}
while ($row = self::$DB->fetch_assoc()) {
$dressed_item[$row['dressed_slot']] = $row;
$this->dressedItem[$row['dressed_slot']] = $row;
}
}
protected function getBonuses()
{
if (!self::$DBSUM) {
self::getBonusesFromDressedItems();
}
return self::$DBSUM;
}
public function getStrengthBonus()
{
//return $this->getBonuses()['sum_strength'];
return self::getBonuses()['sum_strength'];
}
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'];
}
public function getEvasionBonus()
{
return $this->getBonuses()['sum_evasion'];
}
public function getCriticalsBonus()
{
return $this->getBonuses()['sum_criticals'];
}
}