update plugins to use new IITC core mitigation calculations
This commit is contained in:
parent
0fb6650ad0
commit
148d1d10b6
@ -2,7 +2,7 @@
|
||||
// @id iitc-plugin-defense@gluckies
|
||||
// @name IITC plugin: portal defense
|
||||
// @category Layer
|
||||
// @version 0.2.0.@@DATETIMEVERSION@@
|
||||
// @version 0.2.1.@@DATETIMEVERSION@@
|
||||
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
|
||||
// @updateURL @@UPDATEURL@@
|
||||
// @downloadURL @@DOWNLOADURL@@
|
||||
@ -50,41 +50,17 @@ window.plugin.portalDefense.getDisplay = function() {
|
||||
return window.plugin.portalDefense.DisplayEnum.OFF;
|
||||
}
|
||||
|
||||
window.plugin.portalDefense.computeDef = function(portal) {
|
||||
var m = portal.options.details.portalV2.linkedModArray;
|
||||
var ret = {};
|
||||
ret.mod = 0;
|
||||
ret.links = 0;
|
||||
var display = "";
|
||||
$.each(m, function(ind, mod) {
|
||||
if (!mod) return true;
|
||||
if(!mod.stats.MITIGATION)
|
||||
return true;
|
||||
ret.mod += parseInt(mod.stats.MITIGATION);
|
||||
});
|
||||
var link = 0;
|
||||
$(portal.options.details.portalV2.linkedEdges).each(function () {
|
||||
link++;
|
||||
});
|
||||
if (link > 0) {
|
||||
ret.links = Math.round(400/9*Math.atan(link/Math.E));
|
||||
}
|
||||
ret.total = Math.min(95, ret.mod + ret.links);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
window.plugin.portalDefense.renderAttackRegion = function(portal) {
|
||||
plugin.portalDefense.removeAttackRegion(portal);
|
||||
if (window.plugin.portalDefense.currentDisplay == window.plugin.portalDefense.DisplayEnum.OFF) return;
|
||||
|
||||
plugin.portalDefense.regionLayers[portal.options.guid] = [];
|
||||
var defense = window.plugin.portalDefense.computeDef(portal);
|
||||
var defense = window.getPortalMitigationDetails(portal.options.details);
|
||||
if (defense.total) {
|
||||
var display = defense.total;
|
||||
if (window.plugin.portalDefense.currentDisplay == window.plugin.portalDefense.DisplayEnum.DETAIL) {
|
||||
if (defense.mod) {
|
||||
display += "<br>"+"\u2297"+defense.mod;
|
||||
if (defense.shields) {
|
||||
display += "<br>"+"\u2297"+defense.shields;
|
||||
}
|
||||
if(defense.links) {
|
||||
display += "<br>"+"\u21b1"+defense.links;
|
||||
|
@ -2,7 +2,7 @@
|
||||
// @id iitc-plugin-highlight-mitigation@jonatkins
|
||||
// @name IITC plugin: hightlight portals total mitigation
|
||||
// @category Highlighter
|
||||
// @version 0.1.0.@@DATETIMEVERSION@@
|
||||
// @version 0.1.1.@@DATETIMEVERSION@@
|
||||
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
|
||||
// @updateURL @@UPDATEURL@@
|
||||
// @downloadURL @@DOWNLOADURL@@
|
||||
@ -21,42 +21,14 @@
|
||||
// use own namespace for plugin
|
||||
window.plugin.portalHighligherMitigation = function() {};
|
||||
|
||||
// taken from portalDefense plugin. needs to be moved into IITC core
|
||||
window.plugin.portalHighligherMitigation.computeDef = function(portal) {
|
||||
var m = portal.options.details.portalV2.linkedModArray;
|
||||
var ret = {};
|
||||
ret.mod = 0;
|
||||
ret.links = 0;
|
||||
$.each(m, function(ind, mod) {
|
||||
if (!mod) return true;
|
||||
if(!mod.stats.MITIGATION)
|
||||
return true;
|
||||
ret.mod += parseInt(mod.stats.MITIGATION);
|
||||
});
|
||||
var link = 0;
|
||||
$(portal.options.details.portalV2.linkedEdges).each(function () {
|
||||
link++;
|
||||
});
|
||||
if (link > 0) {
|
||||
ret.links = Math.round(400/9*Math.atan(link/Math.E));
|
||||
}
|
||||
ret.total = Math.min(95, ret.mod + ret.links);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
window.plugin.portalHighligherMitigation.highlight = function(data) {
|
||||
|
||||
var defense = window.plugin.portalHighligherMitigation.computeDef (data.portal);
|
||||
var defense = window.getPortalMitigationDetails(data.portal.options.details);
|
||||
|
||||
if (defense.total > 0) {
|
||||
var fill_opacity = (defense.total/95)*.85 + .15;
|
||||
|
||||
// maximum mitigation from links is approx 69, and from shields is 120, giving max of ~189
|
||||
// therefore maximum over mitigation is ~94. let's treat 80 as our max amount and scale that to the blue channel for colour tint
|
||||
var over_mitigation = Math.max(0, defense.mod+defense.links-defense.total);
|
||||
|
||||
var blue = Math.max(0,Math.min(255,Math.round(over_mitigation/80*255)));
|
||||
var blue = Math.max(0,Math.min(255,Math.round(defense.excess/80*255)));
|
||||
|
||||
var colour = 'rgb(255,0,'+blue+')';
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user