fix several issues
- resonator energy - portal owner & capture date - mod type filtering code
This commit is contained in:
parent
b595af30ad
commit
3ee03778ef
@ -169,15 +169,15 @@ window.getPortalMiscDetails = function(guid,d) {
|
||||
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')];
|
||||
|
||||
var player = d.captured && d.captured.capturingPlayerId
|
||||
? '<span class="nickname">' + d.captured.capturingPlayerId + '</span>'
|
||||
var player = d.owner
|
||||
? '<span class="nickname">' + d.owner + '</span>'
|
||||
: null;
|
||||
var playerText = player ? ['owner', player] : null;
|
||||
|
||||
var time = d.captured
|
||||
? '<span title="' + unixTimeToDateTimeString(d.captured.capturedTime, false) + '\n'
|
||||
+ formatInterval(Math.floor((Date.now()-d.captured.capturedTime)/1000), 2) + ' ago">'
|
||||
+ unixTimeToString(d.captured.capturedTime) + '</span>'
|
||||
var time = d.capturedTime
|
||||
? '<span title="' + unixTimeToDateTimeString(d.capturedTime, false) + '\n'
|
||||
+ formatInterval(Math.floor((Date.now()-d.capturedTime)/1000), 2) + ' ago">'
|
||||
+ unixTimeToString(d.capturedTime) + '</span>'
|
||||
: null;
|
||||
var sinceText = time ? ['since', time] : null;
|
||||
|
||||
|
@ -110,11 +110,11 @@ window.getModDetails = function(d) {
|
||||
// if (key === 'REMOVAL_STICKINESS' && val == 0) continue; // stat on all mods recently - unknown meaning, not displayed in stock client
|
||||
|
||||
// special formatting for known mod stats, where the display of the raw value is less useful
|
||||
if (mod.type === 'HEATSINK' && key === 'HACK_SPEED') val = (val/10000)+'%'; // 500000 = 50%
|
||||
else if (mod.type === 'FORCE_AMP' && key === 'FORCE_AMPLIFIER') val = (val/1000)+'x'; // 2000 = 2x
|
||||
else if (mod.type === 'LINK_AMPLIFIER' && key === 'LINK_RANGE_MULTIPLIER') val = (val/1000)+'x' // 2000 = 2x
|
||||
else if (mod.type === 'TURRET' && key === 'HIT_BONUS') val = (val/10000)+'%'; // 2000 = 0.2% (although this seems pretty small to be useful?)
|
||||
else if (mod.type === 'TURRET' && key === 'ATTACK_FREQUENCY') val = (val/1000)+'x' // 2000 = 2x
|
||||
if (key === 'HACK_SPEED') val = (val/10000)+'%'; // 500000 = 50%
|
||||
else if (key === 'FORCE_AMPLIFIER') val = (val/1000)+'x'; // 2000 = 2x
|
||||
else if (key === 'LINK_RANGE_MULTIPLIER') val = (val/1000)+'x' // 2000 = 2x
|
||||
else if (key === 'HIT_BONUS') val = (val/10000)+'%'; // 2000 = 0.2% (although this seems pretty small to be useful?)
|
||||
else if (key === 'ATTACK_FREQUENCY') val = (val/1000)+'x' // 2000 = 2x
|
||||
// else display unmodified. correct for shield mitigation and multihack - unknown for future/other mods
|
||||
|
||||
modTooltip += '\n+' + val + ' ' + key.capitalize().replace(/_/g,' ');
|
||||
@ -169,7 +169,7 @@ window.getResonatorDetails = function(d) {
|
||||
}
|
||||
|
||||
var l = parseInt(reso.level);
|
||||
var v = parseInt(reso.energyTotal);
|
||||
var v = parseInt(reso.energy);
|
||||
var nick = reso.owner;
|
||||
// if array order and slot order drift apart, at least the octant
|
||||
// naming will still be correct.
|
||||
@ -218,8 +218,8 @@ window.renderResonatorDetails = function(slot, level, nrg, dist, nick) {
|
||||
}
|
||||
|
||||
// calculate AP gain from destroying portal and then capturing it by deploying resonators
|
||||
window.getAttackApGainText = function(d,fieldCount) {
|
||||
var breakdown = getAttackApGain(d,fieldCount);
|
||||
window.getAttackApGainText = function(d,fieldCount,linkCount) {
|
||||
var breakdown = getAttackApGain(d,fieldCount,linkCount);
|
||||
var totalGain = breakdown.enemyAp;
|
||||
|
||||
function tt(text) {
|
||||
|
@ -33,7 +33,7 @@ window.getCurrentPortalEnergy = function(d) {
|
||||
var nrg = 0;
|
||||
$.each(d.resonators, function(ind, reso) {
|
||||
if(!reso) return true;
|
||||
nrg += parseInt(reso.energyTotal);
|
||||
nrg += parseInt(reso.energy);
|
||||
});
|
||||
return nrg;
|
||||
}
|
||||
@ -201,11 +201,7 @@ window.fixPortalImageUrl = function(url) {
|
||||
window.getPortalModsByType = function(d, type) {
|
||||
var mods = [];
|
||||
|
||||
$.each(d.mods || [], function(i,mod) {
|
||||
if (mod && mod.type == type) mods.push(mod);
|
||||
});
|
||||
|
||||
var sortKey = {
|
||||
var typeToStat = {
|
||||
RES_SHIELD: 'MITIGATION',
|
||||
FORCE_AMP: 'FORCE_AMPLIFIER',
|
||||
TURRET: 'HIT_BONUS', // and/or ATTACK_FREQUENCY??
|
||||
@ -214,23 +210,17 @@ window.getPortalModsByType = function(d, type) {
|
||||
LINK_AMPLIFIER: 'LINK_RANGE_MULTIPLIER'
|
||||
};
|
||||
|
||||
// prefer to sort mods by stat - so if stats change (as they have for shields and turrets) we still put the highest first
|
||||
if (sortKey[type]) {
|
||||
// we have a stat type to sort by
|
||||
var key = sortKey[type];
|
||||
var stat = typeToStat[type];
|
||||
|
||||
mods.sort (function(a,b) {
|
||||
return b.stats[key] - a.stats[key];
|
||||
$.each(d.mods || [], function(i,mod) {
|
||||
if (mod && mod.stats.hasOwnProperty(stat)) mods.push(mod);
|
||||
});
|
||||
} else {
|
||||
// no known stat type - sort by rarity
|
||||
|
||||
|
||||
// sorting mods by the stat keeps code simpler, when calculating combined mod effects
|
||||
mods.sort (function(a,b) {
|
||||
// rarity values are COMMON, RARE and VERY_RARE. handy, as that's alphabetical order!
|
||||
if (a.rarity < b.rarity) return -1;
|
||||
if (a.rarity > b.rarity) return 1;
|
||||
return 0;
|
||||
return b.stats[stat] - a.stats[stat];
|
||||
});
|
||||
}
|
||||
|
||||
return mods;
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ window.smartphoneInfo = function(data) {
|
||||
var reso = details.resonators[i];
|
||||
if(reso) {
|
||||
l = parseInt(reso.level);
|
||||
v = parseInt(reso.energyTotal);
|
||||
v = parseInt(reso.energy);
|
||||
max = RESO_NRG[l];
|
||||
perc = v/max*100;
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ window.plugin.guessPlayerLevels.extractPortalData = function(data) {
|
||||
Hint: This can only happen to the owner of the portal, so resonators by other players can be used to determine
|
||||
their minimal level */
|
||||
|
||||
var owner = data.details.captured && data.details.captured.capturingPlayerId || "";
|
||||
var owner = data.details.owner && data.details.owner || "";
|
||||
var ownerModCount = 0;
|
||||
data.details.mods.forEach(function(mod) {
|
||||
if(mod && mod.installingUser == owner)
|
||||
@ -435,7 +435,7 @@ window.plugin.guessPlayerLevels.guess = function() {
|
||||
});
|
||||
|
||||
if(details.captured) {
|
||||
var nick = details.captured.capturingPlayerId
|
||||
var nick = details.owner;
|
||||
if(isSystemPlayer(nick)) return true;
|
||||
var lvl = window.plugin.guessPlayerLevels.fetchLevelDetailsByPlayer(nick).min;
|
||||
if(!lvl) return true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user