From 0bdaa2f5c3babf6df25250b4ce8dfc375399cb70 Mon Sep 17 00:00:00 2001 From: fkloft Date: Mon, 19 Jan 2015 21:13:57 +0100 Subject: [PATCH] include force amplifier, attack frequency and hit bonus in portal details --- code/portal_detail_display.js | 36 +++++++++++++-------- code/portal_detail_display_tools.js | 12 +++---- code/portal_info.js | 49 ++++++++++++++++++++++++----- style.css | 10 ++++++ 4 files changed, 81 insertions(+), 26 deletions(-) diff --git a/code/portal_detail_display.js b/code/portal_detail_display.js index 159028e5..3c51cb80 100644 --- a/code/portal_detail_display.js +++ b/code/portal_detail_display.js @@ -187,22 +187,32 @@ window.getPortalMiscDetails = function(guid,d) { var apGainText = getAttackApGainText(d,fieldCount,linkCount); + var attackValues = getPortalAttackValues(d); + // collect and html-ify random data - var randDetailsData = []; - if (true) { // or "if (d.owner) {" ...? but this makes the info panel look rather empty for unclaimed portals - // these pieces of data are only relevant when the portal is captured - randDetailsData.push ( - playerText, getRangeText(d), - linksText, fieldsText, - getMitigationText(d,linkCount), getEnergyText(d) - ); - } - // and these have some use, even for uncaptured portals - randDetailsData.push ( - apGainText, getHackDetailsText(d) - ); + var randDetailsData = [ + // these pieces of data are only relevant when the portal is captured + // maybe check if portal is captured and remove? + // But this makes the info panel look rather empty for unclaimed portals + playerText, getRangeText(d), + linksText, fieldsText, + getMitigationText(d,linkCount), getEnergyText(d), + // and these have some use, even for uncaptured portals + apGainText, getHackDetailsText(d), + ]; + + if(attackValues.attack_frequency != 0) + randDetailsData.push([ + 'attack frequency', + '×'+attackValues.attack_frequency]); + if(attackValues.hit_bonus != 0) + randDetailsData.push(['hit bonus', attackValues.hit_bonus+'%']); + if(attackValues.force_amplifier != 0) + randDetailsData.push([ + 'force amplifier', + '×'+attackValues.force_amplifier]); // artifact details diff --git a/code/portal_detail_display_tools.js b/code/portal_detail_display_tools.js index 4cf34448..a3b54050 100644 --- a/code/portal_detail_display_tools.js +++ b/code/portal_detail_display_tools.js @@ -107,14 +107,14 @@ window.getModDetails = function(d) { if (!mod.stats.hasOwnProperty(key)) continue; var val = mod.stats[key]; -// if (key === 'REMOVAL_STICKINESS' && val == 0) continue; // stat on all mods recently - unknown meaning, not displayed in stock client + // 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 (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 + if (key === 'HACK_SPEED') val = (val/10000)+'%'; // 500000 = 50% + else if (key === 'HIT_BONUS') val = (val/10000)+'%'; // 300000 = 30% + else if (key === 'ATTACK_FREQUENCY') val = (val/1000) +'x'; // 2000 = 2x + else if (key === 'FORCE_AMPLIFIER') val = (val/1000) +'x'; // 2000 = 2x + else if (key === 'LINK_RANGE_MULTIPLIER') 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,' '); diff --git a/code/portal_info.js b/code/portal_info.js index ad87794b..663dab51 100644 --- a/code/portal_info.js +++ b/code/portal_info.js @@ -69,26 +69,22 @@ window.getPortalRange = function(d) { window.getLinkAmpRangeBoost = function(d) { // additional range boost calculation - // (at the time of writing, only rare link amps have been seen in the wild, so there's a little guesswork at how - // the stats work and combine - jon 2013-06-26) // link amps scale: first is full, second a quarter, the last two an eighth var scale = [1.0, 0.25, 0.125, 0.125]; var boost = 0.0; // initial boost is 0.0 (i.e. no boost over standard range) - var count = 0; var linkAmps = getPortalModsByType(d, 'LINK_AMPLIFIER'); - $.each(linkAmps, function(ind, mod) { + linkAmps.forEach(function(mod, i) { // link amp stat LINK_RANGE_MULTIPLIER is 2000 for rare, and gives 2x boost to the range // and very-rare is 7000 and gives 7x the range var baseMultiplier = mod.stats.LINK_RANGE_MULTIPLIER/1000; - boost += baseMultiplier*scale[count]; - count++; + boost += baseMultiplier*scale[i]; }); - return (count > 0) ? boost : 1.0; + return (linkAmps.length > 0) ? boost : 1.0; } @@ -316,3 +312,42 @@ window.getPortalSummaryData = function(d) { type: 'portal' }; } + +window.getPortalAttackValues = function(d) { + var forceamps = getPortalModsByType(d, 'FORCE_AMP'); + var turrets = getPortalModsByType(d, 'TURRET'); + + // at the time of writing, only rare force amps and turrets have been seen in the wild, so there's a little guesswork + // at how the stats work and combine + // algorithm has been compied from getLinkAmpRangeBoost + // FIXME: only extract stats and put the calculation in a method to be used for link range, force amplifier and attack + // frequency + // note: scanner shows rounded values (adding a second FA shows: 2.5x+0.2x=2.8x, which should be 2.5x+0.25x=2.75x) + + // amplifier scale: first is full, second a quarter, the last two an eighth + var scale = [1.0, 0.25, 0.125, 0.125]; + + var attackValues = { + hit_bonus: 0, + force_amplifier: 0, + attack_frequency: 0, + }; + + forceamps.forEach(function(mod, i) { + // force amp stat FORCE_AMPLIFIER is 2000 for rare, and gives 2x boost to the range + var baseMultiplier = mod.stats.FORCE_AMPLIFIER / 1000; + attackValues.force_amplifier += baseMultiplier * scale[i]; + }); + + turrets.forEach(function(mod, i) { + // turret stat ATTACK_FREQUENCY is 2000 for rare, and gives 2x boost to the range + var baseMultiplier = mod.stats.ATTACK_FREQUENCY / 1000; + attackValues.attack_frequency += baseMultiplier * scale[i]; + + attackValues.hit_bonus += mod.stats.HIT_BONUS / 10000; + }); + + return attackValues; +} + + diff --git a/style.css b/style.css index 5f8ee4cd..a07e005a 100644 --- a/style.css +++ b/style.css @@ -1128,3 +1128,13 @@ g.checkpoint:hover circle { padding-left: 10px; } +.text-overflow-ellipsis { + display: inline-block; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; + vertical-align: top; + width: 100%; + line-height: 1em; +} +