diff --git a/code/portal_detail_display.js b/code/portal_detail_display.js
index 88d42d38..6cbe1034 100644
--- a/code/portal_detail_display.js
+++ b/code/portal_detail_display.js
@@ -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 = '
' + genFourColumnTable(randDetails) + '
';
diff --git a/code/portal_detail_display_tools.js b/code/portal_detail_display_tools.js
index e61a056b..2861edf7 100644
--- a/code/portal_detail_display_tools.js
+++ b/code/portal_detail_display_tools.js
@@ -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 += '8×\tDeploy\t= ' + (8 * DEPLOY_RESONATOR) + '\n';
t += '1×\tBonus\t= ' + COMPLETION_BONUS + '\n';
- t += 'Sum: ' + digits(sum) + ' AP';
- return '' + digits(text) + '';
+ t += 'Sum: ' + digits(breakdown.totalAp) + ' AP';
+ return '' + digits(text) + '';
}
- return [tt('AP Gain'), tt(sum)];
+ return [tt('AP Gain'), tt(breakdown.totalAp)];
}
diff --git a/code/portal_info.js b/code/portal_info.js
index edf8298d..2e2e2127 100644
--- a/code/portal_info.js
+++ b/code/portal_info.js
@@ -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
+ };
+}
diff --git a/main.js b/main.js
index 02b12969..8deb5b2f 100644
--- a/main.js
+++ b/main.js
@@ -100,7 +100,7 @@ document.getElementsByTagName('body')[0].innerHTML = ''
+ ' loading global control stats
'
+ ' '
+ ' '
- + ' '
+ + ' '
+ ' '
diff --git a/plugins/compute-ap-stats.user.js b/plugins/compute-ap-stats.user.js
index e10ca23c..3c0e8bd7 100644
--- a/plugins/compute-ap-stats.user.js
+++ b/plugins/compute-ap-stats.user.js
@@ -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];
@@ -103,8 +95,8 @@ window.plugin.compAPStats.guess = function() {
var totalAP_ENL = res[1];
var s = 'Calculated AP gain potential:\n\n';
- s += 'Available Resistance AP: \t' + digits(totalAP_RES) + '\n';
- s += 'Available Enlightened AP: \t' + digits(totalAP_ENL) + '\n';
+ s += 'Available Resistance AP:\t' + digits(totalAP_RES) + '\n';
+ s += 'Available Enlightened AP:\t' + digits(totalAP_ENL) + '\n';
alert(s);
}
diff --git a/plugins/player-tracker.user.js b/plugins/player-tracker.user.js
index 56eba212..aec1abdf 100644
--- a/plugins/player-tracker.user.js
+++ b/plugins/player-tracker.user.js
@@ -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;
}