Esempio n. 1
0
    def get_min_range(self):
        message = OnlineMessage(self.MESSAGES_TO_PLAYER['GetMinRange'])
        self._server.send(message.encode(), self._player_list[0])
        message.decode(self._server.get(self._player_list[0]))
        try:
            min_range = int(message.get_body())
        except ValueError:
            return None

        return min_range
Esempio n. 2
0
    def get_coord(self, dim, player):
        message = OnlineMessage(self.MESSAGES_TO_PLAYER['GetCoord'])
        self._server.send(message.encode(), self.actual_player(player))
        message.decode(self._server.get(self.actual_player(player)))
        try:
            coord = int(message.get_body())
        except ValueError:
            return False

        if 1 <= coord <= dim:
            return coord

        return False
Esempio n. 3
0
    def get_guess(self, min_range, max_range):
        min_max = [min_range, max_range]
        message = OnlineMessage(self.MESSAGES_TO_PLAYER['GetGuess'], min_max)
        self._server.send(message.encode(), self._player_list[0])
        message.decode(self._server.get(self._player_list[0]))

        try:
            guess = int(message.get_body())
        except ValueError:
            return None

        if min_range <= guess <= max_range:
            return guess

        return None