/** * This checks the cache for an existing inventory. If it exists it is * returned. Otherwise a new inventory is created. * * @param string $steamId The 64bit Steam ID or vanity URL of the user * @param bool $fetchNow Whether the data should be fetched now * @param bool $bypassCache Whether the cache should be bypassed * @return DotA2Inventory The inventory created from the given options */ public static function createInventory($steamId, $fetchNow = true, $bypassCache = false) { return parent::create(self::APP_ID, $steamId, $fetchNow, $bypassCache); }
/** * Creates a new instance of a GameItem with the given data * * @param GameInventory $inventory The inventory this item is contained in * @param \stdClass $itemData The data specifying this item * @throws \SteamCondenser\Exceptions\WebApiException on Web API errors */ public function __construct(GameInventory $inventory, $itemData) { $this->inventory = $inventory; $this->defindex = $itemData->defindex; $this->backpackPosition = $itemData->inventory & 0xffff; $this->count = $itemData->quantity; $this->id = $itemData->id; $this->itemClass = $this->getSchemaData()->item_class; $this->level = $itemData->level; $this->name = $this->getSchemaData()->item_name; $origins = $this->inventory->getItemSchema()->getOrigins(); $this->originalId = $itemData->original_id; $this->preliminary = ($itemData->inventory & 0x40000000) != 0; $qualities = $this->inventory->getItemSchema()->getQualities(); $this->quality = $qualities[$itemData->quality]; $this->type = $this->getSchemaData()->item_type_name; if (property_exists($itemData, 'flag_cannot_craft')) { $this->craftable = !!$itemData->flag_cannot_craft; } if (!empty($this->getSchemaData()->item_set)) { $itemSets = $this->inventory->getItemSchema()->getItemSets(); $this->itemSet = $itemSets[$this->getSchemaData()->item_set]; } if (property_exists($itemData, 'origin')) { $this->origin = $origins[$itemData->origin]; } if (property_exists($itemData, 'flag_cannot_trade')) { $this->tradeable = !!$itemData->flag_cannot_trade; } $attributesData = []; if (property_exists($this->getSchemaData(), 'attributes')) { $attributesData = (array) $this->getSchemaData()->attributes; } if (!empty($itemData->attributes)) { $attributesData = array_merge_recursive($attributesData, (array) $itemData->attributes); } $this->attributes = []; foreach ($attributesData as $attributeData) { $attributeKey = property_exists($attributeData, 'defindex') ? $attributeData->defindex : $attributeData->name; if ($attributeKey != null) { $schemaAttributesData = $inventory->getItemSchema()->getAttributes(); $schemaAttributeData = $schemaAttributesData[$attributeKey]; $this->attributes[] = (object) array_merge_recursive((array) $attributeData, (array) $schemaAttributeData); } } }
/** * Sets the language the schema should be fetched in (default is: * <var>'en'</var>) * * @param string $language The language code for the language item * descriptions should be fetched in */ public static function setSchemaLanguage($language) { self::$schemaLanguage = $language; }