2019-03-19 08:56:38 +00:00
|
|
|
local C = Class:extend()
|
|
|
|
|
2020-03-03 14:20:04 +00:00
|
|
|
function C:new(worldGraph, name, hints)
|
2019-03-19 08:56:38 +00:00
|
|
|
self.locations = {}
|
|
|
|
self.world = worldGraph
|
|
|
|
self.name = name
|
2020-02-28 21:52:01 +00:00
|
|
|
self.order = worldGraph.order
|
|
|
|
worldGraph.order = worldGraph.order + 1
|
2020-03-03 14:20:04 +00:00
|
|
|
self.hintList = hints or {}
|
2019-03-19 08:56:38 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function C:canAccess(items)
|
2019-03-21 10:14:56 +00:00
|
|
|
if self.requirements == nil then return true end
|
|
|
|
return self.requirements(self, items)
|
2019-03-19 08:56:38 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function C:getLocation(key)
|
|
|
|
return self.locations[key]
|
|
|
|
end
|
|
|
|
|
2019-03-20 12:37:07 +00:00
|
|
|
function C:getLocations(filterFn)
|
|
|
|
filterFn = filterFn or function(k,v) return true end
|
|
|
|
return _.filter(self.locations, filterFn)
|
2019-03-19 08:56:38 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function C:getEmptyLocations()
|
2020-03-03 14:20:04 +00:00
|
|
|
return self:getLocations(function(k,v) return not v:hasItem() end)
|
2019-03-19 08:56:38 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function C:getFilledLocations()
|
2020-03-03 14:20:04 +00:00
|
|
|
return self:getLocations(function(k,v) return v:hasItem() end)
|
2019-03-19 08:56:38 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function C:writeItems(tscFiles)
|
2019-03-20 12:37:07 +00:00
|
|
|
for key, location in pairs(self.locations) do location:writeItem(tscFiles) end
|
2019-03-19 08:56:38 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
return C
|