From 822d89c50a70277186f5c845e4341236548c16b7 Mon Sep 17 00:00:00 2001 From: Aineopintojen-harjoitustyo-Algoritmit-j Date: Sun, 14 Jan 2024 13:07:08 +0200 Subject: Moving game logic to game/game.py. --- app.py | 34 ++++++++-------------------------- 1 file changed, 8 insertions(+), 26 deletions(-) (limited to 'app.py') diff --git a/app.py b/app.py index 8778881..be711b0 100644 --- a/app.py +++ b/app.py @@ -1,35 +1,17 @@ """ app.py - pääohjelma """ from board.board import Board -from tui.tui import Tui, Action +from tui.tui import Tui +from game.game import Game # pylint: disable = too-few-public-methods class App: """ App - Luokka pääohjelmalle""" def __init__(self): - self.b = Board(13) - self.t = Tui() + self.board = Board() + self.ui = Tui() + self.game = Game(self.board,self.ui) def run(self): - """ käynnistää pääohjelman """ - x, y = 0, 0 - # Printataan tyhjää tilaa, jotta pelalauta mahtuu ruudulle - for _ in range(self.b.size): - print() - - while True: - action, x, y = self.t.matrix_selector(self.b.get_view(), x, y) - match action: - case Action.QUIT: - print("LOPETUS!") - break - case Action.OPEN: - if self.b.get_mask(x, y) and not self.b.make_guess(x, y): - self.t.draw_matrix(self.b.get_view(), -1, -1) - print("KUOLEMA!") - break - if self.b.is_winning(): - self.t.draw_matrix(self.b.get_view(), -1, -1) - print("VOITTO!") - break - case Action.FLAG: - self.b.flag_tile(x, y) + """ käynnistää pelin """ + while self.game.next(): + pass -- cgit v1.2.3