Module:ResourceData: Difference between revisions

From Against the Storm Official Wiki
(added buildings)
(adding better getter methods, improving the commenting)
 
(23 intermediate revisions by the same user not shown)
Line 1: Line 1:
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- Lua storage table for looking up image files based on in-game names.
-- Lua storage module for looking up data about resources, for use in other
-- modules and templates, for example, {{Resource_Link}}.
--
--
--
-- The table contains some deconfliction, but only for spaces and just a few
-- The main data table stores all available data about resources themselves and  
-- cases of singular and plural versions.
-- relies on other modules to store relationships between resources and  
-- Use in-game names for things, and help keep this table updated as the game
-- buildings, services, etc.
-- is updated.
--
--
-- Using the table requires a locally defined lookup function that performs
-- The helper functions include getters (to keep the data hidden) and a large
-- a string.lower on the argument so that the lookup table can accept any case
-- normalization method to provide some robustness when using the template and
-- and still function properly. Otherwise, we would need the table to define
-- from other Lua modules. Looking up a resource requires using in-game names,  
-- Berries = "Berries.png" and berries = "Berries.png" which would suck.
-- but forgives small differences in spacing, apostrophes, and plurals.
-------------------------------------------------------------------------------
-- @module ResourceData
local ResourceData = {}
 
--
-- Dependencies
--
Utility = Utility or require("Module:Utility") -- need normalize functions




-- for returning when REQUIRE'd by other Lua modules.
local IconFilenames = {}


--
-- Constants
--
-- top-level categories; the main tabs in the top of the game window
local CAT_FOODS = "Food"
local CAT_BUILD = "Building Materials"
local CAT_CONSU = "Consumable Items"
local CAT_CRAFT = "Crafting Resources"
local CAT_TRADE = "Trade Goods"
local CAT_FUEXP = "Fuel & Exploration"
local CAT_RAINS = "Rainwater"
local CAT_BLIGH = "Blight Fuel"


-- secondary categories, for use in wiki pages
-- Foods
local C2_RAWFOOD = "Raw Food"
local C2_COMPLEX = "Complex Food"
-- 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"


-------------------------------------------------------------------------------
-- Main data table, with string keys and string values.
-- Some of these are defined inline with string.lower to make the key easier
-- to spell and read correctly.
-------------------------------------------------------------------------------


