Module:ResourceData: Difference between revisions

From Against the Storm Official Wiki
m (improving commenting)
(added a few more getters, and improved commenting. adding more details to buildings as I have time)
Line 1: Line 1:
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- Lua storage module for looking up data about resources, for use in other
-- This module primarily supplies data and lookup functions for other modules
-- modules and templates, for example, {{Resource_Link}}.
-- 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  
-- The main data table stores all available data about resources themselves and
-- and relies on other modules to store relationships between buildings and  
-- relies on other modules to store relationships between resources and  
-- products, services, etc.
-- buildings, services, etc.
--
--
-- The helper functions include getters (to keep the data hidden) and a large
-- The helper functions include getters (to keep the data hidden) and a large
-- normalization method to provide some robustness when using the template and
-- deconfliction method to provide some robustness when using the template
-- from other Lua modules. Looking up a resource requires using in-game names,
-- and from other Lua modules. Looking up a building requires using in-game  
-- but forgives small differences in spacing, apostrophes, and plurals.
-- names, but forgives small differences in spacing, apostrophes, and plurals.
-- @module ResourceData
 
local ResourceData = {}
-- Please help keep this table updated as the game is updated.
-- @module BuildingData
local BuildingData = {}


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






--
--  
-- Constants
-- Constants
--
--  
-- top-level categories; the main tabs in the top of the game window
-- Specializations
local CAT_FOODS = "Food"
local S_ALCH = "Alchemy"
local CAT_BUILD = "Building Materials"
local S_BREW = "Brewing"
local CAT_CONSU = "Consumable Items"
local S_CLOT = "Cloth"
local CAT_CRAFT = "Crafting Resources"
local S_ENGI = "Engineering"
local CAT_TRADE = "Trade Goods"
local S_MEAT = "Meat production"
local CAT_FUEXP = "Fuel & Exploration"
local S_WARM = "Warmth"
local CAT_RAINS = "Rainwater"
local S_WOOD = "Wood"
local CAT_BLIGH = "Blight Fuel"
 
-- 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"


-- secondary categories, for use in wiki pages
-- Rain types for rain engines
-- Foods
local R_DRIZZ = "Drizzle Water"
local C2_RAWFOOD = "Raw Food"
local R_CLEAR = "Clearance Water"
local C2_COMPLEX = "Complex Food"
local R_STORM = "Storm Water"
-- Building Mats
local C2_CONSTRU = "Construction Material"
local C2_RAREMAT = "Rare Material"
-- Consumable Items
local C2_CLOTHIN = "Clothing"
local C2_SERVICE = "Service"
-- Crafting Resources
local C2_RAWMATS = "Raw Material"
local C2_PROCESS = "Processed Material"
local C2_METALOR = "Metal"
local C2_VESSELS = "Vessel"
-- Trade Goods
local C2_VALUABL = "Valuable"
local C2_PACKSGO = "Pack of Good"
local C2_METARES = "Metaresource"
-- Fuel & Exploration
local C2_FUELSAC = "Fuel"
local C2_EXPTOOL = "Tool"
-- Rainwater and Blight Fuel
local C2_RAINWAT = "Rainwater"
local C2_PURGING = "Purging Fire"






--
--
-- Class variables
-- Class Variables
--
--


