Module:Infobox/Compétence

De Starfield Wiki
Révision datée du 31 août 2023 à 09:18 par Kharmitch (discussion | contributions) (Annulation des modifications 1405 de Kims (discussion))
Documentation[voir] [modifier] [purger]

Paramétrage du modèle {{Infobox Compétence}}.

local general = require("Module:Infobox/Fonctions")
local localdata = require("Module:Infobox/Localdata")

-- Famille de compétences
-- TODO: Revoir pour la couleur de Tech, qui n'apparaît pas
-- clairement dans la bande-annonce
family = function(localdata)
	local family = localdata["famille"]
	if family == nil then
		error("Paramètre « famille » absent")
	end
	local FAMILIES = {
		physique = {"PHYSIQUE", "#3f5e40"},
		social   = {"SOCIAL",   "#b08c42"},
		combat   = {"COMBAT",   "#a7302e"},
		science  = {"SCIENCE",  "#24698e"},
		tech     = {"TECH",     "#6e558b"},
	}
	local family_config = FAMILIES[family:lower()]
	if family_config == nil then
		error(string.format(
			"Valeur inconnue du paramètre « famille » : « %s »",
			family
		))
	end
	return tostring(mw.html.create("div")
		:css("background-color", family_config[2])
		:css("color", "white")
		:css("font-weight", "bold")
		:css("text-align", "center")
		:wikitext(family_config[1])
		:done()
	)
end

return {
    parts = {
        general.title(),
        general.image(),
        {
            type = "table",
            title = "Caractéristiques",
            rows = {
                {type = "row", label = "Famille", value = family},
                {type = "row", label = "Effets", value = "effets"},
                {type = "row", label = "Rang", value = "rang"},
            },
        },
        general.creation_kit(),
    }
}