Module:BuildingData: Difference between revisions

From Against the Storm Official Wiki
(added furnace, alchemist's hut, advanced rain collector, and toolshop)
(added small camps; fixed some icon filenames missing extensions)
 
(14 intermediate revisions by the same user not shown)
Line 1: Line 1:
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- Lua storage table for looking up wiki pages, names, and resources
-- This module primarily supplies data and lookup functions for other modules
-- based on in-game names. All data is in English.
-- that support templates like {{Building_link}}.
-- https://hoodedhorse.com/wiki/Against_the_Storm/Template:Building_link
--
-- The main data table stores all available data about buildings themselves
-- and relies on other modules to store relationships between buildings and
-- products, services, etc.
--
--
-- The table contains some deconfliction, but only for spaces, apostrophes, and
-- The helper functions include getters (to keep the data hidden) and a large
-- some singular/plural.
-- deconfliction method to provide some robustness when using the template
-- Use in-game names for things, and help keep this table updated as the game
-- and from other Lua modules. Looking up a building requires using in-game  
-- is updated.
-- names, but forgives small differences in spacing, apostrophes, and plurals.
 
-- Please help keep this table updated as the game is updated.
-- @module BuildingData
local BuildingData = {}
 
--
--
-- Using the table requires a locally defined lookup function that performs
-- Dependencies
-- a string.lower on the argument so that the lookup table can accept any case
--
-- and still function properly. Otherwise, we would need the table to define
RecipeData = RecipeData or require("Module:RecipeData") -- need recipe relationships
-- both Berries = "Berries" and berries = "Berries" which would multiply our
Utility = Utility or require("Module:Utility") -- need normalize functions
-- work.
 
-------------------------------------------------------------------------------
 
 
--  
-- Constants
--  
-- Specializations
local S_ALCH = "Alchemy"
local S_BREW = "Brewing"
local S_CLOT = "Cloth"
local S_ENGI = "Engineering"
local S_MEAT = "Meat production"
local S_WARM = "Warmth"
local S_WOOD = "Wood"


-- Resource names of building costs
local C_BRICK = "Bricks"
local C_FABRI = "Fabric"
local C_PARTS = "Parts"
local C_PIPES = "Pipes"
local C_PLANK = "Planks"


-- for returning when REQUIRE'd by other Lua modules.
-- Rain types for rain engines
local BuildingData = {}
local R_DRIZZ = "Drizzle Water"
local R_CLEAR = "Clearance Water"
local R_STORM = "Storm Water"




--
-- Class Variables
--


-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- Main data table, with string keys and string values.
-- Primary data table for this module.
-- Some of these are defined inline with string.lower to make the key easier
--  
-- to spell and read correctly.
-- This table stores the details of buildings according to in-game information.
-------------------------------------------------------------------------------
-- A design decision of this table is to make the key the same as the page
 
-- name, so that whenever .page is referenced, it can be used again to retrieve
-- a design decision of this table is to make the key the same as the page name.
-- the rest of the data. (The lookup method will handle converting it to
-- (the lookup methods will automatically make it lowercase.)
-- lowercase.)
-- that way, whenever .page is referenced, it can be used again to retrieve
--
-- the rest of the data.
-- Structure:
local tableStrStrData = {
-- @key a lowercase version of the building name, with the same spaces,
-- apostrophes, singular, and spelling
-- @field page the name of the wiki page, case-sensitive, but otherwise must be
-- the same as the key
-- @field iconfile a string of the filename.png of the icon used in the game,
-- case-sensitive and must include extension, but without the "File:"
-- @field specialization[opt] a table of the specializations listed in the
-- in-game encyclopedia (use the constants, above), or omit if none
-- @field cost[opt] a table of the building costs (or omit if none), in the
-- following format:
-- { first cost { number, resource },
--   second cost { number, resource },
--   etc. }
-- @field workers the number of worker slots
-- @field raintype the color of rain used in the Rain Engine of this building
-- (use constants, above), if any
-- @field description the in-game description text, in plain text
-- @table tBuildingData the primary data table for buildings
local tBuildingData = {  
---------------------------------------
-- Buildings
---------------------------------------
-- Starting Buildings
-- Starting Buildings
["ancient hearth"] = {iconfile="Small Hearth icon.png", page="Ancient Hearth"},
["ancient hearth"] = { page="Ancient Hearth",
["main warehouse"] = {iconfile="Main_Storage_icon.png", page="Main Warehouse"},
iconfile="Small Hearth icon.png",  
specialization={ S_WARM },
workers=1,
description="The heart of the colony is protected by the Holy Flame. Villagers gather here to rest, eat, and receive clothing. If the fire goes out, people will lose hope. Can't be moved. Size: 4x4." },
["main warehouse"] = { page="Main Warehouse",
iconfile="Main_Storage_icon.png" },
-- Camps
-- Camps
["foragers' camp"] = {iconfile="Forager's Camp icon", page="Foragers' Camp"},
["small foragers' camp"] = { page="Small Foragers' Camp",  
["harvesters' camp"] = {iconfile="Harvester Camp icon.png", page="Harvesters' Camp"},
iconfile="Small Foragers' Camp icon.png" },
["herbalists' camp"] = {iconfile="Herbalist's_Camp_icon.png", page="Herbalists' Camp"},
["foragers' camp"] = { page="Foragers' Camp",
["stonecutters' camp"] = {iconfile="Stonecutter's Camp icon.png", page="Stonecutters' Camp"},
iconfile="Forager's Camp icon.png" },
["trappers' camp"] = {iconfile="Trapper's Camp icon.png", page="Trappers' Camp"},
["harvesters' camp"] = { page="Harvesters' Camp",
["woodcutters' camp"] = {iconfile="Woodcutters Camp icon", page="Woodcutters' Camp"},
iconfile="Harvester Camp icon.png" },
["small herbalists' camp"] = { page="Small Herbalists' Camp",
iconfile="Small_Herbalists'_Camp_icon.png" },
["herbalists' camp"] = { page="Herbalists' Camp",
iconfile="Herbalist's_Camp_icon.png" },
["stonecutters' camp"] = { page="Stonecutters' Camp",
iconfile="Stonecutter's Camp icon.png" },
["small trappers' camp"] = { page="Small Trappers' Camp",
iconfile="Small_Trappers'_Camp_icon.png" },
["trappers' camp"] = { page="Trappers' Camp",
iconfile="Trapper's Camp icon.png" },
["woodcutters' camp"] = { page="Woodcutters' Camp",  
iconfile="Woodcutters Camp icon.png" },
-- Farms
-- Farms
["farm field"] = {iconfile="Farmfield_icon.png", page="Farm Field"},
["farm field"] = { page="Farm Field",
["herb garden"] = {iconfile="HerbGarden_icon.png", page="Herb Garden"},
iconfile="Farmfield_icon.png" },
["plantation"] = {iconfile="Plantation_icon.png", page="Plantation"},
["greenhouse"] = { page="Greenhouse",
["small farm"] = {iconfile="SmallFarm_icon.png", page="Small Farm"},
iconfile="Greenhouse_icon.png" },
["herb garden"] = { page="Herb Garden",
iconfile="HerbGarden_icon.png" },
["plantation"] = { page="Plantation",
iconfile="Plantation_icon.png" },
["small farm"] = { page="Small Farm",
iconfile="SmallFarm_icon.png" },
-- Food production
-- Food production
["bakery"] = {iconfile="Bakery_icon.png", page="Bakery"},
["bakery"] = { page="Bakery",
["cellar"] = {iconfile="Cellar_icon.png", page="Cellar"},
iconfile="Bakery_icon.png" },
["cookhouse"] = {iconfile="Cookhouse_icon.png", page="Cookhouse"},
["butcher"] = { page="Butcher",
["grill"] = {iconfile="Grill_icon.png", page="Grill"},
iconfile="Butcher_icon.png" },
["ranch"] = {iconfile="Ranch_icon.png", page="Ranch"},
["cellar"] = { page="Cellar",
["smokehouse"] = {iconfile="Smokehouse_icon.png", page="Smokehouse"},
iconfile="Cellar_icon.png" },
["cookhouse"] = { page="Cookhouse",
iconfile="Cookhouse_icon.png" },
["field kitchen"] = { page="Field Kitchen",
iconfile="Field_Kitchen_icon.png" },
["granary"] = { page="Granary",
iconfile="Granary_icon.png" },
["grill"] = { page="Grill",
iconfile="Grill_icon.png" },
["ranch"] = { page="Ranch",
iconfile="Ranch_icon.png" },
["smokehouse"] = { page="Smokehouse",
iconfile="Smokehouse_icon.png" },
-- Housing
-- Housing
["shelter"] = {iconfile="Shelter icon.png", page="Shelter"},
["shelter"] = { page="Shelter",  
["big shelter"] = {iconfile="Big Shelter icon.png", page="Big Shelter"},
iconfile="Shelter icon.png" },
["human house"] = {iconfile="Human House icon.png", page="Human House"},
["big shelter"] = { page="Big Shelter",  
["beaver house"] = {iconfile="Beaver House icon.png", page="Beaver House"},
iconfile="Big Shelter icon.png" },
["lizard house"] = {iconfile="Lizard House icon.png", page="Lizard House"},
["human house"] = { page="Human House",  
["harpy house"] = {iconfile="Harpy House icon.png", page="Harpy House"},
iconfile="Human House icon.png" },
["beaver house"] = { page="Beaver House",  
iconfile="Beaver House icon.png" },
["lizard house"] = { page="Lizard House",  
iconfile="Lizard House icon.png" },
["harpy house"] = { page="Harpy House",  
iconfile="Harpy House icon.png" },
-- Industry
-- Industry
["crude workstation"] = {iconfile="Crude_Workstation_icon.png", page="Crude Workstation"},
["crude workstation"] = { page="Crude Workstation",
["makeshift post"] = {iconfile="Makeshift_Post_icon.png", page="Makeshift Post"},
iconfile="Crude_Workstation_icon.png" },
["advanced rain collector"] = {iconfile="Advanced_Rain_Collector_icon.png", page="Advanced Rain Collector"},
["makeshift post"] = { page="Makeshift Post",
["alchemist's hut"] = {iconfile="Alchemist_Hut_icon.png", page="Alchemist's Hut"},
iconfile="Makeshift_Post_icon.png" },
["artisan"] = {iconfile="Artisan_icon.png", page="Artisan"},
["advanced rain collector"] = { page="Advanced Rain Collector",
["brewery"] = {iconfile="Brewery_icon.png", page="Brewery"},
iconfile="Advanced_Rain_Collector_icon.png",  
["brickyard"] = {iconfile="Brickyard_icon.png", page="Brickyard"},
specialization={ S_ENGI, S_ALCH },
["carpenter"] = {iconfile="Carpenter_icon.png", page="Carpenter"},
cost={ {5,C_PIPES}, {3,C_PARTS}, {5,C_PLANK} },
["clothier"] = {iconfile="Clothier_icon.png", page="Clothier"},
description="Can collect infused rainwater used for crafting and powering Rain Engines in production buildings. The type of collected rainwater depends on the season. Can't be moved. Size: 3x2." },
["cooperage"] = {iconfile="Cooperage_icon.png", page="Cooperage"},
["alchemist's hut"] = { page="Alchemist's Hut",
["druid's hut"] = {iconfile="Druid_icon.png", page="Druid's Hut"},
iconfile="Alchemist_Hut_icon.png",
["furnace"] = {iconfile="Furnace_icon.png", page="Furnace"},
specialization={ S_ALCH, S_BREW },
["kiln"] = {iconfile="Kiln_icon.png", page="Kiln"},
cost={ {5,C_PLANK}, {2,C_BRICK} },
["leatherworker"] = {iconfile="Leatherworks_icon.png", page="Leatherworker"},
workers=2,
["lumber mill"] = {iconfile="Lumbermill_icon.png", page="Lumber Mill"},
raintype=R_CLEAR,
["mine"] = {iconfile="Mine_icon.png", page="Mine"},
description="Can produce: Crystalized Dew (★★), Cosmetics (★★), Wine (★★). Can use: Clearance Water. Can't be moved. Size: 3x2." },
["press"] = {iconfile="Press_icon.png", page="Press"},
["apothecary"] = { page="Apothecary",
["provisioner"] = {iconfile="Provisioner_icon.png", page="Provisioner"},
iconfile="Apothecary_icon.png",  
["rain collector"] = {iconfile="Rain_Collector_icon.png", page="Rain Collector"},
specialization={ S_ALCH },
["rain mill"] = {iconfile="Rain_Mill_icon.png", page="Rain Mill"},
cost={ {5,C_PLANK}, {2,C_BRICK} },
["scribe"] = {iconfile="Scribe_icon.png", page="Scribe"},
workers=2,
["smelter"] = {iconfile="Smelter_icon.png", page="Smelter"},
raintype=R_CLEAR,
["toolshop"] = {iconfile="Toolshop_icon.png", page="Toolshop"},
description="Can produce: Cosmetics (★★), Incense (★★), Biscuits (★★). Can use: Clearance Water. Can't be moved. Size: 3x3." },
["weaver"] = {iconfile="Weaver_icon.png", page="Weaver"},
["artisan"] = { page="Artisan",
iconfile="Artisan_icon.png" },
["brewery"] = { page="Brewery",
iconfile="Brewery_icon.png" },
["brick oven"] = { page="Brick Oven",
iconfile="Brick_Oven_icon.png" },
["brickyard"] = { page="Brickyard",
iconfile="Brickyard_icon.png" },
["carpenter"] = { page="Carpenter",
iconfile="Carpenter_icon.png" },
["clothier"] = { page="Clothier",
iconfile="Clothier_icon.png" },
["cooperage"] = { page="Cooperage",
iconfile="Cooperage_icon.png" },
["druid's hut"] = { page="Druid's Hut",
iconfile="Druid_icon.png" },
["flawless brewery"] = { page="Flawless Brewery",
iconfile="Brewery_icon.png" },
["flawless rain mill"] = { page="Flawless Rain Mill",
iconfile="Rain_Mill_icon.png" },
["furnace"] = { page="Furnace",
iconfile="Furnace_icon.png" },
["kiln"] = { page="Kiln",
iconfile="Kiln_icon.png" },
["leatherworker"] = { page="Leatherworker",
iconfile="Leatherworks_icon.png" },
["lumber mill"] = { page="Lumber Mill",
iconfile="Lumbermill_icon.png" },
["mine"] = { page="Mine",
iconfile="Mine_icon.png" },
["press"] = { page="Press",
iconfile="Press_icon.png" },
["provisioner"] = { page="Provisioner",
iconfile="Provisioner_icon.png" },
["rain collector"] = { page="Rain Collector",
iconfile="Rain_Collector_icon.png" },
["rain mill"] = { page="Rain Mill",
iconfile="Rain_Mill_icon.png" },
["scribe"] = { page="Scribe",
iconfile="Scribe_icon.png" },
["smelter"] = { page="Smelter",
iconfile="Smelter_icon.png" },
["toolshop"] = { page="Toolshop",
iconfile="Toolshop_icon.png" },
["weaver"] = { page="Weaver",
iconfile="Weaver_icon.png" },
-- City Buildings
-- City Buildings
["small hearth"] = {iconfile="Temporary_Hearth_icon.png", page="Small Hearth"},
["archaeologist's office"] = { page="Archaeologist's Office",
["warehouse"] = {iconfile="Storage_icon.png", page="Warehouse"},
iconfile="Archeologist_office_icon.png",
["trading post"] = {iconfile="Trading_Post_icon.png", page="Trading Post"},
cost={ {2,C_PLANK}, {2,C_BRICK}, {2,C_FABRI} },
["blight post"] = {iconfile="Blight_Post_icon.png", page="Blight Post"},
description="A building designed to help you study the past. Can be upgraded to locate archaeological discoveries or improve exploration capabilities. Can be moved for: 5 Wood. Size: 3x3." },
["hydrant"] = {iconfile="Hydrant_icon.png", page="Hydrant"},
["small hearth"] = { page="Small Hearth",
["forsaken altar"] = {iconfile="Altar_icon.png", page="Forsaken Altar"},
iconfile="Temporary_Hearth_icon.png" },
["warehouse"] = { page="Warehouse",
iconfile="Storage_icon.png" },
["trading post"] = { page="Trading Post",
iconfile="Trading_Post_icon.png" },
["blight post"] = { page="Blight Post",
iconfile="Blight_Post_icon.png" },
["hydrant"] = { page="Hydrant",
iconfile="Hydrant_icon.png" },
["forsaken altar"] = { page="Forsaken Altar",
iconfile="Altar_icon.png" },
-- Service Buildings
-- Service Buildings
["bath house"] = {iconfile="Bath_House_icon.png", page="Bath House"},
["bath house"] = { page="Bath House",
["clan hall"] = {iconfile="Clan_Hall_icon.png", page="Clan Hall"},
iconfile="Bath_House_icon.png" },
["explorers' lodge"] = {iconfile="Explorers_Lodge_icon.png", page="Explorers' Lodge"},
["clan hall"] = { page="Clan Hall",
["guild house"] = {iconfile="Guild_House_icon.png", page="Guild House"},
iconfile="Clan_Hall_icon.png" },
["monastery"] = {iconfile="Monastery_icon.png", page="Monastery"},
["explorers' lodge"] = { page="Explorers' Lodge",
["tavern"] = {iconfile="Tavern_icon.png", page="Tavern"},
iconfile="Explorers_Lodge_icon.png" },
["temple"] = {iconfile="Temple_icon.png", page="Temple"},
["guild house"] = { page="Guild House",
}
iconfile="Guild_House_icon.png" },
["monastery"] = { page="Monastery",
iconfile="Monastery_icon.png"},
["tavern"] = { page="Tavern",
iconfile="Tavern_icon.png" },
["temple"] = { page="Temple",
iconfile="Temple_icon.png" },
} -- end of tBuildingData






-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- Main lookup functions
-- Main lookup function
-- Accepts the in-game name and returns the name of the page on the wiki
--
-- associated with that in-game item, resource, building, etc.
-- Accepts the in-game name and returns the corresponding inner table from
-------------------------------------------------------------------------------
-- tBuildingData. It is preferred that callers use the other getter functions
-- that return specific fields of the inner table rather than the whole thing,
-- to protect variations in this module.
-- @param buildingName the name of the building to look up
-- @return the inner table from the big data table corresponding to the provided
-- building name, or nil if it doesn't exist
function BuildingData.getData(buildingName)
-- If the argument to this function is empty or nil, save some time by
-- skipping the normalize function.
if not buildingName or "" == buildingName then
return nil
end
-- normalize the name to try again
    local buildingName = Utility.normalizeBuildingName(buildingName)
-- get the inner table from the big data table and return it; if it doesn't
-- exist, this will return nil anyway
    return tBuildingData[buildingName] or nil
end






-- returns the whole data table for the specified key
---
-- need to run normalize function first
-- Getter method for the page name for a building.
function BuildingData.getData(strArg)
--
-- Accepts the in-game name of the building and returns the corresponding name
-- of the page in the wiki for the building. If the buildingName argument is
-- formatted exactly as in the game, this will return a string matching the
-- argument. Since normalization is performed, this can be used to ensure proper
-- formatting of the building's name.
-- @param buildingName the name of the building
-- @return the name of the page on the wiki, or nil if it doens't exist
function BuildingData.getPagename(buildingName)


-- normalize input
-- get the inner table for the building
    local strArg = BuildingData.normalizeName(strArg)
local tBuilding = BuildingData.getData(buildingName)
if not tBuilding then
return nil
end
-- Get it from the big table below and return it.
-- if the building didn't exist, then nil was already returned, but if the
    return tableStrStrData[strArg]
-- page was undefined, this should return nil instead of an empty string
return tBuilding.page
end
end






-- simpler version if all that's needed is the iconfile.
---
-- error handling by the calling module is required.
-- Getter method for the icon filename for a building.
function BuildingData.getIconFilename(strArg)
--
-- Accepts the in-game name of the building and returns the corresponding
-- filename on the wiki for the building's icon as seen in-game.
-- @param buildingName the name of the building
-- @return the filename, which might be an empty string, or nil if it doesn't
-- exist
function BuildingData.getIconFilename(buildingName)
-- get the inner table for the building
local tBuilding = BuildingData.getData(buildingName)
if not tBuilding then
return nil
end
-- Get the icon filename, if any. If the building doesn't have an icon,
-- then return an empty string. Returning nil is reserved for when the
-- building does not exist.
return tBuilding.iconfile or ""
end


local data = getData(strArg)
 
 
---
-- Getter method for the specializations of a building.
--
-- Accepts the in-game name of the building and returns the corresponding
-- specializations, if any, as a table of strings.
-- @param the name of the building
-- @return a table with the specializations for the building, which might be
-- empty if the building has no specializations, or nil if the building doesn't
-- exist
function BuildingData.getSpecialization(buildingName)
 
-- get the inner table for the building
local tBuilding = BuildingData.getData(buildingName)
-- if this particular data block doesn't have a iconfile, this will return nil
-- if the building didn't exist, return nil
-- therefore, error handling will be necessary
if not tBuilding then
return data.iconfile or nil
return nil
end
local tSpec = {} -- this is our return variable
-- Get the specialization, if any. If there are none, then return that empty
-- table. Returning nil is reserved for when the building does not exist.
if tBuilding.specialization then
-- overwrite the return variable
tSpec = tBuilding.specialization
end
-- At this point, it could be an empty table, signifying that the building
-- exists but has no specialization.
return tSpec
end
end






-- simpler version if all that's needed is the page name.
---
-- error handling by the calling module is required.
-- Getter method for the building costs of a building.
function BuildingData.getPagename(strArg)
--
-- Accepts the in-game name of the building and returns the corresponding
-- costs in resources to build as a table of strings. Buildings that the player
-- starts with or are otherwise free to build will have no costs.
-- @param the name of the building
-- @return a table with the costs of the building, which may be empty if the
-- player starts with the building, or nil if the building doesn't exist; the
-- cost table has the following format:
-- { first cost { number, resource },
--   second cost { number, resource },
--   etc. }
function BuildingData.getCosts(buildingName)


local data = getData(strArg)
-- get the inner table for the building
local tBuilding = BuildingData.getData(buildingName)
-- if the building didn't exist, return nil
if not tBuilding then
return nil
end
local tCost = {} -- this is our return variable
-- Get the costs, if any. If there are none, then return that empty table.
-- Returning nil is reserved for when the building does not exist.
if tBuilding.cost then
-- overwrite the return variable
tCost = tBuilding.cost
end
-- if this particular data block doesn't have a page name, this will return nil
-- At this point, it could be an empty table, signifying that the building
-- therefore, error handling will be necessary
-- exists but has no cost.
return data.page or nil
return tCost
end
end






-- simpler version if all that's needed is the description.
---
-- error handling by the calling module is required.
-- Getter method for the number of worker slots at a building.
function BuildingData.getDescription(strArg)
--  
-- Accepts the in-game name of the building and returns the corresponding
-- number of workers the building can take, if any.
-- @param the name of the building
-- @return the number of workers, which might be zero, or nil if the building
-- doesn't exist
function BuildingData.getWorkers(buildingName)


local data = getData(strArg)
-- get the inner table for the building
local tBuilding = BuildingData.getData(buildingName)
if not tBuilding then
return nil
end
-- if this particular data block doesn't have a description, this will return nil
-- Get the number of worker slots, if any. If there are none, then return  
-- therefore, error handling will be necessary
-- zero. Returning nil is reserved for when the building does not exist.
return data.description or nil
return tBuilding.workers or 0
end
end






-------------------------------------------------------------------------------
---
-- Helper functions
-- Getter method for the type of rain used in Rain Engines in a building.
-------------------------------------------------------------------------------
--  
-- Accepts the in-game name of the building and returns the corresponding
-- rain type.
-- @param the name of the building
-- @return the rain type, if any, or nil if the building doesn't exist
function BuildingData.getRainType(buildingName)
 
-- get the inner table for the building
local tBuilding = BuildingData.getData(buildingName)
if not tBuilding then
return nil
end
-- Get the rain type, if any. If the building cannot have rain engines, then
-- return an empty string. Returning nil is reserved for when the building
-- does not exist.
return tBuilding.raintype or ""
end
 




---
-- Getter method for the description for a building.
--
-- Accepts the in-game name of the building and returns the corresponding
-- description text, as seen in the game.
-- @param buildingName the name of the building
-- @return the description of the building, which might be an empty string, or
-- nil if it doesn't exist
function BuildingData.getDescription(buildingName)


-- Normalize the argument to the standard in-game name, and the one that
-- get the inner table for the building
-- is used as the key in the big lookup table.
local tBuilding = BuildingData.getData(buildingName)
--
if not tBuilding then
-- This function will also make the argument lowercase to reduce the need
return nil
-- to specify more possible alternatives to normalize.
end
function BuildingData.normalizeName(strArg)
strArg = string.lower(strArg)
-- Get the description, if any. If the building doesn't have a description,
-- then return an empty string. Returning nil is reserved for when the  
-- no other functions need this lookup table, so it's defined locally
-- building does not exist.
-- to this function
return tBuilding.description or ""
local tableStrStrAlternatives = {
---------------------------------------
-- Buildings
---------------------------------------
-- Starting Buildings
["ancienthearth"] =  "ancient hearth",
["ancienthearths"] =  "ancient hearth",
["ancient hearths"] = "ancient hearth",
["mainwarehouse"] =  "main warehouse",
["mainwarehouses"] =  "main warehouse",
["main warehouses"] = "main warehouse",
-- Camps
["forager"] =        "foragers' camp",
["foragerscamp"] =    "foragers' camp",
["forager'scamp"] =  "foragers' camp",
["foragers'camp"] =  "foragers' camp",
["forager camp"] =    "foragers' camp",
["forager's camp"] =  "foragers' camp",
["foragers"] =        "foragers' camp",
["foragerscamps"] =  "foragers' camp",
["forager'scamps"] =  "foragers' camp",
["foragers'camps"] =  "foragers' camp",
["forager camps"] =  "foragers' camp",
["forager's camps"] = "foragers' camp",
["harvester"] =        "harvesters' camp",
["harvesterscamp"] =    "harvesters' camp",
["harvester'scamp"] =  "harvesters' camp",
["harvesters'camp"] =  "harvesters' camp",
["harvester camp"] =    "harvesters' camp",
["harvester's camp"] =  "harvesters' camp",
["harvesters"] =        "harvesters' camp",
["harvesterscamps"] =  "harvesters' camp",
["harvester'scamps"] =  "harvesters' camp",
["harvesters'camps"] =  "harvesters' camp",
["harvester camps"] =  "harvesters' camp",
["harvester's camps"] = "harvesters' camp",
["herbalist"] =        "herbalists' camp",
["herbalistscamp"] =    "herbalists' camp",
["herbalist'scamp"] =  "herbalists' camp",
["herbalists'camp"] =  "herbalists' camp",
["herbalist camp"] =    "herbalists' camp",
["herbalist's camp"] =  "herbalists' camp",
["herbalists"] =        "herbalists' camp",
["herbalistscamps"] =  "herbalists' camp",
["herbalist'scamps"] =  "herbalists' camp",
["herbalists'camps"] =  "herbalists' camp",
["herbalist camps"] =  "herbalists' camp",
["herbalist's camps"] = "herbalists' camp",
["stonecutter"] =        "stonecutters' camp",
["stonecutterscamp"] =    "stonecutters' camp",
["stonecutter'scamp"] =  "stonecutters' camp",
["stonecutters'camp"] =  "stonecutters' camp",
["stonecutter camp"] =    "stonecutters' camp",
["stonecutter's camp"] =  "stonecutters' camp",
["stonecutters"] =        "stonecutters' camp",
["stonecutterscamps"] =  "stonecutters' camp",
["stonecutter'scamps"] =  "stonecutters' camp",
["stonecutters'camps"] =  "stonecutters' camp",
["stonecutter camps"] =  "stonecutters' camp",
["stonecutter's camps"] = "stonecutters' camp",
["trapper"] =        "trappers' camp",
["trapperscamp"] =    "trappers' camp",
["trapper'scamp"] =  "trappers' camp",
["trappers'camp"] =  "trappers' camp",
["trapper camp"] =    "trappers' camp",
["trapper's camp"] =  "trappers' camp",
["trappers"] =        "trappers' camp",
["trapperscamps"] =  "trappers' camp",
["trapper'scamps"] =  "trappers' camp",
["trappers'camps"] =  "trappers' camp",
["trapper camps"] =  "trappers' camp",
["trapper's camps"] = "trappers' camp",
["woodcutter"] =        "woodcutters' camp",
["woodcutterscamp"] =    "woodcutters' camp",
["woodcutter'scamp"] =  "woodcutters' camp",
["woodcutters'camp"] =  "woodcutters' camp",
["woodcutter camp"] =    "woodcutters' camp",
["woodcutter's camp"] =  "woodcutters' camp",
["woodcutters"] =        "woodcutters' camp",
["woodcutterscamps"] =  "woodcutters' camp",
["woodcutter'scamps"] =  "woodcutters' camp",
["woodcutters'camps"] =  "woodcutters' camp",
["woodcutter camps"] =  "woodcutters' camp",
["woodcutter's camps"] = "woodcutters' camp",
-- Farms
["field"] =      "farm field",
["fields"] =      "farm field",
["farmfield"] =  "farm field",
["farmfields"] =  "farm field",
["farm fields"] = "farm field",
["herbgarden"] =  "herb garden",
["herbgardens"] =  "herb garden",
["herb gardens"] = "herb garden",
["farm"] =        "small farm",
["farms"] =      "small farm",
["smallfarm"] =  "small farm",
["smallfarms"] =  "small farm",
["small farms"] = "small farm",
-- Food Production
["baker"] =    "bakery",
["bakers"] =  "bakery",
["bakeries"] = "bakery",
["celler"] =  "cellar",
["cellers"] = "cellar",
["cellars"] = "cellar",
["cookhouses"] =  "cookhouse",
["cook house"] =  "cookhouse",
["cook houses"] = "cookhouse",
["grills"] = "grill",
["ranches"] = "ranch",
["smokehouses"] =  "smokehouse",
["smoke house"] =  "smokehouse",
["smoke housea"] = "smokehouse",
-- Housing
["house"] =  "shelter",
["houses"] = "shelter",
["bighouse"] =    "big shelter",
["bighouses"] =  "big shelter",
["bigshelter"] =  "big shelter",
["bigshelters"] = "big shelter",
["humanhouse"] =    "human house",
["humanhouses"] =    "human house",
["human'shouse"] =  "human house",
["humans'house"] =  "human house",
["human houses"] =  "human house",
["human's house"] =  "human house",
["humans' house"] =  "human house",
["human's houses"] = "human house",
["humans' houses"] = "human house",
["beaverhouse"] =    "beaver house",
["beaverhouses"] =    "beaver house",
["beaver'shouse"] =  "beaver house",
["beavers'house"] =  "beaver house",
["beaver'shouses"] =  "beaver house",
["beavers'houses"] =  "beaver house",
["beaver houses"] =  "beaver house",
["beaver's houses"] = "beaver house",
["beavers' houses"] = "beaver house",
["lizardhouse"] =    "lizard house",
["lizardhouses"] =    "lizard house",
["lizard'shouse"] =  "lizard house",
["lizards'house"] =  "lizard house",
["lizard'shouses"] =  "lizard house",
["lizards'houses"] =  "lizard house",
["lizard houses"] =  "lizard house",
["lizard's houses"] = "lizard house",
["lizards' houses"] = "lizard house",
["harpyhouse"] =      "harpy house",
["harpyhouses"] =    "harpy house",
["harpy'shouse"] =    "harpy house",
["harpys'house"] =    "harpy house",
["harpy'shouses"] =  "harpy house",
["harpys'houses"] =  "harpy house",
["harpy houses"] =    "harpy house",
["harpy's houses"] =  "harpy house",
["harpys' houses"] =  "harpy house",
["harpieshouse"] =    "harpy house",
["harpieshouses"] =  "harpy house",
["harpies'house"] =  "harpy house",
["harpies houses"] =  "harpy house",
["harpies' houses"] = "harpy house",
-- Industry
["crudeworkstation"] = "crude workstation",
["crudeworkstations"] = "crude workstation",
["crude workstations"] = "crude workstation",
["makeshiftpost"] = "makeshift post",
["makeshiftposts"] = "makeshift post",
["makeshift posts"] = "makeshift post",
["advancedraincollector"] = "advanced rain collector",
["advancedraincollectors"] = "advanced rain collector",
["advanced rain collectors"] = "advanced rain collector",
["alchemist"] =        "alchemist's hut",
["alchemists"] =      "alchemist's hut",
["alchemisthut"] =    "alchemist's hut",
["alchemisthuts"] =    "alchemist's hut",
["alchemistshut"] =    "alchemist's hut",
["alchemistshuts"] =  "alchemist's hut",
["alchemist'shut"] =  "alchemist's hut",
["alchemist'shuts"] =  "alchemist's hut",
["alchemists'hut"] =  "alchemist's hut",
["alchemists'huts"] =  "alchemist's hut",
["alchemist hut"] =    "alchemist's hut",
["alchemist huts"] =  "alchemist's hut",
["alchemists hut"] =  "alchemist's hut",
["alchemists huts"] =  "alchemist's hut",
["alchemists' hut"] =  "alchemist's hut",
["alchemists' huts"] = "alchemist's hut",
["artisans"] = "artisan",
["brewer"] =    "brewery",
["brewers"] =  "brewery",
["breweries"] = "brewery",
["brickyards"] = "brickyard",
["brick yard"] = "brickyard",
["brick yards"] = "brickyard",
["carpenters"] = "carpenter",
["clothiers"] = "clothier",
["cooper"] =    "cooperage",
["coopers"] =    "cooperage",
["cooperages"] = "cooperage",
["druid"] =        "druid's hut",
["druids"] =      "druid's hut",
["druidhut"] =    "druid's hut",
["druidhuts"] =    "druid's hut",
["druid'shut"] =  "druid's hut",
["druid'shuts"] =  "druid's hut",
["druids'hut"] =  "druid's hut",
["druids'huts"] =  "druid's hut",
["druid hut"] =    "druid's hut",
["druid huts"] =  "druid's hut",
["druids' hut"] =  "druid's hut",
["druids' huts"] = "druid's hut",
["druid's huts"] = "druid's hut",
["furnaces"] = "furnace",
["kilns"] = "kiln",
["leatherworkers"] =  "leatherworker",
["leather worker"] =  "leatherworker",
["leather workers"] = "leatherworker",
["lumbermill"] =  "lumber mill",
["lumbermills"] =  "lumber mill",
["lumber mills"] = "lumber mill",
["mines"] = "mine",
["presses"] = "press",
["provisioners"] = "provisioner",
["raincollector"] = "rain collector",
["raincollectors"] = "rain collector",
["rain collectors"] = "rain collector",
["rainmill"] =  "rain mill",
["rainmills"] =  "rain mill",
["rain mills"] = "rain mill",
["scribes"] = "scribe",
["smelters"] =  "smelter",
["smeltery"] =  "smelter",
["smelteries"] = "smelter",
["tool shop"] = "toolshop",
["weavers"] = "weaver",
-- City buildings
["smallhearth"] =  "small hearth",
["smallhearths"] =  "small hearth",
["small hearths"] = "small hearth",
["warehouses"] =  "warehouse",
["ware house"] =  "warehouse",
["ware houses"] = "warehouse",
["traderpost"] =  "trading post",
["traderposts"] =  "trading post",
["trader posts"] = "trading post",
["tradingpost"] =  "trading post",
["tradingposts"] =  "trading post",
["trading posts"] = "trading post",
["blightpost"] =  "blight post",
["blightposts"] =  "blight post",
["blight posts"] = "blight post",
["hydrants"] = "hydrant",
["forsakenaltar"] =    "forsaken altar",
["forsakenalter"] =    "forsaken altar",
["foresakenaltar"] =  "forsaken altar",
["foresakenalter"] =  "forsaken altar",
["forsakenaltars"] =  "forsaken altar",
["forsakenalters"] =  "forsaken altar",
["foresakenaltars"] =  "forsaken altar",
["foresakenalters"] =  "forsaken altar",
["forsaken altars"] =  "forsaken altar",
["forsaken alters"] =  "forsaken altar",
["foresaken altars"] = "forsaken altar",
["foresaken alters"] = "forsaken altar",
-- Service Buildings
["bath"] =        "bath house",
["baths"] =      "bath house",
["bathhouse"] =  "bath house",
["bathhouses"] =  "bath house",
["bath houses"] = "bath house",
["clan"] =      "clan hall",
["clans"] =      "clan hall",
["clanhall"] =  "clan hall",
["clanhalls"] =  "clan hall",
["clan halls"] = "clan hall",
["explorer"] =          "explorers' lodge",
["explorers"] =        "explorers' lodge",
["explorerlodge"] =    "explorers' lodge",
["explorerslodge"] =    "explorers' lodge",
["explorerlodges"] =    "explorers' lodge",
["explorerslodges"] =  "explorers' lodge",
["explorers'lodges"] =  "explorers' lodge",
["explorer'slodges"] =  "explorers' lodge",
["explorer lodge"] =    "explorers' lodge",
["explorers lodge"] =  "explorers' lodge",
["explorer lodges"] =  "explorers' lodge",
["explorers lodges"] =  "explorers' lodge",
["explorer's lodges"] = "explorers' lodge",
["guild"] =        "guild house",
["guilds"] =      "guild house",
["guildhouse"] =  "guild house",
["guildhouses"] =  "guild house",
["guild houses"] = "guild house",
["monestary"] = "monastery",
["monastary"] = "monastery",
["monestery"] = "monastery",
["monestaries"] = "monastery",
["monastaries"] = "monastery",
["monesteries"] = "monastery",
["taverns"] = "tavern",
["temples"] = "temple"
} -- the end of the huge tableStrStrAlternatives
-- if nothing is found, the result of the lookup will be nil, so
-- just return whatever was passed in as the argument (lowercase)
-- we can assume that the input argument is fine or does not exist
return tableStrStrAlternatives[strArg] or strArg
end
end






-------------------------------------------------------------------------------
-- Return this class when required into another module.
-- Return when required into another Module.
-------------------------------------------------------------------------------
return BuildingData
return BuildingData

Latest revision as of 01:56, 18 February 2023

Documentation for this module may be created at Module:BuildingData/doc

-------------------------------------------------------------------------------
-- This module primarily supplies data and lookup functions for other modules 
-- that support templates like {{Building_link}}.
-- https://hoodedhorse.com/wiki/Against_the_Storm/Template:Building_link
-- 
-- The main data table stores all available data about buildings themselves 
-- and relies on other modules to store relationships between buildings and 
-- products, services, etc.
--
-- The helper functions include getters (to keep the data hidden) and a large
-- deconfliction method to provide some robustness when using the template
-- and from other Lua modules. Looking up a building requires using in-game 
-- names, but forgives small differences in spacing, apostrophes, and plurals.

-- Please help keep this table updated as the game is updated.
-- @module BuildingData
local BuildingData = {}

--
-- Dependencies
--
RecipeData = RecipeData or require("Module:RecipeData") -- need recipe relationships
Utility = Utility or require("Module:Utility") -- need normalize functions



-- 
-- Constants
-- 
-- Specializations
local S_ALCH = "Alchemy"
local S_BREW = "Brewing"
local S_CLOT = "Cloth"
local S_ENGI = "Engineering"
local S_MEAT = "Meat production"
local S_WARM = "Warmth"
local S_WOOD = "Wood"

-- Resource names of building costs
local C_BRICK = "Bricks"
local C_FABRI = "Fabric"
local C_PARTS = "Parts"
local C_PIPES = "Pipes"
local C_PLANK = "Planks"

-- Rain types for rain engines
local R_DRIZZ = "Drizzle Water"
local R_CLEAR = "Clearance Water"
local R_STORM = "Storm Water"



--
-- Class Variables
--

-------------------------------------------------------------------------------
-- Primary data table for this module.
-- 
-- This table stores the details of buildings according to in-game information.
-- A design decision of this table is to make the key the same as the page 
-- name, so that whenever .page is referenced, it can be used again to retrieve 
-- the rest of the data. (The lookup method will handle converting it to 
-- lowercase.)
--
-- Structure:
-- @key a lowercase version of the building name, with the same spaces, 
-- apostrophes, singular, and spelling
-- @field page the name of the wiki page, case-sensitive, but otherwise must be 
-- the same as the key
-- @field iconfile a string of the filename.png of the icon used in the game, 
-- case-sensitive and must include extension, but without the "File:"
-- @field specialization[opt] a table of the specializations listed in the 
-- in-game encyclopedia (use the constants, above), or omit if none
-- @field cost[opt] a table of the building costs (or omit if none), in the 
-- following format:
-- 		{ first cost { number, resource },
--		  second cost { number, resource },
--		  etc. }
-- @field workers the number of worker slots
-- @field raintype the color of rain used in the Rain Engine of this building 
-- (use constants, above), if any
-- @field description the in-game description text, in plain text
-- @table tBuildingData the primary data table for buildings
local tBuildingData = { 
	
	-- Starting Buildings
	["ancient hearth"] = { page="Ancient Hearth", 
		iconfile="Small Hearth icon.png", 
		specialization={ S_WARM }, 
		workers=1, 
		description="The heart of the colony is protected by the Holy Flame. Villagers gather here to rest, eat, and receive clothing. If the fire goes out, people will lose hope. Can't be moved. Size: 4x4." },
	["main warehouse"] = { page="Main Warehouse", 
		iconfile="Main_Storage_icon.png" },
	
	-- Camps
	["small foragers' camp"] = { page="Small Foragers' Camp", 
		iconfile="Small Foragers' Camp icon.png" },
	["foragers' camp"] = { page="Foragers' Camp", 
		iconfile="Forager's Camp icon.png" },
	["harvesters' camp"] = { page="Harvesters' Camp", 
		iconfile="Harvester Camp icon.png" },
	["small herbalists' camp"] = { page="Small Herbalists' Camp", 
		iconfile="Small_Herbalists'_Camp_icon.png" },
	["herbalists' camp"] = { page="Herbalists' Camp", 
		iconfile="Herbalist's_Camp_icon.png" },
	["stonecutters' camp"] = { page="Stonecutters' Camp", 
		iconfile="Stonecutter's Camp icon.png" },
	["small trappers' camp"] = { page="Small Trappers' Camp", 
		iconfile="Small_Trappers'_Camp_icon.png" },
	["trappers' camp"] = { page="Trappers' Camp", 
		iconfile="Trapper's Camp icon.png" },
	["woodcutters' camp"] = { page="Woodcutters' Camp", 
		iconfile="Woodcutters Camp icon.png" },
	
	-- Farms
	["farm field"] = { page="Farm Field", 
		iconfile="Farmfield_icon.png" },
	["greenhouse"] = { page="Greenhouse", 
		iconfile="Greenhouse_icon.png" },
	["herb garden"] = { page="Herb Garden", 
		iconfile="HerbGarden_icon.png" },
	["plantation"] = { page="Plantation", 
		iconfile="Plantation_icon.png" },
	["small farm"] = { page="Small Farm", 
		iconfile="SmallFarm_icon.png" },
	
	-- Food production
	["bakery"] = { page="Bakery", 
		iconfile="Bakery_icon.png" },
	["butcher"] = { page="Butcher", 
		iconfile="Butcher_icon.png" },
	["cellar"] = { page="Cellar", 
		iconfile="Cellar_icon.png" },
	["cookhouse"] = { page="Cookhouse", 
		iconfile="Cookhouse_icon.png" },
	["field kitchen"] = { page="Field Kitchen", 
		iconfile="Field_Kitchen_icon.png" },
	["granary"] = { page="Granary", 
		iconfile="Granary_icon.png" },
	["grill"] = { page="Grill", 
		iconfile="Grill_icon.png" },
	["ranch"] = { page="Ranch", 
		iconfile="Ranch_icon.png" },
	["smokehouse"] = { page="Smokehouse", 
		iconfile="Smokehouse_icon.png" },
	
	-- Housing
	["shelter"] = { page="Shelter", 
		iconfile="Shelter icon.png" },
	["big shelter"] = { page="Big Shelter", 
		iconfile="Big Shelter icon.png" },
	["human house"] = { page="Human House", 
		iconfile="Human House icon.png" },
	["beaver house"] = { page="Beaver House", 
		iconfile="Beaver House icon.png" },
	["lizard house"] = { page="Lizard House", 
		iconfile="Lizard House icon.png" },
	["harpy house"] = { page="Harpy House", 
		iconfile="Harpy House icon.png" },
	
	-- Industry
	["crude workstation"] = { page="Crude Workstation", 
		iconfile="Crude_Workstation_icon.png" },
	["makeshift post"] = { page="Makeshift Post", 
		iconfile="Makeshift_Post_icon.png" },
	["advanced rain collector"] = { page="Advanced Rain Collector", 
		iconfile="Advanced_Rain_Collector_icon.png", 
		specialization={ S_ENGI, S_ALCH }, 
		cost={ {5,C_PIPES}, {3,C_PARTS}, {5,C_PLANK} }, 
		description="Can collect infused rainwater used for crafting and powering Rain Engines in production buildings. The type of collected rainwater depends on the season. Can't be moved. Size: 3x2." },
	["alchemist's hut"] = { page="Alchemist's Hut", 
		iconfile="Alchemist_Hut_icon.png",
		specialization={ S_ALCH, S_BREW }, 
		cost={ {5,C_PLANK}, {2,C_BRICK} }, 
		workers=2, 
		raintype=R_CLEAR, 
		description="Can produce: Crystalized Dew (★★), Cosmetics (★★), Wine (★★). Can use: Clearance Water. Can't be moved. Size: 3x2." },
	["apothecary"] = { page="Apothecary", 
		iconfile="Apothecary_icon.png", 
		specialization={ S_ALCH }, 
		cost={ {5,C_PLANK}, {2,C_BRICK} }, 
		workers=2, 
		raintype=R_CLEAR, 
		description="Can produce: Cosmetics (★★), Incense (★★), Biscuits (★★). Can use: Clearance Water. Can't be moved. Size: 3x3." },
	["artisan"] = { page="Artisan", 
		iconfile="Artisan_icon.png" },
	["brewery"] = { page="Brewery", 
		iconfile="Brewery_icon.png" },
	["brick oven"] = { page="Brick Oven", 
		iconfile="Brick_Oven_icon.png" },
	["brickyard"] = { page="Brickyard", 
		iconfile="Brickyard_icon.png" },
	["carpenter"] = { page="Carpenter", 
		iconfile="Carpenter_icon.png" },
	["clothier"] = { page="Clothier", 
		iconfile="Clothier_icon.png" },
	["cooperage"] = { page="Cooperage", 
		iconfile="Cooperage_icon.png" },
	["druid's hut"] = { page="Druid's Hut", 
		iconfile="Druid_icon.png" },
	["flawless brewery"] = { page="Flawless Brewery", 
		iconfile="Brewery_icon.png" },
	["flawless rain mill"] = { page="Flawless Rain Mill", 
		iconfile="Rain_Mill_icon.png" },
	["furnace"] = { page="Furnace", 
		iconfile="Furnace_icon.png" },
	["kiln"] = { page="Kiln", 
		iconfile="Kiln_icon.png" },
	["leatherworker"] = { page="Leatherworker", 
		iconfile="Leatherworks_icon.png" },
	["lumber mill"] = { page="Lumber Mill", 
		iconfile="Lumbermill_icon.png" },
	["mine"] = { page="Mine", 
		iconfile="Mine_icon.png" },
	["press"] = { page="Press", 
		iconfile="Press_icon.png" },
	["provisioner"] = { page="Provisioner", 
		iconfile="Provisioner_icon.png" },
	["rain collector"] = { page="Rain Collector", 
		iconfile="Rain_Collector_icon.png" },
	["rain mill"] = { page="Rain Mill", 
		iconfile="Rain_Mill_icon.png" },
	["scribe"] = { page="Scribe", 
		iconfile="Scribe_icon.png" },
	["smelter"] = { page="Smelter", 
		iconfile="Smelter_icon.png" },
	["toolshop"] = { page="Toolshop", 
		iconfile="Toolshop_icon.png" },
	["weaver"] = { page="Weaver", 
		iconfile="Weaver_icon.png" },
	
	-- City Buildings
	["archaeologist's office"] = { page="Archaeologist's Office", 
		iconfile="Archeologist_office_icon.png",
		cost={ {2,C_PLANK}, {2,C_BRICK}, {2,C_FABRI} }, 
		description="A building designed to help you study the past. Can be upgraded to locate archaeological discoveries or improve exploration capabilities. Can be moved for: 5 Wood. Size: 3x3." },
	["small hearth"] = { page="Small Hearth", 
		iconfile="Temporary_Hearth_icon.png" },
	["warehouse"] = { page="Warehouse", 
		iconfile="Storage_icon.png" },
	["trading post"] = { page="Trading Post", 
		iconfile="Trading_Post_icon.png" },
	["blight post"] = { page="Blight Post", 
		iconfile="Blight_Post_icon.png" },
	["hydrant"] = { page="Hydrant", 
		iconfile="Hydrant_icon.png" },
	["forsaken altar"] = { page="Forsaken Altar", 
		iconfile="Altar_icon.png" },
	
	-- Service Buildings
	["bath house"] = { page="Bath House", 
		iconfile="Bath_House_icon.png" },
	["clan hall"] = { page="Clan Hall", 
		iconfile="Clan_Hall_icon.png" },
	["explorers' lodge"] = { page="Explorers' Lodge", 
		iconfile="Explorers_Lodge_icon.png" },
	["guild house"] = { page="Guild House",	
		iconfile="Guild_House_icon.png"	},
	["monastery"] = { page="Monastery", 
		iconfile="Monastery_icon.png"},
	["tavern"] = { page="Tavern", 
		iconfile="Tavern_icon.png" },
	["temple"] = { page="Temple", 
		iconfile="Temple_icon.png" },
		
} -- end of tBuildingData



-------------------------------------------------------------------------------
-- Main lookup function
-- 
-- Accepts the in-game name and returns the corresponding inner table from
-- tBuildingData. It is preferred that callers use the other getter functions
-- that return specific fields of the inner table rather than the whole thing,
-- to protect variations in this module.
-- @param buildingName the name of the building to look up
-- @return the inner table from the big data table corresponding to the provided
-- building name, or nil if it doesn't exist
function BuildingData.getData(buildingName)
	
	-- If the argument to this function is empty or nil, save some time by 
	-- skipping the normalize function.
	if not buildingName or "" == buildingName then
		return nil
	end
	
	-- normalize the name to try again
    local buildingName = Utility.normalizeBuildingName(buildingName)
	
	-- get the inner table from the big data table and return it; if it doesn't
	-- exist, this will return nil anyway
    return tBuildingData[buildingName] or nil
end



---
-- Getter method for the page name for a building.
-- 
-- Accepts the in-game name of the building and returns the corresponding name
-- of the page in the wiki for the building. If the buildingName argument is 
-- formatted exactly as in the game, this will return a string matching the
-- argument. Since normalization is performed, this can be used to ensure proper
-- formatting of the building's name.
-- @param buildingName the name of the building
-- @return the name of the page on the wiki, or nil if it doens't exist
function BuildingData.getPagename(buildingName)

	-- get the inner table for the building
	local tBuilding = BuildingData.getData(buildingName)
	if not tBuilding then
		return nil
	end
	
	-- if the building didn't exist, then nil was already returned, but if the
	-- page was undefined, this should return nil instead of an empty string
	return tBuilding.page
end



---
-- Getter method for the icon filename for a building.
-- 
-- Accepts the in-game name of the building and returns the corresponding 
-- filename on the wiki for the building's icon as seen in-game.
-- @param buildingName the name of the building
-- @return the filename, which might be an empty string, or nil if it doesn't 
-- exist
function BuildingData.getIconFilename(buildingName)
	
	-- get the inner table for the building
	local tBuilding = BuildingData.getData(buildingName)
	if not tBuilding then
		return nil
	end
	
	-- Get the icon filename, if any. If the building doesn't have an icon,
	-- then return an empty string. Returning nil is reserved for when the 
	-- building does not exist.
	return tBuilding.iconfile or ""
end



---
-- Getter method for the specializations of a building.
-- 
-- Accepts the in-game name of the building and returns the corresponding 
-- specializations, if any, as a table of strings.
-- @param the name of the building
-- @return a table with the specializations for the building, which might be
-- empty if the building has no specializations, or nil if the building doesn't 
-- exist
function BuildingData.getSpecialization(buildingName)

	-- get the inner table for the building
	local tBuilding = BuildingData.getData(buildingName)
	
	-- if the building didn't exist, return nil
	if not tBuilding then
		return nil
	end
	
	local tSpec = {} -- this is our return variable
	
	-- Get the specialization, if any. If there are none, then return that empty 
	-- table. Returning nil is reserved for when the building does not exist.
	if tBuilding.specialization then
		-- overwrite the return variable
		tSpec = tBuilding.specialization
	end
	
	-- At this point, it could be an empty table, signifying that the building
	-- exists but has no specialization.
	return tSpec
end



---
-- Getter method for the building costs of a building.
-- 
-- Accepts the in-game name of the building and returns the corresponding 
-- costs in resources to build as a table of strings. Buildings that the player
-- starts with or are otherwise free to build will have no costs.
-- @param the name of the building
-- @return a table with the costs of the building, which may be empty if the 
-- player starts with the building, or nil if the building doesn't exist; the
-- cost table has the following format:
-- 		{ first cost { number, resource },
--		  second cost { number, resource },
--		  etc. }
function BuildingData.getCosts(buildingName)

	-- get the inner table for the building
	local tBuilding = BuildingData.getData(buildingName)
	
	-- if the building didn't exist, return nil
	if not tBuilding then
		return nil
	end
	
	local tCost = {} -- this is our return variable
	
	-- Get the costs, if any. If there are none, then return that empty table. 
	-- Returning nil is reserved for when the building does not exist.
	if tBuilding.cost then
		-- overwrite the return variable
		tCost = tBuilding.cost
	end
	
	-- At this point, it could be an empty table, signifying that the building
	-- exists but has no cost.
	return tCost
end



---
-- Getter method for the number of worker slots at a building.
-- 
-- Accepts the in-game name of the building and returns the corresponding 
-- number of workers the building can take, if any.
-- @param the name of the building
-- @return the number of workers, which might be zero, or nil if the building 
-- doesn't exist
function BuildingData.getWorkers(buildingName)

	-- get the inner table for the building
	local tBuilding = BuildingData.getData(buildingName)
	if not tBuilding then
		return nil
	end
	
	-- Get the number of worker slots, if any. If there are none, then return 
	-- zero. Returning nil is reserved for when the building does not exist.
	return tBuilding.workers or 0
end



---
-- Getter method for the type of rain used in Rain Engines in a building.
-- 
-- Accepts the in-game name of the building and returns the corresponding 
-- rain type.
-- @param the name of the building
-- @return the rain type, if any, or nil if the building doesn't exist
function BuildingData.getRainType(buildingName)

	-- get the inner table for the building
	local tBuilding = BuildingData.getData(buildingName)
	if not tBuilding then
		return nil
	end
	
	-- Get the rain type, if any. If the building cannot have rain engines, then 
	-- return an empty string. Returning nil is reserved for when the building 
	-- does not exist.
	return tBuilding.raintype or ""
end



---
-- Getter method for the description for a building.
-- 
-- Accepts the in-game name of the building and returns the corresponding 
-- description text, as seen in the game.
-- @param buildingName the name of the building
-- @return the description of the building, which might be an empty string, or 
-- nil if it doesn't exist
function BuildingData.getDescription(buildingName)

	-- get the inner table for the building
	local tBuilding = BuildingData.getData(buildingName)
	if not tBuilding then
		return nil
	end
	
	-- Get the description, if any. If the building doesn't have a description,
	-- then return an empty string. Returning nil is reserved for when the 
	-- building does not exist.
	return tBuilding.description or ""	
end



-- Return this class when required into another module.
return BuildingData