Merge pull request #25 from vita10gy/scoreboard
Scoreboard Update: Link Length, Field Area
This commit is contained in:
commit
dc685713be
@ -1,7 +1,7 @@
|
|||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @id iitc-plugin-scoreboard@vita10gy
|
// @id iitc-plugin-scoreboard@vita10gy
|
||||||
// @name IITC plugin: show a localized scoreboard.
|
// @name IITC plugin: show a localized scoreboard.
|
||||||
// @version 0.1.4.@@DATETIMEVERSION@@
|
// @version 0.1.5.@@DATETIMEVERSION@@
|
||||||
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
|
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
|
||||||
// @updateURL @@UPDATEURL@@
|
// @updateURL @@UPDATEURL@@
|
||||||
// @downloadURL @@DOWNLOADURL@@
|
// @downloadURL @@DOWNLOADURL@@
|
||||||
@ -33,6 +33,8 @@ window.plugin.scoreboard.resetTeam = function(team) {
|
|||||||
scores[team]['count_links'] = 0;
|
scores[team]['count_links'] = 0;
|
||||||
scores[team]['count_portals'] = 0;
|
scores[team]['count_portals'] = 0;
|
||||||
scores[team]['count_resonators'] = 0;
|
scores[team]['count_resonators'] = 0;
|
||||||
|
scores[team]['link_length'] = 0;
|
||||||
|
scores[team]['field_area'] = 0;
|
||||||
scores[team]['largest'] = {};
|
scores[team]['largest'] = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -46,6 +48,9 @@ window.plugin.scoreboard.initPlayer = function(player, team) {
|
|||||||
scores[player]['count_links'] = 0;
|
scores[player]['count_links'] = 0;
|
||||||
scores[player]['count_portals'] = 0;
|
scores[player]['count_portals'] = 0;
|
||||||
scores[player]['count_resonators'] = 0;
|
scores[player]['count_resonators'] = 0;
|
||||||
|
scores[player]['link_length'] = 0;
|
||||||
|
scores[player]['field_area'] = 0;
|
||||||
|
|
||||||
// scores[player]['count_shields'] = 0;
|
// scores[player]['count_shields'] = 0;
|
||||||
scores[player]['largest'] = {};
|
scores[player]['largest'] = {};
|
||||||
window.plugin.scoreboard.playerGuids.push(player);
|
window.plugin.scoreboard.playerGuids.push(player);
|
||||||
@ -61,6 +66,7 @@ window.plugin.scoreboard.compileStats = function() {
|
|||||||
window.plugin.scoreboard.resetTeam(TEAM_ENL);
|
window.plugin.scoreboard.resetTeam(TEAM_ENL);
|
||||||
|
|
||||||
$.each(window.fields, function(qk, val) {
|
$.each(window.fields, function(qk, val) {
|
||||||
|
|
||||||
var team = getTeam(val.options.data);
|
var team = getTeam(val.options.data);
|
||||||
var player = val.options.data.creator.creatorGuid;
|
var player = val.options.data.creator.creatorGuid;
|
||||||
|
|
||||||
@ -71,23 +77,33 @@ window.plugin.scoreboard.compileStats = function() {
|
|||||||
window.portals[val.options.vertices.vertexB.guid] !== undefined ||
|
window.portals[val.options.vertices.vertexB.guid] !== undefined ||
|
||||||
window.portals[val.options.vertices.vertexC.guid] !== undefined ) {
|
window.portals[val.options.vertices.vertexC.guid] !== undefined ) {
|
||||||
|
|
||||||
|
var fieldArea = window.plugin.scoreboard.fieldArea(val);
|
||||||
somethingInView = true;
|
somethingInView = true;
|
||||||
scores['team'][team]['mu'] += parseInt(val.options.data.entityScore.entityScore);
|
scores['team'][team]['mu'] += parseInt(val.options.data.entityScore.entityScore);
|
||||||
scores['player'][player]['mu'] += parseInt(val.options.data.entityScore.entityScore);
|
scores['player'][player]['mu'] += parseInt(val.options.data.entityScore.entityScore);
|
||||||
scores['team'][team]['count_fields']++;
|
scores['team'][team]['count_fields']++;
|
||||||
scores['player'][player]['count_fields']++;
|
scores['player'][player]['count_fields']++;
|
||||||
|
scores['team'][team]['field_area'] += fieldArea;
|
||||||
|
scores['player'][player]['field_area'] += fieldArea;
|
||||||
|
val.options.data.fieldArea = fieldArea;
|
||||||
var largestMu = scores['team'][team]['largest']['mu'];
|
var largestMu = scores['team'][team]['largest']['mu'];
|
||||||
if(largestMu === undefined || parseInt(largestMu.options.data.entityScore.entityScore) < parseInt(val.options.data.entityScore.entityScore)) {
|
if(largestMu === undefined || parseInt(largestMu.options.data.entityScore.entityScore) < parseInt(val.options.data.entityScore.entityScore)) {
|
||||||
largestMu = val;
|
largestMu = val;
|
||||||
}
|
}
|
||||||
scores['team'][team]['largest']['mu'] = largestMu;
|
scores['team'][team]['largest']['mu'] = largestMu;
|
||||||
|
|
||||||
var largestMu = scores['player'][player]['largest']['mu'];
|
//var largestMu = scores['player'][player]['largest']['mu'];
|
||||||
if(largestMu === undefined || parseInt(largestMu.options.data.entityScore.entityScore) < parseInt(val.options.data.entityScore.entityScore)) {
|
//if(largestMu === undefined || parseInt(largestMu.options.data.entityScore.entityScore) < parseInt(val.options.data.entityScore.entityScore)) {
|
||||||
largestMu = val;
|
// largestMu = val;
|
||||||
|
//}
|
||||||
|
//scores['player'][player]['largest']['mu'] = largestMu;
|
||||||
|
|
||||||
|
var largestArea = scores['team'][team]['largest']['field_area'];
|
||||||
|
if(largestArea === undefined || largestArea.options.data.fieldArea < val.options.data.fieldArea) {
|
||||||
|
largestArea = val;
|
||||||
}
|
}
|
||||||
scores['player'][player]['largest']['mu'] = largestMu;
|
scores['team'][team]['largest']['field_area'] = largestArea;
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$.each(window.links, function(qk, link) {
|
$.each(window.links, function(qk, link) {
|
||||||
@ -97,9 +113,29 @@ window.plugin.scoreboard.compileStats = function() {
|
|||||||
window.plugin.scoreboard.initPlayer(player, team);
|
window.plugin.scoreboard.initPlayer(player, team);
|
||||||
scores['team'][team]['count_links']++;
|
scores['team'][team]['count_links']++;
|
||||||
scores['player'][player]['count_links']++;
|
scores['player'][player]['count_links']++;
|
||||||
|
|
||||||
|
var linkLength = window.plugin.scoreboard.portalDistance(link.options.data.edge.destinationPortalLocation,link.options.data.edge.originPortalLocation);
|
||||||
|
scores['team'][team]['link_length'] += linkLength;
|
||||||
|
scores['player'][player]['link_length'] += linkLength;
|
||||||
|
|
||||||
|
var largestLink = scores['team'][team]['largest']['link'];
|
||||||
|
if(largestLink === undefined || largestLink.distance < linkLength) {
|
||||||
|
largestLink = {};
|
||||||
|
largestLink.distance = linkLength;
|
||||||
|
largestLink.player = player;
|
||||||
|
}
|
||||||
|
scores['team'][team]['largest']['link'] = largestLink;
|
||||||
|
|
||||||
|
//var largestLink = scores['player'][player]['largest']['link'];
|
||||||
|
//if(largestLink === undefined || largestLink < linkLength) {
|
||||||
|
// largestLink = linkLength;
|
||||||
|
//}
|
||||||
|
//scores['player'][player]['largest']['link'] = largestLink;
|
||||||
|
|
||||||
});
|
});
|
||||||
$.each(window.portals, function(qk, portal) {
|
$.each(window.portals, function(qk, portal) {
|
||||||
somethingInView = true;
|
somethingInView = true;
|
||||||
|
|
||||||
var team = getTeam(portal.options.details);
|
var team = getTeam(portal.options.details);
|
||||||
if(team !== TEAM_NONE) {
|
if(team !== TEAM_NONE) {
|
||||||
var player = portal.options.details.captured.capturingPlayerId;
|
var player = portal.options.details.captured.capturingPlayerId;
|
||||||
@ -145,11 +181,11 @@ window.plugin.scoreboard.teamTableRow = function(field,title) {
|
|||||||
var retVal = '<tr><td>'
|
var retVal = '<tr><td>'
|
||||||
+ title
|
+ title
|
||||||
+ '</td><td class="number">'
|
+ '</td><td class="number">'
|
||||||
+ window.digits(scores[TEAM_RES][field])
|
+ window.digits(Math.round(scores[TEAM_RES][field]))
|
||||||
+ '</td><td class="number">'
|
+ '</td><td class="number">'
|
||||||
+ window.digits(scores[TEAM_ENL][field])
|
+ window.digits(Math.round(scores[TEAM_ENL][field]))
|
||||||
+ '</td><td class="number">'
|
+ '</td><td class="number">'
|
||||||
+ window.digits(scores[TEAM_RES][field] + scores[TEAM_ENL][field])
|
+ window.digits(Math.round(scores[TEAM_RES][field] + scores[TEAM_ENL][field]))
|
||||||
+ '</td></tr>';
|
+ '</td></tr>';
|
||||||
return retVal;
|
return retVal;
|
||||||
};
|
};
|
||||||
@ -165,7 +201,27 @@ window.plugin.scoreboard.fieldInfo = function(field) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
retVal = '<div title="' + title + '">'
|
retVal = '<div title="' + title + '">'
|
||||||
+ field.options.data.entityScore.entityScore
|
+ window.digits(field.options.data.entityScore.entityScore)
|
||||||
|
+ ' - ' + window.getPlayerName(field.options.data.creator.creatorGuid)
|
||||||
|
+ '</div>';
|
||||||
|
} else {
|
||||||
|
retVal = 'N/A';
|
||||||
|
}
|
||||||
|
return retVal;
|
||||||
|
};
|
||||||
|
|
||||||
|
window.plugin.scoreboard.fieldInfoArea = function(field) {
|
||||||
|
var title = '';
|
||||||
|
var retVal = '';
|
||||||
|
|
||||||
|
if(field !== undefined) {
|
||||||
|
var portal = window.portals[field.options.vertices.vertexA.guid];
|
||||||
|
if(portal !== undefined) {
|
||||||
|
title = ' @' + portal.options.details.portalV2.descriptiveText.TITLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
retVal = '<div title="' + title + '">'
|
||||||
|
+ window.digits(Math.round(field.options.data.fieldArea))
|
||||||
+ ' - ' + window.getPlayerName(field.options.data.creator.creatorGuid)
|
+ ' - ' + window.getPlayerName(field.options.data.creator.creatorGuid)
|
||||||
+ '</div>';
|
+ '</div>';
|
||||||
} else {
|
} else {
|
||||||
@ -182,9 +238,9 @@ window.plugin.scoreboard.playerTableRow = function(playerGuid) {
|
|||||||
+ window.getPlayerName(playerGuid);
|
+ window.getPlayerName(playerGuid);
|
||||||
+ '</td>';
|
+ '</td>';
|
||||||
|
|
||||||
$.each(['mu','count_fields','count_links','count_portals','count_resonators'], function(i, field) {
|
$.each(['mu','count_fields','field_area','count_links','link_length','count_portals','count_resonators'], function(i, field) {
|
||||||
retVal += '<td class="number">'
|
retVal += '<td class="number">'
|
||||||
+ window.digits(scores[playerGuid][field])
|
+ window.digits(Math.round(scores[playerGuid][field]))
|
||||||
+ '</td>';
|
+ '</td>';
|
||||||
});
|
});
|
||||||
retVal += '</tr>';
|
retVal += '</tr>';
|
||||||
@ -210,8 +266,10 @@ window.plugin.scoreboard.playerTable = function(sortBy) {
|
|||||||
var scoreHtml = '<table>'
|
var scoreHtml = '<table>'
|
||||||
+ '<tr><th ' + sort('names', sortBy) + '>Player</th>'
|
+ '<tr><th ' + sort('names', sortBy) + '>Player</th>'
|
||||||
+ '<th ' + sort('mu', sortBy) + '>Mu</th>'
|
+ '<th ' + sort('mu', sortBy) + '>Mu</th>'
|
||||||
+ '<th ' + sort('count_fields', sortBy) + '>Fields</th>'
|
+ '<th ' + sort('count_fields', sortBy) + '>Field #</th>'
|
||||||
+ '<th ' + sort('count_links', sortBy) + '>Links</th>'
|
+ '<th ' + sort('field_area', sortBy) + '>Field (km²)</th>'
|
||||||
|
+ '<th ' + sort('count_links', sortBy) + '>Link #</th>'
|
||||||
|
+ '<th ' + sort('link_length', sortBy) + '>Link (m)</th>'
|
||||||
+ '<th ' + sort('count_portals', sortBy) + '>Portals</th>'
|
+ '<th ' + sort('count_portals', sortBy) + '>Portals</th>'
|
||||||
+ '<th ' + sort('count_resonators', sortBy) + '>Resonators</th></tr>';
|
+ '<th ' + sort('count_resonators', sortBy) + '>Resonators</th></tr>';
|
||||||
$.each(window.plugin.scoreboard.playerGuids, function(index, guid) {
|
$.each(window.plugin.scoreboard.playerGuids, function(index, guid) {
|
||||||
@ -252,22 +310,48 @@ window.plugin.scoreboard.display = function() {
|
|||||||
scoreHtml += '<table>'
|
scoreHtml += '<table>'
|
||||||
+ '<tr><th></th><th class="number">Resistance</th><th class="number">Enlightened</th><th class="number">Total</th></tr>'
|
+ '<tr><th></th><th class="number">Resistance</th><th class="number">Enlightened</th><th class="number">Total</th></tr>'
|
||||||
+ window.plugin.scoreboard.teamTableRow('mu','Mu')
|
+ window.plugin.scoreboard.teamTableRow('mu','Mu')
|
||||||
+ window.plugin.scoreboard.teamTableRow('count_fields','Fields')
|
+ window.plugin.scoreboard.teamTableRow('count_fields','Field #')
|
||||||
+ window.plugin.scoreboard.teamTableRow('count_links','Links')
|
+ window.plugin.scoreboard.teamTableRow('field_area','Field (km²)')
|
||||||
|
+ window.plugin.scoreboard.teamTableRow('count_links','Link #')
|
||||||
|
+ window.plugin.scoreboard.teamTableRow('link_length','Link (m)')
|
||||||
+ window.plugin.scoreboard.teamTableRow('count_portals','Portals')
|
+ window.plugin.scoreboard.teamTableRow('count_portals','Portals')
|
||||||
+ window.plugin.scoreboard.teamTableRow('count_resonators','Resonators')
|
+ window.plugin.scoreboard.teamTableRow('count_resonators','Resonators')
|
||||||
+ '</table>';
|
+ '</table>';
|
||||||
|
|
||||||
scoreHtml += '<table>'
|
scoreHtml += '<table>'
|
||||||
+ '<tr><th></th><th>Resistance</th><th>Enlightened</th></tr>'
|
+ '<tr><th></th><th>Resistance</th><th>Enlightened</th></tr>'
|
||||||
+ '<tr><td>Largest Field</td><td>'
|
+ '<tr><td>Largest Field (Mu)</td><td>'
|
||||||
+ window.plugin.scoreboard.fieldInfo(scores['team'][TEAM_RES]['largest']['mu'])
|
+ window.plugin.scoreboard.fieldInfo(scores['team'][TEAM_RES]['largest']['mu'])
|
||||||
+ '</td><td>'
|
+ '</td><td>'
|
||||||
+ window.plugin.scoreboard.fieldInfo(scores['team'][TEAM_ENL]['largest']['mu'])
|
+ window.plugin.scoreboard.fieldInfo(scores['team'][TEAM_ENL]['largest']['mu'])
|
||||||
+ '</td></tr>'
|
+ '</td></tr>'
|
||||||
+ '</table>';
|
+ '<tr><td>Largest Field (km²)</td><td>'
|
||||||
|
+ window.plugin.scoreboard.fieldInfoArea(scores['team'][TEAM_RES]['largest']['field_area'])
|
||||||
|
+ '</td><td>'
|
||||||
|
+ window.plugin.scoreboard.fieldInfoArea(scores['team'][TEAM_ENL]['largest']['field_area'])
|
||||||
|
+ '</td></tr>'
|
||||||
|
+ '<tr><td>Longest Link (m)</td><td>';
|
||||||
|
if(scores['team'][TEAM_RES]['largest']['link'] === undefined) {
|
||||||
|
scoreHtml += 'N/A';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
scoreHtml += window.digits(Math.round(scores['team'][TEAM_RES]['largest']['link']['distance']))
|
||||||
|
+ ' - '
|
||||||
|
+ window.getPlayerName(scores['team'][TEAM_RES]['largest']['link']['player']);
|
||||||
|
}
|
||||||
|
scoreHtml += '</td><td>';
|
||||||
|
|
||||||
scoreHtml += '<div id="players">'
|
if(scores['team'][TEAM_ENL]['largest']['link'] === undefined) {
|
||||||
|
scoreHtml += 'N/A';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
scoreHtml += window.digits(Math.round(scores['team'][TEAM_ENL]['largest']['link']['distance']))
|
||||||
|
+ ' - '
|
||||||
|
+ window.getPlayerName(scores['team'][TEAM_ENL]['largest']['link']['player']);
|
||||||
|
}
|
||||||
|
scoreHtml += '</td></tr>'
|
||||||
|
+ '</table>'
|
||||||
|
+ '<div id="players">'
|
||||||
+ window.plugin.scoreboard.playerTable('mu')
|
+ window.plugin.scoreboard.playerTable('mu')
|
||||||
+ '</div>';
|
+ '</div>';
|
||||||
|
|
||||||
@ -287,11 +371,28 @@ window.plugin.scoreboard.display = function() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window.plugin.scoreboard.portalDistance = function(portalAE6Location, portalBE6Location) {
|
||||||
|
portalA = new L.LatLng(portalAE6Location.latE6 / 1E6, portalAE6Location.lngE6 / 1E6);
|
||||||
|
portalB = new L.LatLng(portalBE6Location.latE6 / 1E6, portalBE6Location.lngE6 / 1E6);
|
||||||
|
return (portalA.distanceTo(portalB));
|
||||||
|
}
|
||||||
|
|
||||||
|
window.plugin.scoreboard.fieldArea = function(field) {
|
||||||
|
var verts = field.options.vertices;
|
||||||
|
var sideA = window.plugin.scoreboard.portalDistance(verts.vertexA.location,verts.vertexB.location) / 1000;
|
||||||
|
var sideB = window.plugin.scoreboard.portalDistance(verts.vertexB.location,verts.vertexC.location) / 1000;
|
||||||
|
var sideC = window.plugin.scoreboard.portalDistance(verts.vertexC.location,verts.vertexA.location) / 1000;
|
||||||
|
// Heron's Formula;
|
||||||
|
var perimeter = sideA + sideB + sideC;
|
||||||
|
var s = perimeter/2;
|
||||||
|
return Math.sqrt(s*(s-sideA)*(s-sideB)*(s-sideC));
|
||||||
|
}
|
||||||
|
|
||||||
var setup = function() {
|
var setup = function() {
|
||||||
$('body').append('<div id="scoreboard" style="display:none;"></div>');
|
$('body').append('<div id="scoreboard" style="display:none;"></div>');
|
||||||
$('#toolbox').append('<a onclick="window.plugin.scoreboard.display()">scoreboard</a>');
|
$('#toolbox').append('<a onclick="window.plugin.scoreboard.display()">scoreboard</a>');
|
||||||
$('head').append('<style>' +
|
$('head').append('<style>' +
|
||||||
'.ui-dialog-scoreboard {max-width:500px !important; width:500px !important;}' +
|
'.ui-dialog-scoreboard {max-width:600px !important; width:600px !important;}' +
|
||||||
'#scoreboard table {margin-top:10px; border-collapse: collapse; empty-cells: show; width:100%; clear: both;}' +
|
'#scoreboard table {margin-top:10px; border-collapse: collapse; empty-cells: show; width:100%; clear: both;}' +
|
||||||
'#scoreboard table td, #scoreboard table th {border-bottom: 1px solid #0b314e; padding:3px; color:white; background-color:#1b415e}' +
|
'#scoreboard table td, #scoreboard table th {border-bottom: 1px solid #0b314e; padding:3px; color:white; background-color:#1b415e}' +
|
||||||
'#scoreboard table tr.res td { background-color: #005684; }' +
|
'#scoreboard table tr.res td { background-color: #005684; }' +
|
||||||
|
Loading…
x
Reference in New Issue
Block a user