more work on fixing things for the 2014-05-23 changes
it's a big job - much is still broken
This commit is contained in:
@ -8,7 +8,7 @@
|
||||
// given the entity detail data, returns the team the entity belongs
|
||||
// to. Uses TEAM_* enum values.
|
||||
window.getTeam = function(details) {
|
||||
return teamStringToId(details.controllingTeam && details.controllingTeam.team);
|
||||
return teamStringToId(details.team);
|
||||
}
|
||||
|
||||
window.teamStringToId = function(teamStr) {
|
||||
|
@ -61,7 +61,7 @@ window.findPortalLatLng = function(guid) {
|
||||
// not found in portals - try the cached (and possibly stale) details - good enough for location
|
||||
var details = portalDetail.get(guid);
|
||||
if (details) {
|
||||
return L.latLng (details.locationE6.latE6/1E6, details.locationE6.lngE6/1E6);
|
||||
return L.latLng (details.latE6/1E6, details.lngE6/1E6);
|
||||
}
|
||||
|
||||
// now try searching through fields
|
||||
|
@ -28,9 +28,7 @@ window.renderPortalDetails = function(guid) {
|
||||
|
||||
// details and data can get out of sync. if we have details, construct a matching 'data'
|
||||
if (details) {
|
||||
// the details had the team removed(!) - so we have to use the team in the summary data
|
||||
// however - this can easily be out of date in areas of heavy activity - so could be just plain wrong!
|
||||
data = getPortalSummaryData(details, data && data.team);
|
||||
data = getPortalSummaryData(details);
|
||||
}
|
||||
|
||||
|
||||
@ -42,7 +40,7 @@ window.renderPortalDetails = function(guid) {
|
||||
var statusDetails = details ? '' : '<div id="portalStatus">Loading details...</div>';
|
||||
|
||||
|
||||
var img = fixPortalImageUrl(details ? details.imageByUrl && details.imageByUrl.imageUrl : data.image);
|
||||
var img = fixPortalImageUrl(details ? details.image : data.image);
|
||||
var title = data.title;
|
||||
|
||||
var lat = data.latE6/1E6;
|
||||
@ -165,10 +163,8 @@ window.getPortalMiscDetails = function(guid,d) {
|
||||
if (d) {
|
||||
|
||||
// collect some random data that’s not worth to put in an own method
|
||||
var links = {incoming: 0, outgoing: 0};
|
||||
$.each(d.portalV2.linkedEdges||[], function(ind, link) {
|
||||
links[link.isOrigin ? 'outgoing' : 'incoming']++;
|
||||
});
|
||||
var linkInfo = getPortalLinks(guid);
|
||||
var links = {incoming: linkInfo.in.length, outgoing: linkInfo.out.length};
|
||||
|
||||
function linkExpl(t) { return '<tt title="'+links.outgoing+' links out (8 max)\n'+links.incoming+' links in\n('+(links.outgoing+links.incoming)+' total)">'+t+'</tt>'; }
|
||||
var linksText = [linkExpl('links'), linkExpl(links.outgoing+' out / '+links.incoming+' in')];
|
||||
@ -189,6 +185,8 @@ window.getPortalMiscDetails = function(guid,d) {
|
||||
|
||||
var linkedFields = ['fields', fieldCount];
|
||||
|
||||
var linkCount = getPortalLinksCount(guid);
|
||||
|
||||
// collect and html-ify random data
|
||||
var randDetailsData = [];
|
||||
if (playerText && sinceText) {
|
||||
@ -197,9 +195,9 @@ window.getPortalMiscDetails = function(guid,d) {
|
||||
|
||||
randDetailsData.push (
|
||||
getRangeText(d), getEnergyText(d),
|
||||
linksText, getAvgResoDistText(d),
|
||||
linkedFields, getAttackApGainText(d,fieldCount),
|
||||
getHackDetailsText(d), getMitigationText(d)
|
||||
linksText, ['-','-'],
|
||||
linkedFields, getAttackApGainText(d,fieldCount,linkCount),
|
||||
getHackDetailsText(d), getMitigationText(d,linkCount)
|
||||
);
|
||||
|
||||
// artifact details
|
||||
|
@ -24,20 +24,22 @@ window.getRangeText = function(d) {
|
||||
|
||||
// generates description text from details for portal
|
||||
window.getPortalDescriptionFromDetails = function(details) {
|
||||
var descObj = details.descriptiveText.map;
|
||||
// FIXME: also get real description?
|
||||
var desc = descObj.TITLE;
|
||||
if(descObj.ADDRESS)
|
||||
desc += '\n' + descObj.ADDRESS;
|
||||
// if(descObj.ATTRIBUTION)
|
||||
// desc += '\nby '+descObj.ATTRIBUTION+' ('+descObj.ATTRIBUTION_LINK+')';
|
||||
return desc;
|
||||
return details.title || '(untitled)';
|
||||
|
||||
// var descObj = details.descriptiveText.map;
|
||||
// // FIXME: also get real description?
|
||||
// var desc = descObj.TITLE;
|
||||
// if(descObj.ADDRESS)
|
||||
// desc += '\n' + descObj.ADDRESS;
|
||||
//// if(descObj.ATTRIBUTION)
|
||||
//// desc += '\nby '+descObj.ATTRIBUTION+' ('+descObj.ATTRIBUTION_LINK+')';
|
||||
// return desc;
|
||||
}
|
||||
|
||||
// Grabs more info, including the submitter name for the current main
|
||||
// portal image
|
||||
window.getPortalDescriptionFromDetailsExtended = function(details) {
|
||||
var descObj = details.descriptiveText.map;
|
||||
var descObj = details.title;
|
||||
var photoStreamObj = details.photoStreamInfo;
|
||||
|
||||
var submitterObj = new Object();
|
||||
@ -79,7 +81,7 @@ window.getModDetails = function(d) {
|
||||
var mods = [];
|
||||
var modsTitle = [];
|
||||
var modsColor = [];
|
||||
$.each(d.portalV2.linkedModArray, function(ind, mod) {
|
||||
$.each(d.mods, function(ind, mod) {
|
||||
var modName = '';
|
||||
var modTooltip = '';
|
||||
var modColor = '#000';
|
||||
@ -88,13 +90,7 @@ window.getModDetails = function(d) {
|
||||
// all mods seem to follow the same pattern for the data structure
|
||||
// but let's try and make this robust enough to handle possible future differences
|
||||
|
||||
if (mod.displayName) {
|
||||
modName = mod.displayName;
|
||||
} else if (mod.type) {
|
||||
modName = mod.type;
|
||||
} else {
|
||||
modName = '(unknown mod)';
|
||||
}
|
||||
modName = mod.name || '(unknown mod)';
|
||||
|
||||
if (mod.rarity) {
|
||||
modName = mod.rarity.capitalize().replace(/_/g,' ') + ' ' + modName;
|
||||
@ -137,10 +133,12 @@ window.getModDetails = function(d) {
|
||||
modsColor.push(modColor);
|
||||
});
|
||||
|
||||
var t = '<span'+(modsTitle[0].length ? ' title="'+modsTitle[0]+'"' : '')+' style="color:'+modsColor[0]+'">'+mods[0]+'</span>'
|
||||
+ '<span'+(modsTitle[1].length ? ' title="'+modsTitle[1]+'"' : '')+' style="color:'+modsColor[1]+'">'+mods[1]+'</span>'
|
||||
+ '<span'+(modsTitle[2].length ? ' title="'+modsTitle[2]+'"' : '')+' style="color:'+modsColor[2]+'">'+mods[2]+'</span>'
|
||||
+ '<span'+(modsTitle[3].length ? ' title="'+modsTitle[3]+'"' : '')+' style="color:'+modsColor[3]+'">'+mods[3]+'</span>'
|
||||
|
||||
var t = '';
|
||||
for (var i=0; i<mods.length; i++) {
|
||||
t += '<span'+(modsTitle[i].length ? ' title="'+modsTitle[i]+'"' : '')+' style="color:'+modsColor[i]+'">'+mods[i]+'</span>'
|
||||
}
|
||||
|
||||
|
||||
return t;
|
||||
}
|
||||
@ -153,10 +151,6 @@ window.getEnergyText = function(d) {
|
||||
return ['energy', '<tt title="'+inf+'">' + fill + '</tt>'];
|
||||
}
|
||||
|
||||
window.getAvgResoDistText = function(d) {
|
||||
var avgDist = Math.round(10*getAvgResoDist(d))/10;
|
||||
return ['res dist', avgDist + ' m'];
|
||||
}
|
||||
|
||||
window.getResonatorDetails = function(d) {
|
||||
var resoDetails = [];
|
||||
@ -168,7 +162,7 @@ window.getResonatorDetails = function(d) {
|
||||
// SW S
|
||||
|
||||
$.each([2, 1, 3, 0, 4, 7, 5, 6], function(ind, slot) {
|
||||
var reso = d.resonatorArray.resonators[slot];
|
||||
var reso = d.resonators[slot];
|
||||
if(!reso) {
|
||||
resoDetails.push(renderResonatorDetails(slot, 0, 0, null, null));
|
||||
return true;
|
||||
@ -176,13 +170,12 @@ window.getResonatorDetails = function(d) {
|
||||
|
||||
var l = parseInt(reso.level);
|
||||
var v = parseInt(reso.energyTotal);
|
||||
var nick = reso.ownerGuid;
|
||||
var dist = reso.distanceToPortal;
|
||||
var nick = reso.owner;
|
||||
// if array order and slot order drift apart, at least the octant
|
||||
// naming will still be correct.
|
||||
slot = parseInt(reso.slot);
|
||||
slot = ind;
|
||||
|
||||
resoDetails.push(renderResonatorDetails(slot, l, v, dist, nick));
|
||||
resoDetails.push(renderResonatorDetails(slot, l, v, null, nick));
|
||||
});
|
||||
return '<table id="resodetails">' + genFourColumnTable(resoDetails) + '</table>';
|
||||
|
||||
@ -231,7 +224,7 @@ window.getAttackApGainText = function(d,fieldCount) {
|
||||
|
||||
function tt(text) {
|
||||
var t = '';
|
||||
if (d.controllingTeam && PLAYER.team == d.controllingTeam.team) {
|
||||
if (PLAYER.team == d.team) {
|
||||
totalGain = breakdown.friendlyAp;
|
||||
t += 'Friendly AP:\t' + breakdown.friendlyAp + '\n';
|
||||
t += ' Deploy ' + breakdown.deployCount + ', ';
|
||||
@ -266,8 +259,8 @@ window.getHackDetailsText = function(d) {
|
||||
}
|
||||
|
||||
|
||||
window.getMitigationText = function(d) {
|
||||
var mitigationDetails = getPortalMitigationDetails(d);
|
||||
window.getMitigationText = function(d,linkCount) {
|
||||
var mitigationDetails = getPortalMitigationDetails(d,linkCount);
|
||||
|
||||
var mitigationShort = mitigationDetails.total;
|
||||
if (mitigationDetails.excess) mitigationShort += ' (+'+mitigationDetails.excess+')';
|
||||
|
@ -7,7 +7,7 @@
|
||||
window.getPortalLevel = function(d) {
|
||||
var lvl = 0;
|
||||
var hasReso = false;
|
||||
$.each(d.resonatorArray.resonators, function(ind, reso) {
|
||||
$.each(d.resonators, function(ind, reso) {
|
||||
if(!reso) return true;
|
||||
lvl += parseInt(reso.level);
|
||||
hasReso = true;
|
||||
@ -17,7 +17,7 @@ window.getPortalLevel = function(d) {
|
||||
|
||||
window.getTotalPortalEnergy = function(d) {
|
||||
var nrg = 0;
|
||||
$.each(d.resonatorArray.resonators, function(ind, reso) {
|
||||
$.each(d.resonators, function(ind, reso) {
|
||||
if(!reso) return true;
|
||||
var level = parseInt(reso.level);
|
||||
var max = RESO_NRG[level];
|
||||
@ -31,7 +31,7 @@ window.getPortalEnergy = window.getTotalPortalEnergy;
|
||||
|
||||
window.getCurrentPortalEnergy = function(d) {
|
||||
var nrg = 0;
|
||||
$.each(d.resonatorArray.resonators, function(ind, reso) {
|
||||
$.each(d.resonators, function(ind, reso) {
|
||||
if(!reso) return true;
|
||||
nrg += parseInt(reso.energyTotal);
|
||||
});
|
||||
@ -44,7 +44,7 @@ window.getPortalRange = function(d) {
|
||||
|
||||
var lvl = 0;
|
||||
var resoMissing = false;
|
||||
$.each(d.resonatorArray.resonators, function(ind, reso) {
|
||||
$.each(d.resonators, function(ind, reso) {
|
||||
if(!reso) {
|
||||
resoMissing = true;
|
||||
return;
|
||||
@ -88,19 +88,7 @@ window.getLinkAmpRangeBoost = function(d) {
|
||||
}
|
||||
|
||||
|
||||
window.getAvgResoDist = function(d) {
|
||||
var sum = 0, resos = 0;
|
||||
$.each(d.resonatorArray.resonators, function(ind, reso) {
|
||||
if(!reso) return true;
|
||||
var resDist = parseInt(reso.distanceToPortal);
|
||||
if (resDist == 0) resDist = 0.01; // set a non-zero but very small distance for zero deployment distance. allows the return value to distinguish between zero deployment distance average and zero resonators
|
||||
sum += resDist;
|
||||
resos++;
|
||||
});
|
||||
return resos ? sum/resos : 0;
|
||||
}
|
||||
|
||||
window.getAttackApGain = function(d,fieldCount) {
|
||||
window.getAttackApGain = function(d,fieldCount,linkCount) {
|
||||
if (!fieldCount) fieldCount = 0;
|
||||
|
||||
var resoCount = 0;
|
||||
@ -110,13 +98,12 @@ window.getAttackApGain = function(d,fieldCount) {
|
||||
for(var n = PLAYER.level + 1; n < 9; n++) {
|
||||
maxResonators[n] = 0;
|
||||
}
|
||||
$.each(d.resonatorArray.resonators, function(ind, reso) {
|
||||
$.each(d.resonators, function(ind, reso) {
|
||||
if(!reso)
|
||||
return true;
|
||||
resoCount += 1;
|
||||
var reslevel=parseInt(reso.level);
|
||||
// NOTE: reso.ownerGuid is actually the name - no player GUIDs are visible in the protocol any more
|
||||
if(reso.ownerGuid === PLAYER.nickname) {
|
||||
if(reso.owner === PLAYER.nickname) {
|
||||
if(maxResonators[reslevel] > 0) {
|
||||
maxResonators[reslevel] -= 1;
|
||||
}
|
||||
@ -125,8 +112,6 @@ window.getAttackApGain = function(d,fieldCount) {
|
||||
}
|
||||
});
|
||||
|
||||
var linkCount = d.portalV2.linkedEdges ? d.portalV2.linkedEdges.length : 0;
|
||||
|
||||
|
||||
var resoAp = resoCount * DESTROY_RESONATOR;
|
||||
var linkAp = linkCount * DESTROY_LINK;
|
||||
@ -162,8 +147,8 @@ window.potentialPortalLevel = function(d) {
|
||||
var current_level = getPortalLevel(d);
|
||||
var potential_level = current_level;
|
||||
|
||||
if(d.controllingTeam && PLAYER.team === d.controllingTeam.team) {
|
||||
var resonators_on_portal = d.resonatorArray.resonators;
|
||||
if(PLAYER.team === d.team) {
|
||||
var resonators_on_portal = d.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();
|
||||
@ -171,8 +156,7 @@ window.potentialPortalLevel = function(d) {
|
||||
player_resontators[i] = i > PLAYER.level ? 0 : MAX_RESO_PER_PLAYER[i];
|
||||
}
|
||||
$.each(resonators_on_portal, function(ind, reso) {
|
||||
// NOTE: reso.ownerGuid is actually the player name - GUIDs are not in the protocol any more
|
||||
if(reso !== null && reso.ownerGuid === window.PLAYER.nickname) {
|
||||
if(reso !== null && reso.owner === window.PLAYER.nickname) {
|
||||
player_resontators[reso.level]--;
|
||||
}
|
||||
resonator_levels.push(reso === null ? 0 : reso.level);
|
||||
@ -217,7 +201,7 @@ window.fixPortalImageUrl = function(url) {
|
||||
window.getPortalModsByType = function(d, type) {
|
||||
var mods = [];
|
||||
|
||||
$.each(d.portalV2.linkedModArray || [], function(i,mod) {
|
||||
$.each(d.mods || [], function(i,mod) {
|
||||
if (mod && mod.type == type) mods.push(mod);
|
||||
});
|
||||
|
||||
@ -264,16 +248,15 @@ window.getPortalShieldMitigation = function(d) {
|
||||
return mitigation;
|
||||
}
|
||||
|
||||
window.getPortalLinksMitigation = function(d) {
|
||||
var links = (d.portalV2.linkedEdges||[]).length;
|
||||
var mitigation = Math.round(400/9*Math.atan(links/Math.E));
|
||||
window.getPortalLinksMitigation = function(linkCount) {
|
||||
var mitigation = Math.round(400/9*Math.atan(linkCount/Math.E));
|
||||
return mitigation;
|
||||
}
|
||||
|
||||
window.getPortalMitigationDetails = function(d) {
|
||||
window.getPortalMitigationDetails = function(d,linkCount) {
|
||||
var mitigation = {
|
||||
shields: getPortalShieldMitigation(d),
|
||||
links: getPortalLinksMitigation(d)
|
||||
links: getPortalLinksMitigation(linkCount)
|
||||
};
|
||||
|
||||
// mitigation is limited to 95% (as confirmed by Brandon Badger on G+)
|
||||
@ -311,16 +294,16 @@ window.getPortalHackDetails = function(d) {
|
||||
}
|
||||
|
||||
// given a detailed portal structure, return summary portal data, as seen in the map tile data
|
||||
window.getPortalSummaryData = function(d,probableTeamStr) {
|
||||
window.getPortalSummaryData = function(d) {
|
||||
|
||||
// NOTE: the summary data reports unclaimed portals as level 1 - not zero as elsewhere in IITC
|
||||
var level = parseInt(getPortalLevel(d));
|
||||
if (level == 0) level = 1; //niantic returns neutral portals as level 1, not 0 as used throughout IITC elsewhere
|
||||
|
||||
var resCount = 0;
|
||||
if (d.resonatorArray && d.resonatorArray.resonators) {
|
||||
for (var x in d.resonatorArray.resonators) {
|
||||
if (d.resonatorArray.resonators[x]) resCount++;
|
||||
if (d.resonators) {
|
||||
for (var x in d.resonators) {
|
||||
if (d.resonators[x]) resCount++;
|
||||
}
|
||||
}
|
||||
var maxEnergy = getTotalPortalEnergy(d);
|
||||
@ -329,13 +312,13 @@ window.getPortalSummaryData = function(d,probableTeamStr) {
|
||||
|
||||
return {
|
||||
level: level,
|
||||
title: d.descriptiveText.map.TITLE,
|
||||
image: d.imageByUrl && d.imageByUrl.imageUrl,
|
||||
title: d.title,
|
||||
image: d.image,
|
||||
resCount: resCount,
|
||||
latE6: d.locationE6.latE6,
|
||||
latE6: d.latE6,
|
||||
health: health,
|
||||
team: d.controllingTeam ? d.controllingTeam.team : probableTeamStr,
|
||||
lngE6: d.locationE6.lngE6,
|
||||
team: d.team,
|
||||
lngE6: d.lngE6,
|
||||
type: 'portal'
|
||||
};
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ window.smartphoneInfo = function(data) {
|
||||
var className = TEAM_TO_CSS[getTeam(details)];
|
||||
if(OCTANTS[i] === 'N')
|
||||
className += ' north'
|
||||
var reso = details.resonatorArray.resonators[i];
|
||||
var reso = details.resonators[i];
|
||||
if(reso) {
|
||||
l = parseInt(reso.level);
|
||||
v = parseInt(reso.energyTotal);
|
||||
|
Reference in New Issue
Block a user