From ba0ff06771d5102e01ceb04761bfc5c30ad55102 Mon Sep 17 00:00:00 2001 From: Shawn Clark Date: Tue, 19 Feb 2013 20:41:04 -0800 Subject: [PATCH 1/7] Refactored getDestroyAP - Split the calculations into getAttackApGain. Allows for other functions to get the AP data. - Renamed to getAttackApGainText as it isn't just destroying it is also capturing. Originally the method only calculated the destroy values. --- code/portal_detail_display.js | 2 +- code/portal_detail_display_tools.js | 36 +++++++++-------------------- code/portal_info.js | 32 +++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 26 deletions(-) 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..8c03a604 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..f3af6dad 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 + }; +}; From f2bdcb9fc9fbc756c528f359d21cb8231e7548cb Mon Sep 17 00:00:00 2001 From: Shawn Clark Date: Tue, 19 Feb 2013 23:15:46 -0800 Subject: [PATCH 2/7] Fixing nits --- code/portal_detail_display_tools.js | 4 ++-- code/portal_info.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/code/portal_detail_display_tools.js b/code/portal_detail_display_tools.js index 8c03a604..2861edf7 100644 --- a/code/portal_detail_display_tools.js +++ b/code/portal_detail_display_tools.js @@ -151,5 +151,5 @@ window.getAttackApGainText = function(d) { return '' + digits(text) + ''; } - return [ tt('AP Gain'), tt(breakdown.totalAp) ]; -}; + return [tt('AP Gain'), tt(breakdown.totalAp)]; +} diff --git a/code/portal_info.js b/code/portal_info.js index f3af6dad..82f75011 100644 --- a/code/portal_info.js +++ b/code/portal_info.js @@ -97,4 +97,4 @@ window.getAttackApGain = function(d) { fieldCount : fieldCount, fieldAp : fieldAp }; -}; +} From 51a4dabfc9243da75c20157482a63b1d9fd325e5 Mon Sep 17 00:00:00 2001 From: Shawn Clark Date: Tue, 19 Feb 2013 23:17:19 -0800 Subject: [PATCH 3/7] nits - object field whitespace --- code/portal_info.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/code/portal_info.js b/code/portal_info.js index 82f75011..2e2e2127 100644 --- a/code/portal_info.js +++ b/code/portal_info.js @@ -87,14 +87,14 @@ window.getAttackApGain = function(d) { var totalAp = destroyAp + captureAp; return { - totalAp : totalAp, - destroyAp : destroyAp, - captureAp : captureAp, - resoCount : resoCount, - resoAp : resoAp, - linkCount : linkCount, - linkAp : linkAp, - fieldCount : fieldCount, - fieldAp : fieldAp + totalAp: totalAp, + destroyAp: destroyAp, + captureAp: captureAp, + resoCount: resoCount, + resoAp: resoAp, + linkCount: linkCount, + linkAp: linkAp, + fieldCount: fieldCount, + fieldAp: fieldAp }; } From 785be63d330919a8cc9443879eddeb31ebf6ab18 Mon Sep 17 00:00:00 2001 From: Stefan Breunig Date: Wed, 20 Feb 2013 17:16:48 +0100 Subject: [PATCH 4/7] fix #216 --- main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.js b/main.js index f3939458..aa779f24 100644 --- a/main.js +++ b/main.js @@ -100,7 +100,7 @@ document.getElementsByTagName('body')[0].innerHTML = '' + '
 loading global control stats
' + ' ' + '
' - + ' ' + + ' ' + ' ' From c80d650bba0efba0b1d51df7289686ce8fb77511 Mon Sep 17 00:00:00 2001 From: Stefan Breunig Date: Thu, 21 Feb 2013 00:27:12 +0100 Subject: [PATCH 5/7] player tracker ignored destroy resonators, even though it should only ignore destroyed links. Fixes #238 --- plugins/player-tracker.user.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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; } From 100e3868f211d75683e50d4e0409fa91534dbf97 Mon Sep 17 00:00:00 2001 From: Hollow011 Date: Wed, 20 Feb 2013 23:16:46 -0700 Subject: [PATCH 6/7] Update plugins/compute-ap-stats.user.js --- plugins/compute-ap-stats.user.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/compute-ap-stats.user.js b/plugins/compute-ap-stats.user.js index e10ca23c..5d186b16 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,7 +35,7 @@ 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; @@ -103,8 +103,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); } From d9604db15519ea94507a45285dfa63b7142698df Mon Sep 17 00:00:00 2001 From: Hollow011 Date: Wed, 20 Feb 2013 23:56:50 -0700 Subject: [PATCH 7/7] Update plugins/compute-ap-stats.user.js --- plugins/compute-ap-stats.user.js | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/plugins/compute-ap-stats.user.js b/plugins/compute-ap-stats.user.js index 5d186b16..3c0e8bd7 100644 --- a/plugins/compute-ap-stats.user.js +++ b/plugins/compute-ap-stats.user.js @@ -38,17 +38,9 @@ window.plugin.compAPStats.compAPStats = function() { // 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];