local tableStrStrFilenames = {


---------------------------------------
--
-- Resources
-- Class variables
---------------------------------------
--
 
-------------------------------------------------------------------------------
-- Primary data table for this module.
--
-- This table stories the details of resources 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.)
--
-- *defaults are stored here; these value will be modified during the game by
-- perks and city upgrades
--  
-- Structure:
-- @key a lowercase version of the resource name, with the same spaces,
-- apostrophes, singular/plural, 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 category a string representing the primary in-game category the
-- resource belongs to, in the upper UI on the game screen; use the constants
-- defined above
-- @field cat2 a string representing a more specific category, often referenced
-- by perks, needs, or buildings, for example, "Complex Food" and "Packs of
-- Goods" and "Metal or Ore"; use the constants defined above
-- @field eatable true if the good can be eaten, can omit if false
-- @field burnable true if the good can be burned or sacrified in a Hearth, can
-- omit if false
-- @field burnTime the default* number of seconds the item burns
-- for in a Hearth; can omit if burnable is false
-- @field sacrificeRate the default* number of items sacrified per minute in a
-- Hearth; can omit if burnable is false
-- @field sellValue a decimal, the default* value in Amber when selling (the
-- spreadsheet shows the value as 10x, so 2.4 = 0.24 Amber in-game)
-- @field buyValue a decimal, the default* value in Amber when buying
-- @field description the in-game description
-- @table tResourceData the primary data table for resources
local tResourceData = {
     -- Raw Food
     -- Food/Raw Food
["berries"] = "Berries.png",
["berries"] = { page="Berries",
["eggs"] = "Eggs.png",
iconfile="Icon_Resource_Berries.png",
["insects"] = "Insects.png",
category=CAT_FOODS, cat2=C2_RAWFOOD,
["meat"] = "Meat.png",
eatable=true,
["mushrooms"] = "Mushrooms.png",
sellValue=0.24, buyValue=0.40,
["roots"] = "Roots.png",
description="Common food source. Obtained by: Plantation, Hallowed Herb Garden, Herbalists' Camp, Small Herbalists' Camp."},
["vegetables"] = "Vegetables.png",
["eggs"] = { page="Eggs",
-- Complex Food
iconfile="Eggs.png",
["biscuits"] = "Biscuits.png",
category=CAT_FOODS, cat2=C2_RAWFOOD,
["jerky"] = "Jerky.png",
eatable=true,
[string.lower("PickledGoods")] = "PickledGoods.png",
sellValue=0.24, buyValue=0.40,
["pickled goods"] = "PickledGoods.png",
description="Common food source. Obtained by: Ranch, Trappers' Camp, Small Trappers' Camp."},
["pie"] = "Pie.png",
["insects"] = { page="Insects",
["skewers"] = "Skewers.png",
iconfile="Insects.png",
category=CAT_FOODS, cat2=C2_RAWFOOD,
eatable=true,
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
-- Building Materials
["bricks"] = "Bricks.png",
["bricks"] = { page="Bricks",  
["fabric"] = "Fabric.png",
iconfile="Icon_Resource_Bricks.png",  
["planks"] = "Planks.png",
category=CAT_BUILD, cat2=C2_CONSTRU,
["parts"] = "Parts.png",
sellValue=0.375, buyValue=0.625,  
[string.lower("WildfireEssence")] = "Wildfire Essence.png",
description="Mostly used for construction. Produced by: Crude Workstation, Workshop, Brickyard, Kiln, Furnace."},
["wildfire essence"] = "Wildfire Essence.png",
["fabric"] = { page="Fabric",  
-- Consumable Items
iconfile="Fabric.png",  
["coats"] = "Coats.png",
category=CAT_BUILD, cat2=C2_CONSTRU,
["ale"] = "Ale.png",
sellValue=0.375, buyValue=0.625,
["cosmetics"] = "Cosmetics.png",
description="Used for construction or production of clothes. Produced by: Crude Workstation, Workshop, Weaver, Granary, Leatherworker."},
["incense"] = "Incense.png",
["pipes"] = { page="Pipes",  
["scrolls"] = "Scrolls.png",
iconfile="En_craft_23.png",  
[string.lower("TrainingGear")] = "TrainingGear.png",
category=CAT_BUILD, cat2=C2_CONSTRU,
["training gear"] = "TrainingGear.png",
sellValue=0.58, buyValue=1.00,
["wine"] = "Wine.png",
description="Used to install Rainpunk Engines in production buildings and build Geyser Pumps. Produced by: Crude Workstation, Workshop, Smelter, Toolshop."},
-- Crafting Materials
["planks"] = { page="Planks",  
["clay"] = "Clay.png",
iconfile="Planks.png",  
[string.lower("CopperOre")] = "CopperOre.png",
category=CAT_BUILD, cat2=C2_CONSTRU,
["copper ore"] = "CopperOre.png",
sellValue=0.225, buyValue=0.375,  
[string.lower("CrystalizedDew")] = "CrystalizedDew.png",
description="Mostly used for construction. Produced by: Crude Workstation, Workshop, Lumber Mill, Carpenter, Supplier."},
["crystalized dew"] = "CrystalizedDew.png",
["grain"] = "Grain.png",
-- Building Materials/Rare
["herbs"] = "Herbs.png",
["parts"] = { page="Parts",
["leather"] = "Leather.png",
iconfile="Parts.png",  
["plantfiber"] = "PlantFiber.png",
category=CAT_BUILD, cat2=C2_RAREMAT,
["plant fiber"] = "PlantFiber.png",
sellValue=2.28, buyValue=4.80,
["reeds"] = "Reeds.png",
description="Rare elements used in camp construction. Difficult to produce in this harsh environment."},
["reed"] = "Reeds.png",
["wildfire essence"] = { page="Wildfire Essence",
["resin"] = "Resin.png",
iconfile="Wildfire Essence.png",  
["sparkdew"] = "Sparkdew.png",
category=CAT_BUILD, cat2=C2_RAREMAT,
["stone"] = "Stone.png",
sellValue=6.00, buyValue=10.0,
-- Refined Crafting Materials
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."},
["barrels"] = "Barrels.png",
["barrel"] = "Barrels.png",
-- Consumable Items/Clothing
["copperbar"] = "CopperBar.png",
["coats"] = { page="Coats",  
["copper bar"] = "CopperBar.png",
iconfile="Coats.png",  
["flour"] = "Flour.png",
category=CAT_CONSU, cat2=C2_CLOTHIN,
["pigment"] = "Pigment.png",
sellValue=0.12, buyValue=0.20,
["pigments"] = "Pigment.png",
description="Used as clothing by some villagers. Produced by: Clothier, Smithy, Artisan, Druid's Hut."},
["pottery"] = "Pottery.png",
["waterskins"] = "Waterskins.png",
-- Consumable Items/Service Items
["waterskin"] = "Waterskins.png",
["ale"] = { page="Ale",  
-- Trade Goods
iconfile="Icon_Resource_Ale.png",  
["buildingmaterials"] = "BuildingMaterials.png",
category=CAT_CONSU, cat2=C2_SERVICE,
["packofbuildingmaterials"] = "BuildingMaterials.png",
sellValue=0.21, buyValue=0.35,
["crops"] = "Crops.png",
description="Used for Leisure at: Tavern, Monastery, Forum. Produced by: Grill, Brewery, Flawless Brewery, Tinctury, Scribe."},
["packofcrops"] = "Crops.png",
["cosmetics"] = { page="Cosmetics",  
["luxurygoods"] = "Luxury.png",
iconfile="Cosmetics.png",  
["packofluxurygoods"] = "Luxury.png",
category=CAT_CONSU, cat2=C2_SERVICE,
["provisions"] = "Provisions.png",
sellValue=0.18, buyValue=0.3,
["packofprovisions"] = "Provisions.png",
description="Used for Cleanliness at: Bath House, Holy Market, Market. Produced by: Cooperage, Alchemist's Hut, Apothecary."},
["tradegoods"] = "TradeGoods.png",
["incense"] = { page="Incense",  
["packoftradegoods"] = "TradeGoods.png",
iconfile="Incense.png",  
["amber"] = "Amber.png",
category=CAT_CONSU, cat2=C2_SERVICE,
[string.lower("AncientTablet")] = "AncientTablet.png",
sellValue=0.225, buyValue=0.375,
["ancient tablet"] = "AncientTablet.png",
description="Used for Religion at: Holy Temple, Temple, Monastery, Clan Hall. Produced by: Smokehouse, Brick Oven, Apothecary, Druid's Hut."},
["foodstockpiles"] = "Icon MetaResource FoodStockpiles.png",
["scrolls"] = { page="Scrolls",  
["food stockpiles"] = "Icon MetaResource FoodStockpiles.png",
iconfile="Scrolls.png",  
["metafood"] = "Icon MetaResource FoodStockpiles.png",
category=CAT_CONSU, cat2=C2_SERVICE,
["machinery"] = "Icon MetaResource Machinery.png",
sellValue=0.18, buyValue=0.30,
["metamachinery"] = "Icon MetaResource Machinery.png",
description="Used for Education at: Holy Temple, Temple, Explorers' Lodge, Forum. Produced by: Lumber Mill, Clothier, Flawless Rain Mill, Rain Mill, Scribe."},
["artifact"] = "Icon MetaResource Artifact.png",
["training gear"] = { page="Training Gear",  
["artifacts"] = "Icon MetaResource Artifact.png",
iconfile="TrainingGear.png",  
[string.lower("MetaArtifact")] = "Icon MetaResource Artifact.png",
category=CAT_CONSU, cat2=C2_SERVICE,
-- Fuel & Exploration
sellValue=0.255, buyValue=0.425,
["coal"] = "Coal.png",
description="Used for Brawling at: Tavern, Clan Hall, Explorers' Lodge. Produced by: Cooperage, Weaver, Tinkerer, Manufactory."},
["oil"] = "Oil.png",
["wine"] = { page="Wine",  
["seamarrow"] = "SeaMarrow.png",
iconfile="Wine.png",  
["sea marrow"] = "SeaMarrow.png",
category=CAT_CONSU, cat2=C2_SERVICE,
["wood"] = "Wood.png",
sellValue=0.18, buyValue=0.30,
["simpletools"] = "SimpleTools.png",
description="Used for Luxury at: Guild House, Holy Market, Market. Produced by: Cellar, Alchemist's Hut, Tinctury."},
["simple tools"] = "SimpleTools.png",
["infusedtools"] = "InfusedTools.png",
-- Crafting Materials/Raw Materials
["infused tools"] = "InfusedTools.png",
["clay"] = { page="Clay",  
["purgingfire"] = "PurgingFire.png",
iconfile="Icon_Resource_Clay.png",  
["purging fire"] = "PurgingFire.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
-- Buildings
["flour"] = { page="Flour",
---------------------------------------
iconfile="Flour.png",
category=CAT_CRAFT, cat2=C2_PROCESS,
sellValue=0.22, buyValue=0.38,
description="Used for cooking. Produced by: Flawless Rain Mill, Rain Mill, Press, Provisioner, Stamping Mill, Supplier."},
-- Crafting Materials/Metal & Ore
["copper bars"] = { page="Copper Bars",
iconfile="CopperBar.png",
category=CAT_CRAFT, cat2=C2_METALOR,
sellValue=0.72, buyValue=1.2,
description="Refined copper ore, used for crafting. Produced by: Grill, Furnace, Stamping Mill, Smelter."},
["copper ore"] = { page="Copper Ore",
iconfile="CopperOre.png",
category=CAT_CRAFT, cat2=C2_METALOR,
sellValue=0.18, buyValue=0.30,
description="A soft and malleable metal. Obtained by: Mine."},
["crystalized dew"] = { page="Crystalized Dew",
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."},
-- Starting Buildings
-- Fuel & Exploration/Fuel
["ancienthearth"] = "Small Hearth icon.png",
["coal"] = { page="Coal",  
["ancient hearth"] = "Small Hearth icon.png",
iconfile="Icon_Resource_Coal.png",  
["mainwarehouse"] = "Main_Storage_icon.png",
category=CAT_FUEXP, cat2=C2_FUELSAC,  
["main warehouse"] = "Main_Storage_icon.png",
burnable=true, burnTime=60, sacrificeRate=18,  
-- Camps
sellValue=0.375, buyValue=0.625,  
["foragers'camp"] = "Forager's Camp icon",
description="Efficient fuel. Obtained by: Mine, Brick Oven, Kiln."},
["foragers' camp"] = "Forager's Camp icon",
["oil"] = { page="Oil",  
["forager'scamp"] = "Forager's Camp icon",
iconfile="Oil.png",  
["forager's camp"] = "Forager's Camp icon",
category=CAT_FUEXP, cat2=C2_FUELSAC,  
["harvesters'camp"] = "Harvester Camp icon.png",
burnable=true, burnTime=30, sacrificeRate=15,  
["harvesters' camp"] = "Harvester Camp icon.png",
sellValue=0.195, buyValue=0.325,  
["harvester'scamp"] = "Harvester Camp icon.png",
description="Efficient fuel. Obtained by: Butcher, Press, Druid's Hut."},
["harvester's camp"] = "Harvester Camp icon.png",
["sea marrow"] = { page="Sea Marrow",  
["herbalists'camp"] = "Herbalist's_Camp_icon.png",
iconfile="SeaMarrow.png",  
["herbalists' camp"] = "Herbalist's_Camp_icon.png",
category=CAT_FUEXP, cat2=C2_FUELSAC,  
["herbalist'scamp"] = "Herbalist's_Camp_icon.png",
burnable=true, burnTime=60, sacrificeRate=18,  
["herbalist's camp"] = "Herbalist's_Camp_icon.png",
sellValue=0.375, buyValue=0.625,  
["stonecutters'camp"] = "Stonecutter's Camp icon.png",
description="Efficient fuel. Obtained by: Stonecutters' Camp."},
["stonecutters' camp"] = "Stonecutter's Camp icon.png",
["wood"] = { page="Wood",  
["stonecutter'scamp"] = "Stonecutter's Camp icon.png",
iconfile="Wood.png",  
["stonecutter's camp"] = "Stonecutter's Camp icon.png",
category=CAT_FUEXP, cat2=C2_FUELSAC,  
["woodcutters'camp"] = "Woodcutters Camp icon",
burnable=true, burnTime=15, sacrificeRate=30,  
["woodcutters' camp"] = "Woodcutters Camp icon",
sellValue=0.075, buyValue=0.125,  
["woodcutter'scamp"] = "Woodcutters Camp icon",
description="An abundant, yet crucial resource. Obtained by: Woodcutters' Camp."},
["woodcutter's camp"] = "Woodcutters Camp icon",
["trappers'camp"] = "Trapper's Camp icon.png",
-- Fuel & Exploration/Tools
["trappers' camp"] = "Trapper's Camp icon.png",
["simple tools"] = { page="Simple Tools",  
["trapper'scamp"] = "Trapper's Camp icon.png",
iconfile="SimpleTools.png",  
["trapper's camp"] = "Trapper's Camp icon.png",
category=CAT_FUEXP, cat2=C2_EXPTOOL,  
-- Food Production
sellValue=1.665, buyValue=2.775,  
["farmfield"] = "Farmfield_icon.png",
description="Used in exploration, for opening caches and completing difficult events. Produced by: Carpenter, Smithy, Toolshop, Tinkerer, Scribe."},
["farm field"] = "Farmfield_icon.png",
["infused tools"] = { page="Infused Tools",  
["herbgarden"] = "HerbGarden_icon.png",
iconfile="InfusedTools.png",  
["herb garden"] = "HerbGarden_icon.png",
category=CAT_FUEXP, cat2=C2_EXPTOOL,  
["plantation"] = "Plantation_icon.png",
sellValue=2.115, buyValue=3.525,  
["smallfarm"] = "SmallFarm_icon.png",
description="Used in exploration, for opening caches and completing difficult events. Produced by: Finesmith, Rainpunk Foundry."},
["small farm"] = "SmallFarm_icon.png",
["bakery"] = "Bakery_icon.png",
-- Rainwater
["cellar"] = "Cellar_icon.png",
["clearance water"] = { page="Clearance Water",  
["cookhouse"] = "Cookhouse_icon.png",
iconfile="Yellow_30.png",  
["ranch"] = "Ranch_icon.png",
category=CAT_RAINS, cat2=C2_RAINWAT,  
["smokehouse"] = "Smokehouse_icon.png",
description="Highly concentrated yellow clearance rainwater. Used to power Rain Engines in crafting-oriented buildings."},
["grill"] = "Grill_icon.png",
["drizzle water"] = { page="Drizzle Water",  
-- Housing
iconfile="Green_11.png",  
["shelter"] = "Shelter icon.png",
category=CAT_RAINS, cat2=C2_RAINWAT,  
["bigshelter"] = "Big Shelter icon.png",
description="Highly concentrated green drizzle rainwater. Used to power Rain Engines in food-oriented buildings."},
["big shelter"] = "Big Shelter icon.png",
["storm water"] = { page="Storm Water",  
["humanhouse"] = "Human House icon.png",
iconfile="Blue_14.png",  
["human house"] = "Human House icon.png",
category=CAT_RAINS, cat2=C2_RAINWAT,  
["beaverhouse"] = "Beaver House icon.png",
description="Highly concentrated blue storm rainwater. Used to power Rain Engines in industry-oriented buildings."},
["beaver house"] = "Beaver House icon.png",
["lizardhouse"] = "Lizard House icon.png",
-- Blight Fuel
["lizard house"] = "Lizard House icon.png",
["purging fire"] = { page="Purging Fire",  
["harpyhouse"] = "Harpy House icon.png",
iconfile="PurgingFire.png",  
["harpy house"] = "Harpy House icon.png",
category=CAT_BLIGH, cat2=C2_PURGING,  
-- Industry
sellValue=0.375, buyValue=0.625,  
["crudeworkstation"] = "Crude_Workstation_icon.png",
description="A unique resource used by Blight Fighters to burn down Blightrot Cysts. Produced by: Blight Post."}
["crude workstation"] = "Crude_Workstation_icon.png",
["makeshiftpost"] = "Makeshift_Post_icon.png",
} -- end of tResourceData
["makeshift post"] = "Makeshift_Post_icon.png",
["raincollector"] = "Rain_Collector_icon.png",
["rain collector"] = "Rain_Collector_icon.png",
["mine"] = "Mine_icon.png",
["carpenter"] = "Carpenter_icon.png",
["weaver"] = "Weaver_icon.png",
["clothier"] = "Clothier_icon.png",
["brickyard"] = "Brickyard_icon.png",
["kiln"] = "Kiln_icon.png",
["rainmill"] = "Rain_Mill_icon.png",
["rain mill"] = "Rain_Mill_icon.png",
["provisioner"] = "Provisioner_icon.png",
["artisan"] = "Artisan_icon.png",
["brewery"] = "Brewery_icon.png",
["cooperage"] = "Cooperage_icon.png",
["druids'hut"] = "Druid_icon.png",
["druids' hut"] = "Druid_icon.png",
["druid'shut"] = "Druid_icon.png",
["druid's hut"] = "Druid_icon.png",
["leatherworker"] = "Leatherworks_icon.png",
["lumbermill"] = "Lumbermill_icon.png",
["lumber mill"] = "Lumbermill_icon.png",
["press"] = "Press_icon.png",
["scribe"] = "Scribe_icon.png",
["smelter"] = "Smelter_icon.png",
-- City Buildings
["smallhearth"] = "Temporary_Hearth_icon.png",
["small hearth"] = "Temporary_Hearth_icon.png",
["warehouse"] = "Storage_icon.png",
["tradingpost"] = "Trading_Post_icon.png",
["trading post"] = "Trading_Post_icon.png",
["blightpost"] = "Blight_Post_icon.png",
["blight post"] = "Blight_Post_icon.png",
["hydrant"] = "Hydrant_icon.png",
["forsakenaltar"] = "Altar_icon.png",
["forsaken altar"] = "Altar_icon.png",
-- Service Buildings
[string.lower("BathHouse")] = "Bath_House_icon.png",
["bath house"] = "Bath_House_icon.png",
["clanhall"] = "Clan_Hall_icon.png",
["clan hall"] = "Clan_Hall_icon.png",
["explorers'lodge"] = "Explorers_Lodge_icon.png",
["explorers' lodge"] = "Explorers_Lodge_icon.png",
["explorer'slodge"] = "Explorers_Lodge_icon.png",
["explorer's lodge"] = "Explorers_Lodge_icon.png",
["guildhouse"] = "Guild_House_icon.png",
["guild house"] = "Guild_House_icon.png",
["monastery"] = "Monastery_icon.png",
["tavern"] = "Tavern_icon.png",
["temple"] = "Temple_icon.png"
}




Line 244: Line 462:
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- Main lookup function
-- Main lookup function
-- Accepts the name of an icon, as it appears in the game, and returns the
--
-- filename associated with that in-game item, resource, building, etc.
-- Accepts the in-game name and returns the corresponding inner table from
-------------------------------------------------------------------------------
-- tResourceData. 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 resourceName the name of the resource 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 ResourceData.getData(resourceName)
-- If the argument to this function is empty or nil, save some time by
-- skipping the normalize function.
if not resourceName or "" == resourceName then
return nil
end
-- normalize the name and try again
    local resourceName = Utility.normalizeResourceName(resourceName)
-- get the inner table from the big data table and return it; if it doesn't
-- exist, this will return nil anyway
    return tResourceData[resourceName]
end
 
 
 
---
-- Getter method for the page name for a resource.
--
-- Accepts the in-game name of the resource and returns the corresponding name
-- of the page in the wiki for the resource. If the resourceName 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 resource's name.
-- @param resourceName the name of the resource
-- @return the name of the page on the wiki, or nil if it doens't exist
function ResourceData.getPagename(resourceName)
 
-- get the inner table for the resource
local tResource = ResourceData.getData(resourceName)
if not tResource then
return nil
end
-- if the resource didn't exist, then nil was already returned, but if the
-- page was undefined, this should return nil instead of an empty string
return tResource.page
end
 
 
 
---
-- Getter method for the icon filename for a resource.
--
-- Accepts the in-game name of the resource and returns the corresponding
-- filename on the wiki for the resource's icon as seen in-game.
-- @param resourceName the name of the resource
-- @return the filename, which might be an empty string, or nil if it doesn't
-- exist
function ResourceData.getIconFilename(resourceName)
 
-- get the inner table for the resource
local tResource = ResourceData.getData(resourceName)
if not tResource then
return nil
end
-- Get the icon filename, if any. If the resource doesn't have an icon,
-- then return an empty string. Returning nil is reserved for when the
-- resource does not exist.
return tResource.iconfile or ""
end
 
 
 
---
-- Getter method for the categories of a resoruce.
--
-- Accepts the in-game name of the resource and returns the two corresponding
-- categories. The first is the one seen at the top of the game UI, the second
-- is a more specific, functional category for perks, buildings, etc.
-- @param resourceName the name of the resource
-- @return the first, top-level category, or nil if it doesn't exist
-- @return the second, more specific and functional category, or nil if it
-- doesn't exist
function ResourceData.getCategories(resourceName)
-- get the inner table for the resource
local tResource = ResourceData.getData(resourceName)
if not tResource then
return nil
end
-- if this does not exist, nil is an okay return value
return tResource.category, tResource.cat2
end
 
 
 
---
-- Getter method for the eatability of a resoruce.
--
-- Accepts the in-game name of the resource and returns true if the resource can
-- be consumed by villagers as food.
-- @param resourceName the name of the resource
-- @return true if the resource can be eaten as food, nil or false otherwise
function ResourceData.isEatable(resourceName)
-- get the inner table for the resource
local tResource = ResourceData.getData(resourceName)
if not tResource then
return nil
end
-- if this does not exist, nil is an okay return value, because nil is falsy
return tResource.eatable
end
 
 
 
---
-- Getter method for the burnability of a resoruce.
--
-- Accepts the in-game name of the resource and returns true if the resource can
-- be burned in Hearths as fuel.
-- @param resourceName the name of the resource
-- @return true if the resource can be burned as fuel, nil or false otherwise
function ResourceData.isBurnable(resourceName)
-- get the inner table for the resource
local tResource = ResourceData.getData(resourceName)
if not tResource then
return nil
end
-- if this does not exist, nil is an okay return value, because nil is falsy
return tResource.burnable
end
 
 
 
---
-- Getter method for the burn time and sacrifice rate of a resource.
--
-- Accepts the in-game name of the resource and returns the number of seconds
-- the resource burns in the hearth and the number of items sacrificed per
-- minute when sacrificed in the hearth. These numbers don't have the same unit,
-- but they are how the game communicates these two rates.
-- @param resourceName the name of the resource
-- @return the number of seconds the resource burns in the hearth, or nil if
-- the resource is not burnable
-- @return the number of items per minute when sacrificed in the hearth, and if
-- the resource is not burnable, there will not be a second returned item
function ResourceData.getBurnTimeAndSacrificeRate(resourceName)
-- get the inner table for the resource
local tResource = ResourceData.getData(resourceName)
if not tResource then
return nil
end
-- if these do not exist, nil is an okay return value, because nil is falsy
return tResource.burnTime, tResource.sacrificeRate
end
 
 
 
---
-- Getter method for the selling and buying values of a resource.
--
-- Accepts the in-game name of the resource and returns the value in Amber when
-- selling the resource and the value in Amber when buying the resource.
-- @param resourceName the name of the resource
-- @return the value when selling
-- @return the value when buying
function ResourceData.getSellAndBuyValues(resourceName)
-- get the inner table for the resource
local tResource = ResourceData.getData(resourceName)
if not tResource then
return nil
end
-- if the resource exists but the values are undefined, return zero instead
-- of nil
return tResource.sellValue or 0, tResource.buyValue or 0
end
 
 


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


-- Convert the key to lower case for case-insensitive lookups
-- get the inner table for the resource
    local strLowercaseIconName = string.lower(strIconName)
local tResource = ResourceData.getData(resourceName)
if not tResource then
return nil
end
-- Get it from the big table below and return it.
-- Get the description, if any. If the resource doesn't have a description,
    return tableStrStrFilenames[strLowercaseIconName]
-- then return an empty string. Returning nil is reserved for when the
-- resource does not exist.
return tResource.description or ""
end
end






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

Latest revision as of 03:03, 14 February 2023

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

-------------------------------------------------------------------------------
-- Lua storage module for looking up data about resources, for use in other
-- modules and templates, for example, {{Resource_Link}}.
-- 
--
-- The main data table stores all available data about resources themselves and 
-- relies on other modules to store relationships between resources and 
-- buildings, services, etc.
--
-- The helper functions include getters (to keep the data hidden) and a large
-- normalization method to provide some robustness when using the template and 
-- from other Lua modules. Looking up a resource requires using in-game names, 
-- but forgives small differences in spacing, apostrophes, and plurals.
-- @module ResourceData
local ResourceData = {}

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



--
-- Constants
--
-- top-level categories; the main tabs in the top of the game window
local CAT_FOODS = "Food"
local CAT_BUILD = "Building Materials"
local CAT_CONSU = "Consumable Items"
local CAT_CRAFT = "Crafting Resources"
local CAT_TRADE = "Trade Goods"
local CAT_FUEXP = "Fuel & Exploration"
local CAT_RAINS = "Rainwater"
local CAT_BLIGH = "Blight Fuel"

-- secondary categories, for use in wiki pages
-- Foods
local C2_RAWFOOD = "Raw Food"
local C2_COMPLEX = "Complex Food"
-- 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
--

-------------------------------------------------------------------------------
-- Primary data table for this module.
--
-- This table stories the details of resources 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.)
--
-- *defaults are stored here; these value will be modified during the game by 
-- perks and city upgrades
-- 
-- Structure: 
-- @key a lowercase version of the resource name, with the same spaces, 
-- apostrophes, singular/plural, 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 category a string representing the primary in-game category the 
-- resource belongs to, in the upper UI on the game screen; use the constants
-- defined above
-- @field cat2 a string representing a more specific category, often referenced
-- by perks, needs, or buildings, for example, "Complex Food" and "Packs of 
-- Goods" and "Metal or Ore"; use the constants defined above
-- @field eatable true if the good can be eaten, can omit if false
-- @field burnable true if the good can be burned or sacrified in a Hearth, can 
-- omit if false
-- @field burnTime the default* number of seconds the item burns 
-- for in a Hearth; can omit if burnable is false
-- @field sacrificeRate the default* number of items sacrified per minute in a 
-- Hearth; can omit if burnable is false
-- @field sellValue a decimal, the default* value in Amber when selling (the 
-- spreadsheet shows the value as 10x, so 2.4 = 0.24 Amber in-game)
-- @field buyValue a decimal, the default* value in Amber when buying
-- @field description the in-game description
-- @table tResourceData the primary data table for resources
local tResourceData = {
	
    -- Food/Raw Food
	["berries"] = {	page="Berries", 
		iconfile="Icon_Resource_Berries.png", 
		category=CAT_FOODS, cat2=C2_RAWFOOD, 
		eatable=true, 
		sellValue=0.24, buyValue=0.40, 
		description="Common food source. Obtained by: Plantation, Hallowed Herb Garden, Herbalists' Camp, Small Herbalists' Camp."},
	["eggs"] = { page="Eggs", 
		iconfile="Eggs.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."},
	["insects"] = { page="Insects",
		iconfile="Insects.png",	
		category=CAT_FOODS, cat2=C2_RAWFOOD, 
		eatable=true, 
		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
	["flour"] = { page="Flour",	
		iconfile="Flour.png", 
		category=CAT_CRAFT, cat2=C2_PROCESS, 
		sellValue=0.22, buyValue=0.38, 
		description="Used for cooking. Produced by: Flawless Rain Mill, Rain Mill, Press, Provisioner, Stamping Mill, Supplier."},
		
	-- Crafting Materials/Metal & Ore
	["copper bars"] = { page="Copper Bars", 
		iconfile="CopperBar.png", 
		category=CAT_CRAFT, cat2=C2_METALOR, 
		sellValue=0.72, buyValue=1.2, 
		description="Refined copper ore, used for crafting. Produced by: Grill, Furnace, Stamping Mill, Smelter."},
	["copper ore"] = { page="Copper Ore", 
		iconfile="CopperOre.png", 
		category=CAT_CRAFT, cat2=C2_METALOR, 
		sellValue=0.18, buyValue=0.30, 
		description="A soft and malleable metal. Obtained by: Mine."},
	["crystalized dew"] = { page="Crystalized Dew", 
		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
	["coal"] = { page="Coal", 
		iconfile="Icon_Resource_Coal.png", 
		category=CAT_FUEXP, cat2=C2_FUELSAC, 
		burnable=true, burnTime=60, sacrificeRate=18, 
		sellValue=0.375, buyValue=0.625, 
		description="Efficient fuel. Obtained by: Mine, Brick Oven, Kiln."},
	["oil"] = { page="Oil", 
		iconfile="Oil.png", 
		category=CAT_FUEXP, cat2=C2_FUELSAC, 
		burnable=true, burnTime=30, sacrificeRate=15, 
		sellValue=0.195, buyValue=0.325, 
		description="Efficient fuel. Obtained by: Butcher, Press, Druid's Hut."},
	["sea marrow"] = { page="Sea Marrow", 
		iconfile="SeaMarrow.png", 
		category=CAT_FUEXP, cat2=C2_FUELSAC, 
		burnable=true, burnTime=60, sacrificeRate=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, sacrificeRate=30, 
		sellValue=0.075, buyValue=0.125, 
		description="An abundant, yet crucial resource. Obtained by: Woodcutters' Camp."},
	
	-- Fuel & Exploration/Tools
	["simple tools"] = { page="Simple Tools", 
		iconfile="SimpleTools.png", 
		category=CAT_FUEXP, cat2=C2_EXPTOOL, 
		sellValue=1.665, buyValue=2.775, 
		description="Used in exploration, for opening caches and completing difficult events. Produced by: Carpenter, Smithy, Toolshop, Tinkerer, Scribe."},
	["infused tools"] = { page="Infused Tools", 
		iconfile="InfusedTools.png", 
		category=CAT_FUEXP, cat2=C2_EXPTOOL, 
		sellValue=2.115, buyValue=3.525, 
		description="Used in exploration, for opening caches and completing difficult events. Produced by: Finesmith, Rainpunk Foundry."},
	
	-- Rainwater
	["clearance water"] = { page="Clearance Water", 
		iconfile="Yellow_30.png", 
		category=CAT_RAINS, cat2=C2_RAINWAT, 
		description="Highly concentrated yellow clearance rainwater. Used to power Rain Engines in crafting-oriented buildings."},
	["drizzle water"] = { page="Drizzle Water", 
		iconfile="Green_11.png", 
		category=CAT_RAINS, cat2=C2_RAINWAT, 
		description="Highly concentrated green drizzle rainwater. Used to power Rain Engines in food-oriented buildings."},
	["storm water"] = { page="Storm Water", 
		iconfile="Blue_14.png", 
		category=CAT_RAINS, cat2=C2_RAINWAT, 
		description="Highly concentrated blue storm rainwater. Used to power Rain Engines in industry-oriented buildings."},
	
	-- Blight Fuel
	["purging fire"] = { page="Purging Fire", 
		iconfile="PurgingFire.png", 
		category=CAT_BLIGH, cat2=C2_PURGING, 
		sellValue=0.375, buyValue=0.625, 
		description="A unique resource used by Blight Fighters to burn down Blightrot Cysts. Produced by: Blight Post."}
	
} -- end of tResourceData



-------------------------------------------------------------------------------
-- Main lookup function
--
-- Accepts the in-game name and returns the corresponding inner table from 
-- tResourceData. 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 resourceName the name of the resource 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 ResourceData.getData(resourceName)
	
	-- If the argument to this function is empty or nil, save some time by 
	-- skipping the normalize function.
	if not resourceName or "" == resourceName then
		return nil
	end
	
	-- normalize the name and try again
    local resourceName = Utility.normalizeResourceName(resourceName)
	
	-- get the inner table from the big data table and return it; if it doesn't
	-- exist, this will return nil anyway
    return tResourceData[resourceName]
end



---
-- Getter method for the page name for a resource.
-- 
-- Accepts the in-game name of the resource and returns the corresponding name
-- of the page in the wiki for the resource. If the resourceName 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 resource's name.
-- @param resourceName the name of the resource
-- @return the name of the page on the wiki, or nil if it doens't exist
function ResourceData.getPagename(resourceName)

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



---
-- Getter method for the icon filename for a resource.
-- 
-- Accepts the in-game name of the resource and returns the corresponding 
-- filename on the wiki for the resource's icon as seen in-game.
-- @param resourceName the name of the resource
-- @return the filename, which might be an empty string, or nil if it doesn't 
-- exist
function ResourceData.getIconFilename(resourceName)

	-- get the inner table for the resource
	local tResource = ResourceData.getData(resourceName)
	if not tResource then
		return nil
	end
	
	-- Get the icon filename, if any. If the resource doesn't have an icon,
	-- then return an empty string. Returning nil is reserved for when the 
	-- resource does not exist.
	return tResource.iconfile or ""
end



---
-- Getter method for the categories of a resoruce.
--
-- Accepts the in-game name of the resource and returns the two corresponding 
-- categories. The first is the one seen at the top of the game UI, the second 
-- is a more specific, functional category for perks, buildings, etc.
-- @param resourceName the name of the resource
-- @return the first, top-level category, or nil if it doesn't exist
-- @return the second, more specific and functional category, or nil if it 
-- doesn't exist
function ResourceData.getCategories(resourceName)
	
	-- get the inner table for the resource
	local tResource = ResourceData.getData(resourceName)
	if not tResource then
		return nil
	end
	
	-- if this does not exist, nil is an okay return value
	return tResource.category, tResource.cat2
end



---
-- Getter method for the eatability of a resoruce.
--
-- Accepts the in-game name of the resource and returns true if the resource can
-- be consumed by villagers as food.
-- @param resourceName the name of the resource
-- @return true if the resource can be eaten as food, nil or false otherwise
function ResourceData.isEatable(resourceName)
	
	-- get the inner table for the resource
	local tResource = ResourceData.getData(resourceName)
	if not tResource then
		return nil
	end
	
	-- if this does not exist, nil is an okay return value, because nil is falsy
	return tResource.eatable
end



---
-- Getter method for the burnability of a resoruce.
--
-- Accepts the in-game name of the resource and returns true if the resource can
-- be burned in Hearths as fuel.
-- @param resourceName the name of the resource
-- @return true if the resource can be burned as fuel, nil or false otherwise
function ResourceData.isBurnable(resourceName)
	
	-- get the inner table for the resource
	local tResource = ResourceData.getData(resourceName)
	if not tResource then
		return nil
	end
	
	-- if this does not exist, nil is an okay return value, because nil is falsy
	return tResource.burnable
end



---
-- Getter method for the burn time and sacrifice rate of a resource.
--
-- Accepts the in-game name of the resource and returns the number of seconds 
-- the resource burns in the hearth and the number of items sacrificed per 
-- minute when sacrificed in the hearth. These numbers don't have the same unit, 
-- but they are how the game communicates these two rates.
-- @param resourceName the name of the resource
-- @return the number of seconds the resource burns in the hearth, or nil if 
-- the resource is not burnable
-- @return the number of items per minute when sacrificed in the hearth, and if
-- the resource is not burnable, there will not be a second returned item
function ResourceData.getBurnTimeAndSacrificeRate(resourceName)
	
	-- get the inner table for the resource
	local tResource = ResourceData.getData(resourceName)
	if not tResource then
		return nil
	end
	
	-- if these do not exist, nil is an okay return value, because nil is falsy
	return tResource.burnTime, tResource.sacrificeRate
end



---
-- Getter method for the selling and buying values of a resource.
--
-- Accepts the in-game name of the resource and returns the value in Amber when
-- selling the resource and the value in Amber when buying the resource.
-- @param resourceName the name of the resource
-- @return the value when selling
-- @return the value when buying
function ResourceData.getSellAndBuyValues(resourceName)
	
	-- get the inner table for the resource
	local tResource = ResourceData.getData(resourceName)
	if not tResource then
		return nil
	end
	
	-- if the resource exists but the values are undefined, return zero instead
	-- of nil
	return tResource.sellValue or 0, tResource.buyValue or 0
end



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

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



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