fixes duplicate weapons

This commit is contained in:
duncathan 2020-02-27 18:53:22 -06:00
parent 5c530d318e
commit 1e09dad380

View file

@ -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