Module:PlantDetails

De Eco - Wiki Français
Version datée du 17 novembre 2025 à 19:52 par BuloBon (discussion | contributions) (Page créée avec « local p = {} local Utils = require('Module:Utils') -- Liste simple des plantes / arbres function p.listPlants(frame) local args = Utils.normaliseArgs(frame) return renderPlantList(args.type) end function renderPlantList(plantType) local plantData = require("Module:PlantData") local plantList if plantType == 'Tree' then plantList = plantData.tree_names else plantList = plantData.plant_names end local plants = ''... »)
(diff) ← Version précédente | Version actuelle (diff) | Version suivante → (diff)
Aller à :navigation, rechercher

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

local p = {}

local Utils = require('Module:Utils')

-- Liste simple des plantes / arbres
function p.listPlants(frame)
    local args = Utils.normaliseArgs(frame)
    return renderPlantList(args.type)
end

function renderPlantList(plantType)
    local plantData = require("Module:PlantData")
    local plantList
    if plantType == 'Tree' then
        plantList = plantData.tree_names
    else
        plantList = plantData.plant_names
    end

    local plants = ''
    for _, plant in ipairs(plantList) do
        plants = plants .. "* [[" .. plant .. "]]\n"
    end
    return plants
end


-- Détails d'une plante
function p.main(frame)
    local args = Utils.normaliseArgs(frame)

    if args.plant == nil or args.plant == '' then
        return "Erreur : le paramètre 'plant' doit être spécifié."
    end
	
    local plant = args.plant

    local plantData = require("Module:PlantData")
    local plantTable = plantData.plants[plant]
    if plantTable == nil then
		return "Erreur : **" .. plant .. "** n’a pas été trouvé dans [[Module:PlantData]]."
	end    

	local wikibox = '=== Propriétés de la plante ===\n'
	
	if plantTable.isDecorative == 'Decorative' then
		wikibox = wikibox .. "Cette plante est uniquement **décorative**.\n"
	end
	if plantTable.isWater == 'Underwater' then
		wikibox = wikibox .. "Cette plante **pousse sous l’eau**.\n"
	end
	if plantTable.scytheKills == 'Yes' then
		wikibox = wikibox .. "La [[Faux]] ou la [[Serpe]] **détruit la plante** lors de la récolte.\n"
	end
	
	wikibox = wikibox .. '\n=== Conditions environnementales ===\n'
	wikibox = wikibox .. '{| class="wikitable"\n'

	-- Température
	wikibox = wikibox .. '| rowspan="4" | Température\n'
	wikibox = wikibox .. '| Minimum idéal : ' .. plantTable.idealTempMin .. '\n'
	wikibox = wikibox .. '| rowspan="2" | Plage idéale : intervalle où la plante pousse normalement sans pénalité.\n'
	wikibox = wikibox .. '|-\n| Maximum idéal : ' .. plantTable.idealTempMax .. '\n'
	wikibox = wikibox .. '|-\n| Minimum extrême : ' .. plantTable.extremeTempMin .. '\n'
	wikibox = wikibox .. '| rowspan="2" | Plage extrême : croissance fortement réduite. En dehors de cette plage, la plante ne survit pas.\n'
	wikibox = wikibox .. '|-\n| Maximum extrême : ' .. plantTable.extremeTempMax .. '\n'

	-- Humidité
	wikibox = wikibox .. '|-\n| rowspan="4" | Humidité\n'
	wikibox = wikibox .. '| Minimum idéal : ' .. plantTable.idealMoistureMin .. '\n'
	wikibox = wikibox .. '| rowspan="2" | Plage idéale d’humidité.\n'
	wikibox = wikibox .. '|-\n| Maximum idéal : ' .. plantTable.idealMoistureMax .. '\n'
	wikibox = wikibox .. '|-\n| Minimum extrême : ' .. plantTable.extremeMoistureMin .. '\n'
	wikibox = wikibox .. '| rowspan="2" | Plage extrême d’humidité.\n'
	wikibox = wikibox .. '|-\n| Maximum extrême : ' .. plantTable.extremeMoistureMax .. '\n'

	-- Sel
	wikibox = wikibox .. '|-\n| rowspan="4" | Salinité\n'
	wikibox = wikibox .. '| Minimum idéal : ' .. plantTable.idealSaltMin .. '\n'
	wikibox = wikibox .. '| rowspan="2" | Plage idéale de salinité.\n'
	wikibox = wikibox .. '|-\n| Maximum idéal : ' .. plantTable.idealSaltMax .. '\n'
	wikibox = wikibox .. '|-\n| Minimum extrême : ' .. plantTable.extremeSaltMin .. '\n'
	wikibox = wikibox .. '| rowspan="2" | Plage extrême de salinité.\n'
	wikibox = wikibox .. '|-\n| Maximum extrême : ' .. plantTable.extremeSaltMax .. '\n'

	-- Sol
	wikibox = wikibox .. '|-\n| rowspan="4" | Conditions du sol\n'
	wikibox = wikibox .. '| Azote minimum : ' .. (plantTable.nitrogenHalfSpeed or "Aucun") .. '\n'
	wikibox = wikibox .. '| rowspan="4" | Si un nutriment passe sous ce seuil, la croissance est réduite de moitié.\n'
	wikibox = wikibox .. '|-\n| Phosphore minimum : ' .. (plantTable.phosphorusHalfSpeed or "Aucun") .. '\n'
	wikibox = wikibox .. '|-\n| Potassium minimum : ' .. (plantTable.potassiumHalfSpeed or "Aucun") .. '\n'
	wikibox = wikibox .. '|-\n| Humidité du sol min. : ' .. (plantTable.soilMoistureHalfSpeed or "Aucun") .. '\n'
	wikibox = wikibox .. '|}\n\n'

	-- Récolte
	wikibox = wikibox .. '=== Récolte ===\n'
	wikibox = wikibox .. '{| class="wikitable"\n'
	wikibox = wikibox .. '|-\n| rowspan="3" | Croissance\n'
	wikibox = wikibox .. '| Maturité en : ' .. plantTable.maturity .. ' jours\n'
	wikibox = wikibox .. '| Durée nécessaire avant récolte.\n'
	wikibox = wikibox .. '|-\n| Récoltable à : ' .. plantTable.pickableAtPercent .. '%\n'
	wikibox = wikibox .. '| Pourcentage minimum pour récolter.\n'

	if plantTable.killOnHarvest == 'Yes' then
		wikibox = wikibox .. '|-\n| Récolte fatale\n'
		wikibox = wikibox .. '| La plante doit être replantée avec des graines après récolte.\n'
	else
		wikibox = wikibox .. '|-\n| Renvoie à : ' .. plantTable.postHarvestGrowth .. '%\n'
		wikibox = wikibox .. '| Pourcentage de croissance après récolte.\n'
	end

	wikibox = wikibox .. '|-\n| rowspan="3" | Rendement\n'
	wikibox = wikibox .. '| Minimum : ' .. plantTable.resourceMin .. '\n'
	wikibox = wikibox .. '| Rendement le plus bas.\n'
	wikibox = wikibox .. '|-\n| Maximum : ' .. plantTable.resourceMax .. '\n'
	wikibox = wikibox .. '| Rendement maximal.\n'
	wikibox = wikibox .. '|-\n| Bonus à : ' .. plantTable.resourceBonus .. '%\n'
	wikibox = wikibox .. '| Pourcentage où un bonus s’applique.\n'
	wikibox = wikibox .. '|}\n\n'

	-- Effets sur l'environnement
	wikibox = wikibox .. '=== Effets environnementaux ===\n'
	wikibox = wikibox .. '{| class="wikitable"\n'
	wikibox = wikibox .. '| rowspan="4" | Nutriments absorbés\n'
	wikibox = wikibox .. '| Azote : ' .. (plantTable.nitrogenContent or "Aucun") .. '\n'
	wikibox = wikibox .. '| rowspan="4" | Nutriments absorbés par une plante adulte.\n'
	wikibox = wikibox .. '|-\n| Phosphore : ' .. (plantTable.phosphorusContent or "Aucun") .. '\n'
	wikibox = wikibox .. '|-\n| Potassium : ' .. (plantTable.potassiumContent or "Aucun") .. '\n'
	wikibox = wikibox .. '|-\n| Humidité du sol : ' .. (plantTable.soilMoistureContent or "Aucun") .. '\n'

	wikibox = wikibox .. '|-\n| rowspan="4" | Espace requis\n'
	wikibox = wikibox .. '| Sol fertile : ' .. (plantTable.consumedFertileGround or "Aucun") .. '\n'
	wikibox = wikibox .. '| rowspan="4" | Espace occupé par chaque plante.\n'
	wikibox = wikibox .. '|-\n| Sol fertile sous-marin : ' .. (plantTable.consumedUnderwaterFertileGround or "Aucun") .. '\n'
	wikibox = wikibox .. '|-\n| Espace arbustif : ' .. (plantTable.consumedShrubSpace or "Aucun") .. '\n'
	wikibox = wikibox .. '|-\n| Espace du couvert forestier : ' .. (plantTable.consumedCanopySpace or "Aucun") .. '\n'
	wikibox = wikibox .. '|}\n\n'

	return wikibox
end

return p