portal_info

This file contains functions that handle the extraction and computation of raw data from portal details for various purposes.

Methods

inner fixPortalImageUrl(url) → {string}

Corrects the portal image URL to match the current protocol (http/https).

Parameters:
Name Type Description
url string

The original image URL.

Returns:
string -

The corrected image URL.

inner getAttackApGain(d, fieldCount, linkCount) → {Object}

Calculates the potential AP gain from attacking a portal.

Parameters:
Name Type Description
d Object

The portal detail object containing resonator and ownership information.

fieldCount number

The number of fields attached to the portal.

linkCount number

The number of links attached to the portal.

Returns:
Object -

An object detailing various components of AP gain, including totals for friendly and enemy factions.

inner getCurrentPortalEnergy(d) → {number}

Calculates the current energy of a portal based on its resonators.

Parameters:
Name Type Description
d Object

The portal detail object containing resonator information.

Returns:
number -

The current energy of the portal.

inner getLinkAmpRangeBoost(d) → {number}

Calculates the boost in link range provided by installed Link Amps.

Parameters:
Name Type Description
d Object

The portal detail object containing mod information.

Returns:
number -

The total boost factor for the link range.

Calculates the maximum number of outgoing links that can be created from a portal.

Parameters:
Name Type Description
d Object

The portal detail object containing mod information.

Returns:
number -

The maximum number of outgoing links.

inner getPortalAttackValues(d) → {Object}

Calculates various attack values of a portal, including hit bonus, force amplifier, and attack frequency.

Parameters:
Name Type Description
d Object

The portal detail object containing mod information.

Returns:
Object -

An object containing attack values such as hit bonus, force amplifier, and attack frequency.

inner getPortalHackDetails(d) → {Object}

Calculates hack-related details of a portal, such as hack cooldown and burnout time.

Parameters:
Name Type Description
d Object

The portal detail object containing mod information.

Returns:
Object -

An object containing hack-related details like cooldown time, hack count, and burnout time.

inner getPortalLevel(d) → {number}

Calculates the displayed level of a portal, which is always rounded down from the actual float value.

Parameters:
Name Type Description
d Object

The portal detail object containing resonator information.

Returns:
number -

The calculated portal level.

inner getPortalLinkDefenseBoost(d) → {number}

Calculates the link defense boost provided by installed Ultra Link Amps.

Parameters:
Name Type Description
d Object

The portal detail object containing mod information.

Returns:
number -

The total link defense boost factor.

inner getPortalLinksMitigation(linkCount) → {number}

Calculates the additional mitigation provided by links attached to a portal.

Parameters:
Name Type Description
linkCount number

The number of links attached to the portal.

Returns:
number -

The additional mitigation value provided by the links.

inner getPortalMitigationDetails(d, linkCount) → {Object}

Calculates detailed mitigation information for a portal, including contributions from shields and links.

Parameters:
Name Type Description
d Object

The portal detail object containing mod and resonator information.

linkCount number

The number of links attached to the portal.

Returns:
Object -

An object detailing various components of mitigation.

inner getPortalModsByType(d, type) → {Array}

Returns a list of portal mods filtered by a specific type.

Parameters:
Name Type Description
d Object

The portal detail object containing mod information.

type string

The type of mods to filter (e.g., 'RES_SHIELD', 'LINK_AMPLIFIER').

Returns:
Array -

An array of mods matching the specified type.

inner getPortalRange(d) → {Object}

Calculates the range of a portal for creating links. The range depends on portal level and any installed Link Amps.

Parameters:
Name Type Description
d Object

The portal detail object containing details about the team and resonators.

Returns:
Object -

An object containing the base range (base), boost multiplier (boost), total range after applying the boost (range), and a boolean indicating if the portal is linkable (isLinkable).

inner getPortalShieldMitigation(d) → {number}

Calculates the total mitigation provided by shields installed on a portal.

Parameters:
Name Type Description
d Object

The portal detail object containing mod information.

Returns:
number -

The total mitigation value from all shields installed on the portal.

inner getPortalSummaryData(d) → {Object}

Converts detailed portal information into a summary format similar to that seen in the map tile data.

Parameters:
Name Type Description
d Object

The detailed portal data.

Returns:
Object -

A summary of the portal data, including level, title, image, resonator count, health, and team.

inner getTotalPortalEnergy(d) → {number}

Calculates the total energy capacity of a portal based on its resonators.

Parameters:
Name Type Description
d Object

The portal detail object containing resonator information.

Returns:
number -

The total energy capacity of the portal.