Module:Collection : Différence entre versions

De X-Wing - Le wiki des figurines
Aller à : navigation, rechercher
m (46 révisions importées)
 
(33 révisions intermédiaires par le même utilisateur non affichées)
Ligne 1 : Ligne 1 :
 
local p = {}
 
local p = {}
  
local Boite = {}
+
local Boite = mw.loadData('Module:Collection/Boite')
Boite["UBISWX01"] = {
+
local Vaisseau = mw.loadData('Module:Collection/Vaisseau')
titre = "X-wing Le jeu de figurine",
+
local FabListe = mw.loadData('Module:Collection/FabListe')
vaisseaux = {
+
local AffichageModule = require('Module:Collection/Affichage')
xwing = 1,
 
chasseurtie = 2,
 
},
 
}
 
Boite["UBISWX36"] = {
 
titre = "X-wing Le Réveil de la Force",
 
vaisseaux = {
 
xwingt70 = 1,
 
chasseurtiefo = 2,
 
},
 
}
 
Boite["UBISWX02"] = {
 
titre = "X-wing Paquet d'extension",
 
vaisseaux = {
 
xwing = 1,
 
},
 
}
 
Boite["UBISWX03"] = {
 
titre = "Chasseur Tie Paquet d'extension",
 
vaisseaux = {
 
chasseurtie = 1,
 
},
 
}
 
Boite["UBISWX04"] = {
 
titre = "Y-wing Paquet d'extension",
 
vaisseaux = {
 
ywing = 1,
 
},
 
}
 
Boite["UBISWX05"] = {
 
titre = "Tie Advanced Paquet d'extension",
 
vaisseaux = {
 
tieadvanced = 1,
 
},
 
}
 
Boite["UBISWX06"] = {
 
titre = "Faucon Millenium Paquet d'extension",
 
vaisseaux = {
 
yt1300 = 1,
 
},
 
}
 
Boite["UBISWX07"] = {
 
titre = "Slave-1 Paquet d'extension",
 
vaisseaux = {
 
firespray31 = 1,
 
},
 
}
 
Boite["UBISWX08"] = {
 
titre = "A-wing Paquet d'extension",
 
vaisseaux = {
 
awing = 1,
 
},
 
}
 
Boite["UBISWX09"] = {
 
titre = "Intercepteur Tie Paquet d'extension",
 
vaisseaux = {
 
intercepteurtie = 1,
 
},
 
}
 
Boite["UBISWX12"] = {
 
titre = "HWK-290 Paquet d'extension",
 
vaisseaux = {
 
hwk290 = 1,
 
},
 
}
 
  
local FabListe = {
+
function trim(s)
"UBISWX01",
+
  return (string.gsub(s, "^%s*(.-)%s*$", "%1"))
"UBISWX36",
+
end
"UBISWX02",
+
 
"UBISWX03",
+
function p.boite(frame)
"UBISWX04",
+
    local fabSelectStr = trim(frame.args[1]) or ""
"UBISWX05",
+
    local affIfZero = trim(frame.args[2]) or false
"UBISWX06",
+
    fabSelectTab={}
"UBISWX07",
+
    fabSelectStr:gsub(".",function(c) table.insert(fabSelectTab,c) end)
"UBISWX08",
+
    retour = ""
"UBISWX09",
+
    for i, v in ipairs (fabSelectTab) do
"UBISWX12",
+
        if fabSelectTab[i] ~= nil then
}
+
            if FabListe[i] ~= nil then
 +
                if Boite[FabListe[i]] ~= nil then
 +
                    if (fabSelectTab[i] ~= "0") or (affIfZero == "true") then
 +
                        retour = retour .. "* [[" .. Boite[FabListe[i]].titre .. "]] x " .. fabSelectTab[i] .. "\n"
 +
                    end
 +
                end
 +
            end
 +
        end
 +
    end
 +
    return retour
 +
end
  
 
function p.vaisseau(frame)
 
function p.vaisseau(frame)
     local fabSelectStr = frame.args[1] or ""
