IITC.portal

Namespace for working with portal data: link/field lookups, detail computations and selection helpers.

Namespaces

details

display

highlighter

marker

Methods

static findGuidByPositionE6(latE6, lngE6) → {string|null}

Finds a portal GUID by its position. Searches through currently rendered portals. Note: this includes fields and links.

Parameters:
Name Type Description
latE6 number

The latitude in E6 format.

lngE6 number

The longitude in E6 format.

Returns:
string | null -

The GUID of the portal at the specified location, or null if not found.

static fixImageUrl(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.

static 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.

static getAttackValues(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.

static getCurrentEnergy(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.

static getFields(guid) → {Array}

Searches through the fields for all fields that reference a specified portal.

Parameters:
Name Type Description
guid string

The GUID of the portal to search for fields.

Returns:
Array -

An array containing the GUIDs of fields associated with the portal.

static getFieldsCount(guid) → {number}

Counts the total number of fields associated with a specified portal.

Parameters:
Name Type Description
guid string

The GUID of the portal.

Returns:
number -

The total number of fields associated with the portal.

static getHackDetails(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.

static getHealth(d) → {number}

Calculates the health percentage of a portal based on its current and total energy.

Parameters:
Name Type Description
d Object

The portal detail object containing resonator information.

Returns:
number -

The portal health as a percentage (0-100). Returns 0 if the portal has no total energy.

static getLevel(d) → {number}

Calculates the resonator-based level of a portal. This includes a decimal part and is not clamped to the minimum level of 1

Parameters:
Name Type Description
d Object

The portal detail object containing resonator information.

Returns:
number -

The calculated portal level.

static 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.

static getLinkDefenseBoost(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.

Search through the links data for all that link from and to a portal. Returns an object with separate lists of in and out links. May or may not be as accurate as the portal details, depending on how much data the API returns.

Parameters:
Name Type Description
guid string

The GUID of the portal to search for links.

Returns:
Object -

An object containing arrays of incoming ('in') and outgoing ('out') link GUIDs.

static getLinksCount(guid) → {number}

Counts the total number of links (both incoming and outgoing) for a specified portal.

Parameters:
Name Type Description
guid string

The GUID of the portal.

Returns:
number -

The total number of links for the portal.

static getLinksMitigation(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.

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.

static getMitigationDetails(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.

static getModsByType(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.

static getRange(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).

static getShieldMitigation(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.

static getSummaryData(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.

static getTotalEnergy(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.

static selectByLatLng(lat, lngopt)

Selects a portal by its latitude and longitude.

Parameters:
Name Type Attributes Description
lat number | Array | L.LatLng

The latitude of the portal or an array or L.LatLng object containing both latitude and longitude.

lng number <optional>

The longitude of the portal.

static selectWhenLoadedByGuid(guid)

Select a portal when it appears on the map

Parameters:
Name Type Description
guid string

the guid of the portal

static selectWhenLoadedByLatLng(latLng)

Select a portal when it appears on the map

Parameters:
Name Type Description
latLng L.LatLng

the location of the portal

static zoomToAndShow(guid, latlng)

Zooms the map to a specific portal and shows its details if available.

Parameters:
Name Type Description
guid string

The globally unique identifier of the portal.

latlng L.LatLng | Array.<number>

The latitude and longitude of the portal.