Fandom

Civilization

Module:Data/Col

< Module:Data

6,977pages on
this wiki
Add New Page
Talk0

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

local utils = require("Module:TemplateUtils")
--Sub pages : 
--/Buildings
--/Fathers
--/Units
--/Goods
--/Tribes
--/Resources
--/Terrain
 
local p = {}
 
 --Templates
local buildingrow = [[|-
|%s
|%s
|%s
|%s
|%s
]]
 
local fatherrow = [[|-
|%s
|%s
|%s
]]
 
local unitrow= [[|-
|%s
|%s
|%s
|%s
|%s
|%s
]]
 
local resourcerow = [[|-
|%s
|%s
|%s
|%s
]]
 
local terrainrow = [[|-
|%s
|%s
|%s
|%s
|%s
|%s
|%s
|%s
|%s
|%s
|%s
|%s
|%s
]]
 
local fatherpage = [=[<div class="container-with-margins" style="float:right; max-width:402px; clear:right;">
{| class="wikitable" style="margin:0;"
|+<big><big>'''%s'''</big></big>
|colspan="2" align="center"|%s
|-
! align="left"|Type
|%s
|-
!colspan="2" align="center"|Notes
|-
|colspan="2"|
%s
|}</div>
{{BackArrow|Founding Fathers (Col)|See the list of founding fathers}}{{#if:{{NAMESPACE}} | |[[Category:Founding Fathers (Col)]]}}]=]
 
local goodpage = [=[<div class="container-with-margins" style="float:right; max-width:402px; clear:right;">
{| class="wikitable" style="margin:0;"
|+<big><big>'''%s'''</big></big>
|colspan="2" align="center"|%s
|-
! align="left"|Made into
|%s
|-
! align="left"|Made from
|%s
|-
!colspan="2" align="center"|Notes
|-
|colspan="2"|
%s
|}</div>
{{BackArrow|Goods|Goods}}{{#if:{{NAMESPACE}} | |[[Category:Goods (Col)]]}}]=]
 
local tribepage = [=[<div class="container-with-margins" style="float:right; max-width:402px; clear:right;">
{| class="wikitable" style="margin:0;"
|+<big><big>'''%s'''</big></big>
|colspan="2" align="center"|%s
|-
|align="center"|%s
|align="center"|%s
|-
! align="left"|Type
|%s
|-
! align="left"|Common skills
|%s
|-
! align="left"|Rare skills
|%s
|}</div>
{{BackArrow|Indians (Col)|See the list of tribes}}{{#if:{{NAMESPACE}} | |[[Category:Civilizations (Col)]]}}]=]
 
local terrainpage = [=[<div class="container-with-margins" style="float:right; max-width:402px; clear:right;">
{| class="wikitable" style="margin:0;"
|+<big><big>'''%s'''</big></big>
|colspan="2" align="center"|%s
|-
! align="left"|[[Food (Col)|Food]] yield
|%s
|-
! align="left"|Movement cost
|%s
|-
! align="left"|Defense bonus
|%s
|-
! align="left"|[[Tobacco (Col)|Tobacco]] yield
|%s
|-
! align="left"|[[Cotton (Col)|Cotton]] yield
|%s
|-
! align="left"|[[Sugar (Col)|Sugar]] yield
|%s
|-
! align="left"|[[Furs (Col)|Furs]] yield
|%s
|-
! align="left"|[[Lumber (Col)|Lumber]] yield
|%s
|-
! align="left"|[[Ore (Col)|Ore]] yield
|%s
|-
! align="left"|[[Silver (Col)|Silver]] yield
|%s
|-
! align="left"|Bonus resource
|%s
|-
!colspan="2" align="center"|Notes
|-
|colspan="2"|
%s
|}</div>
{{BackArrow|Terrain (Col)|Terrain article}}{{#if:{{NAMESPACE}} | |[[Category:Terrain (Col)]]}}]=]
 
 
--Utility functions
local function Link(s)
	return "[["..s.." (Col)|"..s.."]]"
end
 
local function LinkAll(t)
	local s = ""
	local first = true
	for k,v in pairs(t) do
		s = s..(first and "" or "<br/>")..Link(v)
		first = false
	end
	return s
end
 
local function attackicon(d)
        local s =""
 
        if d then
            s = "{{tooltip|{{MusketCol}}|This unit can initiate attacks.}}"
        else
            s = "{{tooltip|{{NoMusketCol}}|This unit can only defend.}}"
        end
        return s
end
 
local function unitrowvariables(data)
        local s =""
 
        if data.hammers then
            s = s..(data.hammers or "0").." {{HammerCol}}<br>"..(data.tools or "0").." {{ToolCol}}"
        else
            s = s..(data.train or "N/A")
        end
        return s
end
 
 --Public functions
function p.GetBuildingRow(frame)
	local displayname = frame.args[1]
	local name = string.gsub(displayname , " %(.*","")
	local data = mw.loadData("Module:Data/Col/Buildings")
	local building = data[name]
 
	return frame:preprocess(string.format(buildingrow,
	"[[Image:"..displayname.." (Col).png|60px|link="..displayname.." (Col)]]",
	"[["..displayname.." (Col)|"..name.."]]",
	building.reqbuilding or "None",
	building.reqpop or "None",
	(building.hammers or "0").." {{HammerCol}}<br>"..(building.tools or "0").." {{ToolCol}}"))
end
 
local buildingPageTemplate = [=[<infobox>
    <title><default>%s</default></title>
    <image><default>%s.png</default></image>
    <data><label>Required building</label>
        <default>%s</default></data>
    <data><label>Required population</label>
        <default>%s</default></data>
    <data><label>{{HammerCol}} [[Hammer (Col)|Hammers]] required</label>
        <default>%s</default></data>
    <data><label>{{ToolCol}} [[Tools (Col)|Tools]] required</label>
        <default>%s</default></data>
    <data><label>Notes</label>
        <default>%s</default></data>
</infobox>]=]
 
function p.GetBuildingPage(frame, articlename)
	local PAGENAME = articlename or mw.title.getCurrentTitle().text
	local name = string.gsub(PAGENAME, " %(.*","")
	local data = mw.loadData("Module:Data/Col/Buildings")[name]
	return utils.PreProcess(frame,string.format(buildingPageTemplate,
	    name,
	    PAGENAME,
	    data["reqbuilding"] or "None",
	    data["reqpop"] or 0,
	    data["hammers"] or 0,
	    data["tools"] or 0,
	    data["notes"] or "None"))
end
 
function p.GetBuildingData(frame, articlename, key)
    local PAGENAME = articlename or frame.args[1]
    local key = key or frame.args[2]
	local name = string.gsub(PAGENAME, " %(.*","")
	local data = mw.loadData("Module:Data/Col/Buildings")[name]
 
    for k,value in pairs(data) do 
        if k == key then
            if type(value) == "table" then
                return LinkAll(value)
            else
                return value
            end
        end
    end
    return ""
end
 
function p.GetFatherRow(frame)
	local displayname = frame.args[1]
	local name = string.gsub(displayname , " %(.*","")
	local data = mw.loadData("Module:Data/Col/Fathers")
	local tech = data[name]
 
	return frame:preprocess(string.format(fatherrow,
	"[[Image:"..displayname.." (Col).png|64px|link="..displayname.." (Col)]]",
	"[["..displayname.." (Col)|"..name.."]]",
	tech.type or "None"))
end
 
function p.GetFatherPage(frame)
	local PAGENAME = mw.title.getCurrentTitle().text
	local name = string.gsub(PAGENAME, " %(.*","")
	local data = mw.loadData("Module:Data/Col/Fathers")
	local tech = data[name]
 
	return frame:preprocess(string.format(fatherpage,
	name,
	"[[Image:"..PAGENAME..".png]]",
	tech.type or "None",
	tech.notes or "None"))
end
 
function p.GetGoodPage(frame)
	local PAGENAME = mw.title.getCurrentTitle().text
	local name = string.gsub(PAGENAME, " %(.*","")
	local data = mw.loadData("Module:Data/Col/Goods")
	local tech = data[name]
 
	return frame:preprocess(string.format(goodpage,
	name,
	"[[Image:"..PAGENAME..".png]]",
	tech.madeinto and Link(tech.madeinto) or "None",
	tech.madefrom and Link(tech.madefrom) or "None",
	tech.notes or "None"))
end
 
function p.GetTribePage(frame)
	local PAGENAME = mw.title.getCurrentTitle().text
	local name = string.gsub(PAGENAME, " %(.*","")
	local data = mw.loadData("Module:Data/Col/Tribes")
	local tech = data[name]
 
	return frame:preprocess(string.format(tribepage,
	name,
	"[[Image:"..PAGENAME..".png]]",
	"[[Image:"..name.." Braves (Col).png]]",
	"[[Image:"..name.." settlement (Col).png]]",
	tech.trait or "None",
	tech.skills1 and LinkAll(tech.skills1) or "None",
	tech.skills2 and LinkAll(tech.skills2) or "None"))
end
 
function p.GetUnitRow(frame)
	local displayname = frame.args[1]
	local name = string.gsub(displayname, " %(.*","")
	local data = mw.loadData("Module:Data/Col/Units")
	local unit = data[name]
 
	return frame:preprocess(string.format(unitrow,
	"[[Image:"..displayname.." (Col).png|48px|link="..displayname.." (Col)]]",
	"[["..displayname.." (Col)|"..name.."]]",
	unit.reqbuilding and Link(unit.reqbuilding) or "None",
        unitrowvariables(unit),
	unit.combat or "0",
	unit.moves or "None"))
end
 
function p.GetUnitData(frame, articlename, key)
    local PAGENAME = articlename or frame.args[1]
    local key = key or frame.args[2]
	local name = string.gsub(PAGENAME, " %(.*","")
	local data = mw.loadData("Module:Data/Col/Units")[name]
 
    for k,value in pairs(data) do 
        if k == key then
            if type(value) == "table" then
                return LinkAll(value)
            else
                return value
            end
        end
    end
    return ""
end
 
function p.GetResourceRow(frame)
	local displayname = frame.args[1]
	local name = string.gsub(displayname , " %(.*","")
	local data = mw.loadData("Module:Data/Col/Resources")
	local resource = data[name]
 
	return frame:preprocess(string.format(resourcerow,
	"[[Image:"..displayname.." (Col).png|32px|link="..displayname.." (Col)]]",
	"[["..displayname.." (Col)|"..name.."]]",
	resource.found and LinkAll(resource.found) or "None",
	resource.tilebonus and resource.tilebonus or "None"))
end
 
local resourcePageTemplate = [=[<infobox>
    <title><default>%s</default></title>
    <image><default>%s.png</default></image>
    <data><label>Found in</label>
        <default>%s</default></data>
    <data><label>Tile bonus</label>
        <default>%s</default></data>
</infobox>]=]
 
function p.GetResourcePage(frame)
	local PAGENAME = mw.title.getCurrentTitle().text
	local name = string.gsub(PAGENAME, " %(.*","")
	local data = mw.loadData("Module:Data/Col/Resources")[name]
 
	return frame:preprocess(string.format(resourcePageTemplate,
	name,
	"[[Image:"..PAGENAME..".png|100px]]",
	data.found and LinkAll(data.found) or "None",
	data.tilebonus or "None"))
end
 
function p.GetTerrainRow(frame)
	local displayname = frame.args[1]
	local name = string.gsub(displayname , " %(.*","")
	local data = mw.loadData("Module:Data/Col/Terrain")
	local terrain = data[name]
 
	return frame:preprocess(string.format(terrainrow,
	"[[Image:"..displayname.." (Col).png|32px|link="..displayname.." (Col)]]",
	"[["..displayname.." (Col)|"..name.."]]",
	terrain.food or "0",
	terrain.move or "None",
	terrain.defense or "None",
	terrain.tobacco or "0",
	terrain.cotton or "0",
	terrain.sugar or "0",
	terrain.furs or "0",
	terrain.lumber or "0",
	terrain.ore or "0",
	terrain.silver or "0",
	terrain.resource and Link(terrain.resource) or "None"))
end
 
function p.GetTerrainPage(frame)
	local PAGENAME = mw.title.getCurrentTitle().text
	local name = string.gsub(PAGENAME, " %(.*","")
	local data = mw.loadData("Module:Data/Col/Terrain")[name]
 
	return frame:preprocess(string.format(terrainpage,
	name,
	"[[Image:"..PAGENAME..".png|96px]]",
	data.food or "0",
	data.move or "None",
	data.defense or "None",
	data.tobacco or "0",
	data.cotton or "0",
	data.sugar or "0",
	data.furs or "0",
	data.lumber or "0",
	data.ore or "0",
	data.silver or "0",
	data.resource and Link(data.resource) or "None",
	data.notes or "None"))
end
 
 
return p

Also on Fandom

Random Wiki