diff options
Diffstat (limited to 'console/voerbak_connector.py')
-rw-r--r-- | console/voerbak_connector.py | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/console/voerbak_connector.py b/console/voerbak_connector.py new file mode 100644 index 0000000..b300af0 --- /dev/null +++ b/console/voerbak_connector.py @@ -0,0 +1,48 @@ +from colorama import Fore +import subprocess +import os + +DISC_SHAPE = "o" +DISC_A = Fore.RED + DISC_SHAPE + Fore.RESET +DISC_B = Fore.BLUE + DISC_SHAPE + Fore.RESET +EMPTY = Fore.LIGHTBLACK_EX + "_" + Fore.RESET + +class bord: + def __init__(self, w, h): + self.width = w + self.height = h + self.process = subprocess.Popen(["./voerbak"], + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + msg = bytearray(f"{w} {h}\n", "utf-8") + print({"msg": msg}) + self.process.stdin.write(msg) + self.process.stdin.flush() + + # def print(self): + # for y in range(self.height -1, -1, -1): + # for x in range(self.width): + # print(self.board[x + y * self.width], end=" ") + # print("\n", end="") + + def drop_fisje(self, column): + msg = bytearray(f"{column}\n", "utf-8") + print({"msg": msg}) + self.process.stdin.write(msg) + self.process.stdin.flush() + +def main(): + gert = bord(7, 6) + while True: + # gert.print() + column = int(input("column?: ")) - 1 + if column not in range(gert.width): + continue + # os.system("clear") + gert.drop_fisje(column) + print(gert.process.stdout.readline()) + +if __name__ == "__main__": + main() + |