Fandom

Civilization

Module:Data/CivRev2

< 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.

--Sub pages : 
--/Buildings
--/Techs
--/Units
 
local p = {}
local utils = require("Module:TemplateUtils")
local baseUtils = require("Module:Data")
 
-- Shortcuts for the Linking functions
local function Link(s)
    return utils.Link(s,"CivRev2")
end
 
local function LinkAll(s)
    return utils.LinkAll(s,"CivRev2")
end
 
 --Templates
local buildingrow = [[|-
|%s
|%s
|%s
|%s
|
%s
]]
 
local techrow = [[|-
|%s
|%s
|%s
|%s
|%s
|%s
|%s
]]
 
local unitrow= [[|-
|%s
|%s
|%s
|%s
|%s
|%s
|%s
|%s
|%s
]]
 
local resourcerow = [=[|-
|[[Image:%s (CivRev2).png|32px]]
|[[%s (CivRev2)|%s]]
|%s
|%s
]=]
 
local unittooltip= [=[<span style="float:left">[[File:%s_(CivRev2).png|64px]]</span>'''%s'''<br/>
[[File:Production (CivRev2).png|16px]] %s
[[File:Science (CivRev2).png|16px]] %s<br/>
[[File:%s (CivRev2).png|16px]] %s
[[File:Defense (CivRev2).png|16px]] %s
[[File:Moves (CivRev2).png|16px]] %s
%s]=]
 
function p.GetUnitTooltip(frame, articlename)
	local displayname = articlename or frame.args[1]
	local name = string.gsub(displayname, " %(.*","")
	local data = mw.loadData("Module:Data/CivRev2/Units")
	local unit = data[name]
 
	return utils.PreProcess(frame,string.format(unittooltip,
	displayname,
	displayname,
	unit.cost or "0",
	unit.reqtech and unit.reqtech or "None",
	unit.ranged and "Ranged" or "Attack",
	unit.attack or unit.ranged or "0",
	unit.defense or "0",
	unit.moves or "0",
        unit.navalsupport and "NS "..unit.navalsupport or ""))
end
 
