mirror of
https://github.com/cave-story-randomizer/cave-story-randomizer
synced 2024-11-10 00:45:15 +00:00
Merge pull request #73 from duncathan/doubleguns
fixes duplicate weapons
This commit is contained in:
commit
087da92f42
|
@ -129,30 +129,36 @@ function C:_writePlaintext(tscFiles)
|
|||
end
|
||||
|
||||
function C:_shuffleItems(tscFiles)
|
||||
-- first, fill one of the first cave spots with a weapon that can break blocks
|
||||
_.shuffle(self.worldGraph:getFirstCaveSpots())[1]:setItem(_.shuffle(self.itemDeck:getItemsByAttribute("weaponSN"))[1])
|
||||
|
||||
local mandatory = _.compact(_.shuffle(self.itemDeck:getMandatoryItems(true)))
|
||||
local optional = _.compact(_.shuffle(self.itemDeck:getOptionalItems(true)))
|
||||
local puppies = _.compact(_.shuffle(self.itemDeck:getItemsByAttribute("puppy")))
|
||||
|
||||
if not self.puppy then
|
||||
-- first fill puppies
|
||||
-- then fill puppies, for normal gameplay
|
||||
self:_fastFillItems(puppies, _.shuffle(self.worldGraph:getPuppySpots()))
|
||||
else
|
||||
-- for puppysanity, shuffle puppies in with the mandatory items
|
||||
mandatory = _.shuffle(_.append(mandatory, puppies))
|
||||
puppies = {}
|
||||
end
|
||||
|
||||
-- then fill one of the first cave spots with a weapon that can break blocks
|
||||
_.shuffle(self.worldGraph:getFirstCaveSpots())[1]:setItem(_.shuffle(self.itemDeck:getItemsByAttribute("weaponSN"))[1])
|
||||
|
||||
|
||||
|
||||
-- next fill hell chests, which cannot have mandatory items
|
||||
self:_fastFillItems(optional, _.shuffle(self.worldGraph:getHellSpots()))
|
||||
|
||||
-- place mandatory items with assume fill
|
||||
self:_fillItems(mandatory, _.shuffle(_.reverse(self.worldGraph:getEmptyLocations())))
|
||||
|
||||
-- place optional items with a simple random fill
|
||||
local opt = #optional
|
||||
local loc = #self.worldGraph:getEmptyLocations()
|
||||
if opt > loc then
|
||||
logWarning(("Trying to fill more optional items than there are locations! Items: %d Locations: %d"):format(opt, loc))
|
||||
end
|
||||
self:_fastFillItems(optional, _.shuffle(self.worldGraph:getEmptyLocations()))
|
||||
|
||||
--assert(#self.worldGraph:getEmptyLocations() == 0, self.worldGraph:emptyString() .. "\r\n" .. self.itemDeck:unplacedString())
|
||||
self.worldGraph:writeItems(tscFiles)
|
||||
self.worldGraph:logLocations()
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue