Пример #1
0
    def _describe_comment(move):
        comment = move.get_comment()

        if not comment or comment is None or len(comment) <= 0:
            return ''

        return ' Also said "%s"' % Protocol.sanitize_comment(comment)
    def _describe_comment(move):
        comment = move.get_comment()

        if not comment or comment is None or len(comment) <= 0:
            return ''

        return ' Also said "%s"' % Protocol.sanitize_comment(comment)
Пример #3
0
    def _parse_input(input_):
        input_ = input_.replace(' ', '').lower()

        if Human._starts_with(input_, 'q'):
            raise Exception('Exiting')

        move = Protocol.parse_move(input_)
        if not GameScoringRules.is_move_legal(move):
            raise ProtocolException('Can make max 3 things at a time!')

        return move
Пример #4
0
    def _parse_input(input_):
        input_ = input_.replace(' ', '').lower()

        if Human._starts_with(input_, 'q'):
            raise Exception('Exiting')

        move = Protocol.parse_move(input_)
        if not GameScoringRules.is_move_legal(move):
            raise ProtocolException('Can make max 3 things at a time!')

        return move
Пример #5
0
    def run(self, fighter):
        protocol = Protocol(self._in_stream, self._out_stream)
        protocol.handshake()

        resp = ServerResponse()

        while not self._cancel_flag:
            move = fighter.make_next_move(resp.move, resp.score1, resp.score2)
            protocol.send_request(move)
            resp = protocol.read_response()
Пример #6
0
    def run(self, fighter):
        protocol = Protocol(self._in_stream, self._out_stream)
        protocol.handshake()

        resp = ServerResponse()

        while not self._cancel_flag:
            move = fighter.make_next_move(resp.move, resp.score1, resp.score2)
            protocol.send_request(move)
            resp = protocol.read_response()