Merge pull request #6 from Hollow011/gh-pages
Removed duplicate code based on recent rebase, fixed nits
This commit is contained in:
commit
cefb1c5025
@ -34,7 +34,7 @@ window.renderPortalDetails = function(guid) {
|
||||
// collect and html-ify random data
|
||||
var randDetails = [
|
||||
playerText, sinceText, getRangeText(d), getEnergyText(d),
|
||||
linksText, getAvgResoDistText(d), linkedFields, getDestroyAP(d)
|
||||
linksText, getAvgResoDistText(d), linkedFields, getAttackApGainText(d)
|
||||
];
|
||||
randDetails = '<table id="randdetails">' + genFourColumnTable(randDetails) + '</table>';
|
||||
|
||||
|
@ -135,35 +135,21 @@ window.renderResonatorDetails = function(slot, level, nrg, dist, nick) {
|
||||
return [meter, nick || ''];
|
||||
}
|
||||
|
||||
// calculate AP gain from destroying portal
|
||||
// so far it counts only resonators + links
|
||||
window.getDestroyAP = function(d) {
|
||||
var resoCount = 0;
|
||||
|
||||
$.each(d.resonatorArray.resonators, function(ind, reso) {
|
||||
if(!reso) return true;
|
||||
resoCount += 1;
|
||||
});
|
||||
|
||||
var linkCount = d.portalV2.linkedEdges ? d.portalV2.linkedEdges.length : 0;
|
||||
var fieldCount = d.portalV2.linkedFields ? d.portalV2.linkedFields.length : 0;
|
||||
|
||||
var resoAp = resoCount * DESTROY_RESONATOR;
|
||||
var linkAp = linkCount * DESTROY_LINK;
|
||||
var fieldAp = fieldCount * DESTROY_FIELD;
|
||||
var sum = resoAp + linkAp + fieldAp + CAPTURE_PORTAL + 8*DEPLOY_RESONATOR + COMPLETION_BONUS;
|
||||
// calculate AP gain from destroying portal and then capturing it by deploying resonators
|
||||
window.getAttackApGainText = function(d) {
|
||||
var breakdown = getAttackApGain(d);
|
||||
|
||||
function tt(text) {
|
||||
var t = 'Destroy & Capture:\n';
|
||||
t += resoCount + '×\tResonators\t= ' + digits(resoAp) + '\n';
|
||||
t += linkCount + '×\tLinks\t= ' + digits(linkAp) + '\n';
|
||||
t += fieldCount + '×\tFields\t= ' + digits(fieldAp) + '\n';
|
||||
t += breakdown.resoCount + '×\tResonators\t= ' + digits(breakdown.resoAp) + '\n';
|
||||
t += breakdown.linkCount + '×\tLinks\t= ' + digits(breakdown.linkAp) + '\n';
|
||||
t += breakdown.fieldCount + '×\tFields\t= ' + digits(breakdown.fieldAp) + '\n';
|
||||
t += '1×\tCapture\t= ' + CAPTURE_PORTAL + '\n';
|
||||
t += '8×\tDeploy\t= ' + (8 * DEPLOY_RESONATOR) + '\n';
|
||||
t += '1×\tBonus\t= ' + COMPLETION_BONUS + '\n';
|
||||
t += 'Sum: ' + digits(sum) + ' AP';
|
||||
t += 'Sum: ' + digits(breakdown.totalAp) + ' AP';
|
||||
return '<tt title="' + t + '">' + digits(text) + '</tt>';
|
||||
}
|
||||
|
||||
return [tt('AP Gain'), tt(sum)];
|
||||
return [tt('AP Gain'), tt(breakdown.totalAp)];
|
||||
}
|
||||
|
@ -66,3 +66,35 @@ window.getAvgResoDist = function(d) {
|
||||
});
|
||||
return sum/resos;
|
||||
}
|
||||
|
||||
window.getAttackApGain = function(d) {
|
||||
var resoCount = 0;
|
||||
|
||||
$.each(d.resonatorArray.resonators, function(ind, reso) {
|
||||
if (!reso)
|
||||
return true;
|
||||
resoCount += 1;
|
||||
});
|
||||
|
||||
var linkCount = d.portalV2.linkedEdges ? d.portalV2.linkedEdges.length : 0;
|
||||
var fieldCount = d.portalV2.linkedFields ? d.portalV2.linkedFields.length : 0;
|
||||
|
||||
var resoAp = resoCount * DESTROY_RESONATOR;
|
||||
var linkAp = linkCount * DESTROY_LINK;
|
||||
var fieldAp = fieldCount * DESTROY_FIELD;
|
||||
var destroyAp = resoAp + linkAp + fieldAp;
|
||||
var captureAp = CAPTURE_PORTAL + 8 * DEPLOY_RESONATOR + COMPLETION_BONUS;
|
||||
var totalAp = destroyAp + captureAp;
|
||||
|
||||
return {
|
||||
totalAp: totalAp,
|
||||
destroyAp: destroyAp,
|
||||
captureAp: captureAp,
|
||||
resoCount: resoCount,
|
||||
resoAp: resoAp,
|
||||
linkCount: linkCount,
|
||||
linkAp: linkAp,
|
||||
fieldCount: fieldCount,
|
||||
fieldAp: fieldAp
|
||||
};
|
||||
}
|
||||
|
2
main.js
2
main.js
@ -100,7 +100,7 @@ document.getElementsByTagName('body')[0].innerHTML = ''
|
||||
+ ' <div id="gamestat"> loading global control stats</div>'
|
||||
+ ' <input id="geosearch" placeholder="Search location…" type="text"/>'
|
||||
+ ' <div id="portaldetails"></div>'
|
||||
+ ' <input id="redeem" placeholder="Redeem code…" type="text"/>'
|
||||
+ ' <input id="redeem" placeholder="Redeem code… (currently down from web)" type="text"/>'
|
||||
+ ' <div id="toolbox">'
|
||||
+ ' <a onmouseover="setPermaLink(this)">permalink</a>'
|
||||
+ ' <a href="https://github.com/breunigs/ingress-intel-total-conversion#readme" title="IITC = Ingress Intel Total Conversion.\n\nOn the script’s homepage you can:\n– find updates\n– get plugins\n– report bugs\n– and contribute." style="cursor: help">IITC’s page</a></div>'
|
||||
|
@ -3,8 +3,8 @@
|
||||
// @name iitc: Compute AP statistics
|
||||
// @version 0.1
|
||||
// @namespace https://github.com/breunigs/ingress-intel-total-conversion
|
||||
// @updateURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/compute-AP-stats.user.js
|
||||
// @downloadURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/compute-AP-stats.user.js
|
||||
// @updateURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/compute-ap-stats.user.js
|
||||
// @downloadURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/compute-ap-stats.user.js
|
||||
// @description Tries to determine overal AP stats for the current zoom
|
||||
// @include http://www.ingress.com/intel*
|
||||
// @match http://www.ingress.com/intel*
|
||||
@ -35,20 +35,12 @@ window.plugin.compAPStats.compAPStats = function() {
|
||||
var allEnlFields = [];
|
||||
|
||||
|
||||
// Grab every portal in the viewable area and compute individual AP stats (ignoring links and fields for now)
|
||||
// Grab every portal in the viewable area and compute individual AP stats
|
||||
$.each(window.portals, function(ind, portal) {
|
||||
var d = portal.options.details;
|
||||
var resoCount = 0;
|
||||
|
||||
// see how many resonators the portal has
|
||||
$.each(d.resonatorArray.resonators, function(ind, reso) {
|
||||
if(!reso) return true;
|
||||
resoCount += 1;
|
||||
});
|
||||
|
||||
// sum up the AP for the resonators, and any bonus
|
||||
var resoAp = resoCount * DESTROY_RESONATOR;
|
||||
var portalSum = resoAp + CAPTURE_PORTAL + 8*DEPLOY_RESONATOR + COMPLETION_BONUS;
|
||||
var portalStats = getAttackApGain(d);
|
||||
var portalSum = portalStats.resoAp + portalStats.captureAp;
|
||||
|
||||
if (getTeam(d) === TEAM_ENL) {
|
||||
totalAP_RES += portalSum;
|
||||
@ -83,15 +75,15 @@ window.plugin.compAPStats.compAPStats = function() {
|
||||
});
|
||||
|
||||
// Compute team field AP
|
||||
allResFields = $.unique(allResFields);
|
||||
allResFields = uniqueArray(allResFields);
|
||||
totalAP_ENL += (allResFields.length * DESTROY_FIELD);
|
||||
allEnlFields = $.unique(allEnlFields);
|
||||
allEnlFields = uniqueArray(allEnlFields);
|
||||
totalAP_RES += (allEnlFields.length * DESTROY_FIELD);
|
||||
|
||||
// Compute team Link AP
|
||||
allResEdges = $.unique(allResEdges);
|
||||
allResEdges = uniqueArray(allResEdges);
|
||||
totalAP_ENL += (allResEdges.length * DESTROY_LINK);
|
||||
allEnlEdges = $.unique(allEnlEdges);
|
||||
allEnlEdges = uniqueArray(allEnlEdges);
|
||||
totalAP_RES += (allEnlEdges.length * DESTROY_LINK);
|
||||
|
||||
return [totalAP_RES, totalAP_ENL];
|
||||
|
@ -1,7 +1,7 @@
|
||||
// ==UserScript==
|
||||
// @id iitc-plugin-player-tracker@breunigs
|
||||
// @name iitc: player tracker
|
||||
// @version 0.2
|
||||
// @version 0.3
|
||||
// @namespace https://github.com/breunigs/ingress-intel-total-conversion
|
||||
// @updateURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/player-tracker.user.js
|
||||
// @downloadURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/player-tracker.user.js
|
||||
@ -79,7 +79,7 @@ window.plugin.playerTracker.processNewData = function(data) {
|
||||
// Destroy link messages depend on how the link was originally
|
||||
// created. Therefore it’s not clear which portal the player is
|
||||
// at, so ignore it.
|
||||
if(markup[1].plain.indexOf('destroyed') !== -1) {
|
||||
if(markup[1].plain.indexOf('destroyed the Link') !== -1) {
|
||||
skipThisMessage = true;
|
||||
return false;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user