Show link range details for partially deployed portals.

Calculates the link range for portals with <8 resonators as well, but uses a dashed circle and a striked-through range value for those.

The tooltip over the range value in the details pane shows base range, link amp boost and total range.

The range for portals with missing resonators can be important because links with shorter lengths might originate here. Those will collapse when the total link range drops below their length, but not as soon as a resonator is destroyed.
This commit is contained in:
fkloft 2013-10-16 19:03:39 +02:00
parent 767275fdf5
commit a33bdcbf38
3 changed files with 28 additions and 12 deletions

View File

@ -145,8 +145,13 @@ window.setPortalIndicators = function(d) {
var range = getPortalRange(d);
var coord = [d.locationE6.latE6/1E6, d.locationE6.lngE6/1E6];
portalRangeIndicator = (range > 0
? L.geodesicCircle(coord, range, { fill: false, color: RANGE_INDICATOR_COLOR, weight: 3, clickable: false })
portalRangeIndicator = (range.range > 0
? L.geodesicCircle(coord, range.range, {
fill: false,
color: RANGE_INDICATOR_COLOR,
weight: 3,
dashArray: range.isLinkable ? undefined : "10,10",
clickable: false })
: L.circle(coord, range, { fill: false, stroke: false, clickable: false })
).addTo(map);

View File

@ -5,11 +5,20 @@
// returns displayable text+link about portal range
window.getRangeText = function(d) {
var range = getPortalRange(d);
var title = 'Base range:\t' + digits(Math.floor(range.base))+'m'
+ '\nLink amp boost:\t×'+range.boost
+ '\nRange:\t'+digits(Math.floor(range.range))+'m';
if(!range.isLinkable) title += '\nPortal is missing resonators,\nno new links can be made';
return ['range',
'<a onclick="window.rangeLinkClick()">'
+ (range > 1000
? Math.floor(range/1000) + ' km'
: Math.floor(range) + ' m')
'<a onclick="window.rangeLinkClick()"'
+ (range.isLinkable ? '' : ' style="text-decoration:line-through;"')
+ ' title="'+title+'">'
+ (range.range > 1000
? Math.floor(range.range/1000) + ' km'
: Math.floor(range.range) + ' m')
+ '</a>'];
}

View File

@ -47,18 +47,20 @@ window.getPortalRange = function(d) {
$.each(d.resonatorArray.resonators, function(ind, reso) {
if(!reso) {
resoMissing = true;
return false;
return;
}
lvl += parseInt(reso.level);
});
if(resoMissing) return 0;
var range = 160*Math.pow(getPortalLevel(d), 4);
var range = {
base: 160*Math.pow(getPortalLevel(d), 4),
boost: getLinkAmpRangeBoost(d)
};
var boost = getLinkAmpRangeBoost(d);
return range*boost;
range.range = range.boost * range.base;
range.isLinkable = !resoMissing;
return range;
}
window.getLinkAmpRangeBoost = function(d) {