mirror of
https://github.com/cave-story-randomizer/cave-story-randomizer
synced 2025-01-03 10:46:49 +00:00
solves the misplaced items issue re: puppies getting placed on events
This commit is contained in:
parent
1542c25322
commit
c6efbb225b
|
@ -446,8 +446,8 @@ function worldGraph:getLocations()
|
||||||
end
|
end
|
||||||
|
|
||||||
function worldGraph:getPuppySpots()
|
function worldGraph:getPuppySpots()
|
||||||
local locations = self.locationsArray(self.regions.upperSandZone:getLocations())
|
local locations = self.locationsArray(self.regions.upperSandZone:getEmptyLocations())
|
||||||
for k, location in pairs(self.regions.lowerSandZone:getLocations()) do
|
for k, location in pairs(self.regions.lowerSandZone:getEmptyLocations()) do
|
||||||
if k ~= "jenka" and k ~= "king" and k ~= "eventToroko" then
|
if k ~= "jenka" and k ~= "king" and k ~= "eventToroko" then
|
||||||
table.insert(locations, location)
|
table.insert(locations, location)
|
||||||
end
|
end
|
||||||
|
|
|
@ -103,6 +103,7 @@ end
|
||||||
function C:_shuffleItems(tscFiles)
|
function C:_shuffleItems(tscFiles)
|
||||||
local l, i = #self.worldGraph:getLocations(), #self.itemDeck:getItems()
|
local l, i = #self.worldGraph:getLocations(), #self.itemDeck:getItems()
|
||||||
assert(l == i, ("Locations: %d\r\nItems: %d"):format(l, i))
|
assert(l == i, ("Locations: %d\r\nItems: %d"):format(l, i))
|
||||||
|
|
||||||
-- first fill puppies
|
-- first fill puppies
|
||||||
self:_fastFillItems(self.itemDeck:getItemsByAttribute("puppy"), _.shuffle(self.worldGraph:getPuppySpots()))
|
self:_fastFillItems(self.itemDeck:getItemsByAttribute("puppy"), _.shuffle(self.worldGraph:getPuppySpots()))
|
||||||
|
|
||||||
|
@ -119,15 +120,11 @@ function C:_shuffleItems(tscFiles)
|
||||||
self.worldGraph:writeItems(tscFiles)
|
self.worldGraph:writeItems(tscFiles)
|
||||||
end
|
end
|
||||||
|
|
||||||
function C:_fillItems(items, locations, baseItems)
|
function C:_fillItems(items, locations)
|
||||||
local itemsLeft
|
assert(#items > 0, ("No items provided! Trying to fill %s locations."):format(#locations))
|
||||||
if baseItems ~= nil then
|
|
||||||
itemsLeft = _.union(items, baseItems)
|
|
||||||
else
|
|
||||||
itemsLeft = _.clone(items)
|
|
||||||
end
|
|
||||||
assert(#items <= #locations, string.format("Trying to fill more items than there are locations! Items: %d Locations: %d", #items, #locations))
|
assert(#items <= #locations, string.format("Trying to fill more items than there are locations! Items: %d Locations: %d", #items, #locations))
|
||||||
|
|
||||||
|
local itemsLeft = _.clone(items)
|
||||||
for key, item in ipairs(items) do
|
for key, item in ipairs(items) do
|
||||||
local assumed = self.worldGraph:collect(_.remove(itemsLeft, item))
|
local assumed = self.worldGraph:collect(_.remove(itemsLeft, item))
|
||||||
|
|
||||||
|
@ -140,11 +137,10 @@ function C:_fillItems(items, locations, baseItems)
|
||||||
end
|
end
|
||||||
|
|
||||||
function C:_fastFillItems(items, locations)
|
function C:_fastFillItems(items, locations)
|
||||||
--assert(#items > 0, ("Items: %d Locations: %d"):format(#items, #locations))
|
assert(#items > 0, ("No items provided! Attempting to fast fill %s locations."):format(#locations))
|
||||||
|
|
||||||
for key, location in ipairs(locations) do
|
for key, location in ipairs(locations) do
|
||||||
local item = items[#items]
|
local item = _.pop(items)
|
||||||
table.remove(items)
|
|
||||||
--assert(item ~= nil, ("Items: %d Locations: %d"):format(#items, key))
|
|
||||||
if item == nil then break end -- no items left to place, but there are still locations open
|
if item == nil then break end -- no items left to place, but there are still locations open
|
||||||
location:setItem(item)
|
location:setItem(item)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue