Module:Util/doc

From Fire Emblem Heroes Wiki
Jump to: navigation, search

This is the documentation page for Module:Util

This module blackboxes several FEH-related operations (eg. Fetching heroes, skills, skill info) and is intended for use by other Lua modules. This module should not be called from #invoke directly.

mf(str)[edit source]

Removes special characters from str so that it is usable as a file name; equivalent to {{MF}}.

isNilOrEmpty(val)[edit source]

Checks if the specified value is nil or empty

returnDefaultIfEmpty(val)[edit source]

Returns '-' if the specified value is nil or empty

parseTime(str)[edit source]

Returns the Unix timestamp representing the given ISO 8601 formatted time.

formatTime(t)[edit source]

Returns the ISO 8601 formatted time represented by the given Unix timestamp.

MIN_TIME[edit source]

The constant string 1970-01-01T00:00:00Z.

MAX_TIME[edit source]

The constant string 2038-01-19T03:14:07Z.

getHeroIcon(hero,size)[edit source]

  • Input: Hero name and image size
  • Output: Icon of the Hero that links to the Hero page

getWeaponSortOrder()[edit source]

Obtains the sort order of weapon types, by color then by weapon. Uses WeaponTypes.

Return values[edit source]

A table that maps full weapon types to increasing values, e.g. 'Red Sword'1, 'Red Bow'2.

getMoveSortOrder()[edit source]

Obtains the sort order of move types. Uses MoveTypes.

Return values[edit source]

A table that maps move types to increasing values, e.g. 'Infantry'1, 'Armored'2.

getOriginSortOrder()[edit source]

Obtains the sort order of game titles. Uses the values from GameSortValue.

Return values[edit source]

A table that maps game titles to sort values, e.g. 'Fire Emblem Heroes'0, 'Fire Emblem: Shadow Dragon and the Blade of Light'1, 'Fire Emblem: Mystery of the Emblem'1.

getSkillChains(skills)[edit source]

Returns two tables representing dependencies between the given skills. The first table contains WikiName of skills as keys and lists of the skill's prerequisites as values; the second table is for descendants of skills.

If a table is passed as an argument, it must be a list that contains only the WikiNames of skills to be queried. Otherwise all existing skills are used.

getHeroAvailability(args)[edit source]

Obtains the non-focus rarities, focus rarities, and reward rarities of a Hero or all Heroes. Focus and reward rarities are based on all Summoning Focuses and rewards over time. args should be a Lua table with the following named arguments:

  • page: The page name of the Hero.
  • current: True if only the current general summoning pool is used to populate non-focus rarities, false to use all past general summoning pools as well.
  • new: True if only Heroes that appear in New Heroes or Special Heroes summoning events are considered, false to include all summoning events. Has no effect if page is given.
  • mask: If given, must be a table with the following keys:
    • nonfocus: Query non-focus rarities if this field is true, skip the query otherwise.
    • focus: Query focus rarities if this field is true, skip the query otherwise.
    • reward: Query reward rarities if this field is true, skip the query otherwise.

Return values[edit source]

The availability object is a Lua table with the following fields:

  • nonfocus: Lua sequence of rarities at which a Hero can be summoned as a non-focus unit. Unavailable if omitted using the mask parameter; otherwise, always present even if it is empty.
  • focus: Lua sequence of rarities at which a Hero can be summoned as a focus unit. Similarly masked.
  • reward: Lua sequence of rarities at which a Hero has been rewarded. Similarly masked.

And the following method:

  • bounds(): Returns the minimum and maximum rarities the Hero is available at, based on the rarities present in the object. Returns nil if the Hero is unavailable.

If page is given, the return value is simply the availability object of the Hero with that page name.

If page is nil, the function returns a table instead, where each key is a Hero's page name and the value is the availability object of that Hero. Only Heroes with available rarities appear in this table (e.g. Special Heroes will not appear at all if mask is set to {nonfocus = true}, because they never appear as non-focus units in summoning events).

getRarityText()[edit source]

Returns an array containing rarity texts from 1★ to 5★.

getDifficulties()[edit source]

Returns a sorted array of difficulties.

difficultySort(x, y)[edit source]

Returns the relative order between two unit tab names, based on their difficulties. Can be used as the comparison function to table.sort.