diff options
author | Aineopintojen-harjoitustyo-Algoritmit-j <github-hy-tiralabra@v.hix.fi> | 2024-01-14 15:08:54 +0200 |
---|---|---|
committer | Aineopintojen-harjoitustyo-Algoritmit-j <github-hy-tiralabra@v.hix.fi> | 2024-01-14 15:08:54 +0200 |
commit | 53eea87fe65c5c4f063664c424d4b49176a27984 (patch) | |
tree | ba07b7f17923b86617f4b2bc483beacc8baf365e /tui | |
parent | 3dd13c9ed2fc57c525ddf0dd5c7d130229087a16 (diff) |
Making it possible to ask hints.
Diffstat (limited to 'tui')
-rw-r--r-- | tui/static.py | 4 | ||||
-rw-r--r-- | tui/tui.py | 7 |
2 files changed, 9 insertions, 2 deletions
diff --git a/tui/static.py b/tui/static.py index b594c44..98b6985 100644 --- a/tui/static.py +++ b/tui/static.py @@ -31,7 +31,7 @@ ActionKeys = { "d": Action.RIGHT, " ": Action.OPEN, "\n": Action.OPEN, "f": Action.FLAG, "m": Action.FLAG, "q": Action.QUIT, "p": Action.BOMB, "x": Action.BOMB, "o": Action.SAFE, - "l": Action.QUIT, + "l": Action.QUIT, "?": Action.HINT, "b": Action.HINT } KEY_DESCRIPTIONS = """ @@ -43,6 +43,8 @@ Merkitseminen: t,o - turvallinen Avaaminen: ENTER, SPACE +Vinkki: + ?, b - pyydä botilta vihje Lopetus: l,q,ESC """ @@ -8,7 +8,7 @@ from tui.ansi import Ansi class Tui(): """ Tui - Luokka käyttäjän interaktiota varten """ - def __init__(self): + def __init__(self, bot = None): # Vaatii hieman terminaaliasetusten muokkaamista jotta yksittäiset # napin painallukset voidaan lukea # https://stackoverflow.com/questions/983354/how-do-i-wait-for-a-pressed-key @@ -22,6 +22,8 @@ class Tui(): self.oldflags = fcntl.fcntl(fd, fcntl.F_GETFL) fcntl.fcntl(fd, fcntl.F_SETFL, self.oldflags | os.O_NONBLOCK) + self.bot = bot + def __del__(self): # palautetaan terminaali takaisin alkupetäiseen uskoon @@ -94,6 +96,9 @@ class Tui(): x = 0 case Action.END: x = len(matrix)-1 + case Action.HINT: + if self.bot is not None: + return (Action.BOMB, 0, 0) self.draw_matrix(matrix, x, y) |