Module:CampsData: Difference between revisions

From Against the Storm Official Wiki
(Updating to new data model!)
Tag: Replaced
(Refactoring to better inherit BaseDataModel; improving Luadoc)
Line 1: Line 1:
---@module CampsData
---@class CampsData
---`extends BaseDataModel`
local CampsData = {}
local CampsData = {}


--region Dependencies
---@type BaseDataModel
local BaseDataModel = require("Module:BaseDataModel")
local BaseDataModel = require("Module:BaseDataModel")
local INDEX = BaseDataModel.INDEX
--endregion
--region Private constants
local DATA_FILE = "Module:CampsData/Camps.json"
local DATA_FILE = "Module:CampsData/Camps.json"
--endregion




-- Benchmarking: ~0.0000 seconds
 
--region Private member variables
---@type BaseDataModel
local campsDataModel = BaseDataModel.new(DATA_FILE)
local campsDataModel = BaseDataModel.new(DATA_FILE)
--endregion
--region Public building interface
---@protected
---@function
---Initializes the specified record with special information related to this data model.
---
---@param id string building ID
---@overload BaseDataModel
function CampsData:initializeRecord(id)
    local record = self.dataTable[id]
    record[INDEX.CATEGORY2] = "Gathering Camp"
end
---@public
---@function
---Checks whether the specified ID is a service-type building from this instance's data.
---
---@param id string building ID
---@return boolean _true_ if a service building, _false_ if not, or nil if not found
---@overload BaseDataModel
function CampsData:isServiceBuilding(id)
    -- Ignores the parameter; nothing in this data is a service building
    id = id
    return false
end
--endregion


return campsDataModel
return campsDataModel

Revision as of 22:33, 4 November 2024

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

---@class CampsData
---`extends BaseDataModel`
local CampsData = {}



--region Dependencies

---@type BaseDataModel
local BaseDataModel = require("Module:BaseDataModel")

local INDEX = BaseDataModel.INDEX

--endregion




--region Private constants
local DATA_FILE = "Module:CampsData/Camps.json"
--endregion



--region Private member variables
---@type BaseDataModel
local campsDataModel = BaseDataModel.new(DATA_FILE)
--endregion



--region Public building interface

---@protected
---@function
---Initializes the specified record with special information related to this data model.
---
---@param id string building ID
---@overload BaseDataModel
function CampsData:initializeRecord(id)
    local record = self.dataTable[id]
    record[INDEX.CATEGORY2] = "Gathering Camp"
end

---@public
---@function
---Checks whether the specified ID is a service-type building from this instance's data.
---
---@param id string building ID
---@return boolean _true_ if a service building, _false_ if not, or nil if not found
---@overload BaseDataModel
function CampsData:isServiceBuilding(id)
    -- Ignores the parameter; nothing in this data is a service building
    id = id
    return false
end

--endregion


return campsDataModel