summaryrefslogtreecommitdiff
path: root/app.py
diff options
context:
space:
mode:
authorAineopintojen-harjoitustyo-Algoritmit-j <github-hy-tiralabra@v.hix.fi>2024-01-14 13:07:08 +0200
committerAineopintojen-harjoitustyo-Algoritmit-j <github-hy-tiralabra@v.hix.fi>2024-01-14 13:07:08 +0200
commit822d89c50a70277186f5c845e4341236548c16b7 (patch)
treef1306919615dc786cf7bc5f913d61ea835b99596 /app.py
parent1f9bba90256f0baf605636a93037f1debdcb4623 (diff)
Moving game logic to game/game.py.
Diffstat (limited to 'app.py')
-rw-r--r--app.py34
1 files changed, 8 insertions, 26 deletions
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