Module:Reward Table

From Rise of Cultures Wiki
Jump to navigation Jump to search

Description

Create a reward table


Syntax

{{#invoke: Reward Table | main | [parameter1] | [end_era] }}


Parameters

Parameter Description Default Required
[parameter1]
Select one of the following:
  • Celtic Broch
  • Persian Palace
  • Crypt of the Count
  • Season Pass
  • Treasure Hunt
  • Great Sphinx
  • Tomb of Mausolus
  • Hagia Sophia
  • Sherwood Forest
  • Terracotta Army
  • Sayil Palace
Will return an error if none or incorrect parameter Y
[end_era]
Provide an era number as the last era to display on the table N

Examples

Description Code Output
Retrieve a table of rewards for a building or event
{{#invoke: Reward Table | main | Treasure Hunt }}
BRONZE AGE
Coin.png 100.0 K
MINOAN ERA
Coin.png 200.0 K
CLASSICAL GREECE
Coin.png 400.0 K
EARLY ROME
Coin.png 600.0 K
ROMAN EMPIRE
Coin.png 750.0 K
BYZANTINE ERA
Coin.png 950.0 K
AGE OF THE FRANKS
Coin.png 1.1 M
FEUDAL AGE
Coin.png 1.3 M
IBERIAN ERA
Coin.png 1.5 M
KINGDOM OF SICILY
Coin.png 1.7 M
HIGH MIDDLE AGES
Coin.png 2.0 M
Get a table where the last era is lower than the current last era
{{#invoke: Reward Table | main | Season Pass | 10 }}
STONE AGE
 75Food.png 27,000Coin.png 75,000
BRONZE AGE
 75Food.png 50,000Coin.png 150.0 K
MINOAN ERA
 150Food.png 120.0 KCoin.png 260.0 K
CLASSICAL GREECE
 300Food.png 210.0 KCoin.png 440.0 K
EARLY ROME
 420Food.png 320.0 KCoin.png 625.0 K
ROMAN EMPIRE
 450Food.png 480.0 KCoin.png 940.0 K
BYZANTINE ERA
 450Food.png 600.0 KCoin.png 1.1 M
AGE OF THE FRANKS
 450Food.png 730.0 KCoin.png 1.4 M
FEUDAL AGE
 450Food.png 860.0 KCoin.png 1.6 M
IBERIAN ERA
 450Food.png 1.0 MCoin.png 1.9 M

local DacMod = require( 'Module:DAC' )
local EraMod = require( 'Module:Era' )
local GenMod = require( 'Module:General' )

List = {} --Create a list to be used in the documentation.
Bonus = {}
Bonus_Icon = {}
Era_Start = {}
local Era_End = #Era_Array --Bonuses are used up to this era (Maximum number of eras)

List[#List+1] = 'Celtic Broch'
Bonus[#List] = {}
Bonus_Icon[#List] = {}
Era_Start[#List] = 1 --Create a table starting at era 2 (Stone Age)
Bonus[#List][0] = GenMod.Icon('icon_mystery_chest_gold') --Header (Optional)
Bonus[#List][1] = 'Dac_EvoChest_Coins_250_S'
Bonus_Icon[#List][1] = GenMod.Icon('Coin')
Bonus[#List][2] = 'Dac_EvoChest_Food_250_S'
Bonus_Icon[#List][2] = GenMod.Icon('Food')
	
List[#List+1] = 'Persian Palace'
Bonus[#List] = {}
Bonus_Icon[#List] = {}
Era_Start[#List] = 1 --Create a table starting at era 2 (Stone Age)
Bonus[#List][0] = GenMod.Icon('icon_mystery_chest_gold') --Header (Optional)
Bonus[#List][1] = 'Dac_EvoChest_Coins_250_S'
Bonus_Icon[#List][1] = GenMod.Icon('Coin')
Bonus[#List][2] = 'Dac_EvoChest_Food_250_S'
Bonus_Icon[#List][2] = GenMod.Icon('Food')
	
List[#List+1] = 'Crypt of the Count'
Bonus[#List] = {}
Bonus_Icon[#List] = {}
Era_Start[#List] = 1 --Create a table starting at era 2 (Stone Age)
Bonus[#List][0] = GenMod.Icon('Goods Chest2') --Header (Optional)
Bonus[#List][1] = 'Dac_Reward_Evo_GoodsEach_300_S_Part1'
Bonus_Icon[#List][1] = 'GOODS4'
	
List[#List+1] = 'Season Pass'
Bonus[#List] = {}
Bonus_Icon[#List] = {}
Era_Start[#List] = 1 --Create a table starting at era 2 (Stone Age)
Bonus[#List][0] = '' --Header (Optional)
Bonus[#List][1] = 'Dac_Reward_Good1_300_S'
Bonus_Icon[#List][1] = 'GOODS4'
Bonus[#List][2] = 'Dac_Reward_Food_500_M'
Bonus_Icon[#List][2] = GenMod.Icon('Food')
Bonus[#List][3] = 'Dac_Reward_Coins_750_L'
Bonus_Icon[#List][3] = GenMod.Icon('Coin')
	
List[#List+1] = 'Treasure Hunt'
Bonus[#List] = {}
Bonus_Icon[#List] = {}
Era_Start[#List] = 2 --Create a table starting at era 2 (Bronze Age)
Bonus[#List][0] = '' --Header (Optional)
Bonus[#List][1] = 'Dac_ATH_BuyingAttempts_Coins_BaseCost'
Bonus_Icon[#List][1] = GenMod.Icon('Coin')
	
List[#List+1] = 'Great Sphinx'
Bonus[#List] = {}
Bonus_Icon[#List] = {}
Era_Start[#List] = 2 --Create a table starting at era 2 (Bronze Age)
Bonus[#List][0] = GenMod.Icon('Chest2') --Header (Optional)
Bonus[#List][1] = 'Dac_Reward_Coins_250_S'
Bonus_Icon[#List][1] = GenMod.Icon('Coin')
Bonus[#List][2] = 'Dac_Reward_Food_250_S'
Bonus_Icon[#List][2] = GenMod.Icon('Food')
	
List[#List+1] = 'Tomb of Mausolus'
Bonus[#List] = {}
Bonus_Icon[#List] = {}
Era_Start[#List] = 2 --Create a table starting at era 2 (Bronze Age)
Bonus[#List][0] = GenMod.Icon('icon_mystery_chest_gold') --Header (Optional)
Bonus[#List][1] = 'Dac_Reward_Food_250_S'
Bonus_Icon[#List][1] = GenMod.Icon('Food')
	
List[#List+1] = 'Hagia Sophia'
Bonus[#List] = {}
Bonus_Icon[#List] = {}
Era_Start[#List] = 5 --Create a table starting at era 5 (Early Rome)
Bonus[#List][0] = GenMod.Icon('icon_mystery_chest_gold') --Header (Optional)
Bonus[#List][1] = 'Dac_Reward_Coins_250_S'
Bonus_Icon[#List][1] = GenMod.Icon('Coin')
	
List[#List+1] = 'Sherwood Forest'
Bonus[#List] = {}
Bonus_Icon[#List] = {}
Era_Start[#List] = 5 --Create a table starting at era 5 (Early Rome)
Bonus[#List][0] = GenMod.Icon('Chest2') --Header (Optional)
Bonus[#List][1] = 'Dac_Reward_GoodsEach_60_XXS'
Bonus_Icon[#List][1] = 'GOODS4'
	
List[#List+1] = 'Terracotta Army'
Bonus[#List] = {}
Bonus_Icon[#List] = {}
Era_Start[#List] = 5 --Create a table starting at era 5 (Early Rome)
Bonus[#List][0] = GenMod.Icon('Chest2') --Header (Optional)
Bonus[#List][1] = 'Dac_Reward_Coins_250_S'
Bonus_Icon[#List][1] = GenMod.Icon('Coin')
Bonus[#List][2] = 'Dac_Reward_Food_250_S'
Bonus_Icon[#List][2] = GenMod.Icon('Food')
	
List[#List+1] = 'Sayil Palace'
Bonus[#List] = {}
Bonus_Icon[#List] = {}
Era_Start[#List] = 5 --Create a table starting at era 5 (Early Rome)
Bonus[#List][0] = GenMod.Icon('Chest2') --Header (Optional)
Bonus[#List][1] = 'Dac_Reward_Coins_250_S'
Bonus_Icon[#List][1] = GenMod.Icon('Coin')
Bonus[#List][2] = 'Dac_Reward_Food_250_S'
Bonus_Icon[#List][2] = GenMod.Icon('Food')


local p = {}


function p.main(data)

	Building_Name = data.args[1]:gsub('^%s+', '') --Strip leading spaces
	Building_Name = Building_Name:gsub('%s+$', '') --Strip trailing spaces
	
	-- Check if data.args[2] is a number and within the range of available eras
	if data.args[2] ~= nil and type(tonumber(data.args[2])) == "number" and tonumber(data.args[2]) <= #Era_Array then
	    Era_End = tonumber(data.args[2])
	end


	if Building_Name == nil or Building_Name == '' then return end
	
	for i = 1, #List do
		if Building_Name == List[i] then
			return p.Table(i)
		end
	end

    return 'Module:Reward Table: Option not recognized (' .. Building_Name .. ')'

end


function p.Table(Index)
--Create a table of data
String = '<table class="article-table" style="white-space: nowrap;  margin: 0;">'

	if Bonus[Index][0] ~= '' and Bonus[Index][0] ~= nil then String = String .. '<tr class="bg-th"><td colspan=' .. #Bonus[Index]+1 .. '>' .. Bonus[Index][0] .. '</td></tr>' end

	for Era = Era_Start[Index],  Era_End, 1 do
		local String_Bonus = ''
		
		for j = 1, #Bonus[Index], 1 do
			if DacMod.main(Era_Array[Era][1], Bonus[Index][j]) ~= '' then
				if string.upper(Bonus_Icon[Index][j]) == 'GOODS4' then 
					if #EraMod.Goods(Era, 'Goods4') > 0 then 
						String_Bonus = String_Bonus .. '<td style="text-align: left; display: flex; align-items: center;">' .. EraMod.Goods(Era, 'Goods4')  .. '&nbsp;' .. GenMod.Num_Group( DacMod.main(Era_Array[Era][1], Bonus[Index][j]) ) .. '</td>'
					end
				else
					String_Bonus = String_Bonus .. '<td style="text-align: left;">' .. Bonus_Icon[Index][j] .. ' ' .. GenMod.Num_Group( DacMod.main(Era_Array[Era][1], Bonus[Index][j]) ) .. '</td>'
				end
			end
		end
		
		if #String_Bonus > 0 then
			String = String .. '<tr><td style="background: rgba(' .. Era_Array[Era][3] .. ', 1);">' .. EraMod.Era(Era_Array[Era][1], 'BOX') .. '</td>' .. String_Bonus
		end
		
		String = String .. '</tr>'
	end
	
	String = String .. '</table>'
	return String
end


function p.List()
	
	String = '<ul>'
	
	for i = 1, #List, 1 do
		String = String .. '<li>' .. List[i] .. '</li>'
	end
	
	String = String .. '</ul>'
	
	return String
	
end

return p