-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- Primary data table for this module.
-- 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.)
--
--
-- This table stories the details of resources according to in-game information.
-- Structure:
-- A design decision of this table is to make the key the same as the page name,
-- @key a lowercase version of the building name, with the same spaces,  
-- so that whenever .page is referenced, it can be used again to retrieve the
-- apostrophes, singular, and spelling
-- rest of the data. (The lookup method will handle converting it to lowercase.)
-- @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:"
-- Structure:  
-- @field page the name of the wiki page, case-sensitive, but otherwise must be  
-- @key a lowercase version of the resource name, with the same spaces,  
-- the same as the key
-- apostrophes, singular/plural, and spelling
-- @field specialization[opt] a table of the specializations listed in the  
-- @field iconfile a string of the filename.png of the icon used in the  
-- in-game encyclopedia (use the constants, above), or omit if none
-- game, case-sensitive and must include extension, but without the "File:"
-- @field cost[opt] a table of the building costs (or omit if none), in the  
-- @field page the name of the wiki page, case-sensitive, but otherwise must be the same as the key
-- following format:
-- @
-- { first cost { number, resource },
local RESOURCE_DATA = {
--   second cost { number, resource },
 
--   etc. }
---------------------------------------
-- @field workers the number of worker slots
--[[ RESOURCE_DATA
-- @field raintype the color of rain used in the Rain Engine of this building
*defaults are stored here; these value will be modified during the game by
-- (use constants, above), if any
perks and city upgrades
-- @field description the in-game description text, in plain text
-- page: string: the name of the page on the wiki, case sensitive. this should match
-- @table tBuildingData the primary data table for buildings
the spelling, spacing, and punctuation in the game
local tBuildingData = {  
-- iconfile: string: the filename, ending in .png, on the wiki. do not include
the File: prefix. Align with dev data dumps (from Google Drive) or  
-- Starting Buildings
from extracted assets from the Unity Asset Studio.
["ancient hearth"] = { page="Ancient Hearth",  
-- category: string/constant: the category the good belongs to, in the upper UI on
iconfile="Small Hearth icon.png",  
the game screen, for example "Food" or "Consumable Items." useful for building
specialization={ S_WARM },  
tables of similar items. use the constants above.
workers=1,  
-- cat2: string/constant: a more specific category, often referenced by perks,
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." },
needs, or buildings, for example, "Complex Food" and "Packs of goods"
["main warehouse"] = { page="Main Warehouse",  
and "Metal or Ore"
iconfile="Main_Storage_icon.png" },
-- eatable: boolean: true if the good can be eaten, can omit if false
-- burnable: boolean: true if the good can be burned or sacrified in a Hearth, can omit if false
-- Camps
-- burnTime: int: default* seconds the item burns for in a Hearth, can omit if burnable is false
["foragers' camp"] = { page="Foragers' Camp",  
-- sacrificedRate: int: default* number of items sacrified per minute in a Hearth, can omit if burnable is false
iconfile="Forager's Camp icon" },
-- sellValue: float: default* value when selling, in Amber (the spreadsheet shows value as 10x, so 2.4 = 0.24 in-game)
["harvesters' camp"] = { page="Harvesters' Camp",  
-- buyValue: float: default* value when buying, in Amber
iconfile="Harvester Camp icon.png" },
-- description: string: the in-game description.
["herbalists' camp"] = { page="Herbalists' Camp",  
--]]
iconfile="Herbalist's_Camp_icon.png" },
---------------------------------------
["stonecutters' camp"] = { page="Stonecutters' Camp",  
    -- Food/Raw Food
iconfile="Stonecutter's Camp icon.png" },
["berries"] = { page="Berries",
["trappers' camp"] = { page="Trappers' Camp",  
iconfile="Icon_Resource_Berries.png",
iconfile="Trapper's Camp icon.png" },
category=CAT_FOODS, cat2=C2_RAWFOOD,
["woodcutters' camp"] = { page="Woodcutters' Camp",  
eatable=true,
iconfile="Woodcutters Camp icon" },
sellValue=0.24, buyValue=0.40,
description="Common food source. Obtained by: Plantation, Hallowed Herb Garden, Herbalists' Camp, Small Herbalists' Camp."},
-- Farms
["eggs"] = { page="Eggs",
["farm field"] = { page="Farm Field",  
iconfile="Eggs.png",
iconfile="Farmfield_icon.png" },
category=CAT_FOODS, cat2=C2_RAWFOOD,
["greenhouse"] = { page="Greenhouse",  
eatable=true,
iconfile="Greenhouse_icon.png" },
sellValue=0.24, buyValue=0.40,
["herb garden"] = { page="Herb Garden",  
description="Common food source. Obtained by: Ranch, Trappers' Camp, Small Trappers' Camp."},
iconfile="HerbGarden_icon.png" },
["insects"] = { page="Insects",
["plantation"] = { page="Plantation",  
iconfile="Insects.png",
iconfile="Plantation_icon.png" },
category=CAT_FOODS, cat2=C2_RAWFOOD,
["small farm"] = { page="Small Farm",  
eatable=true,
iconfile="SmallFarm_icon.png" },
sellValue=0.24, buyValue=0.40,
description="Common food source. Obtained by: Trappers' Camp, Small Trappers' Camp."},
["meat"] = { page="Meat",  
iconfile="Meat.png",
category=CAT_FOODS, cat2=C2_RAWFOOD,
eatable=true,
sellValue=0.24, buyValue=0.40,
description="Common food source. Obtained by: Ranch, Trappers' Camp, Small Trappers' Camp."},
["mushrooms"] = { page="Mushrooms",
iconfile="Mushrooms.png",  
category=CAT_FOODS, cat2=C2_RAWFOOD,
eatable=true,
sellValue=0.24, buyValue=0.40,
description="Common food source. Obtained by: Herbalists' Camp, Small Herbalists' Camp, Greenhouse, Homestead."},
["roots"] = { page="Roots",
iconfile="Roots.png",
category=CAT_FOODS, cat2=C2_RAWFOOD,
eatable=true,
sellValue=0.24, buyValue=0.40,
description="Common food source. Obtained by: Hallowed Herb Garden, Herb Garden, Foragers' Camp, Small Foragers' Camp."},
["vegetables"] = { page="Vegetables",  
iconfile="Vegetables.png",
category=CAT_FOODS, cat2=C2_RAWFOOD,
eatable=true,
sellValue=0.24, buyValue=0.40,  
description="Common food source. Obtained by: Hallowed Small Farm, Small Farm, Foragers' Camp, Small Foragers' Camp, Homestead."},
-- Food/Complex Food
["biscuits"] = { page="Biscuits",  
iconfile="Icon_Resource_Biscuits.png",
category=CAT_FOODS, cat2=C2_COMPLEX,
eatable=true,
sellValue=0.30, buyValue=0.50,
description="Tasty and crunchy. Produced by: Field Kitchen, Bakery, Cookhouse, Smelter, Apothecary."},
["jerky"] = { page="Jerky",
iconfile="Jerky.png",
category=CAT_FOODS, cat2=C2_COMPLEX,
eatable=true,
sellValue=0.18, buyValue=0.30,
description="Preserved, dried meat. Produced by: Field Kitchen, Smokehouse, Kiln, Butcher, Cellar."},
["pickled goods"] = { page="Pickled Goods",  
iconfile="PickledGoods.png",
category=CAT_FOODS, cat2=C2_COMPLEX,
eatable=true,
sellValue=0.24, buyValue=0.40,
description="A Beaver specialty. Produced by: Field Kitchen, Granary, Cellar, Brewery, Flawless Brewery."},
["pie"] = { page="Pie",
iconfile="Pie.png",
category=CAT_FOODS, cat2=C2_COMPLEX,
eatable=true,
sellValue=0.30, buyValue=0.50,
description="A Human specialty. Produced by: Bakery, Brick Oven, Furnace."},
["skewers"] = { page="Skewers",
iconfile="Skewers.png",
category=CAT_FOODS, cat2=C2_COMPLEX,
eatable=true,
sellValue=0.24, buyValue=0.40,
description="A Lizard specialty. Produced by: Cookhouse, Grill, Butcher."},
-- Building Materials
["bricks"] = { page="Bricks",  
iconfile="Icon_Resource_Bricks.png",
category=CAT_BUILD, cat2=C2_CONSTRU,
sellValue=0.375, buyValue=0.625,
description="Mostly used for construction. Produced by: Crude Workstation, Workshop, Brickyard, Kiln, Furnace."},
["fabric"] = { page="Fabric",  
iconfile="Fabric.png",
category=CAT_BUILD, cat2=C2_CONSTRU,
sellValue=0.375, buyValue=0.625,
description="Used for construction or production of clothes. Produced by: Crude Workstation, Workshop, Weaver, Granary, Leatherworker."},
["pipes"] = { page="Pipes",  
iconfile="En_craft_23.png",
category=CAT_BUILD, cat2=C2_CONSTRU,
sellValue=0.58, buyValue=1.00,
description="Used to install Rainpunk Engines in production buildings and build Geyser Pumps. Produced by: Crude Workstation, Workshop, Smelter, Toolshop."},
["planks"] = { page="Planks",
iconfile="Planks.png",
category=CAT_BUILD, cat2=C2_CONSTRU,
sellValue=0.225, buyValue=0.375,
description="Mostly used for construction. Produced by: Crude Workstation, Workshop, Lumber Mill, Carpenter, Supplier."},
-- Building Materials/Rare
["parts"] = { page="Parts",
iconfile="Parts.png",
category=CAT_BUILD, cat2=C2_RAREMAT,
sellValue=2.28, buyValue=4.80,
description="Rare elements used in camp construction. Difficult to produce in this harsh environment."},
["wildfire essence"] = { page="Wildfire Essence",  
iconfile="Wildfire Essence.png",
category=CAT_BUILD, cat2=C2_RAREMAT,
sellValue=6.00, buyValue=10.0,
description="A sentient flame trapped in a bottle. This rare material is used to light the Holy Flame in Hearths. Can be acquired from orders, Glade Events, or traders."},
-- Consumable Items/Clothing
["coats"] = { page="Coats",
iconfile="Coats.png",
category=CAT_CONSU, cat2=C2_CLOTHIN,
sellValue=0.12, buyValue=0.20,
description="Used as clothing by some villagers. Produced by: Clothier, Smithy, Artisan, Druid's Hut."},
-- Consumable Items/Service Items
["ale"] = { page="Ale",
iconfile="Icon_Resource_Ale.png",
category=CAT_CONSU, cat2=C2_SERVICE,
sellValue=0.21, buyValue=0.35,
description="Used for Leisure at: Tavern, Monastery, Forum. Produced by: Grill, Brewery, Flawless Brewery, Tinctury, Scribe."},
["cosmetics"] = { page="Cosmetics",  
iconfile="Cosmetics.png",
category=CAT_CONSU, cat2=C2_SERVICE,
sellValue=0.18, buyValue=0.3,
description="Used for Cleanliness at: Bath House, Holy Market, Market. Produced by: Cooperage, Alchemist's Hut, Apothecary."},
["incense"] = { page="Incense",
iconfile="Incense.png",
category=CAT_CONSU, cat2=C2_SERVICE,
sellValue=0.225, buyValue=0.375,
description="Used for Religion at: Holy Temple, Temple, Monastery, Clan Hall. Produced by: Smokehouse, Brick Oven, Apothecary, Druid's Hut."},
["scrolls"] = { page="Scrolls",
iconfile="Scrolls.png",
category=CAT_CONSU, cat2=C2_SERVICE,
sellValue=0.18, buyValue=0.30,
description="Used for Education at: Holy Temple, Temple, Explorers' Lodge, Forum. Produced by: Lumber Mill, Clothier, Flawless Rain Mill, Rain Mill, Scribe."},
["training gear"] = { page="Training Gear",  
iconfile="TrainingGear.png",
category=CAT_CONSU, cat2=C2_SERVICE,
sellValue=0.255, buyValue=0.425,
description="Used for Brawling at: Tavern, Clan Hall, Explorers' Lodge. Produced by: Cooperage, Weaver, Tinkerer, Manufactory."},
["wine"] = { page="Wine",
iconfile="Wine.png",
category=CAT_CONSU, cat2=C2_SERVICE,
sellValue=0.18, buyValue=0.30,
description="Used for Luxury at: Guild House, Holy Market, Market. Produced by: Cellar, Alchemist's Hut, Tinctury."},
-- Crafting Materials/Raw Materials
["clay"] = { page="Clay",  
iconfile="Icon_Resource_Clay.png",
category=CAT_CRAFT, cat2=C2_RAWMATS,
sellValue=0.18, buyValue=0.30,
description="Flesh of the earth. Used mostly for crafting. Obtained by: Stonecutters' Camp, Clay Pit."},
["grain"] = { page="Grain",  
iconfile="Grain.png",
category=CAT_CRAFT, cat2=C2_RAWMATS,
sellValue=0.24, buyValue=0.40,
description="Isn't eaten raw, but can be processed. Obtained by: Hallowed Small Farm, Small Farm, Foragers' Camp, Small Foragers' Camp, Homestead."},
["herbs"] = { page="Herbs",
iconfile="Herbs.png",
category=CAT_CRAFT, cat2=C2_RAWMATS,
sellValue=0.24, buyValue=0.40,
description="Isn't eaten raw, but can be processed. Obtained by: Hallowed Herb Garden, Herb Garden, Herbalists' Camp, Small Herbalists' Camp, Greenhouse."},
["leather"] = { page="Leather",  
iconfile="Leather.png",
category=CAT_CRAFT, cat2=C2_RAWMATS,
sellValue=0.18, buyValue=0.30,
description="Used for crafting. Obtained by: Ranch."},
["pigment"] = { page="Pigment",  
iconfile="Pigment.png",
category=CAT_CRAFT, cat2=C2_RAWMATS,
sellValue=0.15, buyValue=0.25,
description="Used for crafting. Produced by: Cookhouse, Artisan, Tinctury, Manufactory."},
["plant fiber"] = { page="Plant Fiber",
iconfile="PlantFiber.png",
category=CAT_CRAFT, cat2=C2_RAWMATS,
sellValue=0.18, buyValue=0.30,
description="Used for crafting. Obtained by: Hallowed Small Farm, Plantation, Harvesters' Camp, Homestead."},
["reeds"] = { page="Reeds",
iconfile="Reeds.png",
category=CAT_CRAFT, cat2=C2_RAWMATS,
sellValue=0.18, buyValue=0.30,
description="Used for crafting. Obtained by: Harvesters' Camp, Clay Pit."},
["resin"] = { page="Resin",  
iconfile="Resin.png",
category=CAT_CRAFT, cat2=C2_RAWMATS,
sellValue=0.18, buyValue=0.30,
description="Used for crafting. Obtained by: Forester's Hut."},
["stone"] = { page="Stone",
iconfile="Stone.png",
category=CAT_CRAFT, cat2=C2_RAWMATS,
sellValue=0.18, buyValue=0.30,
description="Bones of the earth. Used mostly for crafting. Obtained by: Stonecutters' Camp."},
-- Crafting Materials/Processed Materials
-- Food production
["flour"] = { page="Flour",
["bakery"] = { page="Bakery",  
iconfile="Flour.png",
iconfile="Bakery_icon.png" },
category=CAT_CRAFT, cat2=C2_PROCESS,
["butcher"] = { page="Butcher",  
sellValue=0.22, buyValue=0.38,
iconfile="Butcher_icon.png" },
description="Used for cooking. Produced by: Flawless Rain Mill, Rain Mill, Press, Provisioner, Stamping Mill, Supplier."},
["cellar"] = { page="Cellar",  
iconfile="Cellar_icon.png" },
-- Crafting Materials/Metal & Ore
["cookhouse"] = { page="Cookhouse",  
["copper bars"] = { page="Copper Bars",  
iconfile="Cookhouse_icon.png" },
iconfile="CopperBar.png",
["field kitchen"] = { page="Field Kitchen",  
category=CAT_CRAFT, cat2=C2_METALOR,
iconfile="Field_Kitchen_icon.png" },
sellValue=0.72, buyValue=1.2,
["granary"] = { page="Granary",  
description="Refined copper ore, used for crafting. Produced by: Grill, Furnace, Stamping Mill, Smelter."},
iconfile="Granary_icon.png" },
["copper ore"] = { page="Copper Ore",  
["grill"] = { page="Grill",  
iconfile="CopperOre.png",
iconfile="Grill_icon.png" },
category=CAT_CRAFT, cat2=C2_METALOR,
["ranch"] = { page="Ranch",  
sellValue=0.18, buyValue=0.30,
iconfile="Ranch_icon.png" },
description="A soft and malleable metal. Obtained by: Mine."},
["smokehouse"] = { page="Smokehouse",  
["crystalized dew"] = { page="Crystalized Dew",  
iconfile="Smokehouse_icon.png" },
iconfile="CrystalizedDew.png",
category=CAT_CRAFT, cat2=C2_METALOR,
sellValue=0.72, buyValue=1.20,
description="Crystalized rain essence. Produced by: Forester's Hut, Brickyard, Smelter, Alchemist's Hut."},
-- Crafting Materials/Vessels
["barrels"] = { page="Barrels",  
iconfile="Icon_Resource_Barrels.png",
category=CAT_CRAFT, cat2=C2_VESSELS,
sellValue=0.24, buyValue=0.40,
description="Used for crafting. Produced by: Cooperage, Provisioner, Toolshop, Artisan."},
["pottery"] = { page="Pottery",
iconfile="Pottery.png",
category=CAT_CRAFT, cat2=C2_VESSELS,
sellValue=0.225, buyValue=0.375,
description="Used for crafting. Produced by: Bakery, Smokehouse, Brickyard, Stamping Mill."},
["waterskins"] = { page="Waterskins",
iconfile="Waterskins.png",
category=CAT_CRAFT, cat2=C2_VESSELS,
sellValue=0.225, buyValue=0.375,
description="Used for crafting. Produced by: Clothier, Leatherworker, Toolshop, Supplier."},
-- Trade Goods/Valuable Items
["amber"] = { page="Amber",
iconfile="Icon_Resource_Amber.png",
category=CAT_TRADE, cat2=C2_VALUABL,
sellValue=1.20, buyValue=1.50,
description="A widely accepted currency in the kingdom. Crystalized tree blood... fitting."},
["ancient tablet"] = { page="Ancient Tablet",
iconfile="Icon_Resource_AncientTablet.png",
category=CAT_TRADE, cat2=C2_VALUABL,
sellValue=9.60, buyValue=16.0,
description="Valuable sources of knowledge, highly sought after by traders and the Queen herself. They can be found in Dangerous  or Forbidden Glades."},
-- Trade Goods/Packs of Goods
["pack of building materials"] = { page="Pack of Building Materials",
iconfile="Icon_Resource_BuildingMaterials.png",
category=CAT_TRADE, cat2=C2_PACKSGO,
sellValue=1.05, buyValue=1.60,
description="Goods packed for delivery, used for fulfilling orders or trading. Produced by: Makeshift Post, Flawless Rain Mill, Rain Mill, Tinkerer."},
["pack of crops"] = { page="Pack of Crops",
iconfile="Crops.png",
category=CAT_TRADE, cat2=C2_PACKSGO,
sellValue=0.71, buyValue=1.10,
description="Goods packed for delivery, used for fulfilling orders or trading. Produced by: Makeshift Post, Granary, Brewery, Flawless Brewery."},
["pack of luxury goods"] = { page="Pack of Luxury Goods",  
iconfile="Luxury.png",
category=CAT_TRADE, cat2=C2_PACKSGO,
sellValue=0.78, buyValue=1.20,
description="Goods packed for delivery, used for fulfilling orders or trading. Produced by: Carpenter, Leatherworker, Press."},
["pack of provisions"] = { page="Pack of Provisions",
iconfile="Provisions.png",
category=CAT_TRADE, cat2=C2_PACKSGO,
sellValue=0.48, buyValue=0.80,
description="Goods packed for delivery, used for fulfilling orders or trading. Produced by: Makeshift Post, Provisioner, Manufactory."},
["pack of trade goods"] = { page="Pack of Trade Goods",
iconfile="TradeGoods.png",
category=CAT_TRADE, cat2=C2_PACKSGO,
sellValue=0.96, buyValue=1.60,
description="Goods packed for delivery, used for fulfilling orders or trading. Produced by: Lumber Mill, Weaver, Smithy."},
-- Meta resources
["artifacts"] = { page="Artifacts",  
iconfile="Icon MetaResource Artifact.png",
category=CAT_TRADE, cat2=C2_METARES,
sellValue=0.60, buyValue=0.90,
description="Curiosities of a varied nature. Fascinating, sinister, and all in between. Can be used to buy more advanced upgrades in the Smoldering City."},
["food stockpiles"] = { page="Food Stockpiles",  
iconfile="Icon MetaResource FoodStockpiles.png",
category=CAT_TRADE, cat2=C2_METARES,
sellValue=0.30, buyValue=0.45,
description="A basic currency in the realm. Workers are eager to exchange their labor for food for their families. Can be used to buy upgrades in the Smoldering City."},
["machinery"] = { page="Machinery",  
iconfile="Icon MetaResource Machinery.png",
category=CAT_TRADE, cat2=C2_METARES,
sellValue=0.60, buyValue=0.90,
description="Rainpunk technology ripped from the past. Repurposed using skill and labor. Can be used to buy upgrades in the Smoldering City."},
-- Fuel & Exploration/Fuel
-- Housing
["coal"] = { page="Coal",  
["shelter"] = { page="Shelter",  
iconfile="Icon_Resource_Coal.png",  
iconfile="Shelter icon.png" },
category=CAT_FUEXP, cat2=C2_FUELSAC,  
["big shelter"] = { page="Big Shelter",  
burnable=true, burnTime=60, sacrificedRate=18,
iconfile="Big Shelter icon.png" },
sellValue=0.375, buyValue=0.625,
["human house"] = { page="Human House",  
description="Efficient fuel. Obtained by: Mine, Brick Oven, Kiln."},
iconfile="Human House icon.png" },
["oil"] = { page="Oil",  
["beaver house"] = { page="Beaver House",  
iconfile="Oil.png",  
iconfile="Beaver House icon.png" },
category=CAT_FUEXP, cat2=C2_FUELSAC,  
["lizard house"] = { page="Lizard House",  
burnable=true, burnTime=30, sacrifiedRate=15,
iconfile="Lizard House icon.png" },
sellValue=0.195, buyValue=0.325,
["harpy house"] = { page="Harpy House",  
description="Efficient fuel. Obtained by: Butcher, Press, Druid's Hut."},
iconfile="Harpy House icon.png" },
["sea marrow"] = { page="Sea Marrow",  
iconfile="SeaMarrow.png",
category=CAT_FUEXP, cat2=C2_FUELSAC,
burnable=true, burnTime=60, sacrifiedRate=18,
sellValue=0.375, buyValue=0.625,
description="Efficient fuel. Obtained by: Stonecutters' Camp."},
["wood"] = { page="Wood",  
iconfile="Wood.png",
category=CAT_FUEXP, cat2=C2_FUELSAC,
burnable=true, burnTime=15, sacrifiedRate=30,
sellValue=0.075, buyValue=0.125,
description="An abundant, yet crucial resource. Obtained by: Woodcutters' Camp."},
-- Fuel & Exploration/Tools
-- Industry
["simple tools"] = { page="Simple Tools",  
["crude workstation"] = { page="Crude Workstation",  
iconfile="SimpleTools.png",  
iconfile="Crude_Workstation_icon.png" },
category=CAT_FUEXP, cat2=C2_EXPTOOL,  
["makeshift post"] = { page="Makeshift Post",
sellValue=1.665, buyValue=2.775,  
iconfile="Makeshift_Post_icon.png" },
description="Used in exploration, for opening caches and completing difficult events. Produced by: Carpenter, Smithy, Toolshop, Tinkerer, Scribe."},
["advanced rain collector"] = { page="Advanced Rain Collector",
["infused tools"] = { page="Infused Tools",  
iconfile="Advanced_Rain_Collector_icon.png",  
iconfile="InfusedTools.png",  
specialization={ S_ENGI, S_ALCH },
category=CAT_FUEXP, cat2=C2_EXPTOOL,  
cost={ {5,C_PIPES}, {3,C_PARTS}, {5,C_PLANK} },  
sellValue=2.115, buyValue=3.525,  
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." },
description="Used in exploration, for opening caches and completing difficult events. Produced by: Finesmith, Rainpunk Foundry."},
["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,
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,  
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" },
-- Rainwater
-- City Buildings
["clearance water"] = { page="Clearance Water",  
["archaeologist's office"] = { page="Archaeologist's Office",  
iconfile="Yellow_30.png",  
iconfile="Archeologist_office_icon.png",
category=CAT_RAINS, cat2=C2_RAINWAT,  
cost={ {2,C_PLANK}, {2,C_BRICK}, {2,C_FABRI} },  
description="Highly concentrated yellow clearance rainwater. Used to power Rain Engines in crafting-oriented buildings."},
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." },
["drizzle water"] = { page="Drizzle Water",  
["small hearth"] = { page="Small Hearth",  
iconfile="Green_11.png",  
iconfile="Temporary_Hearth_icon.png" },
category=CAT_RAINS, cat2=C2_RAINWAT,  
["warehouse"] = { page="Warehouse",  
description="Highly concentrated green drizzle rainwater. Used to power Rain Engines in food-oriented buildings."},
iconfile="Storage_icon.png" },
["storm water"] = { page="Storm Water",  
["trading post"] = { page="Trading Post",  
iconfile="Blue_14.png",  
iconfile="Trading_Post_icon.png" },
category=CAT_RAINS, cat2=C2_RAINWAT,  
["blight post"] = { page="Blight Post",  
description="Highly concentrated blue storm rainwater. Used to power Rain Engines in industry-oriented buildings."},
iconfile="Blight_Post_icon.png" },
["hydrant"] = { page="Hydrant",  
iconfile="Hydrant_icon.png" },
["forsaken altar"] = { page="Forsaken Altar",  
iconfile="Altar_icon.png" },
-- Blight Fuel
-- Service Buildings
["purging fire"] = { page="Purging Fire",  
["bath house"] = { page="Bath House",  
iconfile="PurgingFire.png",  
iconfile="Bath_House_icon.png" },
category=CAT_BLIGH, cat2=C2_PURGING,  
["clan hall"] = { page="Clan Hall",  
sellValue=0.375, buyValue=0.625,  
iconfile="Clan_Hall_icon.png" },
description="A unique resource used by Blight Fighters to burn down Blightrot Cysts. Produced by: Blight Post."}
["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 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
-- Some associated lookup functions are necessary to hide the inner table
-- that return specific fields of the inner table rather than the whole thing,
-- names from outside functions. For example, getIconFilename so that we can
-- to protect variations in this module.
-- change the name of .iconfile without breaking other modules.
-- @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 and 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 icon filename for a building.
function ResourceData.getData(strArg)
--
 
-- Accepts the in-game name of the building and returns the corresponding
-- normalize input
-- filename on the wiki for the building's icon as seen in-game.
    local strArg = Utility.normalizeResourceName(strArg)
-- @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 = getData(buildingName)
if not tBuilding then
return nil
end
local icon = "" -- this is our return variable
-- Get it from the big table below and return it.
-- Get the icon filename, if any. If the building doesn't have an icon,
    return RESOURCE_DATA[strArg]
-- then return an empty string. Returning nil is reserved for when the
-- building does not exist.
if tBuilding.iconfile then
--overwrite the return variable
icon = tBuilding.iconfile
end
-- At this point, it could be an empty string, signifying that the building
-- exists but does not have an icon.
return icon
end
end






-- simpler version if all that's needed is the iconfile.
---
-- error handling by the calling module is required.
-- Getter method for the page name for a building.
function ResourceData.getIconFilename(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)


local data = getData(strArg)
-- get the inner table for the building
local tBuilding = getData(buildingName)
-- if this particular data block doesn't have a iconfile, this will return nil
-- if the building didn't exist, then this needs to return nil so it can't
-- therefore, error handling will be necessary
-- be used as a key again
return data.iconfile or nil
return tBuilding.page or nil
end
end
-- and if the table is provided instead of the name to lookup
function ResourceData.getIconFilenameFromData(RESOURCE_DATA)


-- if this particular data block doesn't have a iconfile, this will return nil
 
-- therefore, error handling will be necessary
 
return RESOURCE_DATA.iconfile or nil
---
-- 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 = 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
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 ResourceData.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 = 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
-- and if the table is provided instead of the name to lookup
function ResourceData.getPagenameFromData(RESOURCE_DATA)


-- if this particular data block doesn't have a page name, this will return nil
 
-- therefore, error handling will be necessary
 
return RESOURCE_DATA.page or nil
---
-- 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 = getData(buildingName)
if not tBuilding then
return nil
end
local workerSlots = 0 -- this is our return variable
-- 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.
if tBuilding.workers then
-- overwrite the return variable
workerSlots = tBuilding.workers
end
-- At this point, it could be zero, signifying that the building exists but
-- has no worker slots.
return workerSlots
end
end






-- simpler version if all that's needed is the description.
---
-- error handling by the calling module is required.
-- Getter method for the type of rain used in Rain Engines in a building.
function ResourceData.getDescription(strArg)
--  
-- 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)


local data = getData(strArg)
-- get the inner table for the building
local tBuilding = getData(buildingName)
if not tBuilding then
return nil
end
local rainType = "" -- this is our return variable
-- 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.
if tBuilding.raintype then
-- overwrite the return variable
rainType = tBuilding.raintype
end
-- if this particular data block doesn't have a description, this will return nil
-- At this point, it could be an empty string, signifying that the building
-- therefore, error handling will be necessary
-- exists but does not use any rainwater.
return data.description or nil
return rainType
end
end
-- and if the table is provided instead of the name to lookup
function ResourceData.getDescriptionFromData(RESOURCE_DATA)


-- if this particular data block doesn't have a description, this will return nil
 
-- therefore, error handling will be necessary
 
return RESOURCE_DATA.description or nil
---
-- 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 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 = getData(buildingName)
if not tBuilding then
return nil
end
local desc = "" -- this is our return variable
-- 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.
if tBuilding.description then
--overwrite the return variable
desc = tBuilding.description
end
-- At this point, it could be an empty string, signifying that the building
-- exists but does not have a description.
return desc
end
end






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

Revision as of 14:52, 13 February 2023

Documentation for this module may be created at Module:ResourceData/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 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 page the name of the wiki page, case-sensitive, but otherwise must be 
-- the same as the key
-- @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
	["foragers' camp"] = { page="Foragers' Camp", 
		iconfile="Forager's Camp icon" },
	["harvesters' camp"] = { page="Harvesters' Camp", 
		iconfile="Harvester 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" },
	["trappers' camp"] = { page="Trappers' Camp", 
		iconfile="Trapper's Camp icon.png" },
	["woodcutters' camp"] = { page="Woodcutters' Camp", 
		iconfile="Woodcutters Camp icon" },
	
	-- 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, 
		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, 
		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 and 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 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 = getData(buildingName)
	if not tBuilding then
		return nil
	end
	
	local icon = "" -- this is our return variable
	
	-- 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.
	if tBuilding.iconfile then
		--overwrite the return variable
		icon = tBuilding.iconfile
	end
		
	-- At this point, it could be an empty string, signifying that the building
	-- exists but does not have an icon.
	return icon
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 = getData(buildingName)
	
	-- if the building didn't exist, then this needs to return nil so it can't
	-- be used as a key again
	return tBuilding.page or nil
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 = 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 = 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 = getData(buildingName)
	if not tBuilding then
		return nil
	end
	
	local workerSlots = 0 -- this is our return variable
	
	-- 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.
	if tBuilding.workers then
		-- overwrite the return variable
		workerSlots = tBuilding.workers
	end
	
	-- At this point, it could be zero, signifying that the building exists but 
	-- has no worker slots.
	return workerSlots
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 = getData(buildingName)
	if not tBuilding then
		return nil
	end
	
	local rainType = "" -- this is our return variable
	
	-- 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.
	if tBuilding.raintype then
		-- overwrite the return variable
		rainType = tBuilding.raintype
	end
	
	-- At this point, it could be an empty string, signifying that the building
	-- exists but does not use any rainwater.
	return rainType
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 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 = getData(buildingName)
	if not tBuilding then
		return nil
	end
	
	local desc = "" -- this is our return variable
	
	-- 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.
	if tBuilding.description then
		--overwrite the return variable
		desc = tBuilding.description
	end
		
	-- At this point, it could be an empty string, signifying that the building
	-- exists but does not have a description.
	return desc
end



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