Module:Collection

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

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

local p = {}

local Boite = {}
Boite["UBISWX01"] = {
	titre = "X-wing Le jeu de figurine",
	vaisseaux = {
		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,
	},
}
Boite["UBISWX13"] = {
	titre = "Navette de classe Lambda Paquet d'extension",
	vaisseaux = {
		navetteclasselambda = 1,
	},
}
Boite["UBISWX14"] = {
	titre = "B-wing Paquet d'extension",
	vaisseaux = {
		bwing = 1,
	},
}
Boite["UBISWX15"] = {
	titre = "Bombardier Tie Paquet d'extension",
	vaisseaux = {
		bombardiertie = 1,
	},
}

local Vaisseau = {}
Vaisseau["chasseurtie"] = {
        nom = "Chasseur Tie",
        icone = "{{Chasseur tie icone}}",
        lien = "[[Chasseur Tie]]",
}

local FabListe = {
"UBISWX01",
"UBISWX36",
"UBISWX02",
"UBISWX03",
"UBISWX04",
"UBISWX05",
"UBISWX06",
"UBISWX07",
"UBISWX08",
"UBISWX09",
"UBISWX12",
"UBISWX13",
"UBISWX14",
"UBISWX15",
}

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

function p.vaisseau(frame)
    local fabSelectStr = trim(frame.args[1]) or ""
    fabSelectTab={}
    fabSelectStr:gsub(".",function(c) table.insert(fabSelectTab,c) end)
    local vaissCollecTab={}
    retour = "Ma collection de boite : <br/>"
    for i, v in ipairs (fabSelectTab) do
        if fabSelectTab[i] ~= nil then
            if FabListe[i] ~= nil then
                if Boite[FabListe[i]] ~= nil then
                    retour = retour .. "* " .. Boite[FabListe[i]].titre .. " x " .. fabSelectTab[i] .. "<br/>"
                    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
    retour = retour .. "Ma collection de vaisseau : <br/>"
    for k, v in pairs (vaissCollecTab) do
        retour = retour .. "* " .. k .. " x " .. v .. "<br/>"
    end
    return retour
end
return p