Module:HeroDataParser/doc: Difference between revisions

From Heroes of Might and Magic: Olden Era Official Wiki
Created page with "= HeroDataParser Module Documentation = This module provides accessors for **hero data** stored in `Data:HeroData.json`. It allows retrieving hero class, specialty, starting skills, spells, and generating wikitext lists or army icons. Data is **cached on first access** for improved performance. == Functions == === getClass(frame) === Retrieves the class of a hero. ;Usage <pre>{{#invoke:HeroDataParser|getClass|HeroName}}</pre> ;Parameters * frame.args[1] – strin..."
 
No edit summary
 
Line 1: Line 1:
= HeroDataParser Module Documentation =
= HeroDataParser Module Documentation =


This module provides accessors for **hero data** stored in `Data:HeroData.json`.   
This module provides accessors for '''hero data''' stored in ''Data:HeroData.json''.   
It allows retrieving hero class, specialty, starting skills, spells, and generating wikitext lists or army icons.
It allows retrieving hero class, specialty, starting skills, spells, and generating wikitext lists or army icons.


Data is **cached on first access** for improved performance.
Data is '''cached on first access''' for improved performance.


== Functions ==
== Functions ==

Latest revision as of 16:13, 30 October 2025

HeroDataParser Module Documentation

This module provides accessors for hero data stored in Data:HeroData.json. It allows retrieving hero class, specialty, starting skills, spells, and generating wikitext lists or army icons.

Data is cached on first access for improved performance.

Functions

getClass(frame)

Retrieves the class of a hero.

Usage
{{#invoke:HeroDataParser|getClass|HeroName}}
Parameters
  • frame.args[1] – string: hero name
Returns
  • string: hero's class, or empty string if not found

---

getSpecialty(frame)

Retrieves the specialty of a hero.

Usage
{{#invoke:HeroDataParser|getSpecialty|HeroName}}
Parameters
  • frame.args[1] – string: hero name
Returns
  • string: hero's specialty, or empty string if not found

---

getSkill1(frame)

Retrieves the first starting skill of a hero.

Usage
{{#invoke:HeroDataParser|getSkill1|HeroName}}
Parameters
  • frame.args[1] – string: hero name
Returns
  • string: name of the first starting skill, or nil if none

---

getSkill2(frame)

Retrieves the second starting skill of a hero.

Usage
{{#invoke:HeroDataParser|getSkill2|HeroName}}
Parameters
  • frame.args[1] – string: hero name
Returns
  • string: name of the second starting skill, or nil if none

---

getSpell(frame)

Retrieves the spell of a hero.

Usage
{{#invoke:HeroDataParser|getSpell|HeroName}}
Parameters
  • frame.args[1] – string: hero name
Returns
  • string: hero's spell, or nil if none

---

getFactionHeroes(frame)

Generates a list of heroes belonging to a faction using `|- |style="padding:0.25em 0; border-right:0;" |[[File:{{{1}}}.png|50px]] |style="border-left:0;" | [[{{{1}}}]] |[[]] | |colspan=2 | [[|Advanced ]] |`.

Usage
{{#invoke:HeroDataParser|getFactionHeroes|FactionName}}
Parameters
  • frame.args[1] – string: faction name
Returns
  • wikitext: list of heroes in the faction

---

getClassHeroes(frame)

Generates a list of heroes of a specific class using `|- |style="padding:0.25em 0; border-right:0;" |[[File:{{{1}}}.png|50px]] |style="border-left:0;" | [[{{{1}}}]] |[[]] | |colspan=2 | [[|Advanced ]] |`.

Usage
{{#invoke:HeroDataParser|getClassHeroes|ClassName}}
Parameters
  • frame.args[1] – string: class name
Returns
  • wikitext: list of heroes in the class

---

getStartingArmyIcons(frame)

Generates HTML displaying a hero's starting army icons with unit count.

Usage
{{#invoke:HeroDataParser|getStartingArmyIcons|HeroName}}
Parameters
  • frame.args[1] – string: hero name
Returns
  • HTML: icons of the hero's starting army with unit names and counts
  • Empty string if hero or army data is not available

---

Internal Functions

  • getHeroData() – Loads and caches the hero JSON data from `Data:HeroData.json`.
  • findHero(heroName) – Finds and returns the hero table by name.