summaryrefslogtreecommitdiff
path: root/app.py
diff options
context:
space:
mode:
authorAineopintojen-harjoitustyo-Algoritmit-j <github-hy-tiralabra@v.hix.fi>2024-01-13 13:10:21 +0200
committerAineopintojen-harjoitustyo-Algoritmit-j <github-hy-tiralabra@v.hix.fi>2024-01-13 13:10:21 +0200
commit41f6ff58c4800c85e8c2d53498eddc3590acfde9 (patch)
tree468f30f29126c7711e06e3793cbdfbfe37027991 /app.py
parentdca833cd9a62e163f300572ed0b3ec0dd63aa123 (diff)
Implementing tile flagging.
Diffstat (limited to 'app.py')
-rw-r--r--app.py33
1 files changed, 18 insertions, 15 deletions
diff --git a/app.py b/app.py
index d0d7a14..6a63978 100644
--- a/app.py
+++ b/app.py
@@ -1,5 +1,5 @@
from board.board import Board
-from tui.tui import Tui
+from tui.tui import Tui, Action
b = Board(10)
t = Tui()
@@ -9,17 +9,20 @@ for _ in range(b.size):
print()
while True:
- x, y = t.matrix_selector(b.get_view(), x, y)
- if x == -1:
- t.draw_matrix(b.get_view(),-1,-1)
- print("LOPETUS!")
- break
- if b.get_mask(x,y) and not b.make_guess(x, y):
- t.draw_matrix(b.get_view(),-1,-1)
- print("KUOLEMA!")
- break
- if b.is_winning():
- t.draw_matrix(b.get_view(),-1,-1)
- print("VOITTO!")
- break
-
+ action, x, y = t.matrix_selector(b.get_view(), x, y)
+ match action:
+ case Action.QUIT:
+# t.draw_matrix(b.get_view(),-1,-1)
+ print("LOPETUS!")
+ break
+ case Action.OPEN:
+ if b.get_mask(x,y) and not b.make_guess(x, y):
+ t.draw_matrix(b.get_view(),-1,-1)
+ print("KUOLEMA!")
+ break
+ elif b.is_winning():
+ t.draw_matrix(b.get_view(),-1,-1)
+ print("VOITTO!")
+ break
+ case Action.FLAG:
+ b.flag_tile(x,y) \ No newline at end of file