From b6c689abc6d5860671c45460a99b487eb6872e22 Mon Sep 17 00:00:00 2001 From: Aineopintojen-harjoitustyo-Algoritmit-j Date: Fri, 12 Jan 2024 09:21:04 +0200 Subject: Making checks that area about to be uncovered is not uncovered already. --- app.py | 2 +- board/board.py | 2 ++ tui/tui.py | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app.py b/app.py index e3c6dd4..bf2a159 100644 --- a/app.py +++ b/app.py @@ -14,7 +14,7 @@ while True: t.draw_matrix(b.get_view(),-1,-1) print("LOPETUS!") break - if not b.make_guess(x, y): + if b.get_mask(x,y) and not b.make_guess(x, y): t.draw_matrix(b.get_view(),-1,-1) print("KUOLEMA!") break diff --git a/board/board.py b/board/board.py index 9666bad..3491c01 100644 --- a/board/board.py +++ b/board/board.py @@ -73,6 +73,8 @@ class Board(): area=area.union(self.collect_area(tx, ty, area)) return area + def get_mask(self, x, y): + return self.masked[x][y] def make_guess(self, x, y): if self.invalid_coordinates(x, y): diff --git a/tui/tui.py b/tui/tui.py index ed997a4..2081711 100644 --- a/tui/tui.py +++ b/tui/tui.py @@ -39,8 +39,8 @@ class Tui(): def draw_tile(self, tile, hilighted): chars_and_colors = ( - (' ', 7, 0), ('1', 10, 0), ('2', 12, 0), - ('3', 11, 0), ('4', 9, 0), ('5', 9, 0), + (' ', 7, 0), ('1', 10, 0), ('2', 11, 0), + ('3', 13, 0), ('4', 9, 0), ('5', 9, 0), ('6', 9, 0), ('7', 9, 0), ('8', 9, 0), ('ยค', 15, 1), ('#', 8, 7) ) -- cgit v1.2.3