« Module:Fermentation » : différence entre les versions

369 octets enlevés ,  19 juillet 2021
aucun résumé des modifications
Kims (discussion | contributions)
Aucun résumé des modifications
Kims (discussion | contributions)
Aucun résumé des modifications
Ligne 3 : Ligne 3 :
local LF = '\n'
local LF = '\n'


------------------------------------------------
--------------------------------
-----    Référentiel des interactions    -----  
-----    Référentiel     -----  
------------------------------------------------
--------------------------------


local data = {
local data = {
    -- Interaction spéciale si aucune autre, ne pas toucher --------
["aucune"] = {
image        = "Neutral test color.png",
description  = "Ce personnage ne possède pas d'interaction particulière."
},
    ----------------------------------------------------------------
["fermentable"] = {
["fermentable"] = {
checkIfYes  = false,
description  = "Premier stade du brassage."
},
},
["fermenté"] = {
["fermenté"] = {
checkIfYes  = false,
description  = "Second stade du brassage."
},  
},
["mature"] = {
["mature"] = {
checkIfYes  = false,
description  = "Troisième stade du brassage."
}
}
}
}


------------------------------------------------
--------------------------------


function buildRow(args, def)
function buildRow(argValue, def)
local note = def.note
local note = argValue or ''
if note then
if note ~= '' then note = LF .. note .. LF end
if type(note) == 'function' then
note = note(args)
end
end
return mw.html.create( 'li' )
return mw.html.create( 'li' )
Ligne 39 : Ligne 29 :
:tag( 'div' )
:tag( 'div' )
:addClass( 'avt-interactions-text' )
:addClass( 'avt-interactions-text' )
:tag( 'p' )
:wikitext(def.description)
:done()
:wikitext( note )
:wikitext( note )
:done()
:tag( 'li' )
:wikitext( '[[Fichier:Icon_range_inverse.png|x50px|center]]' )
:done()
:done()
end
end


function p._build(args)
function p._build(args)
local res = mw.html.create( 'ul' )
local res = mw.html.create( 'ul' )
:addClass( 'avt-interactions' )
:addClass( 'avt-interactions' )
local isEmpty = true
-- on trie les arguments par ordre alphabétique
for key, value in pairs(args) do
local keys = {}
for k, v in pairs(args) do
table.insert(keys, k)
end
table.sort(keys)
local isEmpty = true
for i, key in ipairs(keys) do
argValue = args[key]
local def = data[key:lower()]
local def = data[key:lower()]
if def and (not def.checkIfYes or argValue:lower() == OUI) and argValue ~= '-' then
if def and value ~= '-' and value ~= 'vide' then
isEmpty = false
isEmpty = false
res:node(buildRow(args, def))
res:node(buildRow(value, def))
end
end
end
end
-- cas particulier le pnj n'a aucune interaction
-- cas particulier l'inventaire du pnj est vide
if isEmpty then
if isEmpty then
res:node(buildRow(args, data.aucune))
res:node(buildRow(nil, data.vide))
end
end
Ligne 83 : Ligne 70 :
val = mw.text.trim(val)
val = mw.text.trim(val)
if val ~= '' then
if val ~= '' then
args[cle] = mw.text.trim(val)
args[cle] = val
end
end
end
end
45 246

modifications