+
     local fabSelectStr = trim(frame.args[1]) or ""
 +
    local affIfZero = trim(frame.args[2]) or false
 +
    local affType = trim(frame.args[3]) or "Faction"
 
     fabSelectTab={}
 
     fabSelectTab={}
 
     fabSelectStr:gsub(".",function(c) table.insert(fabSelectTab,c) end)
 
     fabSelectStr:gsub(".",function(c) table.insert(fabSelectTab,c) end)
     retour = "Ma collection de boite : <br/>"
+
    local vaissCollecTab={}
 +
     retour = ""
 
     for i, v in ipairs (fabSelectTab) do
 
     for i, v in ipairs (fabSelectTab) do
 
         if fabSelectTab[i] ~= nil then
 
         if fabSelectTab[i] ~= nil then
             if FabListe[ i ] ~= nil then
+
             if FabListe[i] ~= nil then
                 retour = retour .. "* " .. FabListe[ i ] .. " x " .. fabSelectTab[i] .. " - i : " .. i .. "<br/>"
+
                 if Boite[FabListe[i]] ~= nil then
 +
                    for k, v in pairs (Boite[FabListe[i]].vaisseaux) do
 +
                        if vaissCollecTab[k] == nil then
 +
                            vaissCollecTab[k] = v * fabSelectTab[i]
 +
                        else
 +
                            vaissCollecTab[k] = vaissCollecTab[k] + (v * fabSelectTab[i])
 +
                        end
 +
                    end
 +
                end
 
             end
 
             end
 
         end
 
         end
 
     end
 
     end
     return retour
+
     if affType == "Liste" then
 +
        return retour .. AffichageModule.affichageVaisseauListe(vaissCollecTab, affIfZero)
 +
    else
 +
        return retour .. AffichageModule.affichageVaisseauByFaction(vaissCollecTab, affIfZero)
 +
    end
 
end
 
end
 
return p
 
return p

Version actuelle datée du 30 août 2018 à 21:50

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

local p = {}

local Boite = mw.loadData('Module:Collection/Boite')
local Vaisseau = mw.loadData('Module:Collection/Vaisseau')
local FabListe = mw.loadData('Module:Collection/FabListe')
local AffichageModule = require('Module:Collection/Affichage')

function trim(s)
  return (string.gsub(s, "^%s*(.-)%s*$", "%1"))
end

function p.boite(frame)
    local fabSelectStr = trim(frame.args[1]) or ""
    local affIfZero = trim(frame.args[2]) or false
    fabSelectTab={}
    fabSelectStr:gsub(".",function(c) table.insert(fabSelectTab,c) end)
    retour = ""
    for i, v in ipairs (fabSelectTab) do
        if fabSelectTab[i] ~= nil then
            if FabListe[i] ~= nil then
                if Boite[FabListe[i]] ~= nil then
                    if (fabSelectTab[i] ~= "0") or (affIfZero == "true") then
                        retour = retour .. "* [[" .. Boite[FabListe[i]].titre .. "]] x " .. fabSelectTab[i] .. "\n"
                    end
                end
            end
        end
    end
    return retour
end

function p.vaisseau(frame)
    local fabSelectStr = trim(frame.args[1]) or ""
    local affIfZero = trim(frame.args[2]) or false
    local affType = trim(frame.args[3]) or "Faction"
    fabSelectTab={}
    fabSelectStr:gsub(".",function(c) table.insert(fabSelectTab,c) end)
    local vaissCollecTab={}
    retour = ""
    for i, v in ipairs (fabSelectTab) do
        if fabSelectTab[i] ~= nil then
            if FabListe[i] ~= nil then
                if Boite[FabListe[i]] ~= nil then
                    for k, v in pairs (Boite[FabListe[i]].vaisseaux) do
                        if vaissCollecTab[k] == nil then
                            vaissCollecTab[k] = v * fabSelectTab[i]
                        else
                            vaissCollecTab[k] = vaissCollecTab[k] + (v * fabSelectTab[i])
                        end
                    end
                end
            end
        end
    end
    if affType == "Liste" then
        return retour .. AffichageModule.affichageVaisseauListe(vaissCollecTab, affIfZero)
    else
        return retour .. AffichageModule.affichageVaisseauByFaction(vaissCollecTab, affIfZero)
    end
end
return p