Merge branch 'highlighter' of https://github.com/vita10gy/ingress-intel-total-conversion into highlighter
This commit is contained in:
@ -5,12 +5,17 @@
|
||||
window._highlighters = null;
|
||||
window._current_highlighter = localStorage.portal_highlighter;
|
||||
window.changing_highlighters = false;
|
||||
window._no_highlighter = 'No Highlights';
|
||||
|
||||
window.addPortalHighlighter = function(name, callback) {
|
||||
if(_highlighters === null) {
|
||||
_highlighters = {};
|
||||
}
|
||||
_highlighters[name] = callback;
|
||||
if(localStorage.portal_highlighter === undefined) {
|
||||
_current_highlighter = name;
|
||||
localStorage.portal_highlighter = name;
|
||||
}
|
||||
portalHighlighterControl();
|
||||
}
|
||||
|
||||
@ -20,12 +25,16 @@ window.portalHighlighterControl = function() {
|
||||
$("body").append("<select id='portal_highlight_select'></select>");
|
||||
}
|
||||
$("#portal_highlight_select").html('');
|
||||
$("#portal_highlight_select").append($("<option>").attr('value','No Highlights').text('No Highlights'));
|
||||
$.each(_highlighters, function(name, callback) {
|
||||
$("#portal_highlight_select").append($("<option>").attr('value',_no_highlighter).text(_no_highlighter));
|
||||
var h_names = Object.keys(_highlighters).sort();
|
||||
|
||||
$.each(h_names, function(i, name) {
|
||||
$("#portal_highlight_select").append($("<option>").attr('value',name).text(name));
|
||||
});
|
||||
$("#portal_highlight_select").val(localStorage.portal_highlighter);
|
||||
$("#portal_highlight_select").val(_current_highlighter);
|
||||
$("#portal_highlight_select").change(function(){ changePortalHighlights($(this).val());});
|
||||
$(".leaflet-top.leaflet-left").css('padding-top','25px');
|
||||
$(".leaflet-control-scale-line").css('margin-top','25px');
|
||||
}
|
||||
}
|
||||
|
||||
@ -38,6 +47,7 @@ window.changePortalHighlights = function(name) {
|
||||
}
|
||||
|
||||
window.highlightPortal = function(p) {
|
||||
|
||||
if(_highlighters !== null && _highlighters[_current_highlighter] !== undefined) {
|
||||
p.options.highligher = _current_highlighter;
|
||||
_highlighters[_current_highlighter]({portal: p});
|
||||
|
@ -117,3 +117,43 @@ window.getAttackApGain = function(d) {
|
||||
captureAp: captureAp
|
||||
};
|
||||
}
|
||||
|
||||
//This function will return the potential level a player can upgrade it to
|
||||
window.potentialPortalLevel = function(d) {
|
||||
var current_level = getPortalLevel(d);
|
||||
var potential_level = current_level;
|
||||
|
||||
if(PLAYER.team === d.controllingTeam.team) {
|
||||
var resonators_on_portal = d.resonatorArray.resonators;
|
||||
var resonator_levels = new Array();
|
||||
// figure out how many of each of these resonators can be placed by the player
|
||||
var player_resontators = new Array();
|
||||
for(var i=1;i<=MAX_PORTAL_LEVEL; i++) {
|
||||
player_resontators[i] = i > PLAYER.level ? 0 : MAX_RESO_PER_PLAYER[i];
|
||||
}
|
||||
$.each(resonators_on_portal, function(ind, reso) {
|
||||
if(reso !== null && reso.ownerGuid === window.PLAYER.guid) {
|
||||
player_resontators[reso.level]--;
|
||||
}
|
||||
resonator_levels.push(reso === null ? 0 : reso.level);
|
||||
});
|
||||
|
||||
resonator_levels.sort(function(a, b) {
|
||||
return(a - b);
|
||||
});
|
||||
|
||||
// Max out portal
|
||||
var install_index = 0;
|
||||
for(var i=MAX_PORTAL_LEVEL;i>=1; i--) {
|
||||
for(var install = player_resontators[i]; install>0; install--) {
|
||||
if(resonator_levels[install_index] < i) {
|
||||
resonator_levels[install_index] = i;
|
||||
install_index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
//console.log(resonator_levels);
|
||||
potential_level = resonator_levels.reduce(function(a, b) {return a + b;}) / 8;
|
||||
}
|
||||
return(potential_level);
|
||||
}
|
||||
|
Reference in New Issue
Block a user