コード例 #1
0
 /**
  * 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 DotA2BetaInventory 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);
 }
コード例 #2
0
    protected function internalFetch()
    {
        $params = ['SteamID' => $this->steamId64];
        $result = WebApi::getJSONData("IEconItems_{$this->getAppId()}", 'GetPlayerItems', 1, $params);
        $this->items = [];
        $this->preliminaryItems = [];
        foreach ($result->items as $itemData) {
            if ($itemData != null) {
                $inventoryClass = get_called_class();
                $itemClass = $inventoryClass::ITEM_CLASS;
                $item = new $itemClass($this, $itemData);
                if ($item->isPreliminary()) {
                    $this->preliminaryItems[] = $item;
                } else {
                    $this->items[$item->getBackpackPosition() - 1] = $item;
                }
            }
        }
    }
    /**
     * Returns the number of items in the user's backpack
     *
     * @return int The number of items in the backpack
     */
    public function size()
    {
        return sizeof($this->items);
    }
}
GameInventory::initialize();