Exemplo n.º 1
0
    def join_table(self, table_id, bb):
        """
        Called when pressed "Join" button on table

        redirect to table as spectator when there's no account , but if not,
        display a popup/window (see attached) with min/max amount to join the table and an input number to type the amount
        :param bb:
        :param table_id: table id to join (int)
        :return:
        """
        self.ui.statusbar.clearMessage()
        self.bb = bb
        self.table_id = table_id
        if self.no_account:
            # if there's no account so user joins directly as spectator
            self.launch_poker_table(spectator=True)
        else:
            self.request_ = RequestThread.RequestThread(
                params=('POST /json/table/{table_id}/join', None, {
                    'table_id': self.table_id
                }),
                api_obj=self.api)
            self.request_.resp.connect(self.do_join_table)
            self.request_.complete.connect(self.close_thread)
            self.request_.error_signal.connect(
                partial(self.user_retry, 'join_table', (table_id, bb)))
            self.request_.moveToThread(self.request_thread)
            self.request_thread.started.connect(self.request_.run)
            self.request_thread.start()
            show_request_status(self)
Exemplo n.º 2
0
    def prepare_message_send(self):
        content = self.ui.lineEdit_chat.text()
        if content and content.replace(' ', ''):
            content = content.strip()
            if len(content
                   ) < 50:  # length of each message is less than 50 (49 chars)
                # post message content
                body_bytes = f"message={content}".encode('iso-8859-1')
                if not hasattr(self, 'message_thread'):
                    self.message_thread = QtCore.QThread()
                    self.thread_pool.append(self.message_thread)
                self.request_ = RequestThread.RequestThread(
                    ('POST /json/table/{table_id}/message', body_bytes, {
                        'table_id': self.table_id
                    }), self.api)

                self.request_.resp.connect(self.send_message)
                self.request_.error_signal.connect(
                    partial(self.user_retry, 'message'))
                self.request_.complete.connect(self.close_message_thread)

                self.request_.moveToThread(self.message_thread)
                self.message_thread.started.connect(self.request_.run)
                self.message_thread.start()
                show_request_status(self)

                self.ui.lineEdit_chat.clear(
                )  # clear line after message send request posted
Exemplo n.º 3
0
    def available_display_tables(self):
        """
        First connection making for the application to the host provided in the Home window
        Get tables to join and display them with blinds and seats
        :return:
        """
        curframe = inspect.currentframe()
        calframe = inspect.getouterframes(curframe, 2)

        if not hasattr(self, 'request_thread'):
            self.tables_thread = QtCore.QThread()
            self.thread_pool.append(self.tables_thread)
        self.request_ = RequestThread.RequestThread(
            ('GET /json/tables', None, None), self.api)
        self.request_.moveToThread(self.tables_thread)
        if calframe[1][
                3] == 'action_init':  # to get the caller function (action_init for first call from home screen)
            self.request_.resp.connect(partial(self.display_tables, True))
        else:
            self.request_.resp.connect(partial(self.display_tables, False))
        self.request_.error_signal.connect(partial(self.user_retry, 'tables'))
        self.request_.complete.connect(self.close_table_thread)
        self.tables_thread.started.connect(self.request_.run)
        self.tables_thread.start()
        self.ui.statusbar.showMessage(
            "refreshing tables...", 10 * 60 * 1000
        )  # show refreshing status for max 10 minutes (can be cleared before)
Exemplo n.º 4
0
 def prepare_quit_table(self):
     params = ('GET /json/table/{table_id}/quit', None, {
         'table_id': self.table_id
     })
     self.request_ = RequestThread.RequestThread(params, self.api)
     self.request_.moveToThread(self.request_thread)
     self.request_.resp.connect(self.quit_table)
     self.request_.error_signal.connect(
         partial(self.user_retry, 'quit_table'))
     self.request_.complete.connect(self.close_request_thread)
     self.request_thread.started.connect(self.request_.run)
     self.request_thread.start()
     show_request_status(self)
Exemplo n.º 5
0
 def cash_out(self):
     """
     To logout or cashout and get back to home window
     :return:
     """
     self.request_ = RequestThread.RequestThread(
         ('GET /json/cashout', None, None), self.api)
     self.request_.resp.connect(self.do_cashout)
     self.request_.error_signal.connect(partial(self.user_retry, 'cashout'))
     self.request_.complete.connect(self.close_thread)
     self.request_.moveToThread(self.request_thread)
     self.request_thread.started.connect(self.request_.run)
     self.request_thread.start()
     show_request_status(self)
Exemplo n.º 6
0
    def prepare_check_action(self):
        self.request_ = RequestThread.RequestThread(
            params=('POST /json/table/{table_id}/check', None, {
                'table_id': self.table_id
            }),
            api_obj=self.api)
        self.request_.resp.connect(self.do_check_action)
        self.request_.error_signal.connect(partial(self.user_retry, 'check'))
        self.request_.complete.connect(self.close_request_thread)

        self.request_.moveToThread(self.request_thread)
        self.request_thread.started.connect(self.request_.run)
        self.request_thread.start()
        show_request_status(self)
