/**
  * Creates a TF2Stats object by calling the super constructor with the game
  * name "TF2"
  *
  * @param $steamId The custom URL or 64bit Steam ID of the user
  */
 public function __construct($steamId)
 {
     parent::__construct($steamId, "TF2");
     if ($this->isPublic()) {
         $this->accumulatedPoints = intval($this->xmlData->stats->accumulatedPoints);
     }
 }
 /**
  * Creates a new <var>AlienSwarmStats</var> instance by calling the super
  * constructor with the game name <var>"alienswarm"</var>
  *
  * @param mixed $steamId The custom URL or the 64bit Steam ID of the user
  */
 public function __construct($steamId)
 {
     parent::__construct($steamId, 'alienswarm');
     if ($this->isPublic()) {
         $lifetimeStats = $this->xmlData->stats->lifetime;
         $this->hoursPlayed = (string) $lifetimeStats->timePlayed;
         $this->lifetimeStats = array();
         $this->lifetimeStats['accuracy'] = (double) $lifetimeStats->accuracy;
         $this->lifetimeStats['aliensBurned'] = (int) $lifetimeStats->aliensburned;
         $this->lifetimeStats['aliensKilled'] = (int) $lifetimeStats->alienskilled;
         $this->lifetimeStats['campaigns'] = (int) $lifetimeStats->campaigns;
         $this->lifetimeStats['damageTaken'] = (int) $lifetimeStats->damagetaken;
         $this->lifetimeStats['experience'] = (int) $lifetimeStats->experience;
         $this->lifetimeStats['experienceRequired'] = (int) $lifetimeStats->xprequired;
         $this->lifetimeStats['fastHacks'] = (int) $lifetimeStats->fasthacks;
         $this->lifetimeStats['friendlyFire'] = (int) $lifetimeStats->friendlyfire;
         $this->lifetimeStats['gamesSuccessful'] = (int) $lifetimeStats->gamessuccess;
         $this->lifetimeStats['healing'] = (int) $lifetimeStats->healing;
         $this->lifetimeStats['killsPerHour'] = (double) $lifetimeStats->killsperhour;
         $this->lifetimeStats['level'] = (int) $lifetimeStats->level;
         $this->lifetimeStats['promotion'] = (int) $lifetimeStats->promotion;
         $this->lifetimeStats['nextUnlock'] = (string) $lifetimeStats->nextunlock;
         $this->lifetimeStats['nextUnlockImg'] = self::BASE_URL . (string) $lifetimeStats->nextunlockimg;
         $this->lifetimeStats['shotsFired'] = (int) $lifetimeStats->shotsfired;
         $this->lifetimeStats['totalGames'] = (int) $lifetimeStats->totalgames;
         if ($this->lifetimeStats['promotion'] > 0) {
             $this->lifetimeStats['promotionImg'] = self::BASE_URL . (string) $lifetimeStats->promotionpic;
         }
         $this->lifetimeStats['games_successful_percentage'] = $this->lifetimeStats['totalGames'] > 0 ? $this->lifetimeStats['gamesSuccessful'] / $this->lifetimeStats['totalGames'] : 0;
     }
 }
