From 76d283870a7d00d6d44c2619a9a43bc6f43332b3 Mon Sep 17 00:00:00 2001 From: Catherine Taylor Date: Wed, 14 Aug 2013 12:07:39 +0100 Subject: [PATCH 1/2] Create highlighter Imminent Decay --- .../portal-highlighter-imminent-decay.user.js | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 plugins/portal-highlighter-imminent-decay.user.js diff --git a/plugins/portal-highlighter-imminent-decay.user.js b/plugins/portal-highlighter-imminent-decay.user.js new file mode 100644 index 00000000..3dffe31c --- /dev/null +++ b/plugins/portal-highlighter-imminent-decay.user.js @@ -0,0 +1,47 @@ +// ==UserScript== +// @id iitc-plugin-highlight-imminent-decay@cathesaurus +// @name IITC plugin: highlight portals with resonators about to decay +// @category Highlighter +// @version 0.1.0.@@DATETIMEVERSION@@ +// @namespace https://github.com/jonatkins/ingress-intel-total-conversion +// @updateURL @@UPDATEURL@@ +// @downloadURL @@DOWNLOADURL@@ +// @description [@@BUILDNAME@@-@@BUILDDATE@@] Uses the fill color of the portals to show those with one (or more) resonators due to decay within the next day. +// @include https://www.ingress.com/intel* +// @include http://www.ingress.com/intel* +// @match https://www.ingress.com/intel* +// @match http://www.ingress.com/intel* +// @grant none +// ==/UserScript== + +@@PLUGINSTART@@ + +// PLUGIN START //////////////////////////////////////////////////////// + +// use own namespace for plugin +window.plugin.portalHighlighterImminentDecay = function() {}; + +window.plugin.portalHighlighterImminentDecay.highlight = function(data) { + var d = data.portal.options.details; + var portal_deployment = 0; + if(getTeam(d) !== 0) { + if(window.getAvgResoDist(d) > 0 && window.getAvgResoDist(d) < window.HACK_RANGE*0.9) { + portal_deployment = (window.HACK_RANGE - window.getAvgResoDist(d))/window.HACK_RANGE; + } + if(portal_deployment > 0) { + var fill_opacity = portal_deployment*.85 + .15; + color = 'red'; + var params = {fillColor: color, fillOpacity: fill_opacity}; + data.portal.setStyle(params); + } + } + window.COLOR_SELECTED_PORTAL = '#f0f'; +} + +var setup = function() { + window.addPortalHighlighter('ImminentDecay', window.plugin.portalHighlighterImminentDecay.highlight); +} + +// PLUGIN END ////////////////////////////////////////////////////////// + +@@PLUGINEND@@ From d704e8d87218f26f8a3525ee76ba20a782b33012 Mon Sep 17 00:00:00 2001 From: Catherine Taylor Date: Wed, 14 Aug 2013 14:26:26 +0100 Subject: [PATCH 2/2] Adds highlighter logic, and myself to the roll call of contributors. --- CONTRIBS.md | 3 +- .../portal-highlighter-imminent-decay.user.js | 39 +++++++++++++------ 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/CONTRIBS.md b/CONTRIBS.md index 5e0e2a68..0cfccf65 100644 --- a/CONTRIBS.md +++ b/CONTRIBS.md @@ -4,6 +4,7 @@ So far, these people have contributed: [blakjakau](https://github.com/blakjakau), [boombuler](https://github.com/boombuler), [breunigs](https://github.com/breunigs), +[cathesaurus](https://github.com/cathesaurus), [ccjon](https://github.com/ccjon), [cmrn](https://github.com/cmrn), [epf](https://github.com/epf), @@ -25,4 +26,4 @@ So far, these people have contributed: [vita10gy](https://github.com/vita10gy), [Xelio](https://github.com/Xelio), [ZauberNerd](https://github.com/ZauberNerd), -[waynn](https://github.com/waynn) \ No newline at end of file +[waynn](https://github.com/waynn) diff --git a/plugins/portal-highlighter-imminent-decay.user.js b/plugins/portal-highlighter-imminent-decay.user.js index 3dffe31c..7e7b55f2 100644 --- a/plugins/portal-highlighter-imminent-decay.user.js +++ b/plugins/portal-highlighter-imminent-decay.user.js @@ -6,7 +6,7 @@ // @namespace https://github.com/jonatkins/ingress-intel-total-conversion // @updateURL @@UPDATEURL@@ // @downloadURL @@DOWNLOADURL@@ -// @description [@@BUILDNAME@@-@@BUILDDATE@@] Uses the fill color of the portals to show those with one (or more) resonators due to decay within the next day. +// @description [@@BUILDNAME@@-@@BUILDDATE@@] Uses the fill color of the portals to show resonators due to decay within the next day. Red = portal will decay completely, orange = portal will drop all links, yellow = one or more resonators will decay completely. // @include https://www.ingress.com/intel* // @include http://www.ingress.com/intel* // @match https://www.ingress.com/intel* @@ -23,23 +23,40 @@ window.plugin.portalHighlighterImminentDecay = function() {}; window.plugin.portalHighlighterImminentDecay.highlight = function(data) { var d = data.portal.options.details; - var portal_deployment = 0; if(getTeam(d) !== 0) { - if(window.getAvgResoDist(d) > 0 && window.getAvgResoDist(d) < window.HACK_RANGE*0.9) { - portal_deployment = (window.HACK_RANGE - window.getAvgResoDist(d))/window.HACK_RANGE; - } - if(portal_deployment > 0) { - var fill_opacity = portal_deployment*.85 + .15; - color = 'red'; - var params = {fillColor: color, fillOpacity: fill_opacity}; + //Check the energy of every resonator. + var resImminentDecayCount = 0; + var resCount = 0; + $.each(d.resonatorArray.resonators, function(ind, reso) { + if(reso !== null) { + var level = parseInt(reso.level); + var maxResonatorEnergy = window.RESO_NRG[level]; + var currentResonatorEnergy = parseInt(reso.energyTotal); + if((currentResonatorEnergy / maxResonatorEnergy) < 0.15) { + resImminentDecayCount++; + } + resCount++; + } + }); + + if(resImminentDecayCount > 0) { + if(resImminentDecayCount === resCount) { + var color = 'red'; + } else if((resCount - resImminentDecayCount) < 3) { + color = 'orange'; + } else { + color = 'yellow'; + } + // Apply colour to portal. + var params = {fillColor: color, fillOpacity: 1}; data.portal.setStyle(params); - } + } } window.COLOR_SELECTED_PORTAL = '#f0f'; } var setup = function() { - window.addPortalHighlighter('ImminentDecay', window.plugin.portalHighlighterImminentDecay.highlight); + window.addPortalHighlighter('Imminent Decay', window.plugin.portalHighlighterImminentDecay.highlight); } // PLUGIN END //////////////////////////////////////////////////////////