Module:Reward Table
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:
|
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 }} |
| ||||||||||||||||||||||||||||||||||||||||
Get a table where the last era is lower than the current last era | {{#invoke: Reward Table | main | Season Pass | 10 }} |
|
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') .. ' ' .. 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