Module:HeroSubClassData: Difference between revisions
No edit summary |
No edit summary |
||
| Line 3: | Line 3: | ||
-- Table de correspondance inversée (faction_classe) pour coller à la table HeroSpecialization | -- Table de correspondance inversée (faction_classe) pour coller à la table HeroSpecialization | ||
local class_mapping = { | local class_mapping = { | ||
[" | ["herald_1"] = "sub_class_demon_magic_1", | ||
[" | ["warlock_1"] = "sub_class_dungeon_magic_1", | ||
[" | ["cleric_1"] = "sub_class_human_magic_1", | ||
[" | ["druid_1"] = "sub_class_nature_magic_1", | ||
[" | ["necromancer_1"] = "sub_class_undead_magic_1", | ||
[" | ["riftspeaker_1"] = "sub_class_unfrozen_magic_1", | ||
[" | ["enforcer_1"] = "sub_class_demon_might_1", | ||
[" | ["overlord_1"] = "sub_class_dungeon_might_1", | ||
[" | ["knight_1"] = "sub_class_human_might_1", | ||
[" | ["warden_1"] = "sub_class_nature_might_1", | ||
["death | ["death knight_1"]= "sub_class_undead_might_1", | ||
[" | ["oathkeeper_1"] = "sub_class_unfrozen_might_1", | ||
["herald_2"] = "sub_class_demon_magic_2", | |||
["warlock_2"] = "sub_class_dungeon_magic_2", | |||
["cleric_2"] = "sub_class_human_magic_2", | |||
["druid_2"] = "sub_class_nature_magic_2", | |||
["necromancer_2"] = "sub_class_undead_magic_2", | |||
["riftspeaker_2"] = "sub_class_unfrozen_magic_2", | |||
["enforcer_2"] = "sub_class_demon_might_2", | |||
["overlord_2"] = "sub_class_dungeon_might_2", | |||
["knight_2"] = "sub_class_human_might_2", | |||
["warden_2"] = "sub_class_nature_might_2", | |||
["death knight_2"]= "sub_class_undead_might_2", | |||
["oathkeeper_2"] = "sub_class_unfrozen_might_2" | |||
} | } | ||
Revision as of 18:45, 28 May 2026
Template:Documentation
This module provides standardized methods to query mechanical data configurations, activation skill prerequisites, and localized texts mapped to specific hero mastery subclasses directly from the Cargo database tables (specifically HeroSubClass and Translation).
Basic Syntax
To extract any structural variable node or translation block from a hero subclass registry page:
{{#invoke:HeroSubClassData|get|SUBCLASS_ID|VARIABLE|LANGUAGE_CODE}}
SUBCLASS_ID: The technical internal database key identifier assigned to the targeted hero subclass row (e.g.,sub_class_human_might_1).VARIABLE: The specific data field node target identifier to look up (see reference matrix below).LANGUAGE_CODE: (Optional) Sets the localization system language. Defaults to French (fr) if omitted, with automated fallbacks.
---
Technical Reference Index
📝 Localized Text Blocks (Language-Aware)
Queries localized dictionary assets that translate dynamically based on the language parameter input.
| Variable Keyword | Description | Sample Expected Output |
|---|---|---|
name |
The localized public name of the specialty subclass. | Bretteur |
description |
Mechanical lore synopses detailing passive thresholds or stats adjustments. | Coup héroïque inflige +60 point(s)... |
⚙️ Structural & Mechanical Properties
Static code variables returning gameplay rows directly mapped parameters tied into the core game database.
| Variable Keyword | Description | Sample Output |
|---|---|---|
faction |
The alignment technical name faction group linked to the subclass. | human
|
class_type |
Archetypal class methodology branch style. | might
|
icon |
Graphical asset emblem visual token key identifier. | sub_class_human_might_1_icon
|
source_path |
Server file system dump localization repository tree tracker. | DB/heroes_sub_classes/sub_classes_human.json
|
⚔️ Required Activation Skills
Prerequisites requirements parameters checking skills conditions to validate the subclass unlock state.
| Variable Keyword | Description | Variable Keyword | Description |
|---|---|---|---|
activation_skill_1_sid |
Internal ID of required Skill 1 | activation_skill_1_level |
Required level threshold for Skill 1 |
activation_skill_2_sid |
Internal ID of required Skill 2 | activation_skill_2_level |
Required level threshold for Skill 2 |
activation_skill_3_sid |
Internal ID of required Skill 3 | activation_skill_3_level |
Required level threshold for Skill 3 |
activation_skill_4_sid |
Internal ID of required Skill 4 | activation_skill_4_level |
Required level threshold for Skill 4 |
activation_skill_5_sid |
Internal ID of required Skill 5 | activation_skill_5_level |
Required level threshold for Skill 5 |
---
Practical Implementation Examples
Example 1: Creating a Prerequisites Checklist
Pull structural required requirements to display dynamic conditional lists on wiki pages:
To become a {{#invoke:HeroSubClassData|get|sub_class_human_might_1|name|en}}, you need:
* {{#invoke:HeroSubClassData|get|sub_class_human_might_1|activation_skill_1_sid}} at Level {{#invoke:HeroSubClassData|get|sub_class_human_might_1|activation_skill_1_level}}
* {{#invoke:HeroSubClassData|get|sub_class_human_might_1|activation_skill_2_sid}} at Level {{#invoke:HeroSubClassData|get|sub_class_human_might_1|activation_skill_2_level}}
local p = {}
-- Table de correspondance inversée (faction_classe) pour coller à la table HeroSpecialization
local class_mapping = {
["herald_1"] = "sub_class_demon_magic_1",
["warlock_1"] = "sub_class_dungeon_magic_1",
["cleric_1"] = "sub_class_human_magic_1",
["druid_1"] = "sub_class_nature_magic_1",
["necromancer_1"] = "sub_class_undead_magic_1",
["riftspeaker_1"] = "sub_class_unfrozen_magic_1",
["enforcer_1"] = "sub_class_demon_might_1",
["overlord_1"] = "sub_class_dungeon_might_1",
["knight_1"] = "sub_class_human_might_1",
["warden_1"] = "sub_class_nature_might_1",
["death knight_1"]= "sub_class_undead_might_1",
["oathkeeper_1"] = "sub_class_unfrozen_might_1",
["herald_2"] = "sub_class_demon_magic_2",
["warlock_2"] = "sub_class_dungeon_magic_2",
["cleric_2"] = "sub_class_human_magic_2",
["druid_2"] = "sub_class_nature_magic_2",
["necromancer_2"] = "sub_class_undead_magic_2",
["riftspeaker_2"] = "sub_class_unfrozen_magic_2",
["enforcer_2"] = "sub_class_demon_might_2",
["overlord_2"] = "sub_class_dungeon_might_2",
["knight_2"] = "sub_class_human_might_2",
["warden_2"] = "sub_class_nature_might_2",
["death knight_2"]= "sub_class_undead_might_2",
["oathkeeper_2"] = "sub_class_unfrozen_might_2"
}
-- Fonction interne pour traduire le nom usuel en identifiant Cargo valide
local function get_cargo_spec_id(input_id)
if not input_id then return "" end
-- On nettoie les espaces inutiles et on passe tout en minuscules
local clean_id = mw.text.trim(string.lower(input_id))
-- Si le nom est dans notre dictionnaire, on renvoie l'ID Cargo, sinon on garde l'original
return class_mapping[clean_id] or clean_id
end
-- Fonction locale pour mettre la première lettre de chaque mot en majuscule
-- Gère les mots séparés par des espaces ou des underscores (_)
local function capitalize(str)
if not str then return "" end
-- Remplace la première lettre de chaque mot par sa version majuscule
local capitalized = str:gsub("(%a)([%w]*)", function(first, rest)
return first:upper() .. rest:lower()
end)
return capitalized
end
-- Fonction principale pour récupérer une donnée de spécialisation
-- Syntaxe : {{#invoke:HeroSpecializationData|get|ID_SPECIALISATION|CHAMP|LANGUE}}
function p.get(frame)
local args = frame.args[1] and frame.args or frame:getParent().args
-- Conversion automatique du nom de classe saisi vers le format faction_classe
local spec_id = get_cargo_spec_id(args[1])
local field = args[2]
local lang = args[3] or 'en' -- Anglais par défaut
if spec_id == "" or not field then
return "Erreur : ID de spécialisation ou champ manquant."
end
-- 1. Gestion des champs textuels traduits (name, description)
if field == 'name' or field == 'description' then
local queryOpts = {
where = string.format('target_id="%s" AND language="%s" AND type="hero_specialization"', spec_id, lang)
}
local res = mw.ext.cargo.query('Translation', field, queryOpts)
if res and res[1] and res[1][field] then
return res[1][field]
else
-- Système de secours (fallback) vers l'anglais
if lang ~= 'en' then
local fallbackOpts = {
where = string.format('target_id="%s" AND language="en" AND type="hero_specialization"', spec_id)
}
local fallbackRes = mw.ext.cargo.query('Translation', field, fallbackOpts)
if fallbackRes and fallbackRes[1] and fallbackRes[1][field] then
return fallbackRes[1][field]
end
end
return ""
end
end
-- 2. Gestion des données brutes de la table "HeroSpecialization"
local specOpts = {
where = string.format('id="%s"', spec_id)
}
local specRes = mw.ext.cargo.query('HeroSpecialization', field, specOpts)
if specRes and specRes[1] and specRes[1][field] then
local value = specRes[1][field]
-- SI le champ demandé est l'icône, on applique la transformation des majuscules
if field == 'icon' then
return capitalize(value)
end
return value
end
return ""
end
return p


