diff options
author | lonkaars <l.leblansch@gmail.com> | 2021-02-20 13:03:04 +0100 |
---|---|---|
committer | lonkaars <l.leblansch@gmail.com> | 2021-02-20 13:03:04 +0100 |
commit | e1978a9b80f3f7f5a36ca4af5f6df62f494a0d6d (patch) | |
tree | 27b2a142ad1c267f002e7c7e09ea337e4da688ac /api/game/voerbak_connector.py | |
parent | 16044fbf61b06f4d53e2ffcab67569721b3792e2 (diff) |
/game/random endpoint
Diffstat (limited to 'api/game/voerbak_connector.py')
-rw-r--r-- | api/game/voerbak_connector.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/api/game/voerbak_connector.py b/api/game/voerbak_connector.py index 5ccaed8..65551ca 100644 --- a/api/game/voerbak_connector.py +++ b/api/game/voerbak_connector.py @@ -32,12 +32,17 @@ class bord: def get_output(self): return self.process.stdout.readline().decode()[:-1] + def kill_voerbak(self): + self.process.stdin.write(bytearray("0", "utf-8")) + self.process.stdin.flush() + def update_board(self): buffer = self.get_output() while not buffer.isdigit(): if buffer.startswith("w:"): self.win_positions.append(buffer[2:].split("-")) log.info(f"won: {buffer[2:].split('-')}") + self.kill_voerbak() elif buffer.startswith("e:"): log.warning(buffer[2:]) elif buffer.startswith("m:"): @@ -45,6 +50,7 @@ class bord: self.player_1 = True if substr == "true" else False elif buffer.startswith("d:"): self.board_full = True + self.kill_voerbak() buffer = self.get_output() self.board = buffer |