summaryrefslogtreecommitdiff
path: root/app.py
diff options
context:
space:
mode:
Diffstat (limited to 'app.py')
-rw-r--r--app.py33
1 files changed, 11 insertions, 22 deletions
diff --git a/app.py b/app.py
index f10a414..4af66dd 100644
--- a/app.py
+++ b/app.py
@@ -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):