From 9087617e2e023010f5386f222303292dbd015996 Mon Sep 17 00:00:00 2001 From: Aineopintojen-harjoitustyo-Algoritmit-j Date: Sat, 13 Jan 2024 21:27:35 +0200 Subject: Adding tests for rest of board/board.py and removing duplicate code. --- board/board.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'board') diff --git a/board/board.py b/board/board.py index 069b568..22885c7 100644 --- a/board/board.py +++ b/board/board.py @@ -93,8 +93,12 @@ class Board(): """ tarkistaa onko peli voitettu """ for y in range(self.size): for x in range(self.size): - if self.tiles[x][y] != 9 and self.masked[x][y]: - return False + if self.tiles[x][y] == 9: + if not self.masked[x][y]: + return False + else: + if self.masked[x][y]: + return False return True @@ -123,10 +127,6 @@ class Board(): print("Koordinaatit on pelilaudan ulkopuolella", file=stderr) return False - if self.masked[x][y] == 0: - print("Ei voi liputtaa avattua ruutua", file=stderr) - return False - match self.masked[x][y]: case 0: print("Ei voi liputtaa avattua ruutua", file=stderr) -- cgit v1.2.3