From 021bac930723da0605541f1078230fad1e21957f Mon Sep 17 00:00:00 2001 From: duncathan Date: Sun, 1 Mar 2020 03:32:06 -0600 Subject: [PATCH 1/3] adds optional logic for sequence breaks --- src/database/items.lua | 8 +++---- src/database/world_graph.lua | 44 ++++++++++++++++++++++++++++-------- src/randomizer.lua | 1 + 3 files changed, 40 insertions(+), 13 deletions(-) diff --git a/src/database/items.lua b/src/database/items.lua index 944e66b..710a571 100644 --- a/src/database/items.lua +++ b/src/database/items.lua @@ -2,21 +2,21 @@ local function lifeCapsule3() return { name = "Life Capsule", script = "= num + return _num(items, attribute) >= num +end + +function _hp(items, hp) + return 3 + (_num(items, "hp3") * 3) + (_num(items, "hp4") * 4) + (_num(items, "hp5") * 5) end local firstCave = Region:extend() @@ -83,7 +91,7 @@ function arthur:new(worldGraph) self.requirements = function(self, items) if self.world:StartPoint() then - return _has(items, "arthurKey") and _has(items, "weaponSN") + return _has(items, "arthurKey") and _has(items, "weaponSN") and self.world.regions.mimigaVillage:canAccess(items) elseif self.world:Camp() then return self.world.regions.labyrinthB:canAccess(items) elseif self.world:Arthur() then @@ -107,7 +115,7 @@ function eggCorridor1:new(worldGraph) self.requirements = function(self, items) return self.world.regions.arthur:canAccess(items) end - self.locations.cthulhu.requirements = function(self, items) return _has(items, "weaponSN") or _has(items, "flight") end + self.locations.cthulhu.requirements = function(self, items) return _has(items, "weaponSN") or _has(items, "flight") or self.region.world:_dboost(items, 'cthulhu') end self.locations.eventSue.requirements = function(self, items) return _has(items, "idCard") and _has(items, "weaponBoss") end self.locations.eventSue:setItem(self.world.items:getByKey("eventSue")) end @@ -151,7 +159,7 @@ function grasstownEast:new(worldGraph) self.requirements = function(self, items) if not self.world.regions.arthur:canAccess(items) then return false end - if _has(items, "flight") or _has(items, "juice") then + if _has(items, "flight") or _has(items, "juice") or (self.world:_dboost(items, 'chaco') and _has(items, "weapon")) or self.world:_dboost(items, 'paxChaco') then if self.world.regions.grasstownWest:canAccess(items) then return true end end if _has(items, "eventKazuma") and _has(items, "weaponSN") and self.world.regions.plantation:canAccess(items) then return true end @@ -160,7 +168,7 @@ function grasstownEast:new(worldGraph) self.locations.kazuma2.requirements = function(self, items) return _has(items, "rustyKey") end self.locations.execution.requirements = function(self, items) return _has(items, "weaponSN") end - self.locations.hutChest.requirements = function(self, items) return _has(items, "eventFans") or _has(items, "flight") end + self.locations.hutChest.requirements = function(self, items) return _has(items, "eventFans") or _has(items, "flight") or self.region.world:_dboost(items, 'flightlessHut') end self.locations.gumChest.requirements = function(self, items) if _has(items, "gumKey") and _has(items, "weaponBoss") then if _has(items, "eventFans") or _has(items, "flight") then return true end @@ -259,7 +267,7 @@ function labyrinthW:new(worldGraph) self.locations.turboChaba.requirements = function(self, items) return _has(items, "machineGun") end self.locations.snakeChaba.requirements = function(self, items) return _has(items, "fireball") end self.locations.whimChaba.requirements = function(self, items) return _count(items, "polarStar", 2) end - self.locations.campChest.requirements = function(self, items) return _has(items, "flight") or self.region.world:Camp() end + self.locations.campChest.requirements = function(self, items) return _has(items, "flight") or self.region.world:Camp() or self.region.world:_dboost(items, 'camp') end self.locations.puuBlack.requirements = function(self, items) return _has(items, "clinicKey") and _has(items, "weaponBoss") end end @@ -347,7 +355,7 @@ function eggCorridor2:new(worldGraph) end self.locations.dragonChest.requirements = function(self, items) return _has(items, "weaponSN") or _has(items, "eventCore") end - self.locations.sisters.requirements = function(self, items) return _has(items, "weaponBoss") end + self.locations.sisters.requirements = function(self, items) return _has(items, "weaponBoss") or (self.region.world:_dboost(items, 'sisters') and _has(items, "flight")) end end local outerWall = Region:extend() @@ -399,7 +407,7 @@ function plantation:new(worldGraph) self.locations.sprinkler.requirements = function(self, items) return _has(items, "mask") end self.locations.megane.requirements = function(self, items) return _has(items, "brokenSprinkler") and _has(items, "mask") end self.locations.itoh.requirements = function(self, items) return _has(items, "letter") end - self.locations.plantCeiling.requirements = function(self, items) return _has(items, "flight") end + self.locations.plantCeiling.requirements = function(self, items) return _has(items, "flight") or self.region.world:_dboost(items, 'plantation') end self.locations.plantPup.requirements = function(self, items) return _has(items, "eventRocket") end self.locations.curlyShroom.requirements = function(self, items) return _has(items, "eventCurly") and _has(items, "maPignon") end @@ -417,7 +425,7 @@ function lastCave:new(worldGraph) redDemon = Location("Red Demon Boss", "Priso2", "0300", self) } - self.requirements = function(self, items) return _has(items, "eventRocket") and _has(items, "weaponBoss") and _count(items, "booster", 2) end + self.requirements = function(self, items) return _has(items, "weaponBoss") and _count(items, "booster", 2) and (_has(items, "eventRocket") or (self.world:_dboost(items, 'rocket') and _has(items, "machineGun"))) end end local endgame = Region:extend() @@ -441,6 +449,20 @@ function worldGraph:new(items) self.order = 0 self.spawn = "" + self.seqbreak = false + self.dboosts = { + cthulhu = {hp = 3, enabled = true}, + chaco = {hp = 5, enabled = true}, + paxChaco = {hp = 10, enabled = true}, + flightlessHut = {hp = 3, enabled = true}, + -- revChaco = {hp = 3, enabled = true}, + -- paxRevChaco = {hp = 8, enabled = true}, + camp = {hp = 9, enabled = true}, + sisters = {hp = 0, enabled = true}, + plantation = {hp = 15, enabled = true}, + rocket = {hp = 3, enabled = true}, + } + self.regions = { firstCave = firstCave(self), mimigaVillage = mimigaVillage(self), @@ -463,6 +485,10 @@ function worldGraph:new(items) } end +function worldGraph:_dboost(items, key) + return (self.seqbreak or self.dboosts[key].enabled) and _hp(items) > self.dboosts[key].hp +end + function worldGraph:StartPoint() return self.spawn == "Start Point" end function worldGraph:Arthur() return self.spawn == "Arthur's House" end function worldGraph:Camp() return self.spawn == "Camp" end diff --git a/src/randomizer.lua b/src/randomizer.lua index d6db8f2..efa597a 100644 --- a/src/randomizer.lua +++ b/src/randomizer.lua @@ -37,6 +37,7 @@ function C:new() self.obj = "" self.sharecode = "" self.mychar = "" + self.seqbreak = false end function C:setPath(path) From b4e08a2d07ea04546345175d0b0fc39c7aaec121 Mon Sep 17 00:00:00 2001 From: duncathan Date: Sun, 1 Mar 2020 03:32:16 -0600 Subject: [PATCH 2/3] implements UI and settings for sequence breaks --- pre-edited-cs/data/Stage/Cave.pxe | Bin 1064 -> 1064 bytes src/main.lua | 2 +- src/randomizer.lua | 3 +- src/settings.lua | 49 ++++++++++++++---- src/ui/draw.lua | 80 ++++++++++++++++++++++++++---- src/ui/sequence.lua | 19 +++++++ src/ui/settings.lua | 15 +++++- 7 files changed, 143 insertions(+), 25 deletions(-) create mode 100644 src/ui/sequence.lua diff --git a/pre-edited-cs/data/Stage/Cave.pxe b/pre-edited-cs/data/Stage/Cave.pxe index 250f4b7c0e6f31cb0f7bb0513e1e5ccc40024233..cf3565491faa8b7d59cf048c3699339be74a8fdd 100644 GIT binary patch delta 12 TcmZ3%v4UfQ6(i?H>$l7R8n*-y delta 12 TcmZ3%v4UfQ6(h$+>$l7R8nOfs diff --git a/src/main.lua b/src/main.lua index f2ecb68..0c3653d 100644 --- a/src/main.lua +++ b/src/main.lua @@ -16,9 +16,9 @@ require 'lib.bit' local random = require 'randomizer' local settings = require 'settings' +Settings = settings() Randomizer = random() Screen = require 'ui.draw' -Settings = settings() local csdirectory diff --git a/src/randomizer.lua b/src/randomizer.lua index efa597a..ec24335 100644 --- a/src/randomizer.lua +++ b/src/randomizer.lua @@ -37,7 +37,6 @@ function C:new() self.obj = "" self.sharecode = "" self.mychar = "" - self.seqbreak = false end function C:setPath(path) @@ -309,6 +308,8 @@ function C:_updateSettings() Settings.settings.obj = self.obj Settings.settings.mychar = self.mychar Settings.settings.spawn = self.worldGraph.spawn + Settings.settings.seqbreaks = self.worldGraph.seqbreak + Settings.settings.dboosts = _.map(self.worldGraph.dboosts, function(k,v) return v.enabled end) Settings:update() end diff --git a/src/settings.lua b/src/settings.lua index 378525e..d29dcb1 100644 --- a/src/settings.lua +++ b/src/settings.lua @@ -3,17 +3,36 @@ local C = Class:extend() function C:init() self.settings = {} if lf.getInfo('settings.txt') == nil then - self:setDefaults() + self.settings = self:getDefaults() + else + self.settings = lf.load('settings.txt')() + -- add any missing entries if new settings have been added + for k,v in pairs(self:getDefaults()) do + self.settings[k] = self.settings[k] or v + end end - self.settings = lf.load('settings.txt')() + self:update() end -function C:setDefaults() - self.settings.csdirectory = nil - self.settings.puppy = false - self.settings.obj = "objBestEnd" - self.settings.spawn = "Start Point" - self:update() +function C:getDefaults() + return { + csdirectory = "", + puppy = false, + obj = "objBestEnd", + mychar = "assets/myChar/Quote.bmp", + spawn = "Start Point", + seqbreaks = false, + dboosts = { + cthulhu = true, + chaco = true, + paxChaco = true, + flightlessHut = true, + camp = true, + sisters = true, + plantation = true, + rocket = true + } + } end function C:update() @@ -21,6 +40,14 @@ function C:update() end function C:serialize() + local function dboosts() + local line = "{" + for k,v in pairs(self.settings.dboosts) do + line = line .. ("%s = %s,"):format(k,v) + end + return line .. "}" + end + local line = "return {\r\n " line = line .. ("csdirectory = [[%s]],\r\n "):format(self.settings.csdirectory or "") @@ -28,9 +55,11 @@ function C:serialize() line = line .. ("obj = %q,\r\n "):format(self.settings.obj or "") line = line .. ("mychar = %q,\r\n "):format(self.settings.mychar or "") line = line .. ("spawn = %q,\r\n "):format(self.settings.spawn or "") + local dboost = dboosts() + line = line .. ("seqbreaks = %s,\r\n "):format(self.settings.seqbreaks) + line = line .. ("dboosts = %s,\r\n "):format(dboost) - line = line .. "\r\n}" - return line + return line .. "\r\n}" end function C:getSettings() diff --git a/src/ui/draw.lua b/src/ui/draw.lua index 839aa80..e4a9627 100644 --- a/src/ui/draw.lua +++ b/src/ui/draw.lua @@ -6,22 +6,36 @@ local C = Class:extend() local layout = Luigi(require 'ui.main') local settings = Luigi(require 'ui.settings') -layout:setStyle(require 'ui.style') -settings:setStyle(require 'ui.style') -layout:setTheme(require 'lib.luigi.theme.dark') -settings:setTheme(require 'lib.luigi.theme.dark') +local sequence = Luigi(require 'ui.sequence') + +local style = require 'ui.style' +local theme = require 'lib.luigi.theme.dark' + +layout:setStyle(style) +settings:setStyle(style) +sequence:setStyle(style) + +layout:setTheme(theme) +settings:setTheme(theme) +sequence:setTheme(theme) function C:setup() - self:loadSettings(Settings.settings.puppy, Settings.settings.obj, nil, Settings.settings.mychar, Settings.settings.spawn) + self:loadPuppy(Settings.settings.puppy) + self:loadObjective(Settings.settings.obj) + self:loadMyChar(Settings.settings.mychar) + self:loadSpawn(Settings.settings.spawn) + self:loadSeqSettings(Settings.settings.dboosts) background = lg.newImage('assets/background.png') self:draw() layout:show() end -function C:loadSettings(puppy, obj, seed, mychar, spawn) +function C:loadPuppy(puppy) settings.puppy.value = puppy +end +function C:loadObjective(obj) if obj == "objBadEnd" or obj == 1 then settings.objective.index = 1 elseif obj == "objNormalEnd" or obj == 2 then @@ -32,13 +46,17 @@ function C:loadSettings(puppy, obj, seed, mychar, spawn) settings.objective.index = 3 end settings.objective.value = "override" +end +function C:loadSeed(seed) if seed ~= nil then settings.customseed.value = seed or "" settings.seedselect.value = true settings.seedrandom.value = false end +end +function C:loadMyChar(mychar) if mychar == "assets/myChar/Quote.bmp" then settings.mychar.index = 1 elseif mychar == "assets/myChar/Curly.bmp" then @@ -55,7 +73,9 @@ function C:loadSettings(puppy, obj, seed, mychar, spawn) settings.mychar.index = 7 end settings.mychar.value = "override" +end +function C:loadSpawn(spawn) if spawn == "Start Point" or spawn == 0 then settings.spawn.index = 1 elseif spawn == "Arthur's House" or spawn == 1 then @@ -66,6 +86,17 @@ function C:loadSettings(puppy, obj, seed, mychar, spawn) settings.spawn.value = "override" end +function C:loadSeqSettings(seq) + sequence.cthulhu.value = seq.cthulhu + sequence.chaco.value = seq.chaco + sequence.paxChaco.value = seq.paxChaco + sequence.flightlessHut.value = seq.flightlessHut + sequence.camp.value = seq.camp + sequence.sisters.value = seq.sisters + sequence.plantation.value = seq.plantation + sequence.rocket.value = seq.rocket +end + layout.version.text = 'Cave Story Randomizer [Open Mode] v' .. VERSION layout.author.text = 'by shru and duncathan' layout.twitter.text = '(@shruuu and @duncathan_salt)' @@ -85,6 +116,16 @@ layout.go:onPress(function() Randomizer.mychar = settings.mychar.value Randomizer.worldGraph.spawn = settings.spawn.value + Randomizer.worldGraph.seqbreak = settings.seqbreak.value + Randomizer.worldGraph.dboosts.cthulhu.enabled = sequence.cthulhu.value + Randomizer.worldGraph.dboosts.chaco.enabled = sequence.chaco.value + Randomizer.worldGraph.dboosts.paxChaco.enabled = sequence.paxChaco.value + Randomizer.worldGraph.dboosts.flightlessHut.enabled = sequence.flightlessHut.value + Randomizer.worldGraph.dboosts.camp.enabled = sequence.camp.value + Randomizer.worldGraph.dboosts.sisters.enabled = sequence.sisters.value + Randomizer.worldGraph.dboosts.plantation.enabled = sequence.plantation.value + Randomizer.worldGraph.dboosts.rocket.enabled = sequence.rocket.value + C:setStatus(Randomizer:randomize()) layout.sharecode.text = "Copy Sharecode" @@ -104,6 +145,24 @@ settings.closeButton:onPress(function() settings.sharecode.value = "" end) +settings.seqButton:onPress(function() + sequence:show() + settings:hide() +end) + +sequence.allOn:onPress(function() + Screen:loadSeqSettings(_.map(Settings.settings.dboosts, function(k,v) return true end)) +end) + +sequence.allOff:onPress(function() + Screen:loadSeqSettings(_.map(Settings.settings.dboosts, function(k,v) return false end)) +end) + +sequence.close:onPress(function() + sequence:hide() + settings:show() +end) + layout.sharecode:onPress(function() if Randomizer.sharecode ~= "" then love.system.setClipboardText(Randomizer.sharecode) @@ -127,11 +186,10 @@ settings.importshare:onPress(function() if success then settings.importshare.text = "Sharecode Imported" - local pup = bit.band(sharesettings, 4) ~= 0 - local obj = bit.band(sharesettings, 3) - local spn = bit.brshift(bit.band(sharesettings, 24), 3) - seed = seed:gsub("^%s*(.-)%s*$", "%1") -- trim any leading or trailing whitespace - Screen:loadSettings(pup, obj, seed, nil, spn) + Screen:loadPuppy(bit.band(sharesettings, 4) ~= 0) -- settings & (0b00000001 << 2) + Screen:loadObjective(bit.band(sharesettings, 3)) -- settings & 0b00000011 + Screen:loadSpawn(bit.brshift(bit.band(sharesettings, 24), 3)) -- (settings & 0b00011000) >> 3 + Screen:loadSeed(seed:gsub("^%s*(.-)%s*$", "%1")) -- trim any leading or trailing whitespace else settings.importshare.text = "Invalid Sharecode!" end diff --git a/src/ui/sequence.lua b/src/ui/sequence.lua new file mode 100644 index 0000000..f36f9f6 --- /dev/null +++ b/src/ui/sequence.lua @@ -0,0 +1,19 @@ +return { style = 'dialog', + { style = 'dialogHead', text = 'Sequence Break Settings'}, + { style = 'dialogBody', padding = 24, + { type = 'check', value = true, id = 'cthulhu', text = "Cthulhu's Abode (requires 3HP)", minheight = 27 }, + { type = 'check', value = true, id = 'chaco', text = "Chaco Skip (requires 5HP)", minheight = 27 }, + { type = 'check', value = true, id = 'paxChaco', text = "Chaco Skip without a weapon (requires 10HP)", minheight = 27 }, + { type = 'check', value = true, id = 'flightlessHut', text = "Flightless Grasstown Hut (requires 3HP)", minheight = 27 }, + { type = 'check', value = true, id = 'camp', text = "Flightless Camp Chest (requires 9HP)", minheight = 27 }, + { type = 'check', value = true, id = 'sisters', text = "Sisters Skip (requires flight)", minheight = 27 }, + { type = 'check', value = true, id = 'plantation', text = "Flightless Plantation Chest (requires 15HP)", minheight = 27 }, + { type = 'check', value = true, id = 'rocket', text = "Flightless Rocket Skip (requires 3HP, MG, and 2.0)", minheight = 27 }, + }, + { style = 'dialogFoot', + {}, + { style = 'dialogButton', id = 'allOn', text = 'All On' }, + { style = 'dialogButton', id = 'allOff', text = 'All Off' }, + { style = 'dialogButton', id = 'close', text = 'Close' } + } +} \ No newline at end of file diff --git a/src/ui/settings.lua b/src/ui/settings.lua index dcede9a..c493927 100644 --- a/src/ui/settings.lua +++ b/src/ui/settings.lua @@ -6,11 +6,22 @@ return { style = 'dialog', { type = 'label', text = 'Seed', minheight = 32 }, { { type = 'radio', group = 'seed', text = 'Use random seed', value = true, id = 'seedrandom', minheight = 27 }, - { flow = 'y', { type = 'radio', group = 'seed', text = 'Use custom seed', id = 'seedselect', minheight = 27 }, {{ type = 'text', id = 'customseed', width = 200, minheight = 32}, flow = 'x', { type = 'label', id = 'seedcount' }} } + { flow = 'y', { type = 'radio', group = 'seed', text = 'Use custom seed', id = 'seedselect', minheight = 27 }, + { + flow = 'x', + { type = 'text', id = 'customseed', width = 200, minheight = 32}, + { type = 'label', id = 'seedcount' } + } + } }, { type = 'label', text = 'Randomization Options', minheight = 32 }, { type = 'check', value = false, id = 'puppy', text = "Puppysanity", minheight = 27 }, - { height = 64 }, + { flow = 'x', + { type = 'check', value = false, id = 'seqbreak', text = "Sequence breaks", minheight = 32, width = 170}, + { type = 'button', style = 'dialogButton', text = "Modify", id = 'seqButton', width = 70, align = 'center' }, + { width = false } + }, + { height = 'auto' }, }, { { type = 'label', text = 'Objective', minheight = 32 }, From 98ef3ca075525e096e8a439aa89ce07365c515d6 Mon Sep 17 00:00:00 2001 From: duncathan Date: Sun, 1 Mar 2020 04:03:00 -0600 Subject: [PATCH 3/3] implements sharecodes --- src/randomizer.lua | 30 ++++++++++++++++++++-------- src/ui/draw.lua | 50 +++++++++++++++++++++++++++++----------------- 2 files changed, 54 insertions(+), 26 deletions(-) diff --git a/src/randomizer.lua b/src/randomizer.lua index ec24335..dc98e34 100644 --- a/src/randomizer.lua +++ b/src/randomizer.lua @@ -315,16 +315,17 @@ end function C:_updateSharecode(seed) local settings = 0 -- 0b00000000 - -- 0bXXXSSPOO -- P: single bit used for puppysanity - -- O: two bits used for objective - -- S: two bits used for spawn location - -- X: unused + -- O: three bits used for objective + -- S: three bits used for spawn location + -- B: single bit used for sequence breaks + -- 0bBSSSOOOP -- bitshift intervals - local obj = 0 - local pup = 2 - local spn = 3 + local obj = 1 + local pup = 0 + local spn = 4 + local brk = 7 if self.obj == "objBadEnd" then settings = bit.bor(settings, bit.blshift(1, obj)) @@ -343,11 +344,24 @@ function C:_updateSharecode(seed) settings = bit.bor(settings, bit.blshift(2, spn)) end + local seq = 0 + if self.worldGraph.seqbreak then + settings = bit.bor(settings, bit.blshift(1, brk)) + if self.worldGraph.dboosts.cthulhu.enabled then seq = bit.bor(seq, 1) end + if self.worldGraph.dboosts.chaco.enabled then seq = bit.bor(seq, 2) end + if self.worldGraph.dboosts.paxChaco.enabled then seq = bit.bor(seq, 4) end + if self.worldGraph.dboosts.flightlessHut.enabled then seq = bit.bor(seq, 8) end + if self.worldGraph.dboosts.camp.enabled then seq = bit.bor(seq, 16) end + if self.worldGraph.dboosts.sisters.enabled then seq = bit.bor(seq, 32) end + if self.worldGraph.dboosts.plantation.enabled then seq = bit.bor(seq, 64) end + if self.worldGraph.dboosts.rocket.enabled then seq = bit.bor(seq, 128) end + end + if #seed < 20 then seed = seed .. (" "):rep(20-#seed) end - local packed = love.data.pack("data", "sB", seed, settings) + local packed = love.data.pack("data", "sBB", seed, settings, seq) self.sharecode = love.data.encode("string", "base64", packed) logNotice(("Sharecode: %s"):format(self.sharecode)) diff --git a/src/ui/draw.lua b/src/ui/draw.lua index e4a9627..d8ef861 100644 --- a/src/ui/draw.lua +++ b/src/ui/draw.lua @@ -24,7 +24,7 @@ function C:setup() self:loadObjective(Settings.settings.obj) self:loadMyChar(Settings.settings.mychar) self:loadSpawn(Settings.settings.spawn) - self:loadSeqSettings(Settings.settings.dboosts) + self:loadSeqSettings(Settings.settings.seqbreaks, Settings.settings.dboosts) background = lg.newImage('assets/background.png') self:draw() @@ -86,15 +86,18 @@ function C:loadSpawn(spawn) settings.spawn.value = "override" end -function C:loadSeqSettings(seq) - sequence.cthulhu.value = seq.cthulhu - sequence.chaco.value = seq.chaco - sequence.paxChaco.value = seq.paxChaco - sequence.flightlessHut.value = seq.flightlessHut - sequence.camp.value = seq.camp - sequence.sisters.value = seq.sisters - sequence.plantation.value = seq.plantation - sequence.rocket.value = seq.rocket +function C:loadSeqSettings(breaks, seq) + if breaks then settings.seqbreak.value = breaks end + if breaks or breaks == nil then + sequence.cthulhu.value = seq.cthulhu + sequence.chaco.value = seq.chaco + sequence.paxChaco.value = seq.paxChaco + sequence.flightlessHut.value = seq.flightlessHut + sequence.camp.value = seq.camp + sequence.sisters.value = seq.sisters + sequence.plantation.value = seq.plantation + sequence.rocket.value = seq.rocket + end end layout.version.text = 'Cave Story Randomizer [Open Mode] v' .. VERSION @@ -151,11 +154,11 @@ settings.seqButton:onPress(function() end) sequence.allOn:onPress(function() - Screen:loadSeqSettings(_.map(Settings.settings.dboosts, function(k,v) return true end)) + Screen:loadSeqSettings(nil, _.map(Settings.settings.dboosts, function(k,v) return true end)) end) sequence.allOff:onPress(function() - Screen:loadSeqSettings(_.map(Settings.settings.dboosts, function(k,v) return false end)) + Screen:loadSeqSettings(nil, _.map(Settings.settings.dboosts, function(k,v) return false end)) end) sequence.close:onPress(function() @@ -178,18 +181,29 @@ settings.customseed:onChange(function() end) settings.importshare:onPress(function() - local success, seed, sharesettings = pcall(function() + local success, seed, sharesettings, seq = pcall(function() local packed = love.data.decode("data", "base64", settings.sharecode.value) - local seed, settings = love.data.unpack("sB", packed) - return seed, settings + local seed, settings, seq = love.data.unpack("sBB", packed) + assert(#seed == 20) + return seed, settings, seq end) if success then settings.importshare.text = "Sharecode Imported" - Screen:loadPuppy(bit.band(sharesettings, 4) ~= 0) -- settings & (0b00000001 << 2) - Screen:loadObjective(bit.band(sharesettings, 3)) -- settings & 0b00000011 - Screen:loadSpawn(bit.brshift(bit.band(sharesettings, 24), 3)) -- (settings & 0b00011000) >> 3 + Screen:loadPuppy(bit.band(sharesettings, 1) ~= 0) -- settings & 0b00000001 + Screen:loadObjective(bit.brshift(bit.band(sharesettings, 14), 1)) -- (settings & 0b00001110) >> 1 + Screen:loadSpawn(bit.brshift(bit.band(sharesettings, 112), 4)) -- (settings & 0b01110000) >> 4 Screen:loadSeed(seed:gsub("^%s*(.-)%s*$", "%1")) -- trim any leading or trailing whitespace + Screen:loadSeqSettings(bit.band(sharesettings, 128) ~= 0, { -- (settings & 0b10000000) + cthulhu = bit.band(seq, 1) ~= 0, + chaco = bit.band(seq, 2) ~= 0, + paxChaco = bit.band(seq, 4) ~= 0, + flightlessHut = bit.band(seq, 8) ~= 0, + camp = bit.band(seq, 16) ~= 0, + sisters = bit.band(seq, 32) ~= 0, + plantation = bit.band(seq, 64) ~= 0, + rocket = bit.band(seq, 128) ~= 0 + }) else settings.importshare.text = "Invalid Sharecode!" end