Modül:RolBox
Bu modül için bir Modül:RolBox/belge belgelendirmesi oluşturabilirsiniz
local p = {}
local function splitList(str)
local t = {}
for item in string.gmatch(str, "([^,]+)") do
table.insert(t, mw.text.trim(item))
end
return t
end
local function buildBadges(list, baseClass)
local html = ""
for _, v in ipairs(list) do
html = html .. string.format('<span class="%s">%s</span>', baseClass, v)
end
return html
end
function p.render(frame)
local parent = frame:getParent() or frame
local args = parent.args
local name = args["ad"] or args["isim"] or ""
local code = args["kod"] or ""
local duty = args["gorev"] or ""
local position = args["pozisyon"] or ""
local desc = args["aciklama"] or ""
local critical = args["kritik"] or ""
local secondary = args["ikincil"] or ""
local icons = args["simgeler"] or ""
local criticalList = critical ~= "" and splitList(critical) or {}
local secondaryList = secondary ~= "" and splitList(secondary) or {}
local iconList = icons ~= "" and splitList(icons) or {}
-- Görev rozetine ek sınıf (support/attack/defend vb.)
local dutyClass = "fm-rolecard__duty"
local dutyLower = mw.ustring.lower(duty or "")
if dutyLower ~= "" then
if dutyLower:find("support") or dutyLower:find("destek") then
dutyClass = dutyClass .. " fm-rolecard__duty--support"
elseif dutyLower:find("attack") or dutyLower:find("hücum") then
dutyClass = dutyClass .. " fm-rolecard__duty--attack"
elseif dutyLower:find("defend") or dutyLower:find("savunma") then
dutyClass = dutyClass .. " fm-rolecard__duty--defend"
end
end
local criticalHtml = buildBadges(criticalList, "fm-rolecard__badge fm-rolecard__badge--critical")
local secondaryHtml = buildBadges(secondaryList, "fm-rolecard__badge fm-rolecard__badge--secondary")
local iconsHtml = ""
for _, v in ipairs(iconList) do
iconsHtml = iconsHtml .. string.format('<span class="fm-rolecard__icon">%s</span>', v)
end
local metaLine = ""
local parts = {}
if code ~= "" then table.insert(parts, code) end
if position ~= "" then table.insert(parts, position) end
if #parts > 0 then
metaLine = '<div class="fm-rolecard__meta">' .. table.concat(parts, " • ") .. '</div>'
end
local descHtml = ""
if desc ~= "" then
descHtml = string.format('<div class="fm-rolecard__description">%s</div>', desc)
end
local criticalBlock = ""
if critical ~= "" then
criticalBlock = string.format([[
<div class="fm-rolecard__section">
<div class="fm-rolecard__section-title">Kritik Özellikler</div>
<div class="fm-rolecard__badge-list">%s</div>
</div>
]], criticalHtml)
end
local secondaryBlock = ""
if secondary ~= "" then
secondaryBlock = string.format([[
<div class="fm-rolecard__section">
<div class="fm-rolecard__section-title">İkincil Özellikler</div>
<div class="fm-rolecard__badge-list">%s</div>
</div>
]], secondaryHtml)
end
local iconsBlock = ""
if icons ~= "" then
iconsBlock = string.format([[
<div class="fm-rolecard__section fm-rolecard__section--icons">
<div class="fm-rolecard__badge-list">%s</div>
</div>
]], iconsHtml)
end
local html = string.format([[
<div class="fm-rolecard">
<div class="fm-rolecard__header">
<div class="fm-rolecard__title-group">
<div class="fm-rolecard__name">%s</div>
%s
</div>
<div class="%s">%s</div>
</div>
%s
%s
%s
%s
</div>
]],
name,
metaLine,
dutyClass, duty,
descHtml,
criticalBlock,
secondaryBlock,
iconsBlock
)
return html
end
return p