Exemplo n.º 1
0
    def __init__(self, host=None, port=None):
        """Initialize a MaverickPlayer

        If host or port specified and not None, use them instead of defaults

        NOTE: MaverickPlayer.startPlaying must be run to set playerID, gameID,
        and isWhite before the player can make moves"""

        MaverickClient.__init__(self, host=host, port=port)

        # These variables must be overridden
        self.playerID = None    # ID for player's system registration
        self.gameID = None      # ID for game that the player is in
        self.isWhite = None     # Is the player white?
Exemplo n.º 2
0
    def __init__(self, host=None, port=None):
        """Initialize a MaverickPlayer

        If host or port specified and not None, use them instead of defaults

        NOTE: MaverickPlayer.startPlaying must be run to set playerID, gameID,
        and isWhite before the player can make moves"""

        MaverickClient.__init__(self, host=host, port=port)

        # These variables must be overridden
        self.playerID = None  # ID for player's system registration
        self.gameID = None  # ID for game that the player is in
        self.isWhite = None  # Is the player white?
Exemplo n.º 3
0
    def _request_isMyTurn(self):
        """Requests the player's turn status from the Maverick server

        @return: True if it is my turn, False otherwise"""
        return MaverickClient._request_isMyTurn(self,
                                                self.gameID,
                                                self.playerID)
Exemplo n.º 4
0
    def _request_getState(self):
        """Retrieves the current game state from the server

        @return: A dictionary of the following form:
                {"youAreColor": ChessBoard.WHITE or ChessBoard.BLACK,
                "isWhitesTurn": True or False,
                "board": a ChessBoard object representing the current board,
                "history": list of plies}"""

        return MaverickClient._request_getState(self,
                                                   self.playerID, self.gameID)
Exemplo n.º 5
0
    def _request_getStatus(self):
        """Requests the status of this game from the Maverick server

        @return: one of ChessMatch.STATUS_PENDING,
                        ChessMatch.STATUS_ONGOING,
                        ChessMatch.STATUS_BLACK_WON,
                        ChessMatch.STATUS_WHITE_WON,
                        ChessMatch.STATUS_DRAWN,
                        ChessMatch.STATUS_CANCELLED,"""

        return MaverickClient._request_getStatus(self, self.gameID)
Exemplo n.º 6
0
    def _request_getState(self):
        """Retrieves the current game state from the server

        @return: A dictionary of the following form:
                {"youAreColor": ChessBoard.WHITE or ChessBoard.BLACK,
                "isWhitesTurn": True or False,
                "board": a ChessBoard object representing the current board,
                "history": list of plies}"""

        return MaverickClient._request_getState(self, self.playerID,
                                                self.gameID)
Exemplo n.º 7
0
    def _request_getStatus(self):
        """Requests the status of this game from the Maverick server

        @return: one of ChessMatch.STATUS_PENDING,
                        ChessMatch.STATUS_ONGOING,
                        ChessMatch.STATUS_BLACK_WON,
                        ChessMatch.STATUS_WHITE_WON,
                        ChessMatch.STATUS_DRAWN,
                        ChessMatch.STATUS_CANCELLED,"""

        return MaverickClient._request_getStatus(self, self.gameID)
Exemplo n.º 8
0
 def _request_makePly(self, fromPosn, toPosn):
     """Sends a makePly request to the server for the given ply"""
     MaverickClient._request_makePly(self,
                                    self.playerID, self.gameID,
                                    fromPosn, toPosn)
Exemplo n.º 9
0
 def _request_makePly(self, fromPosn, toPosn):
     """Sends a makePly request to the server for the given ply"""
     MaverickClient._request_makePly(self, self.playerID, self.gameID,
                                     fromPosn, toPosn)
Exemplo n.º 10
0
    def _request_isMyTurn(self):
        """Requests the player's turn status from the Maverick server

        @return: True if it is my turn, False otherwise"""
        return MaverickClient._request_isMyTurn(self, self.gameID,
                                                self.playerID)