Module:Township: Difference between revisions

getWorshipTable: Add season modifiers
(Various amends to update for v1.1.2, still WIP)
(getWorshipTable: Add season modifiers)
Line 277: Line 277:
for j, biomeID in ipairs(building.biomes) do
for j, biomeID in ipairs(building.biomes) do
local biome = biomesByID[biomeID]
local biome = biomesByID[biomeID]
if firstRow then  
if firstRow then
table.insert(resultPart, '\n|-')
table.insert(resultPart, '\n|-')
table.insert(resultPart, '\n|class="table-img"' .. rowSpan .. '| ' .. Icons.Icon({buildingName, type='building', notext=true, size=50}))
table.insert(resultPart, '\n|class="table-img"' .. rowSpan .. '| ' .. Icons.Icon({buildingName, type='building', notext=true, size=50}))
Line 311: Line 311:
function p.getTraderTable(frame)
function p.getTraderTable(frame)
-- Get the resources data with associated trader data
-- Get the resources data with associated trader data
 
-- Build the text
-- Build the text
local ret = {}
local ret = {}
Line 317: Line 317:
if #resource.itemConversions ~= 0 then -- Skips GP
if #resource.itemConversions ~= 0 then -- Skips GP
local ret_resource = {}
local ret_resource = {}
 
-- Header
-- Header
table.insert(ret_resource, '\r\n==='..resource.name..'===')
table.insert(ret_resource, '\r\n==='..resource.name..'===')
Line 418: Line 418:
table.insert(ret, '\n|-\n!Requirements')
table.insert(ret, '\n|-\n!Requirements')
for _, worship in ipairs(worships) do
for _, worship in ipairs(worships) do
table.insert(ret, '\n|style="text-align:center"| ' .. Shop.getRequirementString(worship.unlockRequirements))
local cellStyle = (Shared.tableIsEmpty(worship.unlockRequirements) and 'class="table-na"') or 'style="text-align:center"'
table.insert(ret, '\n|' .. cellStyle ..'| ' .. Shop.getRequirementString(worship.unlockRequirements))
end
 
-- Season multipliers
table.insert(ret, '\n|-\n!Bonus Seasons')
for _, worship in ipairs(worships) do
local bonusPart = {}
local cellStyle = 'style="text-align:center"'
if Shared.tableIsEmpty(worship.seasonMultiplier) then
bonusPart, cellStyle = {'None'}, 'class="table-na"'
end
for i, seasonMult in ipairs(worship.seasonMultiplier) do
local season = GameData.getEntityByID(Township.seasons, seasonMult.seasonID)
if season ~= nil then
table.insert(bonusPart, Icons.Icon({season.name, type='township', nolink=true}) .. ' (' .. seasonMult.multiplier .. 'x)')
end
end
table.insert(ret, '\n|' .. cellStyle .. '| ' .. table.concat(bonusPart, '<br/>'))
end
end