ingress-intel-total-conversion/plugins/show-portal-weakness.user.js
Jon Atkins 1452a1c534 fix missing resonators highlight opacity - was backwards
portal weakness highlighter - combination of missing resonators and needs recharge. the best that can be done with available data
2013-12-01 19:35:39 +00:00

57 lines
2.0 KiB
JavaScript

// ==UserScript==
// @id iitc-plugin-show-portal-weakness@vita10gy
// @name IITC plugin: show portal weakness
// @category Highlighter
// @version 0.7.2.@@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 denote if the portal is weak (Needs recharging, missing a resonator, needs mods) Red, needs energy and mods. Orange, only needs energy (either recharge or resonators). Yellow, only needs mods.
// @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.portalWeakness = function() {};
window.plugin.portalWeakness.highlightWeakness = function(data) {
if(data.portal.options.team != TEAM_NONE) {
var res_count = data.portal.options.data.resCount;
var portal_health = data.portal.options.data.health/100;
var weakness = (res_count/8) * (portal_health/100);
if(weakness < 1) {
var fill_opacity = weakness*.85 + .15;
var color = 'red';
fill_opacity = Math.round(fill_opacity*100)/100;
var params = {fillColor: color, fillOpacity: fill_opacity};
// Hole per missing resonator
if (res_count < 8) {
var dash = new Array((8 - res_count) + 1).join("1,4,") + "100,0"
params.dashArray = dash;
}
data.portal.setStyle(params);
}
}
}
var setup = function() {
window.addPortalHighlighter('Portal Weakness', window.plugin.portalWeakness.highlightWeakness);
}
// PLUGIN END //////////////////////////////////////////////////////////
@@PLUGINEND@@