Merge pull request #73 from duncathan/doubleguns

fixes duplicate weapons
This commit is contained in:
duncathan salt 2020-02-27 18:53:41 -06:00 committed by GitHub
commit 087da92f42
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -129,30 +129,36 @@ function C:_writePlaintext(tscFiles)
end end
function C:_shuffleItems(tscFiles) 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 mandatory = _.compact(_.shuffle(self.itemDeck:getMandatoryItems(true)))
local optional = _.compact(_.shuffle(self.itemDeck:getOptionalItems(true))) local optional = _.compact(_.shuffle(self.itemDeck:getOptionalItems(true)))
local puppies = _.compact(_.shuffle(self.itemDeck:getItemsByAttribute("puppy"))) local puppies = _.compact(_.shuffle(self.itemDeck:getItemsByAttribute("puppy")))
if not self.puppy then if not self.puppy then
-- first fill puppies -- then fill puppies, for normal gameplay
self:_fastFillItems(puppies, _.shuffle(self.worldGraph:getPuppySpots())) self:_fastFillItems(puppies, _.shuffle(self.worldGraph:getPuppySpots()))
else else
-- for puppysanity, shuffle puppies in with the mandatory items -- for puppysanity, shuffle puppies in with the mandatory items
mandatory = _.shuffle(_.append(mandatory, puppies)) mandatory = _.shuffle(_.append(mandatory, puppies))
puppies = {}
end 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 -- next fill hell chests, which cannot have mandatory items
self:_fastFillItems(optional, _.shuffle(self.worldGraph:getHellSpots())) self:_fastFillItems(optional, _.shuffle(self.worldGraph:getHellSpots()))
-- place mandatory items with assume fill
self:_fillItems(mandatory, _.shuffle(_.reverse(self.worldGraph:getEmptyLocations()))) 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())) 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:writeItems(tscFiles)
self.worldGraph:logLocations() self.worldGraph:logLocations()
end end