Skip to content

Instantly share code, notes, and snippets.

@JacobMuchow
Last active August 29, 2015 14:08
Show Gist options
  • Save JacobMuchow/ee9d38e86c13d7178ae9 to your computer and use it in GitHub Desktop.
Save JacobMuchow/ee9d38e86c13d7178ae9 to your computer and use it in GitHub Desktop.
TagPro- Records on a remote server how often the team with the most degrees wins
// ==UserScript==
// @name Teams Stacking Stats
// @namespace http://*.koalabeast.com:*
// @version 1.0
// @description Records on a remote server how often the team with the most degrees wins
// @author Jacob Muchow (Mufro)
// @match http://koalabeast.com
// @include http://*.koalabeast.com:*
// ==/UserScript==
tagpro.ready(function() {
console.log("Team Stacking Stats started");
tagpro.socket.on('end', function() {
var players = tagpro.players;
var team1 = 0;
var team2 = 0;
var winner = 0;
var data = "";
if(tagpro.score.r > tagpro.score.b)
winner = 1;
else if(tagpro.score.r < tagpro.score.b)
winner = 2;
for(var i = 1; i < 9; i++) {
var player = players[i];
if(player != null) {
if(player.team == 1)
team1 += player.degree;
else if(player.team == 2)
team2 += player.degree;
}
}
if(winner == 1 && team1 > team2)
data = "won";
else if(winner == 2 && team2 > team1)
data = "won";
$.ajax ({
type: "POST",
dataType : 'json',
async: true,
url: 'http://www.muchowsoftware.com/TagPro/team_stats.php',
data: { data: data }
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment