mirror of
https://github.com/cave-story-randomizer/cave-story-randomizer
synced 2024-12-29 00:07:39 +00:00
splits out item hint initialization into its own function for clarity
This commit is contained in:
parent
c9e8d0452d
commit
5cd8fdddc2
|
@ -413,6 +413,21 @@ local function _itemData()
|
||||||
obj100Percent = objective("100%", "<FL+6004<IT+0005")
|
obj100Percent = objective("100%", "<FL+6004<IT+0005")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local array = {}
|
||||||
|
for k, t in pairs(data) do
|
||||||
|
t.key = k
|
||||||
|
t.placed = t.placed or false
|
||||||
|
t.attributes = t.attributes or {}
|
||||||
|
table.insert(t.attributes, k)
|
||||||
|
table.insert(array, t)
|
||||||
|
|
||||||
|
initializeHints(t)
|
||||||
|
end
|
||||||
|
|
||||||
|
return array
|
||||||
|
end
|
||||||
|
|
||||||
|
local function initializeHints(item)
|
||||||
local hintArray = {
|
local hintArray = {
|
||||||
--mandatory = {"a required item"},
|
--mandatory = {"a required item"},
|
||||||
puppy = {"a puppy", "a living being"},
|
puppy = {"a puppy", "a living being"},
|
||||||
|
@ -425,27 +440,16 @@ local function _itemData()
|
||||||
missileLauncher = {"a Missile upgrade"}
|
missileLauncher = {"a Missile upgrade"}
|
||||||
}
|
}
|
||||||
|
|
||||||
local array = {}
|
item.hints = item.hints or {} -- initialize item's hints array if not already
|
||||||
for k, t in pairs(data) do
|
|
||||||
t.key = k
|
|
||||||
t.placed = t.placed or false
|
|
||||||
t.attributes = t.attributes or {}
|
|
||||||
table.insert(t.attributes, k)
|
|
||||||
table.insert(array, t)
|
|
||||||
|
|
||||||
t.hints = t.hints or {}
|
-- loop through item's attributes and add any matching hints from the hintArray table
|
||||||
for k,v in ipairs(t.attributes) do
|
for k,v in ipairs(t.attributes) do
|
||||||
for k2,v2 in ipairs(hintArray[v] or {}) do
|
for k2,v2 in ipairs(hintArray[v] or {}) do
|
||||||
table.insert(t.hints, v2)
|
table.insert(t.hints, v2)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return array
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
local C = Class:extend()
|
local C = Class:extend()
|
||||||
|
|
||||||
function C:new()
|
function C:new()
|
||||||
|
|
Loading…
Reference in a new issue