/** * Creates a new instance of a Golden Wrench with the given data * * @param \stdClass $wrenchData The JSON data for this wrench * @throws SteamCondenserException If the SteamId for the owner of the * wrench cannot be created */ private function __construct($wrenchData) { $this->date = (int) $wrenchData->timestamp; $this->id = (int) $wrenchData->itemID; $this->number = (int) $wrenchData->wrenchNumber; $this->owner = SteamId::create((string) $wrenchData->steamID, false); }
/** * Creates a <var>GameStats</var> object and fetches data from the Steam * Community for the given user and game * * @param string $userId The custom URL or the 64bit Steam ID of the user * @param string $appId The app ID or friendly name of the game * @throws SteamCondenserException if the stats cannot be fetched */ protected function __construct($userId, $appId) { $this->schema = GameStatsSchema::create($appId); $this->user = SteamId::create($userId, false); $this->appId = $appId; $this->steamId64 = $this->user->getSteamId64(); $params = ['appid' => $this->schema->getAppId(), 'steamid' => $this->steamId64]; $data = WebApi::getJSONObject('ISteamUserStats', 'GetUserStatsForGame', 2, $params); $this->achievements = []; foreach ($data->playerstats->achievements as $achievement) { $apiName = $achievement->name; $unlocked = $achievement->achieved == 1; $this->achievements[] = $this->schema->getAchievement($apiName)->getInstance($this->user, $unlocked); } $this->values = []; foreach ($data->playerstats->stats as $datum) { $this->values[] = $this->schema->getDatum($datum->name)->getInstance($this->user, $datum->value); } }
/** * @var $singleGames SteamGame[] */ $singleGames = $id->getGames(); $localMultiplayerGames = array_filter($singleGames, function ($game) { return SteamCache::hasLocalMultiplayer($game->getAppId()); }); if (count($localMultiplayerGames) == 0) { throw new Exception("No games found"); } $randomGame = $localMultiplayerGames[array_rand($localMultiplayerGames)]; return new \Symfony\Component\HttpFoundation\JsonResponse(array('status' => 'success', 'response' => array('id' => $randomGame->getAppId(), 'name' => $randomGame->getName(), 'store' => $randomGame->getStoreUrl(), 'image' => $randomGame->getLogoUrl()))); } $gameCollections = []; foreach ($users as $user) { $id = SteamId::create($user); $gameCollections[] = $id->getGames(); } $gameCollections[] = function ($a, $b) { /** * @var $a SteamGame * @var $b SteamGame */ if ($a instanceof SteamGame && $b instanceof SteamGame) { if ($a->getAppId() === $b->getAppId()) { if (SteamCache::hasOnlineMultiplayer($a->getAppId())) { return 0; } } } return 1;
/** * Returns the base Steam Community URL for the stats contained in this * object * * @return string The base URL used for queries on these stats */ public function getBaseUrl() { return self::_getBaseUrl($this->user->getId(), $this->game->getId()); }
/** * Creates a new inventory object for the given user. This calls * <var>fetch()</var> to update the data and create the GameItem instances * contained in this player's inventory * * @param int $appId The application ID of the game * @param string $steamId64 The 64bit Steam ID of the user * @param bool $fetchNow Whether the data should be fetched now * @throws \SteamCondenser\Exceptions\WebApiException on Web API errors */ protected function __construct($appId, $steamId64, $fetchNow = true) { $this->appId = $appId; $this->steamId64 = $steamId64; $this->user = SteamId::create($steamId64, false); if ($fetchNow) { $this->fetch(); } $this->cache(); array_keys(self::$cache); array_keys(self::$cache[$appId]); }
/** * Fetches the friends of this user * * This creates a new <var>SteamId</var> instance for each of the friends * without fetching their data. * * @see getFriends() * @see __construct() * @throws SteamCondenserException if an error occurs while parsing the * data */ private function fetchFriends() { $friendsData = $this->getData($this->getBaseUrl() . '/friends?xml=1'); $this->friends = []; foreach ($friendsData->friends->friend as $friend) { $this->friends[] = SteamId::create((string) $friend, false); } }
/** * Creates a new inventory object for the given user. This calls * <var>fetch()</var> to update the data and create the GameItem instances * contained in this player's inventory * * @param int $appId The application ID of the game * @param string $steamId64 The 64bit Steam ID of the user * @throws \SteamCondenser\Exceptions\WebApiException on Web API errors */ protected function __construct($appId, $steamId64) { $this->appId = $appId; $this->steamId64 = $steamId64; $this->user = SteamId::create($steamId64, false); }
/** * Creates a new <var>SteamId</var> instance using a SteamID as used on * servers * * The SteamID from the server is converted into a 64bit numeric SteamID * first before this is used to retrieve the corresponding Steam Community * profile. * * @param string $steamId The SteamID string as used on servers, like * <var>STEAM_0:0:12345</var> * @return SteamId The <var>SteamId</var> instance belonging to the given * SteamID * @see convertSteamIdToCommunityId() * @see __construct() */ public static function getFromSteamId($steamId) { return SteamId::create(self::convertSteamIdToCommunityId($steamId)); }