Module:HeroList

From Heroes of Might and Magic: Olden Era Official Wiki

Description

This module generates an automated table of heroes belonging to a specific faction. It dynamically retrieves localization for hero names, classes, and specializations, and formats the starting skills and spells into a clean, sortable layout.

Usage

The module is invoked via the display function:

{{#invoke:HeroList|display|faction=...|language=...}}

Parameters

Parameter Description Example
faction The name of the faction (as stored in the Translation table). faction=Necropolis
language Forces the Wiki language (if omitted, it detects the page suffix). language=fr

Key Features

  • Dynamic Localization: Translates headers (Name, Class, etc.) and hero-specific data (Names, Skills, Spells) based on the provided language.
  • Automatic Formatting:
    • Displays hero portraits and icons.
    • Formats specializations with tooltips showing descriptions.
    • Lists starting skills and spells as link-lists with icons.
  • Sorting Support: The table uses the sortable class, allowing users to reorder heroes based on columns.
  • Data Cleanup: Automatically filters out campaign, tutorial, and internal testing heroes (e.g., cm_fun).

Implementation Example

To display all heroes of the "Necropolis" faction:

== Necropolis Heroes ==
{{#invoke:HeroList|display|faction=Necropolis}}

Technical Notes

  • The module queries the Hero table and joins data with the Translation table.
  • It uses sortable tables; ensure the MediaWiki "Sortable" extension is active for full functionality.
  • Specialization icons are automatically inferred from the HeroSpecialization table and formatted to match faction naming conventions.

Examples

{{#invoke:HeroList|display|faction=Necropolis}}

Résultats pour dungeon_hero_10: 32
Langue trouvée: cs
Langue trouvée: cs
Langue trouvée: de
Langue trouvée: de
Langue trouvée: en
Langue trouvée: en
Langue trouvée: es
Langue trouvée: es
Langue trouvée: fr
Langue trouvée: fr
Langue trouvée: hu
Langue trouvée: hu
Langue trouvée: it
Langue trouvée: it
Langue trouvée: ja
Langue trouvée: ja
Langue trouvée: ko
Langue trouvée: ko
Langue trouvée: pl
Langue trouvée: pl
Langue trouvée: pt_br
Langue trouvée: pt_br
Langue trouvée: ru
Langue trouvée: ru
Langue trouvée: tr
Langue trouvée: tr
Langue trouvée: uk
Langue trouvée: uk
Langue trouvée: zh-hans
Langue trouvée: zh-hans
Langue trouvée: zh-hant
Langue trouvée: zh-hant

{{#invoke:HeroList|display|faction=Grove|language=ja}}

Résultats pour dungeon_hero_10: 32
Langue trouvée: cs
Langue trouvée: cs
Langue trouvée: de
Langue trouvée: de
Langue trouvée: en
Langue trouvée: en
Langue trouvée: es
Langue trouvée: es
Langue trouvée: fr
Langue trouvée: fr
Langue trouvée: hu
Langue trouvée: hu
Langue trouvée: it
Langue trouvée: it
Langue trouvée: ja
Langue trouvée: ja
Langue trouvée: ko
Langue trouvée: ko
Langue trouvée: pl
Langue trouvée: pl
Langue trouvée: pt_br
Langue trouvée: pt_br
Langue trouvée: ru
Langue trouvée: ru
Langue trouvée: tr
Langue trouvée: tr
Langue trouvée: uk
Langue trouvée: uk
Langue trouvée: zh-hans
Langue trouvée: zh-hans
Langue trouvée: zh-hant
Langue trouvée: zh-hant


local p = {}
function p.display(frame)
    local target = "dungeon_hero_10" -- On fixe l'ID pour le test
    local query = mw.ext.cargo.query("Translation", "target_id, language", {
        where = string.format("target_id = '%s'", target)
    })
    
    local output = "Résultats pour " .. target .. ": " .. #query .. "<br>"
    for _, row in ipairs(query) do
        output = output .. "Langue trouvée: " .. row.language .. "<br>"
    end
    return output
end
return p