def get_command(self): while 1: line = self.conn.read_line() if not line: return try: return ipc.parse_command(line) except ValueError: self.conn.write_line('REJECTED:Unparseable command')
def get_command(self): while 1: line = input() if not line: return try: ret = ipc.parse_command(line) self.conn.write_line(line) return ret except ValueError: print("Command will not parse successfully, refusing to send")
def get_command(self): line = self.conn.read_line() if line: return ipc.parse_command(line)
conn.close() sys.exit() def parse_gamestart_details(details): r = {} for (k, _, v) in (kv.partition("=") for kv in details.split(",")): r[k] = v return r gamestart = conn.read_line() if not gamestart: quit() print(gamestart) command, details = ipc.parse_command(gamestart) if "GAMESTART" != command: quit() game_opts = parse_gamestart_details(details) def setup_game(game_opts): board_size = int(game_opts["board_size"]) board_rows = int(game_opts["board_rows"]) human = HumanPlayer(game_opts["color"], conn) remote = RemotePlayer(checkers.Color.other(game_opts["color"]), conn) board = checkers.CheckerBoard(board_size, board_rows) players = [human, remote] if game_opts["turn"] == "second": players.reverse() return checkers.CheckerGame(board, players)