si8debar fixes:
- ensure consistant display based on portal details, by creating portal summary data from details - pass field count into AP calculation, for accurate destroy amounts - use portal.options.level, so unclaimed appear as zero
This commit is contained in:
parent
b1198727b4
commit
ce2ecf90f3
@ -26,6 +26,11 @@ window.renderPortalDetails = function(guid) {
|
|||||||
var data = portal.options.data;
|
var data = portal.options.data;
|
||||||
var details = portalDetail.get(guid);
|
var details = portalDetail.get(guid);
|
||||||
|
|
||||||
|
// details and data can get out of sync. if we have details, construct a matching 'data'
|
||||||
|
if (details) {
|
||||||
|
data = getPortalSummaryData(details);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
var modDetails = details ? '<div class="mods">'+getModDetails(details)+'</div>' : '';
|
var modDetails = details ? '<div class="mods">'+getModDetails(details)+'</div>' : '';
|
||||||
var miscDetails = details ? getPortalMiscDetails(guid,details) : '';
|
var miscDetails = details ? getPortalMiscDetails(guid,details) : '';
|
||||||
@ -78,8 +83,8 @@ window.renderPortalDetails = function(guid) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// portal level. start with basic data - then extend with fractional info in tooltip if available
|
// portal level. start with basic data - then extend with fractional info in tooltip if available
|
||||||
var levelInt = data ? data.level : getPortalLevel(details);
|
var levelInt = portal.options.level;
|
||||||
var levelDetails = data.level;
|
var levelDetails = portal.options.level;
|
||||||
if (details) {
|
if (details) {
|
||||||
levelDetails = getPortalLevel(details);
|
levelDetails = getPortalLevel(details);
|
||||||
if(levelDetails != 8) {
|
if(levelDetails != 8) {
|
||||||
@ -178,7 +183,9 @@ window.getPortalMiscDetails = function(guid,d) {
|
|||||||
: null;
|
: null;
|
||||||
var sinceText = time ? ['since', time] : null;
|
var sinceText = time ? ['since', time] : null;
|
||||||
|
|
||||||
var linkedFields = ['fields', getPortalFields(guid).length];
|
var fieldCount = getPortalFieldsCount(guid);
|
||||||
|
|
||||||
|
var linkedFields = ['fields', fieldCount];
|
||||||
|
|
||||||
// collect and html-ify random data
|
// collect and html-ify random data
|
||||||
var randDetailsData = [];
|
var randDetailsData = [];
|
||||||
@ -189,7 +196,7 @@ window.getPortalMiscDetails = function(guid,d) {
|
|||||||
randDetailsData.push (
|
randDetailsData.push (
|
||||||
getRangeText(d), getEnergyText(d),
|
getRangeText(d), getEnergyText(d),
|
||||||
linksText, getAvgResoDistText(d),
|
linksText, getAvgResoDistText(d),
|
||||||
linkedFields, getAttackApGainText(d),
|
linkedFields, getAttackApGainText(d,fieldCount),
|
||||||
getHackDetailsText(d), getMitigationText(d)
|
getHackDetailsText(d), getMitigationText(d)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -100,7 +100,9 @@ window.getAvgResoDist = function(d) {
|
|||||||
return resos ? sum/resos : 0;
|
return resos ? sum/resos : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
window.getAttackApGain = function(d) {
|
window.getAttackApGain = function(d,fieldCount) {
|
||||||
|
if (!fieldCount) fieldCount = 0;
|
||||||
|
|
||||||
var resoCount = 0;
|
var resoCount = 0;
|
||||||
var maxResonators = MAX_RESO_PER_PLAYER.slice(0);
|
var maxResonators = MAX_RESO_PER_PLAYER.slice(0);
|
||||||
var curResonators = [ 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
var curResonators = [ 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
||||||
@ -125,9 +127,6 @@ window.getAttackApGain = function(d) {
|
|||||||
|
|
||||||
var linkCount = d.portalV2.linkedEdges ? d.portalV2.linkedEdges.length : 0;
|
var linkCount = d.portalV2.linkedEdges ? d.portalV2.linkedEdges.length : 0;
|
||||||
|
|
||||||
//FIXME: portalV2.linkedFields was never a piece of data from the server - it was something faked in IITC
|
|
||||||
//with the portal guid, window.getPortalFields will return the count of linked fields - but no guid passed into here
|
|
||||||
var fieldCount = d.portalV2.linkedFields ? d.portalV2.linkedFields.length : 0;
|
|
||||||
|
|
||||||
var resoAp = resoCount * DESTROY_RESONATOR;
|
var resoAp = resoCount * DESTROY_RESONATOR;
|
||||||
var linkAp = linkCount * DESTROY_LINK;
|
var linkAp = linkCount * DESTROY_LINK;
|
||||||
@ -311,4 +310,30 @@ window.getPortalHackDetails = function(d) {
|
|||||||
return {cooldown: cooldownTime, hacks: numHacks, burnout: cooldownTime*(numHacks-1)};
|
return {cooldown: cooldownTime, hacks: numHacks, burnout: cooldownTime*(numHacks-1)};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// given a detailed portal structure, return summary portal data, as seen in the map tile data
|
||||||
|
window.getPortalSummaryData = function(d) {
|
||||||
|
|
||||||
|
// NOTE: the summary data reports unclaimed portals as level 1 - not zero as elsewhere in IITC
|
||||||
|
var level = d.controllingTeam.team == "NEUTRAL" ? 1 : parseInt(getPortalLevel(d));
|
||||||
|
var resCount = 0;
|
||||||
|
if (d.resonatorArray && d.resonatorArray.resonators) {
|
||||||
|
for (var x in d.resonatorArray.resonators) {
|
||||||
|
if (d.resonatorArray.resonators[x]) resCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var maxEnergy = getTotalPortalEnergy(d);
|
||||||
|
var curEnergy = getCurrentPortalEnergy(d);
|
||||||
|
var health = maxEnergy>0 ? parseInt(curEnergy/maxEnergy*100) : 0;
|
||||||
|
|
||||||
|
return {
|
||||||
|
level: level,
|
||||||
|
title: d.portalV2.descriptiveText.TITLE,
|
||||||
|
image: d.imageByUrl && d.imageByUrl.imageUrl,
|
||||||
|
resCount: resCount,
|
||||||
|
latE6: d.locationE6.latE6,
|
||||||
|
health: health,
|
||||||
|
team: d.controllingTeam.team,
|
||||||
|
lngE6: d.locationE6.lngE6,
|
||||||
|
type: 'portal'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user