From 156f415ce9ed09a01f94c43923331b3d7c257089 Mon Sep 17 00:00:00 2001 From: MahtraDR <93822896+MahtraDR@users.noreply.github.com> Date: Fri, 3 May 2024 23:26:43 +1200 Subject: [PATCH] [scripts][common-moonmage] De-duplicating code Also adds case for when a telescope is closed, as on first-use. --- common-moonmage.lic | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/common-moonmage.lic b/common-moonmage.lic index 916aa3155b..958d49d503 100644 --- a/common-moonmage.lic +++ b/common-moonmage.lic @@ -84,7 +84,7 @@ module DRCMM end def center_telescope(target) - DRC.bput("center telescope on #{target}", + case DRC.bput("center telescope on #{target}", 'Center what', 'You put your eye', 'open it to make any use of it', @@ -93,7 +93,14 @@ module DRCMM "You would probably need a periscope to do that", 'Your search for', 'Your vision is too fuzzy', + "You'll need to open it to make any use of it", 'You must have both hands free') + when 'The pain is too much', "That's a bit tough to do when you can't see the sky" + echo("Planet #{target} not visible. Are you indoors perhaps?") + when "You'll need to open it to make any use of it" + fput("open my telescope") + fput("center telescope on #{target}") + end end def align(skill) @@ -300,10 +307,7 @@ module DRCMM observed_planets = [] planets.each do |planet| - case DRC.bput("center telescope on #{planet}", 'You put your eye', 'The pain is too much', "That's a bit tough to do when you can't see the sky") - when 'The pain is too much', "That's a bit tough to do when you can't see the sky" - break - end + center_telescope(planet) observed_planets << planet unless Flags['planet-not-visible'] Flags.reset('planet-not-visible') end