Code smell.
This commit is contained in:
@@ -13,20 +13,20 @@ use stdClass;
|
||||
|
||||
class DressedItems
|
||||
{
|
||||
private int $USERID;
|
||||
private int $userId;
|
||||
private stdClass $dressedItem;
|
||||
private static Db $db;
|
||||
private object $dressed;
|
||||
|
||||
/**
|
||||
* DressedItems constructor.
|
||||
* @param int $user_id ID игрока.
|
||||
* @param int $userId ID игрока.
|
||||
*/
|
||||
public function __construct(int $user_id)
|
||||
public function __construct(int $userId)
|
||||
{
|
||||
self::$db = Db::getInstance();
|
||||
$this->USERID = $user_id;
|
||||
$this->dressed = self::$db->ofetchAll('select * from inventory where dressed_slot > 0 and owner_id = ?', $this->USERID);
|
||||
$this->userId = $userId;
|
||||
$this->dressed = self::$db->ofetchAll('select * from inventory where dressed_slot > 0 and owner_id = ?', $this->userId);
|
||||
}
|
||||
|
||||
public static function getDressedItemBySlot($itemSlot, $ownerId)
|
||||
@@ -46,33 +46,33 @@ class DressedItems
|
||||
|
||||
/**
|
||||
* Снимает с предмета статус одетого на персонажа в определённом слоте персонажа.
|
||||
* @param $slot_id - номер слота.
|
||||
* @param $slotId - номер слота.
|
||||
*/
|
||||
public function undressItem($slot_id)
|
||||
public function undressItem($slotId)
|
||||
{
|
||||
self::getItemsInSlots();
|
||||
// Проверяем, что используется один из 12 слотов и наличие предмета в слоте.
|
||||
if (in_array($slot_id, Item::ITEM_TYPES_ALLOWED_IN_SLOTS) && $this->dressedItem->$slot_id) {
|
||||
Inventory::undressOne($slot_id, $this->USERID);
|
||||
if (in_array($slotId, Item::TYPES_ALLOWED_IN_SLOTS) && $this->dressedItem->$slotId) {
|
||||
Inventory::undressOne($slotId, $this->userId);
|
||||
}
|
||||
}
|
||||
|
||||
public static function undressAllItems($user_id)
|
||||
public static function undressAllItems($userId)
|
||||
{
|
||||
return self::$db->execute('UPDATE inventory SET dressed_slot = 0 WHERE dressed_slot BETWEEN 1 AND 12 AND owner_id = ?', $user_id);
|
||||
return self::$db->execute('UPDATE inventory SET dressed_slot = 0 WHERE dressed_slot BETWEEN 1 AND 12 AND owner_id = ?', $userId);
|
||||
}
|
||||
|
||||
public function checkRequirements()
|
||||
{
|
||||
$stats = (new UserStats($this->USERID))->getFullStats();
|
||||
$q = 'select count(*) from inventory where
|
||||
dressed_slot > 0 and
|
||||
$stats = (new UserStats($this->userId))->getFullStats();
|
||||
$q = 'select count(*) from inventory where
|
||||
dressed_slot > 0 and
|
||||
need_strength > ? and
|
||||
need_dexterity > ? and
|
||||
need_intuition > ? and
|
||||
need_endurance > ? and
|
||||
need_dexterity > ? and
|
||||
need_intuition > ? and
|
||||
need_endurance > ? and
|
||||
need_intelligence > ? and
|
||||
need_wisdom > ? and
|
||||
need_wisdom > ? and
|
||||
owner_id = ?';
|
||||
$args = [
|
||||
$stats->strength,
|
||||
@@ -81,10 +81,10 @@ class DressedItems
|
||||
$stats->endurance,
|
||||
$stats->intelligence,
|
||||
$stats->wisdom,
|
||||
$this->USERID
|
||||
$this->userId
|
||||
];
|
||||
if (self::$db->fetchColumn($q, $args) > 0) {
|
||||
self::undressAllItems($this->USERID);
|
||||
self::undressAllItems($this->userId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user