splits sphere analysis and logging into separate functions

This commit is contained in:
duncathan 2021-04-06 01:11:47 -06:00
parent ea6549139c
commit aa1dadef18
2 changed files with 42 additions and 17 deletions

View file

@ -456,9 +456,7 @@ function endgame:new(worldGraph)
self.locations.hellB1.getPrebuiltHint = prebuilt
self.locations.hellB3.getPrebuiltHint = prebuilt
self.requirements = function(self, items)
return self.world:canBeatGame(items)
end
self.requirements = function(self, items) return false end -- just pretend you never get here
end
local hintRegion = Region:extend()
@ -590,7 +588,8 @@ function worldGraph:canBeatGame(items, obj)
return true
end
if obj == "objAllBosses" then return bossReqs(self, items) end
return false -- removing ANY items from 100% makes a seed uncompletable
return false -- I don't actually think the check below works as intended, false is sufficient for now since 100% and completable logic should be mutually exclusive anyway
--return #items > #self:getLocations() - #self:getHintLocations() - 2 -- removing ANY items (besides in hell) from 100% makes a seed uncompletable
end
function worldGraph:getLocations()
@ -664,7 +663,7 @@ function worldGraph:getFilledLocations(realOnly)
local locations = {}
for key, region in pairs(self.regions) do
for k, location in pairs(region:getFilledLocations()) do
if not realOnly or not (_.find(location.item.attributes,"abstract") or _.find(location.item.attributes,"mrLittle")) then table.insert(locations, location) end
if not realOnly or not _.find(location.item.attributes,"abstract") then table.insert(locations, location) end
end
end
return locations

View file

@ -48,6 +48,7 @@ function C:new()
self.mychar = ""
self.shuffleMusic = false
self.completableLogic = true
self.spheres = {}
end
function C:setPath(path)
@ -77,7 +78,7 @@ function C:randomize()
self:_generateHash()
if self.shuffleMusic then self.music:shuffleMusic(tscFiles) end
self:_analyzeSpheres()
self:_logSpheres()
self:_generateRoute()
self:_writeModifiedData(tscFiles)
@ -259,29 +260,54 @@ function C:_fastFillItems(items, locations)
end
end
function C:_analyzeSpheres()
local spheres = {}
function C:_analyzeSpheres(forceUpdate)
if not forceUpdate and #self.spheres > 0 then
return self.spheres
end
self.spheres = {}
local items = {}
local locations
local i = 0
repeat
i = i+1
local collected
collected, locations = self.worldGraph:collect(items, locations, true)
local sphereItems = _.difference(collected, items)
items = collected
if #sphereItems == 0 then break end
logSphere(("Sphere %i"):format(i))
local sphere = {}
for k,v in pairs(sphereItems) do
if not self.worldGraph:_has({v}, "abstract") then
logSphere(("\t %s: %s"):format(v.location_name, v.name))
table.insert(sphere, v)
end
if #sphere == 0 then break end
table.insert(self.spheres, sphere)
until false
if self.obj ~= "objBadEnd" and self.obj ~= "objNormalEnd" then
-- add the hell sphere at the very end, shh it works trust me
local sphere = {}
table.insert(sphere, self.worldGraph.regions.endgame.locations.hellB1.item)
table.insert(sphere, self.worldGraph.regions.endgame.locations.hellB3.item)
table.insert(self.spheres, sphere)
end
return self.spheres
end
function C:_logSpheres()
local total = 0
for i,sphere in ipairs(self:_analyzeSpheres()) do
logSphere(("Sphere %i"):format(i))
for i2,item in ipairs(sphere) do
if not _.contains(item.attributes, "abstract") then
total = total + 1
end
if not _.contains(item.attributes, "objective") then
logSphere(("\t %s: %s"):format(item.location_name, item.name))
end
end
until false
end
logSphere(("Maximum items to collect: %i"):format(total))
end
function C:_generateRoute()