<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.hoodedhorse.com/Against_the_Storm/index.php?action=history&amp;feed=atom&amp;title=Module%3ABiomesData</id>
	<title>Module:BiomesData - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.hoodedhorse.com/Against_the_Storm/index.php?action=history&amp;feed=atom&amp;title=Module%3ABiomesData"/>
	<link rel="alternate" type="text/html" href="https://wiki.hoodedhorse.com/Against_the_Storm/index.php?title=Module:BiomesData&amp;action=history"/>
	<updated>2026-10-02T07:43:30Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.44.5</generator>
	<entry>
		<id>https://wiki.hoodedhorse.com/Against_the_Storm/index.php?title=Module:BiomesData&amp;diff=10167&amp;oldid=prev</id>
		<title>76561197969631737: Created with 1.7.2 data drop from devs</title>
		<link rel="alternate" type="text/html" href="https://wiki.hoodedhorse.com/Against_the_Storm/index.php?title=Module:BiomesData&amp;diff=10167&amp;oldid=prev"/>
		<updated>2025-03-13T18:32:47Z</updated>

		<summary type="html">&lt;p&gt;Created with 1.7.2 data drop from devs&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;---@class BiomesData&lt;br /&gt;
local BiomesData = {}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--region Dependencies&lt;br /&gt;
&lt;br /&gt;
local JsonUtils = require(&amp;quot;Module:JsonUtils&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
--endregion&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--region Private constants&lt;br /&gt;
&lt;br /&gt;
local DATA_FILE = &amp;quot;Module:BiomesData/Biomes.json&amp;quot;&lt;br /&gt;
&lt;br /&gt;
local SCHEMA = {&lt;br /&gt;
    ID = &amp;quot;id&amp;quot;,&lt;br /&gt;
    ICON = &amp;quot;iconName&amp;quot;,&lt;br /&gt;
    DLC_REQUIRED = &amp;quot;dlc&amp;quot;,&lt;br /&gt;
    NAME = &amp;quot;displayName&amp;quot;,&lt;br /&gt;
    DESCRIPTION = &amp;quot;description&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
    SOIL_GRADE = &amp;quot;soilGrade&amp;quot;,&lt;br /&gt;
    TOWN_TYPE = &amp;quot;townTypeName&amp;quot;,&lt;br /&gt;
    WANTED_GOODS_IDS_ARRAY = &amp;quot;wantedGoods&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
    TREES_IDS_ARRAY = &amp;quot;trees&amp;quot;,&lt;br /&gt;
    DEPOSITS_IDS_ARRAY = &amp;quot;deposits&amp;quot;,&lt;br /&gt;
    ORE_IDS_ARRAY = &amp;quot;ore&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
    EFFECTS_IDS_ARRAY = &amp;quot;effects&amp;quot;,&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
--endregion&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--region Localization string constants&lt;br /&gt;
&lt;br /&gt;
--endregion&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--region Private member variables&lt;br /&gt;
&lt;br /&gt;
local biomesData&lt;br /&gt;
&lt;br /&gt;
--endregion&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--region Private methods&lt;br /&gt;
&lt;br /&gt;
 local function loadData()&lt;br /&gt;
&lt;br /&gt;
    if not biomesData then&lt;br /&gt;
&lt;br /&gt;
        local newData = JsonUtils.convertJSONToLuaTable(DATA_FILE)&lt;br /&gt;
&lt;br /&gt;
        --Promote the ID to be the key of the main data table.&lt;br /&gt;
        biomesData = {}&lt;br /&gt;
        for _, biome in ipairs(newData) do&lt;br /&gt;
            biomesData[biome[SCHEMA.ID]] = biome&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function getBiomeFieldByID(biomeID, fieldName)&lt;br /&gt;
&lt;br /&gt;
    loadData()&lt;br /&gt;
    local biome = biomesData[biomeID]&lt;br /&gt;
    if not biome then&lt;br /&gt;
        return nil&lt;br /&gt;
    else&lt;br /&gt;
        return biome[fieldName]&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--endregion&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--region Public methods&lt;br /&gt;
&lt;br /&gt;
---@public&lt;br /&gt;
---Gets an array of all IDs of biomes in the data.&lt;br /&gt;
---&lt;br /&gt;
---@return table an array of IDs&lt;br /&gt;
function BiomesData.getAllBiomeIDs()&lt;br /&gt;
&lt;br /&gt;
    loadData()&lt;br /&gt;
&lt;br /&gt;
    local biomeIDs = {}&lt;br /&gt;
    for id, _ in pairs(biomesData) do&lt;br /&gt;
        table.insert(biomeIDs, id)&lt;br /&gt;
    end&lt;br /&gt;
    return biomeIDs&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
---@public&lt;br /&gt;
---Gets the icon filename for the specified biome.&lt;br /&gt;
---&lt;br /&gt;
---@param biomeID string&lt;br /&gt;
---@return string the icon filename&lt;br /&gt;
function BiomesData.getIcon(biomeID)&lt;br /&gt;
    return getBiomeFieldByID(biomeID, SCHEMA.ICON)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
---@public&lt;br /&gt;
-----Gets the name of the specified biome.&lt;br /&gt;
-----&lt;br /&gt;
-----@param biomeID string&lt;br /&gt;
-----@return string the display name&lt;br /&gt;
function BiomesData.getName(biomeID)&lt;br /&gt;
    return getBiomeFieldByID(biomeID, SCHEMA.NAME)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
---@public&lt;br /&gt;
---Gets the description of the specified biome.&lt;br /&gt;
---&lt;br /&gt;
---@param biomeID string&lt;br /&gt;
---@return string description&lt;br /&gt;
function BiomesData.getDescription(biomeID)&lt;br /&gt;
    return getBiomeFieldByID(biomeID, SCHEMA.DESCRIPTION)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
---@public&lt;br /&gt;
---Checks whether the specified deposit is in the specified biome.&lt;br /&gt;
---&lt;br /&gt;
---@param depositID string ID of a deposit&lt;br /&gt;
---@param biomeID string&lt;br /&gt;
---@return boolean true if the deposit is in the biome&lt;br /&gt;
function BiomesData.isDepositInBiome(depositID, biomeID)&lt;br /&gt;
&lt;br /&gt;
    local depositsArray = getBiomeFieldByID(biomeID, SCHEMA.DEPOSITS_IDS_ARRAY)&lt;br /&gt;
    for _, id in ipairs(depositsArray) do&lt;br /&gt;
        if id == depositID then&lt;br /&gt;
            return true&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    return false&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
---@public&lt;br /&gt;
---Checks whether the specified tree is in the specified biome.&lt;br /&gt;
---&lt;br /&gt;
---@param treeID string ID of a tree&lt;br /&gt;
---@param biomeID string&lt;br /&gt;
---@return boolean true if the tree is in the biome&lt;br /&gt;
function BiomesData.isTreeInBiome(treeID, biomeID)&lt;br /&gt;
    local treesArray = getBiomeFieldByID(biomeID, SCHEMA.TREES_IDS_ARRAY)&lt;br /&gt;
    for _, id in ipairs(treesArray) do&lt;br /&gt;
        if id == treeID then&lt;br /&gt;
            return true&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    return false&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
---@public&lt;br /&gt;
---Checks whether the specified ore is in the specified biome.&lt;br /&gt;
---&lt;br /&gt;
---@param oreID string ID of a tree&lt;br /&gt;
---@param biomeID string&lt;br /&gt;
---@return boolean true if the ore is in the biome&lt;br /&gt;
function BiomesData.isOreInBiome(oreID, biomeID)&lt;br /&gt;
    local oresArray = getBiomeFieldByID(biomeID, SCHEMA.ORE_IDS_ARRAY)&lt;br /&gt;
    for _, id in ipairs(oresArray) do&lt;br /&gt;
        if id == oreID then&lt;br /&gt;
            return true&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    return false&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
---@public&lt;br /&gt;
---Shortcut method if you don&amp;#039;t know the type of node, but need to check all three (deposits, trees, ores) to see if the ID is in the specified biome.&lt;br /&gt;
---&lt;br /&gt;
---@param nodeID string ID of a node of some type&lt;br /&gt;
---@param biomeID string&lt;br /&gt;
---@return boolean true if the specified node of some type is in the biome&lt;br /&gt;
function BiomesData.isNodeOfAnyTypeInBiome(nodeID, biomeID)&lt;br /&gt;
&lt;br /&gt;
    local found = BiomesData.isDepositInBiome(nodeID, biomeID)&lt;br /&gt;
    if found then&lt;br /&gt;
        return true&lt;br /&gt;
    end&lt;br /&gt;
    found = BiomesData.isTreeInBiome(nodeID, biomeID)&lt;br /&gt;
    if found then&lt;br /&gt;
        return true&lt;br /&gt;
    end&lt;br /&gt;
    found = BiomesData.isOreInBiome(nodeID, biomeID)&lt;br /&gt;
    if found then&lt;br /&gt;
        return true&lt;br /&gt;
    end&lt;br /&gt;
    return false&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--endregion&lt;br /&gt;
&lt;br /&gt;
return BiomesData&lt;/div&gt;</summary>
		<author><name>76561197969631737</name></author>
	</entry>
</feed>