reworked the item deck for ease of use for the new shuffle algorithm

This commit is contained in:
duncathan 2019-03-11 06:12:11 -06:00
parent 80ffb75261
commit a47664f854
2 changed files with 41 additions and 26 deletions

View file

@ -135,32 +135,32 @@ local data = {
keySpot = {
requirements = {},
map = "Weed",
event = "#0000"
event = "#0700"
},
jellyCapsule = {
requirements = {},
map = "Weed",
event = "#0000"
event = "#0701"
},
santa = {
requirements = {{"santaKey"}},
map = "Santa",
event = "#0000"
event = "#0501"
},
charcoal = {
requirements = {{"santaKey", "juice"}},
map = "Santa",
event = "#0000"
event = "#0302"
}
chaco = {
requirements = {{"santaKey"}, {"fireball"}},
requirements = {{"santaKey"}},
map = "Chako",
event = "#6969"
event = "#0211"
},
kulala = {
requirements = {{"santaKey", "weaponBoss"}, {"fireball"}},
requirements = {{"santaKey", "weaponBoss"}},
map = "Weed",
event = "0000"
event = "0702"
}
}
},
@ -173,37 +173,37 @@ local data = {
kazuma1 = {
requirements = {},
map = "Weed",
event = "#0000"
event = "#0800"
},
kazuma2 = {
requirements = {{"eventFans"}},
map = "Weed",
event = "#0000"
event = "#0801"
},
execution = {
requirements = {{"weaponSN"}},
map = "WeedD",
event = "#0000"
event = "#0305"
},
outsideHut = {
requirements = {{"eventFans"}, {"flight"}},
map = "Weed",
event = "#0000"
event = "#0302"
},
hutChest = {
requirements = {{"eventFans"}, {"flight"}},
map = "WeedB",
event = "#0000"
event = "#0300"
},
gumChest = {
requirements = {{"eventFans", "gumKey", "weaponBoss"}, {"flight", "gumKey", "weaponBoss"}},
map = "Frog",
event = "#0000"
event = "#0300"
},
malco = {
requirements = {{"eventFans", "juice", "charcoal", "gum"}},
map = "Malco",
event = "#0000"
event = "#0350"
}
},
events = {

View file

@ -8,27 +8,31 @@ function C:new()
local item = _.clone(v)
table.insert(self._left, item)
end
self._placed = {}
end
local function _filterAny(item) return true end
local function _filterAnyExceptMissiles(item) return item.kind ~= "missiles" end
local function _filterWeapon(item) return item.kind == "weapon" end
function C:getAny()
return self:_getItem(_filterAny)
end
function C:getAnyExceptMissiles()
return self:_getItem(_filterAnyExceptMissiles)
function C:getAnyByAttribute(attribute)
function _filterAnyByAttribute(item, attribute)
for k, v in pairs(item.attributes) do
if v == attribute then return true
end
return false
end
return self:_getItem(_filterAnyByAttribute)
end
function C:getByKey(key)
local filterByKey = function(item) return item.key == key end
return self:_getItem(filterByKey)
function C:placeAny()
return self:place(self:getAny())
end
function C:getWeapon()
return self:_getItem(_filterWeapon)
function C:placeAnyByAttribute(attributes)
return self:place(self:getAnyByAttribute(attributes))
end
function C:_getItem(filterFn)
@ -46,9 +50,20 @@ function C:_getItem(filterFn)
-- Select an item.
local selected = _.sample(applicable)
local index = indexMap[selected]
table.remove(self._left, index)
return selected
return selected, index
end
function C:place(item, index)
table.remove(self._left, index)
table.insert(self._placed, item)
return item
end
function C:getPlacedItems(item)
local placed = {table.unpack(self._placed)} -- clone the table
if(item) then table.insert(placed, item) end
return placed
end
return C