Modul:HeroCard: Unterschied zwischen den Versionen
Keine Bearbeitungszusammenfassung |
Keine Bearbeitungszusammenfassung |
||
| Zeile 3: | Zeile 3: | ||
-- ======= CONFIG / DEFAULTS ======= | -- ======= CONFIG / DEFAULTS ======= | ||
local CFG = { | local CFG = { | ||
main_order = { "damage", "hp", "armor" }, | main_order = { "damage", "hp", "armor" }, | ||
main_meta = { | main_meta = { | ||
damage = { label = "Schaden", | damage = { label = "Schaden", icon = "AttackIcon.png", | ||
hp = { label = "Gesundheit", | desc = "Dies bezeichnet die Menge an Gesundheit, die Gegner durch deine Treffer verlieren." }, | ||
armor = { label = "Rüstung", | hp = { label = "Gesundheit", icon = "HealthIcon.png", | ||
desc = "Wie viel Schaden du einstecken kannst, bevor du besiegt wirst." }, | |||
armor = { label = "Rüstung", icon = "ArmorIcon.png", | |||
desc = "Reduziert den erlittenen Schaden." }, | |||
}, | }, | ||
adv_order = { "precision", "bonus_damage", "speed", "dodge" }, | adv_order = { "precision", "bonus_damage", "speed", "dodge" }, | ||
adv_meta = { | adv_meta = { | ||
precision = { label = "Krit.-Chance", | precision = { label = "Krit.-Chance", icon = "CriticalChanceIcon.png", | ||
bonus_damage = { label = "Kritischer Schaden", icon = "CriticalDamageIcon.png" }, | desc = "Wahrscheinlichkeit, mit einem Angriff einen kritischen Treffer zu landen." }, | ||
speed = { label = "Angriffsgeschwindigkeit", | bonus_damage = { label = "Kritischer Schaden", icon = "CriticalDamageIcon.png", | ||
dodge = { label = "Ausweichen", | desc = "Zusätzlicher Schaden, der bei kritischen Treffern verursacht wird." }, | ||
speed = { label = "Angriffsgeschwindigkeit", icon = "AttackSpeedIcon.png", | |||
desc = "Wie schnell der Held angreift (kleiner ist schneller)." }, | |||
dodge = { label = "Ausweichen", icon = "DodgeIcon.png", | |||
desc = "Chance, einem gegnerischen Angriff vollständig auszuweichen." }, | |||
}, | }, | ||
-- Icon-Mapping | -- Icon-Mapping (deine Schreibweisen, UNVERÄNDERT) | ||
icon_map = { | icon_map = { | ||
attackstyle = { | attackstyle = { | ||
melee | melee = "MeleeIcon.png", | ||
spellcaster = "SpellcasterIcon.png", | spellcaster = "SpellcasterIcon.png", | ||
ranged | ranged = "RangedIcon.png", | ||
}, | }, | ||
specialization = { | specialization = { | ||
| Zeile 42: | Zeile 48: | ||
}, | }, | ||
-- DE-Übersetzung der Werte aus HeroData | -- DE-Übersetzung der Werte aus HeroData (UNVERÄNDERT außer Tipp-Korrekturen) | ||
i18n = { | i18n = { | ||
class = { | class = { | ||
| Zeile 113: | Zeile 119: | ||
end | end | ||
-- Pill/Adv: Icon 36px, | -- Pill/Adv: Icon 36px, **kein** title-Attribut; Tooltip-Daten via data-* | ||
local function pill(htmlParent, label, val, icon, showLabels) | local function pill(htmlParent, label, val, icon, showLabels, desc) | ||
if isempty(val) then return end | if isempty(val) then return end | ||
local box = htmlParent:tag("div"):addClass("kr-hc-pill"):attr("title", label or "") | local box = htmlParent:tag("div"):addClass("kr-hc-pill kr-tip") | ||
:attr("data-tip-title", label or "") | |||
:attr("data-tip-desc", desc or "") | |||
local left = box:tag("div"):addClass("kr-hc-pill-icon") | local left = box:tag("div"):addClass("kr-hc-pill-icon") | ||
if not isempty(icon) then left:wikitext(fileWikitext(icon, { size="36x36px", link="", lazy=true })) end | if not isempty(icon) then left:wikitext(fileWikitext(icon, { size="36x36px", link="", lazy=true })) end | ||
| Zeile 124: | Zeile 132: | ||
text:tag("div"):addClass("kr-hc-pill-value"):wikitext(val) | text:tag("div"):addClass("kr-hc-pill-value"):wikitext(val) | ||
end | end | ||
local function adv(htmlParent, label, val, icon, showLabels) | local function adv(htmlParent, label, val, icon, showLabels, desc) | ||
if isempty(val) then return end | if isempty(val) then return end | ||
local box = htmlParent:tag("div"):addClass("kr-hc-adv"):attr("title", label or "") | local box = htmlParent:tag("div"):addClass("kr-hc-adv kr-tip") | ||
:attr("data-tip-title", label or "") | |||
:attr("data-tip-desc", desc or "") | |||
local left = box:tag("div"):addClass("kr-hc-adv-icon") | local left = box:tag("div"):addClass("kr-hc-adv-icon") | ||
if not isempty(icon) then left:wikitext(fileWikitext(icon, { size="36x36px", link="", lazy=true })) end | if not isempty(icon) then left:wikitext(fileWikitext(icon, { size="36x36px", link="", lazy=true })) end | ||
| Zeile 135: | Zeile 145: | ||
end | end | ||
-- Freischaltung → | -- Freischaltung → (dein Text, leicht erweitert) | ||
local function unlock_text_de(s) | local function unlock_text_de(s) | ||
if s == nil or s == "" then return nil end | if s == nil or s == "" then return nil end | ||
| Zeile 144: | Zeile 154: | ||
if t:match("pirate%s*ship") then return "Wird auf dem Piratenschiff freigeschaltet." end | if t:match("pirate%s*ship") then return "Wird auf dem Piratenschiff freigeschaltet." end | ||
-- | -- Vollständige eigene Sätze einfach übernehmen | ||
if s:match("[%.%!%?]$") or t:find(" ") then | if s:match("[%.%!%?]$") or t:find(" ") then return s end | ||
return "Freischaltung: " .. s | return "Freischaltung: " .. s | ||
end | end | ||
-- ======= RENDER ======= | -- ======= RENDER ======= | ||
| Zeile 165: | Zeile 171: | ||
local showLabels = norm(args.show_labels) == "1" or norm(args.show_labels) == "yes" | local showLabels = norm(args.show_labels) == "1" or norm(args.show_labels) == "yes" | ||
-- Basics ( | -- Basics (DE) | ||
local class | local class = tr("class", pick(args.class, data.class)) | ||
local attackstyleRaw = pick(args.attackstyle, data.attackstyle) | local attackstyleRaw = pick(args.attackstyle, data.attackstyle) | ||
local specializationRaw = pick(args.specialization, data.specialization) | local specializationRaw = pick(args.specialization, data.specialization) | ||
local resourceRaw = pick(args.resource, data.resource) | local resourceRaw = pick(args.resource, data.resource) | ||
local attackstyle | local attackstyle = tr("attackstyle", attackstyleRaw) | ||
local specialization = tr("specialization", specializationRaw) | local specialization = tr("specialization", specializationRaw) | ||
local resource | local resource = tr("resource", resourceRaw) | ||
local unlock_at | local unlock_at = pick(args.unlock_at, data.unlock_at) | ||
local awakening_bonusRaw = pick(args.awakening_bonus, data.awakening_bonus) | local awakening_bonusRaw= pick(args.awakening_bonus, data.awakening_bonus) | ||
local awakening_bonus | local awakening_bonus = tr("awakening_bonus", awakening_bonusRaw) | ||
-- Icons | -- Icons | ||
local attackstyle_icon = mapIcon("attackstyle", attackstyleRaw, pick(args.attackstyle_icon, data.attackstyle_icon)) | local attackstyle_icon = mapIcon("attackstyle", attackstyleRaw, pick(args.attackstyle_icon, data.attackstyle_icon)) | ||
local specialization_icon = mapIcon("specialization", specializationRaw, pick(args.specialization_icon, data.specialization_icon)) | local specialization_icon = mapIcon("specialization", specializationRaw, pick(args.specialization_icon, data.specialization_icon)) | ||
| Zeile 190: | Zeile 196: | ||
if showLabels then root:addClass("kr-show-labels") end | if showLabels then root:addClass("kr-show-labels") end | ||
-- Avatar | -- Avatar | ||
root:tag("div"):addClass("kr-hc-avatar") | root:tag("div"):addClass("kr-hc-avatar") | ||
:wikitext(fileWikitext(avatar, { class="kr-hc-avatar-img", link=linkto, lazy=true })) | :wikitext(fileWikitext(avatar, { class="kr-hc-avatar-img", link=linkto, lazy=true })) | ||
-- Content | -- Content | ||
local content = root:tag("div"):addClass("kr-hc-content") | local content = root:tag("div"):addClass("kr-hc-content") | ||
if not isempty(name) then | if not isempty(name) then | ||
local h = content:tag("h2"):addClass("kr-hc-name") | local h = content:tag("h2"):addClass("kr-hc-name") | ||
| Zeile 208: | Zeile 212: | ||
if (not info or not info.ok) and debugWanted then | if (not info or not info.ok) and debugWanted then | ||
content:tag("div"):addClass("kr-hc-debug") | content:tag("div"):addClass("kr-hc-debug"):wikitext("<strong>HeroData not loaded.</strong>") | ||
end | end | ||
-- Basics 2×2 | -- Basics 2×2 | ||
local basicsGrid = content:tag("div"):addClass("kr-hc-basics2") | local basicsGrid = content:tag("div"):addClass("kr-hc-basics2") | ||
local function pair(label, value, icon) | local function pair(label, value, icon) | ||
| Zeile 230: | Zeile 233: | ||
pair("Ressource:", resource, resource_icon) | pair("Ressource:", resource, resource_icon) | ||
-- Hauptattribute | -- Hauptattribute (mit Tooltip-Texten) | ||
content:tag("h3"):addClass("kr-hc-h"):wikitext("Hauptattribute") | content:tag("h3"):addClass("kr-hc-h"):wikitext("Hauptattribute") | ||
local mains = content:tag("div"):addClass("kr-hc-main-attrs") | local mains = content:tag("div"):addClass("kr-hc-main-attrs") | ||
| Zeile 236: | Zeile 239: | ||
for i, key in ipairs(CFG.main_order) do | for i, key in ipairs(CFG.main_order) do | ||
local meta = CFG.main_meta[key] | local meta = CFG.main_meta[key] | ||
local val = pick(args["main"..i.."_val"], heroMain[key]) | local val = pick(args["main"..i.."_val"], heroMain[key]) | ||
local icon = pick(args["main"..i.."_icon"], meta.icon) | |||
local desc = pick(args["main"..i.."_desc"], meta.desc) | |||
pill(mains, meta.label, val, icon, showLabels, desc) | |||
end | end | ||
| Zeile 246: | Zeile 251: | ||
for i, key in ipairs(CFG.adv_order) do | for i, key in ipairs(CFG.adv_order) do | ||
local meta = CFG.adv_meta[key] | local meta = CFG.adv_meta[key] | ||
local val = pick(args["adv"..i.."_val"], heroAdv[key]) | local val = pick(args["adv"..i.."_val"], heroAdv[key]) | ||
adv | local icon = pick(args["adv"..i.."_icon"], meta.icon) | ||
local desc = pick(args["adv"..i.."_desc"], meta.desc) | |||
adv(advs, meta.label, val, icon, showLabels, desc) | |||
end | end | ||
for i = #CFG.adv_order + 1, 8 do | for i = #CFG.adv_order + 1, 8 do | ||
local val = args["adv"..i.."_val"] | local val = args["adv"..i.."_val"] | ||
if isempty(val) then break end | if isempty(val) then break end | ||
adv(advs, args["adv"..i.."_label"] or "", val, args["adv"..i.."_icon"], showLabels) | adv(advs, args["adv"..i.."_label"] or "", val, args["adv"..i.."_icon"], showLabels, args["adv"..i.."_desc"]) | ||
end | end | ||
-- Erweckungsbonus (Icon 64px | -- Erweckungsbonus (Icon 64px, eigener Tooltip) | ||
if not isempty(awakening_bonus) then | if not isempty(awakening_bonus) then | ||
content:tag("h3"):addClass("kr-hc-h"):wikitext("Erweckungsbonus") | content:tag("h3"):addClass("kr-hc-h"):wikitext("Erweckungsbonus") | ||
local awk = content:tag("div"):addClass("kr-hc-awakening") | local awk = content:tag("div"):addClass("kr-hc-awakening") | ||
local box = awk:tag("div"):addClass("kr-hc-adv"):attr("title", "Erweckungsbonus") | local box = awk:tag("div"):addClass("kr-hc-adv kr-tip") | ||
:attr("data-tip-title", "Erweckungsbonus") | |||
:attr("data-tip-desc", pick(args.awakening_desc, "Bonus, der beim Erwachen freigeschaltet wird.")) | |||
if not isempty(awakening_bonus_icon) then | if not isempty(awakening_bonus_icon) then | ||
box:tag("div"):addClass("kr-hc-adv-icon") | box:tag("div"):addClass("kr-hc-adv-icon") | ||
| Zeile 270: | Zeile 279: | ||
end | end | ||
if debugWanted then | if debugWanted then | ||
content:tag("pre"):addClass("kr-hc-debug") | content:tag("pre"):addClass("kr-hc-debug") | ||
| Zeile 279: | Zeile 287: | ||
end | end | ||
function p.selftest() | function p.selftest() | ||
local heroes, info = loadHeroes() | local heroes, info = loadHeroes() | ||
Version vom 9. Oktober 2025, 10:50 Uhr
Die Dokumentation für dieses Modul kann unter Modul:HeroCard/Doku erstellt werden
local p = {}
-- ======= CONFIG / DEFAULTS =======
local CFG = {
main_order = { "damage", "hp", "armor" },
main_meta = {
damage = { label = "Schaden", icon = "AttackIcon.png",
desc = "Dies bezeichnet die Menge an Gesundheit, die Gegner durch deine Treffer verlieren." },
hp = { label = "Gesundheit", icon = "HealthIcon.png",
desc = "Wie viel Schaden du einstecken kannst, bevor du besiegt wirst." },
armor = { label = "Rüstung", icon = "ArmorIcon.png",
desc = "Reduziert den erlittenen Schaden." },
},
adv_order = { "precision", "bonus_damage", "speed", "dodge" },
adv_meta = {
precision = { label = "Krit.-Chance", icon = "CriticalChanceIcon.png",
desc = "Wahrscheinlichkeit, mit einem Angriff einen kritischen Treffer zu landen." },
bonus_damage = { label = "Kritischer Schaden", icon = "CriticalDamageIcon.png",
desc = "Zusätzlicher Schaden, der bei kritischen Treffern verursacht wird." },
speed = { label = "Angriffsgeschwindigkeit", icon = "AttackSpeedIcon.png",
desc = "Wie schnell der Held angreift (kleiner ist schneller)." },
dodge = { label = "Ausweichen", icon = "DodgeIcon.png",
desc = "Chance, einem gegnerischen Angriff vollständig auszuweichen." },
},
-- Icon-Mapping (deine Schreibweisen, UNVERÄNDERT)
icon_map = {
attackstyle = {
melee = "MeleeIcon.png",
spellcaster = "SpellcasterIcon.png",
ranged = "RangedIcon.png",
},
specialization = {
healer = "HealerIcon.png",
damage = "DamageIcon.png",
tank = "TankIcon.png",
},
resource = {
mana = "ManaIcon.png",
rage = "RageIcon.png",
energy = "EnergyIcon.png",
},
awakening_bonus = {
["raining gold"] = "RainingGold.png",
["all main attributes"] = "AllAttributes.png",
prestigious = "Prestigious.png",
}
},
-- DE-Übersetzung der Werte aus HeroData (UNVERÄNDERT außer Tipp-Korrekturen)
i18n = {
class = {
warrior="Krieger", paladin="Paladin", rouge="Schurke",
mage="Magier", druid="Druide", ranger="Waldläufer"
},
attackstyle = {
melee="Nahkampf", ranged="Fernkampf", spellcaster="Zauberwirker"
},
specialization = { healer="Heiler", damage="Schaden", tank="Tank" },
resource = { mana="Mana", rage="Wut", energy="Energie" },
awakening_bonus = {
["raining gold"]="Goldregen",
["all main attributes"]="Alle Hauptattribute",
prestigious="Prestigevoll"
}
}
}
-- ======= HELPERS =======
local function isempty(v) return v == nil or v == "" end
local function pick(...)
local n = select('#', ...)
for i = 1, n do
local v = select(i, ...)
if not (v == nil or v == "") then return v end
end
return nil
end
local function norm(s)
if isempty(s) then return "" end
return mw.ustring.lower(mw.text.trim(s)):gsub("%s+", " ")
end
local function getArgs(frame)
local args, f1, f2 = {}, frame.args or {}, (frame:getParent() and frame:getParent().args) or {}
for k,v in pairs(f1) do if not isempty(v) then args[k]=v end end
for k,v in pairs(f2) do if not isempty(v) then args[k]=v end end
return args
end
local function loadHeroes()
local tried, lastErr = {}, nil
for _,title in ipairs{ "Modul:HeroData", "Module:HeroData" } do
local ok, mod = pcall(require, title)
if ok and type(mod) == "table" and type(mod.heroes) == "table" then
return mod.heroes, { ok=true, from=title }
else
table.insert(tried, title); lastErr = mod
end
end
return nil, { ok=false, tried=tried, err=lastErr }
end
local function fileWikitext(filename, opts)
if isempty(filename) then return "" end
local parts = { ("Datei:%s"):format(filename) }
if opts and opts.size then table.insert(parts, opts.size) end
if opts and opts.link then table.insert(parts, "link=" .. opts.link) end
if opts and opts.class then table.insert(parts, "class=" .. opts.class) end
if opts and opts.lazy then table.insert(parts, "loading=lazy") end
return string.format("[[%s]]", table.concat(parts, "|"))
end
local function mapIcon(kind, value, override)
if not isempty(override) then return override end
local t = CFG.icon_map[kind] or {}
return t[norm(value)]
end
local function tr(kind, value)
if isempty(value) then return value end
local m = CFG.i18n[kind] or {}
return m[norm(value)] or value
end
-- Pill/Adv: Icon 36px, **kein** title-Attribut; Tooltip-Daten via data-*
local function pill(htmlParent, label, val, icon, showLabels, desc)
if isempty(val) then return end
local box = htmlParent:tag("div"):addClass("kr-hc-pill kr-tip")
:attr("data-tip-title", label or "")
:attr("data-tip-desc", desc or "")
local left = box:tag("div"):addClass("kr-hc-pill-icon")
if not isempty(icon) then left:wikitext(fileWikitext(icon, { size="36x36px", link="", lazy=true })) end
local text = box:tag("div"):addClass("kr-hc-pill-text")
local lab = text:tag("div"):addClass("kr-hc-pill-label"):wikitext(label or "")
if not showLabels then lab:addClass("is-hidden") end
text:tag("div"):addClass("kr-hc-pill-value"):wikitext(val)
end
local function adv(htmlParent, label, val, icon, showLabels, desc)
if isempty(val) then return end
local box = htmlParent:tag("div"):addClass("kr-hc-adv kr-tip")
:attr("data-tip-title", label or "")
:attr("data-tip-desc", desc or "")
local left = box:tag("div"):addClass("kr-hc-adv-icon")
if not isempty(icon) then left:wikitext(fileWikitext(icon, { size="36x36px", link="", lazy=true })) end
local main = box:tag("div"):addClass("kr-hc-adv-main")
local lab = main:tag("div"):addClass("kr-hc-adv-label"):wikitext(label or "")
if not showLabels then lab:addClass("is-hidden") end
main:tag("div"):addClass("kr-hc-adv-value"):wikitext(val)
end
-- Freischaltung → (dein Text, leicht erweitert)
local function unlock_text_de(s)
if s == nil or s == "" then return nil end
local t = mw.ustring.lower(mw.text.trim(s)):gsub("%s+", " ")
local n = t:match("stage%s*(%d+)")
if n then return "Freischaltung bei Abschnitt: " .. n end
if t:match("pirate%s*ship") then return "Wird auf dem Piratenschiff freigeschaltet." end
-- Vollständige eigene Sätze einfach übernehmen
if s:match("[%.%!%?]$") or t:find(" ") then return s end
return "Freischaltung: " .. s
end
-- ======= RENDER =======
function p.render(frame)
local args = getArgs(frame)
local name = pick(args.name, args[1]) or ""
local heroes, info = loadHeroes()
local data = (heroes and (heroes[name] or heroes[mw.ustring.gsub(name or "", "_", " ")])) or {}
local debugWanted = norm(args.debug) == "1" or norm(args.debug) == "yes"
local showLabels = norm(args.show_labels) == "1" or norm(args.show_labels) == "yes"
-- Basics (DE)
local class = tr("class", pick(args.class, data.class))
local attackstyleRaw = pick(args.attackstyle, data.attackstyle)
local specializationRaw = pick(args.specialization, data.specialization)
local resourceRaw = pick(args.resource, data.resource)
local attackstyle = tr("attackstyle", attackstyleRaw)
local specialization = tr("specialization", specializationRaw)
local resource = tr("resource", resourceRaw)
local unlock_at = pick(args.unlock_at, data.unlock_at)
local awakening_bonusRaw= pick(args.awakening_bonus, data.awakening_bonus)
local awakening_bonus = tr("awakening_bonus", awakening_bonusRaw)
-- Icons
local attackstyle_icon = mapIcon("attackstyle", attackstyleRaw, pick(args.attackstyle_icon, data.attackstyle_icon))
local specialization_icon = mapIcon("specialization", specializationRaw, pick(args.specialization_icon, data.specialization_icon))
local resource_icon = mapIcon("resource", resourceRaw, pick(args.resource_icon, data.resource_icon))
local awakening_bonus_icon= mapIcon("awakening_bonus",awakening_bonusRaw,pick(args.awakening_bonus_icon,data.awakening_bonus_icon))
-- Bilder/Links
local linkto = pick(args.linkto, name)
local avatar = pick(args.avatar, (not isempty(name) and (name .. ".png")) or nil)
local root = mw.html.create("div"):addClass("kr-hero-card")
if showLabels then root:addClass("kr-show-labels") end
-- Avatar
root:tag("div"):addClass("kr-hc-avatar")
:wikitext(fileWikitext(avatar, { class="kr-hc-avatar-img", link=linkto, lazy=true }))
-- Content
local content = root:tag("div"):addClass("kr-hc-content")
if not isempty(name) then
local h = content:tag("h2"):addClass("kr-hc-name")
local unlock_text = unlock_text_de(unlock_at)
h:wikitext(string.format("[[%s|%s]]%s",
linkto, name,
unlock_text and (" <span class=\"kr-hc-unlock\">(" .. unlock_text .. ")</span>") or ""
))
end
if (not info or not info.ok) and debugWanted then
content:tag("div"):addClass("kr-hc-debug"):wikitext("<strong>HeroData not loaded.</strong>")
end
-- Basics 2×2
local basicsGrid = content:tag("div"):addClass("kr-hc-basics2")
local function pair(label, value, icon)
if isempty(value) then return end
local it = basicsGrid:tag("div"):addClass("kr-hc-basic")
it:tag("span"):addClass("label"):wikitext(label)
local v = it:tag("span"):addClass("value")
v:wikitext(value)
if not isempty(icon) then
v:tag("span"):addClass("value-icon")
:wikitext(fileWikitext(icon, { size="24x24px", link="", lazy=true }))
end
end
pair("Klasse:", class, nil)
pair("Spezialisierung:", specialization, specialization_icon)
pair("Angriffsart:", attackstyle, attackstyle_icon)
pair("Ressource:", resource, resource_icon)
-- Hauptattribute (mit Tooltip-Texten)
content:tag("h3"):addClass("kr-hc-h"):wikitext("Hauptattribute")
local mains = content:tag("div"):addClass("kr-hc-main-attrs")
local heroMain= type(data.main) == "table" and data.main or {}
for i, key in ipairs(CFG.main_order) do
local meta = CFG.main_meta[key]
local val = pick(args["main"..i.."_val"], heroMain[key])
local icon = pick(args["main"..i.."_icon"], meta.icon)
local desc = pick(args["main"..i.."_desc"], meta.desc)
pill(mains, meta.label, val, icon, showLabels, desc)
end
-- Erweiterte Attribute
content:tag("h3"):addClass("kr-hc-h"):wikitext("Erweiterte Attribute")
local advs = content:tag("div"):addClass("kr-hc-adv-attrs")
local heroAdv= type(data.adv) == "table" and data.adv or {}
for i, key in ipairs(CFG.adv_order) do
local meta = CFG.adv_meta[key]
local val = pick(args["adv"..i.."_val"], heroAdv[key])
local icon = pick(args["adv"..i.."_icon"], meta.icon)
local desc = pick(args["adv"..i.."_desc"], meta.desc)
adv(advs, meta.label, val, icon, showLabels, desc)
end
for i = #CFG.adv_order + 1, 8 do
local val = args["adv"..i.."_val"]
if isempty(val) then break end
adv(advs, args["adv"..i.."_label"] or "", val, args["adv"..i.."_icon"], showLabels, args["adv"..i.."_desc"])
end
-- Erweckungsbonus (Icon 64px, eigener Tooltip)
if not isempty(awakening_bonus) then
content:tag("h3"):addClass("kr-hc-h"):wikitext("Erweckungsbonus")
local awk = content:tag("div"):addClass("kr-hc-awakening")
local box = awk:tag("div"):addClass("kr-hc-adv kr-tip")
:attr("data-tip-title", "Erweckungsbonus")
:attr("data-tip-desc", pick(args.awakening_desc, "Bonus, der beim Erwachen freigeschaltet wird."))
if not isempty(awakening_bonus_icon) then
box:tag("div"):addClass("kr-hc-adv-icon")
:wikitext(fileWikitext(awakening_bonus_icon, { size="64x64px", link="", lazy=true }))
end
local main = box:tag("div"):addClass("kr-hc-adv-main")
local lab = main:tag("div"):addClass("kr-hc-adv-label"):wikitext("Erweckungsbonus")
if not showLabels then lab:addClass("is-hidden") end
main:tag("div"):addClass("kr-hc-adv-value"):wikitext(awakening_bonus)
end
if debugWanted then
content:tag("pre"):addClass("kr-hc-debug")
:wikitext(mw.text.nowiki(mw.dumpObject({name=name, data=data, module=info})))
end
return tostring(root)
end
function p.selftest()
local heroes, info = loadHeroes()
local out = mw.html.create("div")
if not (info and info.ok) then
out:tag("p"):wikitext("HeroData NOT loaded.")
return tostring(out)
end
out:tag("p"):wikitext("HeroData loaded from: " .. info.from)
local ul = out:tag("ul"); for n,_ in pairs(heroes) do ul:tag("li"):wikitext(n) end
return tostring(out)
end
return p