From 871646fcccfb671e5b5ae63c4ce04878b8b1a60a Mon Sep 17 00:00:00 2001 From: Patrick Marsee Date: Sun, 10 May 2020 23:54:48 -0400 Subject: [PATCH] Added automove option which is on by default. Added helpful hints for invalid options. --- gameshell.py | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/gameshell.py b/gameshell.py index 45c7e51..27dbc12 100644 --- a/gameshell.py +++ b/gameshell.py @@ -73,9 +73,27 @@ class GameShell(Shell): while i < len(args): if args[i] == 'color': i += 1 - if args[i] in ('0', '3', '4', '8', '24'): - self.colorMode = int(args[i]) - i += 1 + if len(args) > i: + if args[i] in ('0', '3', '4', '8', '24'): + self.colorMode = int(args[i]) + i += 1 + else: + print("Valid color depths are 0, 3, 4, 8, and 24.") + else: + print("Valid color depths are 0, 3, 4, 8, and 24.") + elif args[i] == 'automove': + i += 1 + if len(args) > i: + if args[i] in ('on', 'off'): + self.gameBase.autoMove = args[i] == 'on' + i += 1 + else: + print("Valid options are 'on' and 'off'.") + else: + print("Valid options are 'on' and 'off'.") + else: + print("Could not identify option {}".format(args[i])) + i += 1 def __colorTestRoutine(self, lower, upper): colors = []