Пример #3
0
 /**
  * Creates a DefenseGridStats object by calling the super constructor with
  * the game name "defensegrid:awakening"
  * 
  * @param String $steamId
  */
 public function __construct($steamId)
 {
     parent::__construct($steamId, 'defensegrid:awakening');
     if ($this->isPublic()) {
         $generalData = $this->xmlData->stats->general;
         $this->bronzeMedals = (int) $generalData->bronze_medals_won->value;
         $this->silverMedals = (int) $generalData->silver_medals_won->value;
         $this->goldMedals = (int) $generalData->gold_medals_won->value;
         $this->levelsPlayed = (int) $generalData->levels_played_total->value;
         $this->levelsPlayedCampaign = (int) $generalData->levels_played_campaign->value;
         $this->levelsPlayedChallenge = (int) $generalData->levels_played_challenge->value;
         $this->levelsWon = (int) $generalData->levels_won_total->value;
         $this->levelsWonCampaign = (int) $generalData->levels_won_campaign->value;
         $this->levelsWonChallenge = (int) $generalData->levels_won_challenge->value;
         $this->encountered = (int) $generalData->total_aliens_encountered->value;
         $this->killed = (int) $generalData->total_aliens_killed->value;
         $this->killedCampaign = (int) $generalData->total_aliens_killed_campaign->value;
         $this->killedChallenge = (int) $generalData->total_aliens_killed_challenge->value;
         $this->resources = (int) $generalData->resources_recovered->value;
         $this->heatDamage = (double) $generalData->heatdamage->value;
         $this->timePlayed = (double) $generalData->time_played->value;
         $this->interest = (double) $generalData->interest_gained->value;
         $this->damage = (double) $generalData->tower_damage_total->value;
         $this->damageCampaign = (double) $generalData->tower_damage_total_campaign->value;
         $this->damageChallenge = (double) $generalData->tower_damage_total_challenge->value;
         $this->orbitalLaserFired = (double) $this->xmlData->stats->orbitallaser->fired->value;
         $this->orbitalLaserDamage = (double) $this->xmlData->stats->orbitallaser->damage->value;
     }
 }
 public function __construct($steamId, $gameName)
 {
     parent::__construct($steamId, $gameName);
     if ($this->isPublic() && !empty($this->xmlData->stats->mostrecentgame)) {
         $this->mostRecentGame['difficulty'] = (string) $this->xmlData->stats->mostrecentgame->difficulty;
         $this->mostRecentGame['escaped'] = (bool) $this->xmlData->stats->mostrecentgame->bEscaped;
         $this->mostRecentGame['movie'] = (string) $this->xmlData->stats->mostrecentgame->movie;
         $this->mostRecentGame['timePlayed'] = (string) $this->xmlData->stats->mostrecentgame->time;
     }
 }
 /**
  * Creates a new <var>TF2Stats</var> instance by calling the super
  * constructor with the game name <var>"tf2"</var>
  *
  * @param string $steamId The custom URL or 64bit Steam ID of the user
  * @param bool $beta if <var>true</var>, creates stats for the public TF2
  *        beta
  */
 public function __construct($steamId, $beta = false)
 {
     parent::__construct($steamId, $beta ? '520' : 'tf2');
     if ($this->isPublic()) {
         if (!empty($this->xmlData->stats->accumulatedPoints)) {
             $this->accumulatedPoints = (int) $this->xmlData->stats->accumulatedPoints;
         }
         if (!empty($this->xmlData->stats->secondsPlayedAllClassesLifetime)) {
             $this->totalPlaytime = (int) $this->xmlData->stats->secondsPlayedAllClassesLifetime;
         }
     }
 }
 /**
  * Creates a CSSStats object by calling the super constructor with the game
  * name "cs:s"
  * @param steamId The custom URL or the 64bit Steam ID of the user
  * @throws SteamCondenserException If an error occurs
  */
 public function __construct($steamId)
 {
     parent::__construct($steamId, 'cs:s');
     if ($this->isPublic()) {
         $statsData = $this->xmlData->stats;
         $this->lastMatchStats = array();
         $this->totalStats = array();
         $this->lastMatchStats['costPerKill'] = (double) $statsData->lastmatch->costkill;
         $this->lastMatchStats['ctWins'] = (int) $statsData->lastmatch->ct_wins;
         $this->lastMatchStats['damage'] = (int) $statsData->lastmatch->dmg;
         $this->lastMatchStats['deaths'] = (int) $statsData->lastmatch->deaths;
         $this->lastMatchStats['dominations'] = (int) $statsData->lastmatch->dominations;
         $this->lastMatchStats['favoriteWeaponId'] = (int) $statsData->lastmatch->favwpnid;
         $this->lastMatchStats['kills'] = (int) $statsData->lastmatch->kills;
         $this->lastMatchStats['maxPlayers'] = (int) $statsData->lastmatch->max_players;
         $this->lastMatchStats['money'] = (int) $statsData->lastmatch->money;
         $this->lastMatchStats['revenges'] = (int) $statsData->lastmatch->revenges;
         $this->lastMatchStats['stars'] = (int) $statsData->lastmatch->stars;
         $this->lastMatchStats['tWins'] = (int) $statsData->lastmatch->t_wins;
         $this->lastMatchStats['wins'] = (int) $statsData->lastmatch->wins;
         $this->totalStats['blindKills'] = (int) $statsData->lifetime->blindkills;
         $this->totalStats['bombsDefused'] = (int) $statsData->lifetime->bombsdefused;
         $this->totalStats['bombsPlanted'] = (int) $statsData->lifetime->bombsplanted;
         $this->totalStats['damage'] = (int) $statsData->lifetime->dmg;
         $this->totalStats['deaths'] = (int) $statsData->summary->deaths;
         $this->totalStats['dominationOverkills'] = (int) $statsData->lifetime->dominationoverkills;
         $this->totalStats['dominations'] = (int) $statsData->lifetime->dominations;
         $this->totalStats['earnedMoney'] = (int) $statsData->lifetime->money;
         $this->totalStats['enemyWeaponKills'] = (int) $statsData->lifetime->enemywpnkills;
         $this->totalStats['headshots'] = (int) $statsData->lifetime->headshots;
         $this->totalStats['hits'] = (int) $statsData->summary->shotshit;
         $this->totalStats['hostagesRescued'] = (int) $statsData->lifetime->hostagesrescued;
         $this->totalStats['kills'] = (int) $statsData->summary->kills;
         $this->totalStats['knifeKills'] = (int) $statsData->lifetime->knifekills;
         $this->totalStats['logosSprayed'] = (int) $statsData->lifetime->decals;
         $this->totalStats['nightvisionDamage'] = (int) $statsData->lifetime->nvgdmg;
         $this->totalStats['pistolRoundsWon'] = (int) $statsData->lifetime->pistolrounds;
         $this->totalStats['revenges'] = (int) $statsData->lifetime->revenges;
         $this->totalStats['roundsPlayed'] = (int) $statsData->summary->rounds;
         $this->totalStats['roundsWon'] = (int) $statsData->summary->wins;
         $this->totalStats['secondsPlayed'] = (int) $statsData->summary->timeplayed;
         $this->totalStats['shots'] = (int) $statsData->summary->shots;
         $this->totalStats['stars'] = (int) $statsData->summary->stars;
         $this->totalStats['weaponsDonated'] = (int) $statsData->lifetime->wpndonated;
         $this->totalStats['windowsBroken'] = (int) $statsData->lifetime->winbroken;
         $this->totalStats['zoomedSniperKills'] = (int) $statsData->lifetime->zsniperkills;
         $this->lastMatchStats['kdratio'] = $this->totalStats['deaths'] > 0 ? $this->lastMatchStats['kills'] / $this->lastMatchStats['deaths'] : 0;
         $this->totalStats['accuracy'] = $this->totalStats['shots'] > 0 ? $this->totalStats['hits'] / $this->totalStats['shots'] : 0;
         $this->totalStats['kdratio'] = $this->totalStats['deaths'] > 0 ? $this->totalStats['kills'] / $this->totalStats['deaths'] : 0;
         $this->totalStats['roundsLost'] = $this->totalStats['roundsPlayed'] - $this->totalStats['roundsWon'];
     }
 }
 /**
  * Creates a <var>DoDSStats</var> instance by calling the super constructor
  * with the game name <var>"DoD:S"</var>
  *
  * @param string $steamId The custom URL or 64bit Steam ID of the user
  */
 public function __construct($steamId)
 {
     parent::__construct($steamId, 'DoD:S');
 }
Пример #8
0
 /**
  * Returns the stats for the given game for the owner of this SteamID
  *
  * @param mixed $id The full or short name or the application ID of the
  *        game stats should be fetched for
  * @return GameStats The statistics for the game with the given name
  * @throws SteamCondenserException if the user does not own this game or it
  *         does not have any stats
  */
 public function getGameStats($id)
 {
     $game = $this->findGame($id);
     if (!$game->hasStats()) {
         throw new SteamCondenserException("\"{$game->getName()}\" does not have stats.");
     }
     if (empty($this->customUrl)) {
         return GameStats::createGameStats($this->steamId64, $game->getShortName());
     } else {
         return GameStats::createGameStats($this->customUrl, $game->getShortName());
     }
 }
 /**
  * Creates a stats object for the given user and this game
  *
  * @param string $steamId The custom URL or the 64bit Steam ID of the user
  * @return GameStats The stats of this game for the given user
  */
 public function getUserStats($steamId)
 {
     if (!$this->hasStats()) {
         return null;
     }
     return GameStats::createGameStats($steamId, $this->shortName);
 }
 /**
  * Returns a GameStats object for the given game for the owner of this SteamID
  *
  * @param $gameName
  * @return GameStats
  */
 public function getGameStats($gameName)
 {
     if (in_array($gameName, array_values($this->getGames()))) {
         $friendlyName = $gameName;
     } else {
         if (array_key_exists(strtolower($gameName), $this->getGames())) {
             $friendlyName = $this->games[strtolower($gameName)];
         } else {
             throw new SteamCondenserException("Stats for game {$gameName} do not exist.");
         }
     }
     if (empty($this->customUrl)) {
         return GameStats::createGameStats($this->steamId64, $friendlyName);
     } else {
         return GameStats::createGameStats($this->customUrl, $friendlyName);
     }
 }
 /**
  * Creates a <var>Portal2Stats</var> object by calling the super
  * constructor with the game name <var>"portal2"</var>
  *
  * @param string $steamId The custom URL or 64bit Steam ID of the user
  */
 public function __construct($steamId)
 {
     parent::__construct($steamId, 'portal2');
 }