local unitpage = [=[<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"| Technology required
|%s
|-
! align="left"|Cost
|%s
|-
! align="left"|Attack/Defense
|%s
|-
! align="left"|Ranged attack
|%s
|-
! align="left"|Naval support
|%s
|-
! align="left"|Moves
|%s
|-
! align="left"|Lineage
|%s
|-
!colspan="2" align="center"|Notes
|-
|colspan="2"|
%s
|}</div>
{{BackArrow|List of units in CivRev2|Back to the list of units}}{{#if:{{NAMESPACE}} | |[[Category:Units (CivRev2)]]}}]=]
 
local buildingpage = [=[<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"| Technology required
|%s
|-
! align="left"|Cost
|%s
|-
!colspan="2" align="center"|Effect
|-
|colspan="2"|
%s
|}</div>
{{BackArrow|List of buildings in CivRev2|Back to the list of buildings}}{{#if:{{NAMESPACE}} | |[[Category:Buildings (CivRev2)]]}}]=]
 
local wonderpage = [=[<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<br/>
A Wonder in ''[[Civilization Revolution 2]]''
|-
! align="left"|Cost
|%s
|-
! align="left"| Technology required
|%s
|-
! align="left"| Obsoleted by
|%s
|-
!colspan="2" align="center"|Effect
|-
|colspan="2"|
%s
|}</div>
{{BackArrow|List of wonders in CivRev2|Back to the list of wonders}}{{#if:{{NAMESPACE}} | |[[Category:Wonders (CivRev2)]]}}]=]
 
local leaderpage = [=[<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<br/>
Leader of the %s in ''[[Civilization Revolution 2]]''
|-
!colspan="2" align="center"|Era Bonuses
|-
! align="left"|Ancient
| %s
|-
! align="left"|Medieval
| %s
|-
! align="left"|Industrial
| %s
|-
! align="left"|Modern
| %s
|}</div>
{{BackArrow|List of leaders in CivRev2|Back to the list of leaders}}{{#if:{{NAMESPACE}} | |[[Category:Leaders (CivRev2)]]}}]=]
 
local civpage = [=[<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"|<br/>
A civilization in ''[[Civilization Revolution 2]]''
|-
!colspan="2" align="center"|Era Bonuses
|-
! align="left"|Leaders
| %s
|-
! align="left"|Begin the game with
| %s
|}</div>
{{BackArrow|List of civilizations in CivRev2|Back to the list of civilizations}}{{#if:{{NAMESPACE}} | |[[Category:Civilizations (CivRev2)]]}}]=]
 
local resourcepage = [=[<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"| [[Image:%s (CivRev2).png|120px|%s]] <br/>
A resource in ''[[Civilization Revolution 2]]''
|-
! align="left"|Technology required
| %s
|-
! align="left"|Boosts<br/><small>(When worked)</small>
| %s
|}</div>
{{BackArrow|List of resources in CivRev2|Back to the list of resources}}{{#if:{{NAMESPACE}} | |[[Category:Resources (CivRev2)]]}}]=]
 
--Utility functions
local function GetTechLeadsTo(data, name)
	local leadsto = {}
	for k,v in pairs(data) do
		if v.reqtech then
			for i,j in pairs(v.reqtech) do
				if j == name then table.insert(leadsto,k) end
			end
		end
	end
	return leadsto
end 
 
 
function p.GetTechLeadsTo(frame)
    return LinkAll(GetTechLeadsTo(mw.loadData("Module:Data/CivRev2/Techs"), frame.args[1]))
end
 
 
local function GetLeadersForCiv(name)
	return baseUtils.SelectAllKeysFromWhere(mw.loadData("Module:Data/CivRev2/Leaders"), "civ", name)
end 
 
local function BuildingNotes(building)
	local s = ""
	if building.upgrade then
		s = "'''Upgrades to '''"..Link(building.upgrade).."<br/>"
	elseif building.reqbuilding then
		s = "'''Requires '''"..Link(building.reqbuilding).."<br/>"
	end
	return s..building.notes
end
 --Public functions
function p.GetBuildingRow(frame, articlename)
	local displayname = articlename or frame.args[1]
	local name = string.gsub(displayname , " %(.*","")
	local data = mw.loadData("Module:Data/CivRev2/Buildings")
	local building = data[name]
 
	return utils.PreProcess(frame,string.format(buildingrow,
	"[[Image:"..displayname.." (CivRev2).png|64px|link="..displayname.." (CivRev2)]]",
	"[["..displayname.." (CivRev2)|"..name.."]]",
	building.reqtech and Link(building.reqtech) or "None",
	building.cost and building.cost or "None",
	BuildingNotes(building)))
end
 
function p.GetBuildingPage(frame, articlename)
	local PAGENAME = articlename or mw.title.getCurrentTitle().text
	local name = string.gsub(PAGENAME, " %(.*","")
	local data = mw.loadData("Module:Data/CivRev2/Buildings")[name]
 
	return utils.PreProcess(frame,string.format(buildingpage,
	name,
	"[[Image:"..PAGENAME..".png|120px]]",
	data.reqtech and Link(data.reqtech) or "None",
	data.cost and data.cost or "None",
	BuildingNotes(data)))
end
 
function p.GetWonderPage(frame, articlename)
	local PAGENAME = articlename or mw.title.getCurrentTitle().text
	local name = string.gsub(PAGENAME, " %(.*","")
	local data = mw.loadData("Module:Data/CivRev2/Wonders")[name]
 
	return utils.PreProcess(frame,string.format(wonderpage,
	name,
	"[[Image:"..PAGENAME..".png|120px]]",
	data.cost and data.cost or "N/A",
	data.reqtech and Link(data.reqtech) or "N/A",
	data.obsoletes and Link(data.obsoletes) or "None",
	data.effect))
end
 
function p.GetTechRow(frame, articlename)
	local displayname = articlename or frame.args[1]
	local name = string.gsub(displayname , " %(.*","")
	local data = mw.loadData("Module:Data/CivRev2/Techs")
	local tech = data[name]
 
	local leadsto = GetTechLeadsTo(data,name)
 
	return utils.PreProcess(frame,string.format(techrow,
	"[[Image:"..displayname.." (CivRev2).png|64px|link="..displayname.." (CivRev2)]]",
	"[["..displayname.." (CivRev2)|"..name.."]]",
	tech.reqtech and LinkAll(tech.reqtech) or "None",
	(#leadsto > 0) and LinkAll(leadsto) or "None",
	tech.enables and LinkAll(tech.enables) or "None",
	tech.obsoletes and LinkAll(tech.obsoletes) or "None",
	tech.bonus or ""))
end
 
function p.GetUnitRow(frame, articlename)
	local displayname = articlename or frame.args[1]
	local name = string.gsub(displayname, " %(.*","")
	local data = mw.loadData("Module:Data/CivRev2/Units")
	local unit = data[name]
 
	return utils.PreProcess(frame,string.format(unitrow,
	"[[Image:"..displayname.." (CivRev2).png|64px|link="..displayname.." (CivRev2)]]",
	"[["..displayname.." (CivRev2)|"..name.."]]",
	unit.reqtech and Link(unit.reqtech) or "None",
	unit.cost or "None",
	(unit.attack or "0").."/"..(unit.defense or "0"),
	(unit.ranged or "0"),
        (unit.navalsupport or "0"),
	unit.moves or "None",
	unit.lineage and LinkAll(unit.lineage) or "None"))
end
 
function p.GetUnitPage(frame, articlename)
	local PAGENAME = articlename or articlename or mw.title.getCurrentTitle().text
	local name = string.gsub(PAGENAME, " %(.*","")
	local data = mw.loadData("Module:Data/CivRev2/Units")[name]
 
	return utils.PreProcess(frame,string.format(unitpage ,
	name,
	"[[Image:"..PAGENAME..".png|120px]]",
	data.reqtech and Link(data.reqtech) or "None",
	data.cost or "None",
	(data.attack or "0").."/"..(data.defense or "0"),
	data.ranged or "0",
        data.navalsupport or "0",
	data.moves or "None",
	data.lineage and LinkAll(data.lineage) or "None",
	data.notes or "None"))
end
 
function p.GetLeaderPage(frame, articlename)
	local PAGENAME = articlename or mw.title.getCurrentTitle().text
	local name = string.gsub(PAGENAME, " %(.*","")
	local data = mw.loadData("Module:Data/CivRev2/Leaders")
	local leader = data[name]
	local missing = "([[Module:Data/CivRev2/Leaders|Information missing]])"
 
	if leader == nil then
		return "''Leader infobox data not found. Check the page name or add the data to [[Module:Data/CivRev2/Leaders]].''[[Category:Leaders (CivRev2)]]"
	end
 
	return utils.PreProcess(frame,string.format(leaderpage,
	name,
	"[[Image:"..PAGENAME..".png|120px]]",
	leader.civ and Link(leader.civ) or "None",
	leader.ancient or missing,
	leader.medieval or missing,
	leader.industrial or missing,
	leader.modern or missing))
end
 
function p.GetCivPage(frame, articlename)
	local PAGENAME = articlename or mw.title.getCurrentTitle().text
	local name = string.gsub(PAGENAME, " %(.*","")
	local data = mw.loadData("Module:Data/CivRev2/Civilizations")
	local civ = data[name]
	local leaders = GetLeadersForCiv(name)
 
	if civ == nil then
		return "''Civilization infobox data not found. Check the page name or add the data to [[Module:Data/CivRev2/Civilizations]].''[[Category:Civilizations (CivRev2)]]"
	end
 
	return utils.PreProcess(frame,string.format(civpage,
	name,
	--"[[Image:"..PAGENAME..".png|120px]]",
	LinkAll(leaders, "CivRev2"),
	civ.begin or "None"))
end
 
local function GetResource(frame, articlename, template)
	local PAGENAME = articlename or mw.title.getCurrentTitle().text
	local name = string.gsub(PAGENAME, " %(.*","")
	local data = mw.loadData("Module:Data/CivRev2/Resources")
	local resource = data[name]
	local missing = "([[Module:Data/CivRev2/Resources|Information missing]])"
 
	if resource == nil then
		return "''Resource infobox data not found. Check the page name or add the data to [[Module:Data/CivRev2/Resources]].''[[Category:Resources (CivRev2)]]"
	end
 
	return utils.PreProcess(frame,string.format(template,
	name, name, name,
	resource.reqtech and Link(resource.reqtech) or "None",
	resource.bonus))
end
 
function p.GetResourcePage(frame, articlename)
	return GetResource(frame, articlename, resourcepage)
end
 
 
function p.GetResourceRow(frame, articlename)
	return GetResource(frame, frame and frame.args[1] or articlename, resourcerow)
end
 
return p

Also on Fandom

Random Wiki