diff options
author | Aineopintojen-harjoitustyo-Algoritmit-j <github-hy-tiralabra@v.hix.fi> | 2024-01-30 07:54:36 +0200 |
---|---|---|
committer | Aineopintojen-harjoitustyo-Algoritmit-j <github-hy-tiralabra@v.hix.fi> | 2024-01-30 07:54:36 +0200 |
commit | fa6a80ea7107c3a1e7c1fa600817b0c5f7be5d36 (patch) | |
tree | 3c8b4f28a8ccdac825f0075c3fbd9aa437150cb1 /app.py | |
parent | cef4a07bb411a120d5b2e15373f3f5f1fec7c71b (diff) |
Refactoring options processing.
Diffstat (limited to 'app.py')
-rw-r--r-- | app.py | 33 |
1 files changed, 11 insertions, 22 deletions
@@ -9,31 +9,20 @@ class App: """ App - Luokka pääohjelmalle""" def __init__(self, args=None): level = Level.BEGINNER - auto, uncertain, quiet = False, False, False + tui_opts = {'bot': DSSPBot} if args: - level = Level.INTERMEDIATE if args.intermediate else level - level = Level.EXPERT if args.expert else level - width, height, bombs = LevelSpecs[level] - auto = args.auto - auto, uncertain = (True, True) if args.uncertain else (auto, False) - auto, uncertain, quiet = (True, True, True) \ - if args.quiet else (auto, uncertain, False) - self.bot = SimpleBot(uncertain=uncertain) if args.simple \ - else DSSPBot(uncertain=uncertain) - self.ui = Tui ( - bot=self.bot, - autoplay=auto, - interact=not uncertain, - suppress=quiet, - width=width, - height=height, - bombs=bombs - ) + # pylint: disable = pointless-statement + (level:=Level.INTERMEDIATE) if args.intermediate else () + (level:=Level.EXPERT) if args.expert else () + + tui_opts['bot'] = SimpleBot if args.simple else DSSPBot + tui_opts['autoplay'] = args.auto + tui_opts['interactive'] = not args.uncertain + tui_opts['suppress'] = args.quiet + tui_opts['height'] = LevelSpecs[level][1] self.board = Board(level=level) - self.bot = DSSPBot(uncertain=uncertain) if self.bot is None \ - else self.bot - self.ui = Tui(bot=self.bot) if self.ui is None else self.ui + self.ui = Tui(**tui_opts) self.game = Game(self.board,self.ui) def run(self): |