Module:Donnees jeu : Différence entre versions

De X-Wing 2.0 - Le wiki des figurines
Aller à : navigation, rechercher
Ligne 37 : Ligne 37 :
 
                 return typeCarteStr .. " - " .. typeAmeliorationStr .. " - " .. formationStr .. " - " .. nomCarteStr.. " - " .. typeDonnees .. " : non défini [[Catégorie:Données de jeu manquantes]]"
 
                 return typeCarteStr .. " - " .. typeAmeliorationStr .. " - " .. formationStr .. " - " .. nomCarteStr.. " - " .. typeDonnees .. " : non défini [[Catégorie:Données de jeu manquantes]]"
 
             end
 
             end
             return Data[typeCarteStr][typeAmeliorationStr][formationStr][nomCarteStr][typeDonnees]
+
             return Data[typeCarteStr][typeAmeliorationStr][formationStr][nomCarteStr][typeDonnees] .. "<ref>Données en version 1.2 (janvier 2019)</ref>"
 
         end
 
         end
 
         if Data[typeCarteStr][nomCarteStr] == nil then
 
         if Data[typeCarteStr][nomCarteStr] == nil then

Version du 18 mars 2019 à 11:55

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

local p = {}

local Data = mw.loadData('Module:Donnees jeu/Data')
local AmeliorationType = mw.loadData('Module:Donnees jeu/AmeliorationType')

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

function p.affichage(frame)
    local typeCarteStr = trim(frame.args[1]) or ""
    local nomCarteStr = trim(frame.args[2]) or ""
    local typeDonnees = trim(frame.args[3]) or "Cout"
    local formationStr = ""
    local typeAmeliorationStr = ""
    if typeCarteStr == "Amelioration" then
        typeAmeliorationStr = nomCarteStr
        formationStr = typeDonnees
        nomCarteStr = trim(frame.args[4]) or ""
        typeDonnees = trim(frame.args[5]) or ""
    end
    if typeDonnees == "Cout" then
        if Data[typeCarteStr] == nil then
            return typeCarteStr .. " : non défini [[Catégorie:Données de jeu manquantes]]"
        end
        if typeCarteStr == "Amelioration" then
            if Data[typeCarteStr][typeAmeliorationStr] == nil then
                return typeCarteStr .. " - " .. typeAmeliorationStr .. " : non défini [[Catégorie:Données de jeu manquantes]]"
            end
            if Data[typeCarteStr][typeAmeliorationStr][formationStr] == nil then
                return typeCarteStr .. " - " .. typeAmeliorationStr .. " - " .. formationStr .. " : non défini [[Catégorie:Données de jeu manquantes]]"
            end
            if Data[typeCarteStr][typeAmeliorationStr][formationStr][nomCarteStr] == nil then
                return typeCarteStr .. " - " .. typeAmeliorationStr .. " - " .. formationStr .. " - " .. nomCarteStr.. " : non défini [[Catégorie:Données de jeu manquantes]]"
            end
            if Data[typeCarteStr][typeAmeliorationStr][formationStr][nomCarteStr][typeDonnees] == nil then
                return typeCarteStr .. " - " .. typeAmeliorationStr .. " - " .. formationStr .. " - " .. nomCarteStr.. " - " .. typeDonnees .. " : non défini [[Catégorie:Données de jeu manquantes]]"
            end
            return Data[typeCarteStr][typeAmeliorationStr][formationStr][nomCarteStr][typeDonnees] .. "<ref>Données en version 1.2 (janvier 2019)</ref>"
        end
        if Data[typeCarteStr][nomCarteStr] == nil then
            return typeCarteStr .. " - " .. nomCarteStr .. " : non défini [[Catégorie:Données de jeu manquantes]]"
        end
        if Data[typeCarteStr][nomCarteStr][typeDonnees] == nil then
            return typeCarteStr .. " - " .. nomCarteStr .. " - " .. typeDonnees .. " : non défini [[Catégorie:Données de jeu manquantes]]"
        end
        return Data[typeCarteStr][nomCarteStr][typeDonnees] .. "<ref>Données en version 1.2 (janvier 2019)</ref>"
    end
    if typeDonnees == "Amelioration" then
        retour = "== Améliorations ==\n"
        if Data[typeCarteStr] == nil then
            return typeCarteStr .. " : non défini"
        end
        if Data[typeCarteStr][nomCarteStr] == nil then
            return typeCarteStr .. " - " .. nomCarteStr .. " : non défini [[Catégorie:Données de jeu manquantes]]"
        end
        if Data[typeCarteStr][nomCarteStr][typeDonnees] == nil then
            return typeCarteStr .. " - " .. nomCarteStr .. " - " .. typeDonnees .. " : non défini [[Catégorie:Données de jeu manquantes]]"
        end
        for k, a in pairs (Data[typeCarteStr][nomCarteStr][typeDonnees]) do
            retour = retour .. "* " .. AmeliorationType[k].icone .. " " .. AmeliorationType[k].lien .. " x " .. a .. "\n"
        end
        if retour == "== Améliorations ==\n" then
            retour = retour .. "* Aucune\n"
        end
        retour = retour .. "<ref>Données en version 1.2 (janvier 2019)</ref>\n"
        return retour
    end
end
return p