Module:BuildingData
From Against the Storm Official Wiki
Documentation for this module may be created at Module:BuildingData/doc
-------------------------------------------------------------------------------
-- Lua storage table for looking up wiki pages, names, and resources
-- based on in-game names. All data is in English.
--
-- The table contains some deconfliction, but only for spaces, apostrophes, and
-- some singular/plural.
-- Use in-game names for things, and help keep this table updated as the game
-- is updated.
--
-- Using the table requires a locally defined lookup function that performs
-- a string.lower on the argument so that the lookup table can accept any case
-- and still function properly. Otherwise, we would need the table to define
-- both Berries = "Berries" and berries = "Berries" which would multiply our
-- work.
-------------------------------------------------------------------------------
-- for returning when REQUIRE'd by other Lua modules.
local BuildingData = {}
-------------------------------------------------------------------------------
-- 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.
-------------------------------------------------------------------------------
-- a design decision of this table is to make the key the same as the page name.
-- (the lookup methods will automatically make it lowercase.)
-- that way, whenever .page is referenced, it can be used again to retrieve
-- the rest of the data.
local tableStrStrData = {
---------------------------------------
-- Buildings
---------------------------------------
-- Starting Buildings
["ancient hearth"] = {iconfile="Small Hearth icon.png", page="Ancient Hearth"},
["main warehouse"] = {iconfile="Main_Storage_icon.png", page="Main Warehouse"},
-- Camps
["foragers' camp"] = {iconfile="Forager's Camp icon", page="Foragers' Camp"},
["harvesters' camp"] = {iconfile="Harvester Camp icon.png", page="Harvesters' Camp"},
["herbalists' camp"] = {iconfile="Herbalist's_Camp_icon.png", page="Herbalists' Camp"},
["stonecutters' camp"] = {iconfile="Stonecutter's Camp icon.png", page="Stonecutters' Camp"},
["trappers' camp"] = {iconfile="Trapper's Camp icon.png", page="Trappers' Camp"},
["woodcutters' camp"] = {iconfile="Woodcutters Camp icon", page="Woodcutters' Camp"},
-- Farms
["farm field"] = {iconfile="Farmfield_icon.png", page="Farm Field"},
["herb garden"] = {iconfile="HerbGarden_icon.png", page="Herb Garden"},
["plantation"] = {iconfile="Plantation_icon.png", page="Plantation"},
["small farm"] = {iconfile="SmallFarm_icon.png", page="Small Farm"},
-- Food production
["bakery"] = {iconfile="Bakery_icon.png", page="Bakery"},
["cellar"] = {iconfile="Cellar_icon.png", page="Cellar"},
["cookhouse"] = {iconfile="Cookhouse_icon.png", page="Cookhouse"},
["grill"] = {iconfile="Grill_icon.png", page="Grill"},
["ranch"] = {iconfile="Ranch_icon.png", page="Ranch"},
["smokehouse"] = {iconfile="Smokehouse_icon.png", page="Smokehouse"},
-- Housing
["shelter"] = {iconfile="Shelter icon.png", page="Shelter"},
["big shelter"] = {iconfile="Big Shelter icon.png", page="Big Shelter"},
["human house"] = {iconfile="Human House icon.png", page="Human House"},
["beaver house"] = {iconfile="Beaver House icon.png", page="Beaver House"},
["lizard house"] = {iconfile="Lizard House icon.png", page="Lizard House"},
["harpy house"] = {iconfile="Harpy House icon.png", page="Harpy House"},
-- Industry
["crude workstation"] = {iconfile="Crude_Workstation_icon.png", page="Crude Workstation"},
["makeshift post"] = {iconfile="Makeshift_Post_icon.png", page="Makeshift Post"},
["artisan"] = {iconfile="Artisan_icon.png", page="Artisan"},
["brewery"] = {iconfile="Brewery_icon.png", page="Brewery"},
["brickyard"] = {iconfile="Brickyard_icon.png", page="Brickyard"},
["carpenter"] = {iconfile="Carpenter_icon.png", page="Carpenter"},
["clothier"] = {iconfile="Clothier_icon.png", page="Clothier"},
["cooperage"] = {iconfile="Cooperage_icon.png", page="Cooperage"},
["druid's hut"] = {iconfile="Druid_icon.png", page="Druid's Hut"},
["kiln"] = {iconfile="Kiln_icon.png", page="Kiln"},
["leatherworker"] = {iconfile="Leatherworks_icon.png", page="Leatherworker"},
["lumber mill"] = {iconfile="Lumbermill_icon.png", page="Lumber Mill"},
["mine"] = {iconfile="Mine_icon.png", page="Mine"},
["press"] = {iconfile="Press_icon.png", page="Press"},
["provisioner"] = {iconfile="Provisioner_icon.png", page="Provisioner"},
["rain collector"] = {iconfile="Rain_Collector_icon.png", page="Rain Collector"},
["rain mill"] = {iconfile="Rain_Mill_icon.png", page="Rain Mill"},
["scribe"] = {iconfile="Scribe_icon.png", page="Scribe"},
["smelter"] = {iconfile="Smelter_icon.png", page="Smelter"},
["weaver"] = {iconfile="Weaver_icon.png", page="Weaver"},
-- City Buildings
["small hearth"] = {iconfile="Temporary_Hearth_icon.png", page="Small Hearth"},
["warehouse"] = {iconfile="Storage_icon.png", page="Warehouse"},
["trading post"] = {iconfile="Trading_Post_icon.png", page="Trading Post"},
["blight post"] = {iconfile="Blight_Post_icon.png", page="Blight Post"},
["hydrant"] = {iconfile="Hydrant_icon.png", page="Hydrant"},
["forsaken altar"] = {iconfile="Altar_icon.png", page="Forsaken Altar"},
-- Service Buildings
["bath house"] = {iconfile="Bath_House_icon.png", page="Bath House"},
["clan hall"] = {iconfile="Clan_Hall_icon.png", page="Clan Hall"},
["explorers' lodge"] = {iconfile="Explorers_Lodge_icon.png", page="Explorers' Lodge"},
["guild house"] = {iconfile="Guild_House_icon.png", page="Guild House"},
["monastery"] = {iconfile="Monastery_icon.png", page="Monastery"},
["tavern"] = {iconfile="Tavern_icon.png", page="Tavern"},
["temple"] = {iconfile="Temple_icon.png", page="Temple"},
}
-------------------------------------------------------------------------------
-- Main lookup functions
-- Accepts the in-game name and returns the name of the page on the wiki
-- associated with that in-game item, resource, building, etc.
-------------------------------------------------------------------------------
-- returns the whole data table for the specified key
-- need to run normalize function first
function BuildingData.getData(strArg)
-- normalize input
local strArg = BuildingData.normalizeName(strArg)
-- Get it from the big table below and return it.
return tableStrStrData[strArg]
end
-- simpler version if all that's needed is the iconfile.
-- error handling by the calling module is required.
function BuildingData.getIconFilename(strArg)
local data = getData(strArg)
-- if this particular data block doesn't have a iconfile, this will return nil
-- therefore, error handling will be necessary
return data.iconfile or nil
end
-- simpler version if all that's needed is the page name.
-- error handling by the calling module is required.
function BuildingData.getPagename(strArg)
local data = getData(strArg)
-- if this particular data block doesn't have a page name, this will return nil
-- therefore, error handling will be necessary
return data.page or nil
end
-- simpler version if all that's needed is the description.
-- error handling by the calling module is required.
function BuildingData.getDescription(strArg)
local data = getData(strArg)
-- if this particular data block doesn't have a description, this will return nil
-- therefore, error handling will be necessary
return data.description or nil
end
-------------------------------------------------------------------------------
-- Helper functions
-------------------------------------------------------------------------------
-- Normalize the argument to the standard in-game name, and the one that
-- is used as the key in the big lookup table.
--
-- This function will also make the argument lowercase to reduce the need
-- to specify more possible alternatives to normalize.
function BuildingData.normalizeName(strArg)
strArg = string.lower(strArg)
-- no other functions need this lookup table, so it's defined locally
-- to this function
local tableStrStrAlternatives = {
---------------------------------------
-- Buildings
---------------------------------------
-- Starting Buildings
["ancienthearth"] = "ancient hearth",
["ancienthearths"] = "ancient hearth",
["ancient hearths"] = "ancient hearth",
["mainwarehouse"] = "main warehouse",
["mainwarehouses"] = "main warehouse",
["main warehouses"] = "main warehouse",
-- Camps
["forager"] = "foragers' camp",
["foragerscamp"] = "foragers' camp",
["forager'scamp"] = "foragers' camp",
["foragers'camp"] = "foragers' camp",
["forager camp"] = "foragers' camp",
["forager's camp"] = "foragers' camp",
["foragers"] = "foragers' camp",
["foragerscamps"] = "foragers' camp",
["forager'scamps"] = "foragers' camp",
["foragers'camps"] = "foragers' camp",
["forager camps"] = "foragers' camp",
["forager's camps"] = "foragers' camp",
["harvester"] = "harvesters' camp",
["harvesterscamp"] = "harvesters' camp",
["harvester'scamp"] = "harvesters' camp",
["harvesters'camp"] = "harvesters' camp",
["harvester camp"] = "harvesters' camp",
["harvester's camp"] = "harvesters' camp",
["harvesters"] = "harvesters' camp",
["harvesterscamps"] = "harvesters' camp",
["harvester'scamps"] = "harvesters' camp",
["harvesters'camps"] = "harvesters' camp",
["harvester camps"] = "harvesters' camp",
["harvester's camps"] = "harvesters' camp",
["herbalist"] = "herbalists' camp",
["herbalistscamp"] = "herbalists' camp",
["herbalist'scamp"] = "herbalists' camp",
["herbalists'camp"] = "herbalists' camp",
["herbalist camp"] = "herbalists' camp",
["herbalist's camp"] = "herbalists' camp",
["herbalists"] = "herbalists' camp",
["herbalistscamps"] = "herbalists' camp",
["herbalist'scamps"] = "herbalists' camp",
["herbalists'camps"] = "herbalists' camp",
["herbalist camps"] = "herbalists' camp",
["herbalist's camps"] = "herbalists' camp",
["stonecutter"] = "stonecutters' camp",
["stonecutterscamp"] = "stonecutters' camp",
["stonecutter'scamp"] = "stonecutters' camp",
["stonecutters'camp"] = "stonecutters' camp",
["stonecutter camp"] = "stonecutters' camp",
["stonecutter's camp"] = "stonecutters' camp",
["stonecutters"] = "stonecutters' camp",
["stonecutterscamps"] = "stonecutters' camp",
["stonecutter'scamps"] = "stonecutters' camp",
["stonecutters'camps"] = "stonecutters' camp",
["stonecutter camps"] = "stonecutters' camp",
["stonecutter's camps"] = "stonecutters' camp",
["trapper"] = "trappers' camp",
["trapperscamp"] = "trappers' camp",
["trapper'scamp"] = "trappers' camp",
["trappers'camp"] = "trappers' camp",
["trapper camp"] = "trappers' camp",
["trapper's camp"] = "trappers' camp",
["trappers"] = "trappers' camp",
["trapperscamps"] = "trappers' camp",
["trapper'scamps"] = "trappers' camp",
["trappers'camps"] = "trappers' camp",
["trapper camps"] = "trappers' camp",
["trapper's camps"] = "trappers' camp",
["woodcutter"] = "woodcutters' camp",
["woodcutterscamp"] = "woodcutters' camp",
["woodcutter'scamp"] = "woodcutters' camp",
["woodcutters'camp"] = "woodcutters' camp",
["woodcutter camp"] = "woodcutters' camp",
["woodcutter's camp"] = "woodcutters' camp",
["woodcutters"] = "woodcutters' camp",
["woodcutterscamps"] = "woodcutters' camp",
["woodcutter'scamps"] = "woodcutters' camp",
["woodcutters'camps"] = "woodcutters' camp",
["woodcutter camps"] = "woodcutters' camp",
["woodcutter's camps"] = "woodcutters' camp",
-- Farms
["field"] = "farm field",
["fields"] = "farm field",
["farmfield"] = "farm field",
["farmfields"] = "farm field",
["farm fields"] = "farm field",
["herbgarden"] = "herb garden",
["herbgardens"] = "herb garden",
["herb gardens"] = "herb garden",
["farm"] = "small farm",
["farms"] = "small farm",
["smallfarm"] = "small farm",
["smallfarms"] = "small farm",
["small farms"] = "small farm",
-- Food Production
["baker"] = "bakery",
["bakers"] = "bakery",
["bakeries"] = "bakery",
["celler"] = "cellar",
["cellers"] = "cellar",
["cellars"] = "cellar",
["cookhouses"] = "cookhouse",
["cook house"] = "cookhouse",
["cook houses"] = "cookhouse",
["grills"] = "grill",
["ranches"] = "ranch",
["smokehouses"] = "smokehouse",
["smoke house"] = "smokehouse",
["smoke housea"] = "smokehouse",
-- Housing
["house"] = "shelter",
["houses"] = "shelter",
["bighouse"] = "big shelter",
["bighouses"] = "big shelter",
["bigshelter"] = "big shelter",
["bigshelters"] = "big shelter",
["humanhouse"] = "human house",
["humanhouses"] = "human house",
["human'shouse"] = "human house",
["humans'house"] = "human house",
["human houses"] = "human house",
["human's house"] = "human house",
["humans' house"] = "human house",
["human's houses"] = "human house",
["humans' houses"] = "human house",
["beaverhouse"] = "beaver house",
["beaverhouses"] = "beaver house",
["beaver'shouse"] = "beaver house",
["beavers'house"] = "beaver house",
["beaver'shouses"] = "beaver house",
["beavers'houses"] = "beaver house",
["beaver houses"] = "beaver house",
["beaver's houses"] = "beaver house",
["beavers' houses"] = "beaver house",
["lizardhouse"] = "lizard house",
["lizardhouses"] = "lizard house",
["lizard'shouse"] = "lizard house",
["lizards'house"] = "lizard house",
["lizard'shouses"] = "lizard house",
["lizards'houses"] = "lizard house",
["lizard houses"] = "lizard house",
["lizard's houses"] = "lizard house",
["lizards' houses"] = "lizard house",
["harpyhouse"] = "harpy house",
["harpyhouses"] = "harpy house",
["harpy'shouse"] = "harpy house",
["harpys'house"] = "harpy house",
["harpy'shouses"] = "harpy house",
["harpys'houses"] = "harpy house",
["harpy houses"] = "harpy house",
["harpy's houses"] = "harpy house",
["harpys' houses"] = "harpy house",
["harpieshouse"] = "harpy house",
["harpieshouses"] = "harpy house",
["harpies'house"] = "harpy house",
["harpies houses"] = "harpy house",
["harpies' houses"] = "harpy house",
-- Industry
["crudeworkstation"] = "crude workstation",
["crudeworkstations"] = "crude workstation",
["crude workstations"] = "crude workstation",
["makeshiftpost"] = "makeshift post",
["makeshiftposts"] = "makeshift post",
["makeshift posts"] = "makeshift post",
["artisans"] = "artisan",
["brewer"] = "brewery",
["brewers"] = "brewery",
["breweries"] = "brewery",
["brickyards"] = "brickyard",
["brick yard"] = "brickyard",
["brick yards"] = "brickyard",
["carpenters"] = "carpenter",
["clothiers"] = "clothier",
["cooper"] = "cooperage",
["coopers"] = "cooperage",
["cooperages"] = "cooperage",
["druid"] = "druid's hut",
["druids"] = "druid's hut",
["druidhut"] = "druid's hut",
["druidhuts"] = "druid's hut",
["druid'shut"] = "druid's hut",
["druid'shuts"] = "druid's hut",
["druids'hut"] = "druid's hut",
["druids'huts"] = "druid's hut",
["druid hut"] = "druid's hut",
["druid huts"] = "druid's hut",
["druids' hut"] = "druid's hut",
["druids' huts"] = "druid's hut",
["druid's huts"] = "druid's hut",
["kilns"] = "kiln",
["leatherworkers"] = "leatherworker",
["leather worker"] = "leatherworker",
["leather workers"] = "leatherworker",
["lumbermill"] = "lumber mill",
["lumbermills"] = "lumber mill",
["lumber mills"] = "lumber mill",
["mines"] = "mine",
["presses"] = "press",
["provisioners"] = "provisioner",
["raincollector"] = "rain collector",
["raincollectors"] = "rain collector",
["rain collectors"] = "rain collector",
["rainmill"] = "rain mill",
["rainmills"] = "rain mill",
["rain mills"] = "rain mill",
["scribes"] = "scribe",
["smelters"] = "smelter",
["smeltery"] = "smelter",
["smelteries"] = "smelter",
["weavers"] = "weaver",
-- City buildings
["smallhearth"] = "small hearth",
["smallhearths"] = "small hearth",
["small hearths"] = "small hearth",
["warehouses"] = "warehouse",
["ware house"] = "warehouse",
["ware houses"] = "warehouse",
["traderpost"] = "trading post",
["traderposts"] = "trading post",
["trader posts"] = "trading post",
["tradingpost"] = "trading post",
["tradingposts"] = "trading post",
["trading posts"] = "trading post",
["blightpost"] = "blight post",
["blightposts"] = "blight post",
["blight posts"] = "blight post",
["hydrants"] = "hydrant",
["forsakenaltar"] = "forsaken altar",
["forsakenalter"] = "forsaken altar",
["foresakenaltar"] = "forsaken altar",
["foresakenalter"] = "forsaken altar",
["forsakenaltars"] = "forsaken altar",
["forsakenalters"] = "forsaken altar",
["foresakenaltars"] = "forsaken altar",
["foresakenalters"] = "forsaken altar",
["forsaken altars"] = "forsaken altar",
["forsaken alters"] = "forsaken altar",
["foresaken altars"] = "forsaken altar",
["foresaken alters"] = "forsaken altar",
-- Service Buildings
["bath"] = "bath house",
["baths"] = "bath house",
["bathhouse"] = "bath house",
["bathhouses"] = "bath house",
["bath houses"] = "bath house",
["clan"] = "clan hall",
["clans"] = "clan hall",
["clanhall"] = "clan hall",
["clanhalls"] = "clan hall",
["clan halls"] = "clan hall",
["explorer"] = "explorers' lodge",
["explorers"] = "explorers' lodge",
["explorerlodge"] = "explorers' lodge",
["explorerslodge"] = "explorers' lodge",
["explorerlodges"] = "explorers' lodge",
["explorerslodges"] = "explorers' lodge",
["explorers'lodges"] = "explorers' lodge",
["explorer'slodges"] = "explorers' lodge",
["explorer lodge"] = "explorers' lodge",
["explorers lodge"] = "explorers' lodge",
["explorer lodges"] = "explorers' lodge",
["explorers lodges"] = "explorers' lodge",
["explorer's lodges"] = "explorers' lodge",
["guild"] = "guild house",
["guilds"] = "guild house",
["guildhouse"] = "guild house",
["guildhouses"] = "guild house",
["guild houses"] = "guild house",
["monestary"] = "monastery",
["monastary"] = "monastery",
["monestery"] = "monastery",
["monestaries"] = "monastery",
["monastaries"] = "monastery",
["monesteries"] = "monastery",
["taverns"] = "tavern",
["temples"] = "temple"
} -- the end of the huge tableStrStrAlternatives
-- if nothing is found, the result of the lookup will be nil, so
-- just return whatever was passed in as the argument (lowercase)
-- we can assume that the input argument is fine or does not exist
return tableStrStrAlternatives[strArg] or strArg
end
-------------------------------------------------------------------------------
-- Return when required into another Module.
-------------------------------------------------------------------------------
return BuildingData


