From 6927ba662190c6924095ef46f802fe98ef5a3398 Mon Sep 17 00:00:00 2001 From: desertkaz Date: Thu, 28 Mar 2024 18:48:06 -0700 Subject: [PATCH 1/3] handle maze reset instead of exiting When maze shuffles, existing behavior was to print a message and exit. This change allows script to handle this shuffle and begin mapping again. --- dusk-labyrinth.lic | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dusk-labyrinth.lic b/dusk-labyrinth.lic index 7528253372..3169704466 100644 --- a/dusk-labyrinth.lic +++ b/dusk-labyrinth.lic @@ -132,7 +132,7 @@ class DuskLab DRC.message("Maze reshuffled, trying to find a direction to move to") ['n', 'ne', 'e', 'se', 's', 'sw', 'w', 'nw'].each do |dir| if move(dir) - break + return end end DRC.message('Unable to move to another room after maze shuffled') From fbc43863a03a7e71b9117f543877bbaf6a753014 Mon Sep 17 00:00:00 2001 From: desertkaz Date: Thu, 28 Mar 2024 20:48:53 -0700 Subject: [PATCH 2/3] break out of each before returning --- dusk-labyrinth.lic | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dusk-labyrinth.lic b/dusk-labyrinth.lic index 3169704466..3925105e2e 100644 --- a/dusk-labyrinth.lic +++ b/dusk-labyrinth.lic @@ -130,11 +130,12 @@ class DuskLab # Randomly move in directions until one works. def wander_randomly DRC.message("Maze reshuffled, trying to find a direction to move to") - ['n', 'ne', 'e', 'se', 's', 'sw', 'w', 'nw'].each do |dir| + success = ['n', 'ne', 'e', 'se', 's', 'sw', 'w', 'nw'].each do |dir| if move(dir) - return + break(true) end end + return if success DRC.message('Unable to move to another room after maze shuffled') DRC.message('Try to move yourself to another room then restart script') exit From b7f6d64a43418b43fbb787d1794280cd1e531f02 Mon Sep 17 00:00:00 2001 From: desertkaz Date: Thu, 28 Mar 2024 20:51:54 -0700 Subject: [PATCH 3/3] fix lint issues --- dusk-labyrinth.lic | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dusk-labyrinth.lic b/dusk-labyrinth.lic index 3925105e2e..c522dc115a 100644 --- a/dusk-labyrinth.lic +++ b/dusk-labyrinth.lic @@ -135,7 +135,8 @@ class DuskLab break(true) end end - return if success + return if success + DRC.message('Unable to move to another room after maze shuffled') DRC.message('Try to move yourself to another room then restart script') exit