Module:Collection/Affichage

De X-Wing - Le wiki des figurines
Aller à : navigation, rechercher

La documentation pour ce module peut être créée à Module:Collection/Affichage/doc

local p = {}

local Boite = mw.loadData('Module:Collection/Boite')
local Vaisseau = mw.loadData('Module:Collection/Vaisseau')

local Faction = {}
Faction[1] = {
        nom = "Alliance rebelle",
        icone = mw.getCurrentFrame():expandTemplate({ title = 'Alliance rebelle logo', args = {} }),
}
Faction[2] = {
        nom = "Empire galactique",
        icone = mw.getCurrentFrame():expandTemplate({ title = 'Empire galactique logo', args = {} }),
}
Faction[3] = {
        nom = "Racails et scélérats",
        icone = mw.getCurrentFrame():expandTemplate({ title = 'Racailles scelerats logo', args = {} }),
}
Faction[4] = {
        nom = "Résistance",
        icone = mw.getCurrentFrame():expandTemplate({ title = 'La resistance logo', args = {} }),
}
Faction[5] = {
        nom = "Premier Ordre",
        icone = mw.getCurrentFrame():expandTemplate({ title = 'Premier ordre logo', args = {} }),
}

function p.affichageVaisseauListe(vaissCollecTab, affIfZero)
    retour = ""
    for k, v in pairs (vaissCollecTab) do
        if (v ~= 0) or (affIfZero == "true") then
            if Vaisseau[k] ~= nil then
                retour = retour .. "* " .. Vaisseau[k].lien .. " x " .. v .. "\n"
            end
        end
    end

    return retour
end

function p.affichageVaisseauByFaction(vaissCollecTab, affIfZero)
    retour = ""
    for kFac, vFac in pairs (Faction) do
        affLogoFac = false
        for kVai, vVai in pairs (vaissCollecTab) do
            if Vaisseau[kVai] ~= nil then
                if ((vVai ~= 0) or (affIfZero == "true")) and (Vaisseau[kVai].factiondefaut == vFac.nom) then
                    if affLogoFac == false then
                        affLogoFac = true
                        retour = retour .. vFac.icone .." "
                    end
                    retour = retour .. "[[" .. Vaisseau[kVai].nom .. "|" .. Vaisseau[kVai].icone .. "]] x " .. vVai .. " "
                end
            end
        end
        retour = retour .. "\n\n"
    end

    return retour
end

return p