summaryrefslogtreecommitdiff
path: root/app.py
diff options
context:
space:
mode:
authorAineopintojen-harjoitustyo-Algoritmit-j <github-hy-tiralabra@v.hix.fi>2024-01-13 21:01:55 +0200
committerAineopintojen-harjoitustyo-Algoritmit-j <github-hy-tiralabra@v.hix.fi>2024-01-13 21:01:55 +0200
commitb12c97653c2ee004292b0fdfd770a2c59451854b (patch)
tree558d86421b118290ab68743785fd84e6208b17cd /app.py
parent30ee34f106c5052cf0a60361d3220427b5753557 (diff)
Linting rest of the files and adding pylint to GHA.
Diffstat (limited to 'app.py')
-rw-r--r--app.py51
1 files changed, 29 insertions, 22 deletions
diff --git a/app.py b/app.py
index c31627e..8778881 100644
--- a/app.py
+++ b/app.py
@@ -2,27 +2,34 @@
from board.board import Board
from tui.tui import Tui, Action
-b = Board(13)
-t = Tui()
-x, y = 0, 0
+# pylint: disable = too-few-public-methods
+class App:
+ """ App - Luokka pääohjelmalle"""
+ def __init__(self):
+ self.b = Board(13)
+ self.t = Tui()
-for _ in range(b.size):
- print()
+ 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 = t.matrix_selector(b.get_view(), x, y)
- match action:
- case Action.QUIT:
- 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
- if b.is_winning():
- t.draw_matrix(b.get_view(), -1, -1)
- print("VOITTO!")
- break
- case Action.FLAG:
- b.flag_tile(x, y)
+ 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)