diff options
author | Aineopintojen-harjoitustyo-Algoritmit-j <github-hy-tiralabra@v.hix.fi> | 2024-01-13 13:10:21 +0200 |
---|---|---|
committer | Aineopintojen-harjoitustyo-Algoritmit-j <github-hy-tiralabra@v.hix.fi> | 2024-01-13 13:10:21 +0200 |
commit | 41f6ff58c4800c85e8c2d53498eddc3590acfde9 (patch) | |
tree | 468f30f29126c7711e06e3793cbdfbfe37027991 /tui | |
parent | dca833cd9a62e163f300572ed0b3ec0dd63aa123 (diff) |
Implementing tile flagging.
Diffstat (limited to 'tui')
-rw-r--r-- | tui/tui.py | 31 |
1 files changed, 19 insertions, 12 deletions
@@ -1,4 +1,10 @@ import termios, fcntl, sys, os +from enum import Enum + +class Action(Enum): + QUIT = 0 + OPEN = 1 + FLAG = 2 class Tui(): def __init__(self): @@ -40,7 +46,8 @@ class Tui(): (' ', 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) + ('¤', 15, 1), ('#', 8, 7), ('B', 8, 7), + ('?', 8, 7) ) if hilighted: @@ -61,7 +68,7 @@ class Tui(): x == hx and y == hy ) print() - def matrix_selector(self, matrix, x,y ): + def matrix_selector(self, matrix, x, y ): self.draw_matrix(matrix, x, y) while True: try: @@ -69,20 +76,20 @@ class Tui(): except: continue match c: - case 'A': + case 'A' | 'w': y-=1 - case 'B': + case 'D' | 'a': + x-=1 + case 'B' | 's': y+=1 - case 'C': + case 'C' | 'd': x+=1 - case 'D': - x-=1 - case '': - continue case 'q': - return (-1,-1) - case ' ': - return (x,y) + return (Action.QUIT,-1,-1) + case ' ' | '\n': + return (Action.OPEN, x, y) + case 'f' | 'm': + return (Action.FLAG, x, y) case _: continue x = 0 if x < 0 else x |