From df3aff4628f62cbb0fb4bc1b25d402b8a88e9588 Mon Sep 17 00:00:00 2001 From: duncathan Date: Tue, 25 Feb 2020 22:54:19 -0600 Subject: [PATCH] adds support for puppysanity to randomizer --- src/randomizer.lua | 20 +++++++++++++++----- src/ui/draw.lua | 1 + src/ui/settings.lua | 3 +++ 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/randomizer.lua b/src/randomizer.lua index d22d40f..b404678 100644 --- a/src/randomizer.lua +++ b/src/randomizer.lua @@ -33,6 +33,7 @@ function C:new() self.itemDeck = Items() self.worldGraph = WorldGraph(self.itemDeck) self.customseed = nil + self.puppy = false end function C:setPath(path) @@ -128,13 +129,22 @@ function C:_writePlaintext(tscFiles) end function C:_shuffleItems(tscFiles) - -- first fill puppies - self:_fastFillItems(self.itemDeck:getItemsByAttribute("puppy"), _.shuffle(self.worldGraph:getPuppySpots())) - -- 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]) - 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 + self:_fastFillItems(puppies, _.shuffle(self.worldGraph:getPuppySpots())) + else + -- for puppysanity, shuffle puppies in with the mandatory items + mandatory = _.shuffle(_.append(mandatory, 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())) diff --git a/src/ui/draw.lua b/src/ui/draw.lua index 32ce620..e7a40f8 100644 --- a/src/ui/draw.lua +++ b/src/ui/draw.lua @@ -28,6 +28,7 @@ layout.go:onPress(function() if settings.seedselect.value and settings.customseed.value ~= "" then Randomizer.customseed = settings.customseed.value end + Randomizer.puppy = settings.puppy.value C:setStatus(Randomizer:randomize()) Randomizer:new() else diff --git a/src/ui/settings.lua b/src/ui/settings.lua index 1cac569..5fbad75 100644 --- a/src/ui/settings.lua +++ b/src/ui/settings.lua @@ -6,6 +6,9 @@ return { style = 'dialog', { type = 'radio', group = 'seed', text = 'Use random seed', value = true }, { flow = 'y', { type = 'radio', group = 'seed', text = 'Use custom seed', id = 'seedselect'}, { type = 'text', id = 'customseed', width = 150 }, {height = false} } }, + { type = 'label', text = 'Randomization Options' }, + { type = 'check', value = false, id = 'puppy', text = "Puppysanity"}, + { height = false }, }, { style = 'dialogFoot', {},