mirror of
https://github.com/cave-story-randomizer/cave-story-randomizer
synced 2024-11-08 07:54:31 +00:00
splits sphere analysis and logging into separate functions
This commit is contained in:
parent
ea6549139c
commit
aa1dadef18
|
@ -456,9 +456,7 @@ function endgame:new(worldGraph)
|
||||||
self.locations.hellB1.getPrebuiltHint = prebuilt
|
self.locations.hellB1.getPrebuiltHint = prebuilt
|
||||||
self.locations.hellB3.getPrebuiltHint = prebuilt
|
self.locations.hellB3.getPrebuiltHint = prebuilt
|
||||||
|
|
||||||
self.requirements = function(self, items)
|
self.requirements = function(self, items) return false end -- just pretend you never get here
|
||||||
return self.world:canBeatGame(items)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local hintRegion = Region:extend()
|
local hintRegion = Region:extend()
|
||||||
|
@ -590,7 +588,8 @@ function worldGraph:canBeatGame(items, obj)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
if obj == "objAllBosses" then return bossReqs(self, items) 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
|
end
|
||||||
|
|
||||||
function worldGraph:getLocations()
|
function worldGraph:getLocations()
|
||||||
|
@ -664,7 +663,7 @@ function worldGraph:getFilledLocations(realOnly)
|
||||||
local locations = {}
|
local locations = {}
|
||||||
for key, region in pairs(self.regions) do
|
for key, region in pairs(self.regions) do
|
||||||
for k, location in pairs(region:getFilledLocations()) 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
|
||||||
end
|
end
|
||||||
return locations
|
return locations
|
||||||
|
|
|
@ -48,6 +48,7 @@ function C:new()
|
||||||
self.mychar = ""
|
self.mychar = ""
|
||||||
self.shuffleMusic = false
|
self.shuffleMusic = false
|
||||||
self.completableLogic = true
|
self.completableLogic = true
|
||||||
|
self.spheres = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
function C:setPath(path)
|
function C:setPath(path)
|
||||||
|
@ -77,7 +78,7 @@ function C:randomize()
|
||||||
self:_generateHash()
|
self:_generateHash()
|
||||||
if self.shuffleMusic then self.music:shuffleMusic(tscFiles) end
|
if self.shuffleMusic then self.music:shuffleMusic(tscFiles) end
|
||||||
|
|
||||||
self:_analyzeSpheres()
|
self:_logSpheres()
|
||||||
self:_generateRoute()
|
self:_generateRoute()
|
||||||
|
|
||||||
self:_writeModifiedData(tscFiles)
|
self:_writeModifiedData(tscFiles)
|
||||||
|
@ -259,29 +260,54 @@ function C:_fastFillItems(items, locations)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function C:_analyzeSpheres()
|
function C:_analyzeSpheres(forceUpdate)
|
||||||
local spheres = {}
|
if not forceUpdate and #self.spheres > 0 then
|
||||||
|
return self.spheres
|
||||||
|
end
|
||||||
|
self.spheres = {}
|
||||||
|
|
||||||
local items = {}
|
local items = {}
|
||||||
local locations
|
local locations
|
||||||
|
|
||||||
local i = 0
|
|
||||||
repeat
|
repeat
|
||||||
i = i+1
|
|
||||||
|
|
||||||
local collected
|
local collected
|
||||||
collected, locations = self.worldGraph:collect(items, locations, true)
|
collected, locations = self.worldGraph:collect(items, locations, true)
|
||||||
local sphereItems = _.difference(collected, items)
|
local sphereItems = _.difference(collected, items)
|
||||||
items = collected
|
items = collected
|
||||||
|
|
||||||
if #sphereItems == 0 then break end
|
local sphere = {}
|
||||||
|
|
||||||
logSphere(("Sphere %i"):format(i))
|
|
||||||
for k,v in pairs(sphereItems) do
|
for k,v in pairs(sphereItems) do
|
||||||
if not self.worldGraph:_has({v}, "abstract") then
|
table.insert(sphere, v)
|
||||||
logSphere(("\t %s: %s"):format(v.location_name, v.name))
|
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
|
||||||
end
|
end
|
||||||
until false
|
end
|
||||||
|
logSphere(("Maximum items to collect: %i"):format(total))
|
||||||
end
|
end
|
||||||
|
|
||||||
function C:_generateRoute()
|
function C:_generateRoute()
|
||||||
|
|
Loading…
Reference in a new issue