Exemplo n.º 7
0
    def establish_connection(self):
        self.request_ = RequestThread.RequestThread(params=("GET /json/account", None, None),
                                                    api_obj=self.table_list.api)
        if not hasattr(self, "request_thread"):
            self.request_thread = QtCore.QThread()
            self.thread_pool.append(self.request_thread)

        self.request_.resp.connect(self.connect_table)
        self.request_.error_signal.connect(self.show_error_message)
        self.request_.complete.connect(self.pass_hide)

        self.request_.moveToThread(self.request_thread)
        self.request_thread.started.connect(self.request_.run)
        self.request_thread.start()
Exemplo n.º 8
0
    def prepare_raise_action(self):
        amt_raise = self.ui.horizontalSlider_amt.value()
        body_bytes = f"amount={amt_raise}".encode('iso-8859-1')
        self.request_ = RequestThread.RequestThread(
            ('POST /json/table/{table_id}/raise', body_bytes, {
                'table_id': self.table_id
            }),
            api_obj=self.api)
        self.request_.resp.connect(self.do_raise_action)
        self.request_.error_signal.connect(partial(self.user_retry, 'raise'))
        self.request_.complete.connect(self.close_request_thread)

        self.request_.moveToThread(self.request_thread)
        self.request_thread.started.connect(self.request_.run)
        self.request_thread.start()
        show_request_status(self)
Exemplo n.º 9
0
    def prepare_captcha_post_data(self, input_args):
        self.captcha_dialog.close()
        btc_address = input_args[0]
        captcha_code = input_args[1]
        body_bytes = f"address={btc_address}&captcha={captcha_code}".encode(
            'ascii')
        self.request_ = RequestThread.RequestThread(
            ('POST /json/send', body_bytes, None), api_obj=self.api)

        self.request_.resp.connect(self.post_captcha)
        self.request_.error_signal.connect(
            partial(self.user_retry, 'post_captcha', (input_args, )))
        self.request_.complete.connect(self.close_thread)

        self.request_.moveToThread(self.request_thread)
        self.request_thread.started.connect(self.request_.run)
        self.request_thread.start()
        show_request_status(self)
Exemplo n.º 10
0
    def request_captcha(self):
        """
        called when user do not have an account, and user presses the PlayNow button
        :return:
        """
        params = ('GET /json/join', None, None)
        if not hasattr(self, 'request_thread'
                       ):  # don't spawn new thread if there's already one
            self.request_thread = QtCore.QThread()
            self.thread_pool.append(self.request_thread)
        self.request_ = RequestThread.RequestThread(params, self.api)
        self.request_.resp.connect(self.open_captcha_window)
        self.request_.error_signal.connect(
            partial(self.user_retry, 'get_captcha'))
        self.request_.complete.connect(self.close_thread)
        self.request_.moveToThread(self.request_thread)
        self.request_thread.started.connect(self.request_.run)
        self.request_thread.start()

        show_request_status(self)
Exemplo n.º 11
0
    def prepare_update(self):
        if not self.spectator:
            self.ui.statusbar.showMessage("Joining table...", 20 * 60 * 1000)

        self.timer_pause = True  # set timer pause, so that countdown pauses during table update
        params = tuple(
            ['GET /json/table/{table_id}', None, {
                'table_id': self.table_id
            }])
        if not hasattr(self, 'table_thread'):
            self.table_thread = QtCore.QThread()
            self.thread_pool.append(self.table_thread)
        self.request_ = RequestThread.RequestThread(params, self.api)
        self.request_.moveToThread(self.table_thread)
        self.request_.resp.connect(self.update_table)
        self.request_.error_signal.connect(
            partial(self.user_retry, 'update_table'))
        self.request_.complete.connect(self.close_table_thread)
        self.table_thread.started.connect(self.request_.run)
        self.table_thread.start()
        show_request_status(self)
Exemplo n.º 12
0
 def prepare_account_check(self):
     """
     Refresh user account status
     """
     self.request_acc = RequestThread.RequestThread(
         params=('GET /json/account', None, None),
         call_dict=None,
         api_obj=self.api)
     if not hasattr(self, 'request_thread'
                    ):  # don't spawn new thread if there's already one
         self.request_thread = QtCore.QThread()
         self.thread_pool.append(self.request_thread)
     self.request_acc.resp.connect(self.recv_account_status)
     self.request_acc.error_signal.connect(
         partial(self.user_retry, 'get_account'))
     self.request_acc.complete.connect(self.close_thread)
     self.request_acc.moveToThread(self.request_thread)
     self.request_thread.started.connect(self.request_acc.run)
     self.request_thread.start()
     self.ui.statusbar.showMessage(
         "refreshing account...",
         10 * 60 * 1000)  # show refreshing status for max 10
Exemplo n.º 13
0
    def prepare_accept_amount_value(self, value: int):
        """
        If user did not have an account and user pressed Join button on table.
        And has entered an amount to join the table
        :param value:
        :return:
        """
        body_bytes = f"amount={value}".encode('ascii')
        self.request_ = RequestThread.RequestThread(
            ('POST /json/table/{table_id}/join/confirm', body_bytes, {
                'table_id': self.table_id
            }),
            api_obj=self.api)
        self.request_.resp.connect(self.confirm_join)
        self.request_.complete.connect(self.close_thread)
        self.request_.error_signal.connect(
            partial(self.user_retry, 'confirm_join', (value, )))

        self.request_.moveToThread(self.request_thread)
        self.request_thread.started.connect(self.request_.run)
        self.request_thread.start()

        show_request_status(self)