$(function() {
	var jumboTron = {
		$headerField: $("#jHeader"),
		$bodyField: $("#jBody"),
		init: function(header, body) {
			this.header = header;
			this.body = body;
			this.render();
		},
		render: function() {
			this.$headerField.html(this.header);
			this.$bodyField.html(this.body);
		}
	}

	var statTable = {
		$tableBody: $("#statTableBody"),
		stats: [],
		init: function(stats) {
			this.stats = stats;
			this.render();
		},
 		render: function() {
			this.$tableBody.empty();
			for(var a = 0; a < this.stats.length; a++) {
				this.$tableBody.append(this.getTableRow(this.stats[a]));
			}
		},
		getTableRow: function(stat) {
			if(stat.mouseOverText != undefined && stat.mouseOverText != null) {
				return "<tr><td><span title='"+stat.mouseOverText+"'>"+stat.name+"</span></td><td>"+stat.value+"</td></tr>";
			} else {
				return "<tr><td><span>"+stat.name+"</span></td><td>"+stat.value+"</td></tr>";
			}
		}
	}

	var gameTable = {
		$tableBody: $("#gameTableBody"),
		games: [],
		init: function(userID, rawGames) {
			this.userID = userID;
			this.rawGames = rawGames;
			this.transformGames();
			this.render();
		},
		transformGames: function() {
			console.log(this.rawGames)
			for(var a = 0; a < this.rawGames.length; a++) {
				var opponent = this.rawGames[a].users[0].userID == this.userID ? this.rawGames[a].users[1] : this.rawGames[a].users[0];
				var result = opponent.rank == "1" ? "Lost" : "Won";
				var replayName = this.rawGames[a].replayName;
				this.games.push({
					opponent: opponent,
					result: result,
					replayName: replayName
				});
			}
		},
		render: function() {

			this.$tableBody.empty();
			for(var a = 0; a < this.games.length; a++) {
				this.$tableBody.append(this.getTableRow(this.games[a]));
			}
		},
		getTableRow: function(game) {
			return "<tr><td><a href='user.php?userID="+game.opponent.userID+"'>"+game.opponent.username+"</a></td><td><span class='"+game.result.toLowerCase()+"'>"+game.result+"</span></td><td><a target='_blank' href='../storage/replays/"+game.replayName+"'><span class='glyphicon glyphicon-save-file'></span></a></td></tr>";
		}
	}

	function statsFromUser(user, numUsers) {
		var statDetails = {
			"numSubmissions": {name: "Number of Bots Submitted", mouseOverText: ""},
			"numGames": {name: "Number of Games Played", mouseOverText: ""},
			"language": {name: "Language", mouseOverText: ""},
			"territoryRanking": {name: "Territory", mouseOverText: "", percentile: true},
			"strengthRanking": {name: "Strength", mouseOverText: "", percentile: true},
			"productionRanking": {name: "Production", mouseOverText: "", percentile: true},
			"stillRanking": {name: "Still Move Frequency", mouseOverText: "", percentile: true},
			"turnTimeRanking": {name: "Time per Turn (ms)", mouseOverText: "", percentile: true}
		};
		var stats = [];
		for(var key in statDetails) {
			if(user[key] != undefined && user[key] != null) {
				if(statDetails[key].percentile == true) {
					stats.push({name: statDetails[key].name, mouseOverText: statDetails[key].mouseOverText, value: user[key]+" of "+numUsers})
				} else {
					stats.push({name: statDetails[key].name, mouseOverText: statDetails[key].mouseOverText, value: user[key]})
				}
			}
		}
		return stats;
	}

	var userID = getGET("userID");
	var user = getUser(userID);
	var extraStats = getExtraStats(userID);
	$.extend(user, extraStats);
	var numUsers = getNumActiveUsers();

	$(document).prop('title', user.username);

	jumboTron.init(user.username, "Ranked " + user.rank + " of " + numUsers);
	statTable.init(statsFromUser(user, numUsers));
	gameTable.init(userID, getLatestGamesForUser(userID, 10));

})

@@ -2182,16 +2182,75 @@
 ils = %7B%0A
+%09%09%09%22score%22: %7Bname: %22Trueskill Rating%22, mouseOverText: %22%22%7D,%0A
 %09%09%09%22numS
@@ -2479,16 +2479,24 @@
 erritory
+ Ranking
 %22, mouse
@@ -2566,16 +2566,24 @@
 Strength
+ Ranking
 %22, mouse
@@ -2657,16 +2657,24 @@
 oduction
+ Ranking
 %22, mouse
@@ -3356,16 +3356,17 @@
 erID%22);%0A
+%0A
 %09var use
@@ -3456,16 +3456,84 @@
 Stats);%0A
+%09user%5B%22score%22%5D = Math.round(100*(user%5B%22mu%22%5D-3*user%5B%22sigma%22%5D))/100;%0A%0A
 %09var num

Add score to user page