Skip to content

Instantly share code, notes, and snippets.

@chapel
Created October 15, 2010 13:04
Show Gist options
  • Save chapel/628145 to your computer and use it in GitHub Desktop.
Save chapel/628145 to your computer and use it in GitHub Desktop.
var request = require('request'),
sys = require('sys');
var gamerTag = 'thechapel';
getGames = function() {
getData = function(url, cb) {
request({uri:url}, function (error, response, body) {
if (!error && response.statusCode == 200) {
cb(body);
}
});
}
gameList = function(body) {
//console.log(body);
var gamesHistory = JSON.parse(body);
var gamesPlayed = gamesHistory.RecentGames;
var modifiedRating = [];
for(i=0; i<gamesPlayed.length; i++) {
var gameDate = new Date(parseInt(gamesPlayed[i].GameTimestamp.substr(6)));
console.log(gameDate.getMonth()+"/"+gameDate.getDate()+" "+gameDate.getHours());
var gameNum = gamesPlayed[i].GameId;
gameData = function(body) {
var stats = JSON.parse(body);
var players = stats.GameDetails.Players;
for(e=0; e<players.length; e++) {
var playerName = players[e].PlayerDetail.gamertag;
if (playerName == gamerTag) {
if (players[e].IndividualStandingWithNoRegardForTeams < 4) {
modifiedRating++;
}
else {
modifiedRating--;
}
console.log(e + ". Modified Rating: " + modifiedRating + " (" + players[e].Rating + "/" + players[e].IndividualStandingWithNoRegardForTeams + ") " + playerName);
}
}
}
getData('http://www.bungie.net/api/reach/reachapijson.svc/game/details/<secretcode>/'+gameNum, gameData);
}
}
getData('http://www.bungie.net/api/reach/reachapijson.svc/player/gamehistory/<secretcode>/'+gamerTag+'/arena/0', gameList);
}
getGames();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment