Difference between revisions of "Module:OInfobox-Building"

Jump to navigation Jump to search
m
no edit summary
m
m
 
(61 intermediate revisions by the same user not shown)
Line 1: Line 1:
-- adapted from Levrin's iteration to Sakaratte's original --
-- adapted by Olessan from Levrin's iteration to Sakaratte's original --
-- Layout changed and all labels, etc, updated to pull from Module:BuildingINdex --
-- I may expand later to have functions for other infobox types (but this game doesn't really need any other?? 22/04/2025 --
local com = require('Module:Common')
local com = require('Module:Common')
local a = require('Module:Arguments')
local a = require('Module:Arguments')
Line 45: Line 47:
     end
     end


    local function createDataRow(label, value, defaultValue)
        local function createDataRow(label, value, defaultValue)
         if not value and not defaultValue then
        local actualValue = value or defaultValue
 
         if not actualValue or actualValue == '' then  
             return nil
             return nil
         end
         end
Line 60: Line 64:
             :tag('span')
             :tag('span')
                 :addClass('infobox-data')
                 :addClass('infobox-data')
                 :wikitext(value or defaultValue)
                 :wikitext(actualValue)
         else
         else
             dataRow:tag('span')
             dataRow:tag('span')
                 :addClass('infobox-data')
                 :addClass('infobox-data')
                 :wikitext(value or defaultValue)
                 :wikitext(actualValue)
         end
         end


Line 194: Line 198:
         local first = true
         local first = true
           for resource, amount in pairs(buildingData.influence) do
           for resource, amount in pairs(buildingData.influence) do
           if resource ~= 'tier' and resource ~= 'perEach splendour' then -- Exclude 'tier' and 'perEach splendour'
           if resource ~= 'tier' and resource ~= 'bsplendour' then -- Exclude 'tier' and 'bsplendour'
             local displayAmount = amount
             local displayAmount = amount
             if first and buildingData.influence.tier then
             if first and buildingData.influence.tier then
Line 232: Line 236:
         --/
         --/
         --SECTION-RUNNING-COSTS
         --SECTION-RUNNING-COSTS
        local costData = {}
local costData = {}
local goldCoinsFound = false


if buildingData.costs or buildingData.influence['perEach splendour'] then
    if buildingData.costs or buildingData.influence['bsplendour'] then
            local costData = {}
        for resource, amount in pairs(buildingData.costs) do
            for resource, amount in pairs(buildingData.costs) do
            if resource == 'gold coins' then
                local resourceIcon = i.icon('gold coins', nil, nil, 'gold coins', 'en')
                table.insert(costData, {label = '[[File:Gold Coins.png|frameless|20x20px]] ' .. '[[Gold Coins|Build Cost]]', value = amount})
                goldCoinsFound = true
            elseif resource ~= 'maintenance' then
                 local resourceIcon = i.icon(resource, nil, nil, com.firstUpper({resource}), 'en')
                 local resourceIcon = i.icon(resource, nil, nil, com.firstUpper({resource}), 'en')
                 table.insert(costData, {label = resourceIcon, value = amount})
                 table.insert(costData, {label = resourceIcon, value = amount})
             end
             end
            if resource ~= 'maintenance' then
-- Add 'perEach splendour' to running costs if it exists
            local displayAmount = amount
if buildingData.influence['perEach splendour'] then
            if second and buildingData.costs.maintenance then
             local resourceIcon = i.icon('splendor', nil, nil, 'Splendor', 'en') -- Assuming a generic splendor icon
              displayAmount = displayAmount .. ' ' .. buildingData.costs.maintenance
        table.insert(costData, {label = resourceIcon .. ' (per each)', value = buildingData.influence['perEach splendour']})
              second = false
            end
              end
          end
            if #costData > 0 then
        end
                addSection(infobox, costData, 'Economic Impact', 2)
       
            end
        if buildingData.costs and buildingData.costs['maintenance'] then
             local resourceIcon = i.icon('maintenance', nil, nil, 'maintenance', 'en')
            table.insert(costData, {label = resourceIcon, value = '[[File:Gold Coins.png|frameless|20x20px]] ' .. buildingData.costs['maintenance'] .. ' monthly'})
        end
 
        if buildingData.influence['bsplendour'] then
            local resourceIcon = i.icon('bsplendour', nil, nil, 'splendor', 'en')
            table.insert(costData, {label = '[[File:Splendor.png|frameless|20x20px]] ' .. '[[Splendour|Splendour]]', value = '+ ' .. buildingData.influence['bsplendour'] .. ' ea'})
        end
 
        if #costData > 0 then
            addSection(infobox, costData, 'Economic Impact', 2)
        end
         end
         end
        --/
     end
     end
     --/
     --/
606

edits

Navigation menu