summaryrefslogtreecommitdiff
path: root/tui/ansi_draw.py
diff options
context:
space:
mode:
authorAineopintojen-harjoitustyo-Algoritmit-j <github-hy-tiralabra@v.hix.fi>2024-01-29 02:34:32 +0200
committerAineopintojen-harjoitustyo-Algoritmit-j <github-hy-tiralabra@v.hix.fi>2024-01-29 02:34:32 +0200
commite591d15abc4943a74c39f0fcab065213828a1514 (patch)
treebc22931abb08d8c213ba4eb81a85298d69e88890 /tui/ansi_draw.py
parent0c034e6fbae0833f8524caf223deab450e9bb1b4 (diff)
Updating too much. Renewed bots and tui.
Diffstat (limited to 'tui/ansi_draw.py')
-rw-r--r--tui/ansi_draw.py61
1 files changed, 61 insertions, 0 deletions
diff --git a/tui/ansi_draw.py b/tui/ansi_draw.py
new file mode 100644
index 0000000..dd304d0
--- /dev/null
+++ b/tui/ansi_draw.py
@@ -0,0 +1,61 @@
+""" tui/ansi_draw.py - perustukset ansi tulostelulle """
+# pylint: disable = multiple-imports
+from .ansi import Ansi
+from .static import TileTypes
+
+class AnsiDraw():
+ """ AnsiDraw - "piirtelee" näytölle kirjailmilla """
+ def __init__(self, height = 15):
+ print(end="\n"*height)
+
+ def __del__(self):
+ print()
+
+ def __tile(self, tile, hilighted):
+ """ "piirtää" yhden ruudun """
+ for ch, colors in zip(TileTypes[tile].text, TileTypes[tile].colors):
+ color, bg = colors
+ Ansi.color(Ansi.BLACK if hilighted else color)
+ Ansi.bg(Ansi.CYAN if hilighted else bg)
+ print(end=ch)
+ Ansi.reset()
+
+
+ def matrix(self, matrix, hx, hy):
+ """ "piirtää" ruudukon """
+ Ansi.cup(len(matrix[0]))
+ # pylint: disable=consider-using-enumerate
+ for y in range(len(matrix[0])):
+ for x in range(len(matrix)):
+ hilight = matrix[x][y] != 9 and x == hx and y == hy
+ self.__tile(matrix[x][y], hilight)
+ print()
+
+
+ def status_line(self, text):
+ """ draw_status_line - tulostaa pelitietorivin"""
+ print(end=text+'\r')
+
+class SuppressDraw():
+ """ SuppressDraw - vain status """
+ # pylint: disable = unused-argument
+
+ def matrix(self, matrix, hx, hy):
+ """ "piirtää" ruudukon """
+ return True
+
+ def status_line(self, text):
+ """ draw_status_line - tulostaa pelitietorivin"""
+ print(end=text+'\r')
+
+class NoDraw():
+ """ NoDraw - ei mitään """
+ # pylint: disable = unused-argument
+
+ def matrix(self, matrix, hx, hy):
+ """ "piirtää" ruudukon """
+ return True
+
+ def status_line(self, text):
+ """ draw_status_line - tulostaa pelitietorivin"""
+ return True