diff options
author | Aineopintojen-harjoitustyo-Algoritmit-j <github-hy-tiralabra@v.hix.fi> | 2024-02-17 09:41:48 +0200 |
---|---|---|
committer | Aineopintojen-harjoitustyo-Algoritmit-j <github-hy-tiralabra@v.hix.fi> | 2024-02-17 09:41:48 +0200 |
commit | e785dbd4f726c5716f21071ed25dc35ac87c0c74 (patch) | |
tree | 781373b78380a1ffd1ea8c5dc8ceb2bd313631e9 /src/miinaharava/app.py | |
parent | 4eff4a32cfa594cc2a3df3885de92d407edc6675 (diff) |
Dev tools and directory structure rework.
Diffstat (limited to 'src/miinaharava/app.py')
-rw-r--r-- | src/miinaharava/app.py | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/miinaharava/app.py b/src/miinaharava/app.py new file mode 100644 index 0000000..8553fe5 --- /dev/null +++ b/src/miinaharava/app.py @@ -0,0 +1,42 @@ +""" app.py - pääohjelma """ +from board import Board, Level +from tui import Tui +from game import Game +from bots import SimpleBot, DSSPBot + +# pylint: disable = too-few-public-methods +class App: + """ App - Luokka pääohjelmalle""" + def __init__(self, args=None): + board_opts = {'level': Level.BEGINNER} + tui_opts = {'bot': DSSPBot} + if args: + # pylint: disable = multiple-statements + if args.intermediate: board_opts['level'] = Level.INTERMEDIATE + if args.expert: board_opts['level'] = Level.EXPERT + if args.board: + board_opts['board'] = args.board + else: + if args.mines: board_opts['mines'] = args.mines + if args.size: + board_opts['width'] = args.size[0] + board_opts['height'] = args.size[1] + + if args.bot==0: tui_opts['bot'] = None + if args.bot==1: tui_opts['bot'] = SimpleBot + tui_opts['autoplay'] = args.autoplay > 0 + tui_opts['interactive'] = args.autoplay != 2 + tui_opts['suppress'] = args.quiet + tui_opts['delay'] = args.delay + + self.board = Board(**board_opts) + tui_opts['level_name'] = self.board.get_level_name() + tui_opts['height'] = self.board.get_height() + self.ui = Tui(**tui_opts) + self.game = Game(self.board,self.ui) + + def run(self): + """ käynnistää pelin """ + while self.game.next(): + pass + return self.board.is_winning() |