/** * Returns all possible loot. * * <p> * In order to use this method you have to have global items list loaded. * </p> * * @version 0.2.0+SVN * @since 0.1.0 * @return array List of item types. * @throws E_OTS_NotLoaded When there is no items list available in global POT instance. * @throws DOMException On DOM operation error. */ public function getItems() { $loot = array(); $keys = array(); $items = POT::getItemsList(); $element = $this->documentElement->getElementsByTagName('loot')->item(0); // checks if it has any loot if (isset($element)) { // adds all items foreach ($element->getElementsByTagName('item') as $item) { $id = $item->getAttribute('id'); // avoid redundancy if (!in_array($id, $keys)) { $keys[] = $id; $loot[] = $items->getItemType($id); } } } return $loot; }
/** * Returns item type of reagent item. * * <p> * Note: You need to have global items list resource loaded in order to use this method. * </p> * * @version 0.2.0+SVN * @since 0.1.0 * @return OTS_ItemType|null Returns item type of reagent item (null if not exists). * @throws E_OTS_NotLoaded When there is no global items list available. * @throws DOMException On DOM operation error. */ public function getReagent() { return POT::getItemsList()->getItemType((int) $this->element->getAttribute('reagentId')); }
/** * Returns type of item. * * @version 0.2.0+SVN * @since 0.1.0 * @return OTS_ItemType Returns item type of item (null if not exists). * @throws E_OTS_NotLoaded If global items list wasn't loaded. */ public function getItemType() { return POT::getItemsList()->getItemType($this->id); }
/** * Returns items tree from given depot. * * <p> * You need global items list resources loaded in order to use this method. * </p> * * @version 0.2.0+SVN * @since 0.0.3 * @param int $depot Depot ID to get items. * @return OTS_Item|null Item in given depot (items tree if in given depot there is a container). If there is no item in depot then null value will be returned. * @throws E_OTS_NotLoaded If player is not loaded or there is no global items list resource loaded. * @throws E_OTS_NotAContainer If item which is not of type container contains sub items. * @throws PDOException On PDO operation error. */ public function getDepot($depot) { if (!isset($this->data['id'])) { throw new E_OTS_NotLoaded(); } // loads current item $item = $this->db->query('SELECT ' . $this->db->fieldName('itemtype') . ', ' . $this->db->fieldName('sid') . ', ' . $this->db->fieldName('count') . ', ' . $this->db->fieldName('attributes') . ' FROM ' . $this->db->tableName('player_depotitems') . ' WHERE ' . $this->db->fieldName('player_id') . ' = ' . $this->data['id'] . ' AND ' . $this->db->fieldName($depot > POT::DEPOT_SID_FIRST ? 'sid' : 'pid') . ' = ' . (int) $depot)->fetch(); if (empty($item)) { return null; } // checks if there are any items under current one $items = array(); foreach ($this->db->query('SELECT ' . $this->db->fieldName('sid') . ' FROM ' . $this->db->tableName('player_depotitems') . ' WHERE ' . $this->db->fieldName('player_id') . ' = ' . $this->data['id'] . ' AND ' . $this->db->fieldName('pid') . ' = ' . $item['sid'])->fetchAll() as $sub) { $items[] = $this->getDepot($sub['sid']); } // item type $depot = POT::getItemsList()->getItemType($item['itemtype'])->createItem(); $depot->setCount($item['count']); $depot->setAttributes($item['attributes']); // checks if current item has any contained items if (!empty($items)) { // checks if item is realy a container if (!$depot instanceof OTS_Container) { throw new E_OTS_NotAContainer(); } // puts items into container foreach ($items as $sub) { $depot->addItem($sub); } } return $depot; }
/** * Fetch an item color from cache or OTB. * * @param $itemid * @return false|array RGB */ public static function itemColor($itemid) { if (!isset(self::$items[$itemid])) { if (!\POT::areItemsLoaded()) { \POT::loadItems(public_path() . '/xml'); } $list = \POT::getItemsList(); if ($list->hasItemTypeId($itemid)) { $item = $list->getItemType($itemid); if ($item->hasAttribute('minimapColor')) { self::$items[$itemid] = self::$rgbs[$item->getAttribute('minimapColor')]; } } if (!isset(self::$items[$itemid])) { self::$items[$itemid] = false; } } return self::$items[$itemid]; }