コード例 #1
0
ファイル: test_gp.py プロジェクト: isoundy000/qipai-2
    def OnPaint(self, e):
        width, height = self.GetClientSize()

        if USE_BUFFERED_DC:
            dc = wx.BufferedPaintDC(self, self._Buffer)
        else:
            dc = wx.PaintDC(self)
        brBack = wx.Brush('#053154', wx.SOLID)
        dc.SetBackground(brBack)
        dc.Clear()

        pokerW, pokerH = self.bmpPoker['0'].GetSize()
        x = 0
        y = 0

        # draw player's hand cards
        dc.SetTextForeground(wx.WHITE)
        for i in range(0, 2):
            x = 0
            cp_no = self.gp.curr_player_no
            playerid = "player%d" % (1 - i)
            dc.DrawText(playerid, x, self.rcHand[1 - i].GetY())
            if cp_no == (1 - i):
                # draw arrow
                arlist = [(0, 0), (8, 8), (0, 16)]
                dc.DrawPolygon(arlist, self.rcHand[1 - i].GetX() - 10,
                               self.rcHand[1 - i].GetY() + pokerH / 2 - 8)

            player = libqp.gp_get_player(self.gp, 1 - i)
            hand = libqp.gp_get_player_hand(player)
            num = libqp.hand_num(hand)
            x = self.rcHand[1 - i].GetX()
            y = self.rcHand[1 - i].GetY()
            for j in range(0, num):
                card = libqp.hand_get(hand, j)
                keyname = libqp.card_text(card)
                if self.flag_up[j] > 0 and cp_no == (1 - i):
                    dc.DrawBitmap(self.bmpPoker[keyname], x, y - self.upH, 0)
                else:
                    dc.DrawBitmap(self.bmpPoker[keyname], x, y, 0)
                x = x + self.pokerOffsetW

        # draw last hand
        num = self.gp.last_hand.num
        x = (width - ((num - 1) * self.pokerOffsetW + pokerW)) / 2
        for i in range(0, num):
            card = libqp.hand_get(self.gp.last_hand, i)
            keyname = libqp.card_text(card)
            dc.DrawBitmap(self.bmpPoker[keyname], x, 0, 0)
            x = x + self.pokerOffsetW

        # info
        info = "rule:%d\n" % self.gp.game_rule
        info += "state:%d\n" % (self.gp.game_state)
        info += "curr player:%d\n" % (self.gp.curr_player_no)
        info += "last hand:%d,%d\n" % (self.gp.last_hand.type,
                                       self.gp.last_hand.param)
        info += "select:%d,%d" % (self.sel_handtype, self.sel_handparam)
        dc.DrawText(info, 0, 0)
コード例 #2
0
ファイル: test_gp.py プロジェクト: github188/qipai
    def OnPaint(self, e):
        width, height = self.GetClientSize()
        
        if USE_BUFFERED_DC:
            dc = wx.BufferedPaintDC(self, self._Buffer)
        else:
            dc = wx.PaintDC(self)
        brBack = wx.Brush('#053154', wx.SOLID);
        dc.SetBackground(brBack)
        dc.Clear()
        
        pokerW, pokerH = self.bmpPoker['0'].GetSize()
        x = 0
        y = 0
           
        # draw player's hand cards
        dc.SetTextForeground(wx.WHITE)
        for i in range(0, 2):
            x = 0
            cp_no = self.gp.curr_player_no
            playerid = "player%d" % (1 - i)
            dc.DrawText(playerid, x, self.rcHand[1-i].GetY())
            if cp_no == (1 - i):
                # draw arrow
                arlist = [(0,0), (8,8), (0,16)]
                dc.DrawPolygon(arlist, self.rcHand[1-i].GetX() - 10,
                    self.rcHand[1-i].GetY() + pokerH / 2 - 8)

            player = libqp.gp_get_player(self.gp, 1 - i)
            hand = libqp.gp_get_player_hand(player)
            num = libqp.hand_num(hand)
            x = self.rcHand[1-i].GetX()
            y = self.rcHand[1-i].GetY()
            for j in range(0, num):
                card = libqp.hand_get(hand, j)
                keyname = libqp.card_text(card)
                if self.flag_up[j] > 0 and cp_no == (1 - i):
                    dc.DrawBitmap(self.bmpPoker[keyname], x, y - self.upH, 0)
                else:
                    dc.DrawBitmap(self.bmpPoker[keyname], x, y, 0)
                x = x + self.pokerOffsetW
               
        # draw last hand
        num = self.gp.last_hand.num
        x = (width - ((num - 1) * self.pokerOffsetW + pokerW)) / 2
        for i in range(0, num):
            card = libqp.hand_get(self.gp.last_hand, i)
            keyname = libqp.card_text(card)
            dc.DrawBitmap(self.bmpPoker[keyname], x, 0, 0)
            x = x + self.pokerOffsetW
        
        # info
        info = "rule:%d\n" % self.gp.game_rule
        info += "state:%d\n" % (self.gp.game_state)
        info += "curr player:%d\n" % (self.gp.curr_player_no)
        info += "last hand:%d,%d\n" % (self.gp.last_hand.type,self.gp.last_hand.param)
        info += "select:%d,%d" % (self.sel_handtype,self.sel_handparam)
        dc.DrawText(info, 0, 0)
コード例 #3
0
ファイル: test_texas.py プロジェクト: huangtao/qipai
 def CalcRect(self):
     width, height = self.GetClientSize()
     pokerW, pokerH = self.bmpPoker["0"].GetSize()
     y = height
     for i in range(0, 2):
         self.rcHand[1 - i].SetY(y - pokerH)
         player = libqp.texas_get_player(self.texas, 1 - i)
         hand = libqp.texas_get_player_hand(player)
         num = libqp.hand_num(hand)
         self.rcHand[1 - i].SetWidth(pokerW + (num - 1) * self.pokerOffsetW)
         self.rcHand[1 - i].SetHeight(pokerH)
         y = y - pokerH - self.blankH
コード例 #4
0
ファイル: test_texas.py プロジェクト: isoundy000/qipai-2
 def CalcRect(self):
     width, height = self.GetClientSize()
     pokerW, pokerH = self.bmpPoker['0'].GetSize()
     y = height
     for i in range(0, 2):
         self.rcHand[1 - i].SetY(y - pokerH)
         player = libqp.texas_get_player(self.texas, 1 - i)
         hand = libqp.texas_get_player_hand(player)
         num = libqp.hand_num(hand)
         self.rcHand[1 - i].SetWidth(pokerW + (num - 1) * self.pokerOffsetW)
         self.rcHand[1 - i].SetHeight(pokerH)
         y = y - pokerH - self.blankH
コード例 #5
0
ファイル: test_ddz.py プロジェクト: github188/qipai
 def OnLeftDown(self, e):
     pokerW, pokerH = self.bmpPoker['0'].GetSize()
     pt = e.GetPosition()
     cp_no = self.ddz.curr_player_no
     rc = wx.Rect(self.rcHand[cp_no].GetX(),
         self.rcHand[cp_no].GetY(),
         self.rcHand[cp_no].GetWidth(),
         self.rcHand[cp_no].GetHeight())
     rc.SetY(rc.GetY() - self.upH)
     rc.SetHeight(rc.GetHeight() + self.upH)
     flag = 0
     if rc.Inside(pt):
         player = libqp.ddz_get_player(self.ddz, cp_no)
         hand = libqp.ddz_get_player_hand(player)
         num = libqp.hand_num(hand)
         if pt.x > (rc.GetRight() - pokerW):
             if self.flag_up[num-1] > 0:
                 y1 = rc.GetTop()
                 y2 = y1 + pokerH
                 if pt.y >= y1 and pt.y <= y2:
                     self.flag_up[num-1] = 0
                     flag = 1
             else:
                 y1 = rc.GetTop() + self.upH
                 y2 = y1 + pokerH                    
                 if pt.y >= y1 and pt.y <= y2:
                     self.flag_up[num-1] = 1
                     flag = 1
         else:
             idx = (pt.x - rc.GetLeft()) / self.pokerOffsetW
             if self.flag_up[idx] > 0:
                 y1 = rc.GetTop()
                 y2 = y1 + pokerH
                 if pt.y >= y1 and pt.y <= y2:
                     self.flag_up[idx] = 0
                     flag = 1
             else:
                 y1 = rc.GetTop() + self.upH
                 y2 = y1 + pokerH
                 if pt.y >= y1 and pt.y <= y2:
                     self.flag_up[idx] = 1
                     flag = 1
     if flag > 0:
         self.Refresh()
コード例 #6
0
ファイル: test_gp.py プロジェクト: isoundy000/qipai-2
 def OnLeftDown(self, e):
     pokerW, pokerH = self.bmpPoker['0'].GetSize()
     pt = e.GetPosition()
     cp_no = self.gp.curr_player_no
     rc = wx.Rect(self.rcHand[cp_no].GetX(), self.rcHand[cp_no].GetY(),
                  self.rcHand[cp_no].GetWidth(),
                  self.rcHand[cp_no].GetHeight())
     rc.SetY(rc.GetY() - self.upH)
     rc.SetHeight(rc.GetHeight() + self.upH)
     flag = 0
     if rc.Inside(pt):
         player = libqp.gp_get_player(self.gp, cp_no)
         hand = libqp.gp_get_player_hand(player)
         num = libqp.hand_num(hand)
         if pt.x > (rc.GetRight() - pokerW):
             if self.flag_up[num - 1] > 0:
                 y1 = rc.GetTop()
                 y2 = y1 + pokerH
                 if pt.y >= y1 and pt.y <= y2:
                     self.flag_up[num - 1] = 0
                     flag = 1
             else:
                 y1 = rc.GetTop() + self.upH
                 y2 = y1 + pokerH
                 if pt.y >= y1 and pt.y <= y2:
                     self.flag_up[num - 1] = 1
                     flag = 1
         else:
             idx = (pt.x - rc.GetLeft()) / self.pokerOffsetW
             if self.flag_up[idx] > 0:
                 y1 = rc.GetTop()
                 y2 = y1 + pokerH
                 if pt.y >= y1 and pt.y <= y2:
                     self.flag_up[idx] = 0
                     flag = 1
             else:
                 y1 = rc.GetTop() + self.upH
                 y2 = y1 + pokerH
                 if pt.y >= y1 and pt.y <= y2:
                     self.flag_up[idx] = 1
                     flag = 1
     if flag > 0:
         self.Refresh()
コード例 #7
0
ファイル: test_gp.py プロジェクト: isoundy000/qipai-2
 def OnRightDown(self, e):
     pt = e.GetPosition()
     cp_no = self.gp.curr_player_no
     if self.rcHand[cp_no].Inside(pt):
         outlist = []
         for i in range(0, 50):
             if self.flag_up[i] > 0:
                 outlist.append(i)
         if len(outlist) > 0:
             player = libqp.gp_get_player(self.gp, cp_no)
             hand_p = libqp.gp_get_player_hand(player)
             hand_out = libqp.hand_new(len(outlist))
             for j in outlist:
                 card = libqp.hand_get(hand_p, j)
                 libqp.hand_push(hand_out, card)
             htype = libqp.hand_type()
             libqp.gp_handtype(self.gp, hand_out, htype)
             ret = libqp.gp_canplay(self.gp, hand_out, htype)
             if ret > 0:
                 libqp.gp_play(self.gp, cp_no, hand_out)
                 num = libqp.hand_num(hand_p)
                 pokerW, pokerH = self.bmpPoker['0'].GetSize()
                 self.rcHand[cp_no].SetWidth(pokerW +
                                             (num - 1) * self.pokerOffsetW)
                 for i in range(0, 50):
                     self.flag_up[i] = 0
                 self.Refresh()
             else:
                 print "can't play:", htype.type, htype.logic_value1
         else:
             # pass
             libqp.gp_pass(self.gp, cp_no)
             self.Refresh()
     else:
         # reset flag_up
         flag = 0
         for i in range(0, 50):
             if self.flag_up[i] > 0:
                 flag = 1
                 self.flag_up[i] = 0
         if flag > 0:
             self.Refresh()
コード例 #8
0
ファイル: test_ddz.py プロジェクト: github188/qipai
 def OnRightDown(self, e):
     pt = e.GetPosition()
     cp_no = self.ddz.curr_player_no
     if self.rcHand[cp_no].Inside(pt):
         outlist = []
         for i in range(0, 50):
             if self.flag_up[i] > 0:
                 outlist.append(i)
         if len(outlist) > 0:
             player = libqp.ddz_get_player(self.ddz, cp_no)
             hand_p = libqp.ddz_get_player_hand(player)
             hand_out = libqp.hand_new(len(outlist))
             for j in outlist:
                 card = libqp.hand_get(hand_p, j)
                 libqp.hand_push(hand_out, card)
             htype = libqp.hand_type()
             libqp.ddz_handtype(hand_out, htype)
             ret = libqp.ddz_canplay(self.ddz, hand_out, htype)
             if ret > 0:
                 libqp.ddz_play(self.ddz, cp_no, hand_out)
                 num = libqp.hand_num(hand_p)
                 pokerW, pokerH = self.bmpPoker['0'].GetSize()
                 self.rcHand[cp_no].SetWidth(pokerW + (num - 1) * self.pokerOffsetW)
                 for i in range(0, 50):
                     self.flag_up[i] = 0
                 self.Refresh()
             else:
                 print "can't play:",htype.type,htype.logic_value1
         else:
             # pass
             libqp.ddz_pass(self.ddz, cp_no)
             self.Refresh()
     else:
         # reset flag_up
         flag = 0
         for i in range(0, 50):
             if self.flag_up[i] > 0:
                 flag = 1
                 self.flag_up[i] = 0
         if flag > 0:
             self.Refresh()
コード例 #9
0
ファイル: test_texas.py プロジェクト: huangtao/qipai
    def OnPaint(self, e):
        width, height = self.GetClientSize()

        if USE_BUFFERED_DC:
            dc = wx.BufferedPaintDC(self, self._Buffer)
        else:
            dc = wx.PaintDC(self)
        brBack = wx.Brush("#053154", wx.SOLID)
        dc.SetBackground(brBack)
        dc.Clear()

        pokerW, pokerH = self.bmpPoker["0"].GetSize()
        x = 0
        y = 0

        max_no = 0
        max_handtype = libqp.hand_type()

        # draw player's hand cards
        dc.SetTextForeground(wx.WHITE)
        for i in range(0, 2):
            x = 0
            cp_no = self.texas.curr_player_no
            playerid = "player%d" % (1 - i)
            dc.DrawText(playerid, x, self.rcHand[1 - i].GetY())
            if cp_no == (1 - i):
                # draw arrow
                arlist = [(0, 0), (8, 8), (0, 16)]
                dc.DrawPolygon(arlist, self.rcHand[1 - i].GetX() - 10, self.rcHand[1 - i].GetY() + pokerH / 2 - 8)

            player = libqp.texas_get_player(self.texas, 1 - i)
            hand = libqp.texas_get_player_hand(player)
            num = libqp.hand_num(hand)
            x = self.rcHand[1 - i].GetX()
            y = self.rcHand[1 - i].GetY()
            for j in range(0, num):
                card = libqp.hand_get(hand, j)
                keyname = libqp.card_text(card)
                if self.flag_up[j] > 0 and cp_no == (1 - i):
                    dc.DrawBitmap(self.bmpPoker[keyname], x, y - self.upH, 0)
                else:
                    dc.DrawBitmap(self.bmpPoker[keyname], x, y, 0)
                x = x + pokerW + 2

            if libqp.texas_get_state(self.texas) >= 2:
                rx = x + 10
                htresult = libqp.hand_new(5)
                hand_all = libqp.hand_new(7)
                libqp.texas_group(self.texas, 1 - i, hand_all)
                # libqp.hand_dump(hand_all, 7)
                htype = libqp.hand_type()
                libqp.hand_zero(htresult)
                r = libqp.texas_handtype(hand_all, htype, htresult)
                # print r,htype.logic_value1
                # libqp.hand_dump(htresult, 5)
                if i == 0:
                    max_handtype.type = htype.type
                    max_handtype.logic_value1 = htype.logic_value1
                    max_handtype.logic_value2 = htype.logic_value2
                    max_handtype.logic_value3 = htype.logic_value3
                    max_no = 1 - i
                else:
                    # print "ht1=%d,ht2=%d" % (max_handtype.type,htype.type)
                    mflag = libqp.texas_compare(max_handtype, htype)
                    if mflag < 0:
                        max_handtype.type = htype.type
                        max_handtype.logic_value1 = htype.logic_value1
                        max_handtype.logic_value2 = htype.logic_value2
                        max_handtype.logic_value3 = htype.logic_value3
                        max_no = 1 - i

                for j in range(0, libqp.hand_num(htresult)):
                    card = libqp.hand_get(htresult, j)
                    keyname = libqp.card_text(card)
                    dc.DrawBitmap(self.bmpPoker[keyname], rx, y, 0)
                    rx = rx + self.pokerOffsetW
                ht_x = rx + 10 + pokerW
                ht_y = y
                if htype.type == libqp.TEXAS_HIGHCARD:
                    htstr = "TEXAS_HIGHCARD"
                elif htype.type == libqp.TEXAS_PAIR1:
                    htstr = "TEXAS_PAIR1"
                elif htype.type == libqp.TEXAS_PAIR2:
                    htstr = "TEXAS_PAIR2"
                elif htype.type == libqp.TEXAS_THREE:
                    htstr = "TEXAS_THREE"
                elif htype.type == libqp.TEXAS_STRAIGHT:
                    htstr = "TEXAS_STRAIGHT"
                elif htype.type == libqp.TEXAS_FLUSH:
                    htstr = "TEXAS_FLUSH"
                elif htype.type == libqp.TEXAS_FULLHOUSE:
                    htstr = "TEXAS_FULLHOUSE"
                elif htype.type == libqp.TEXAS_FOUR:
                    htstr = "TEXAS_FOUR"
                elif htype.type == libqp.TEXAS_STRAIGHT_FLUSH:
                    htstr = "TEXAS_STRAIGHT_FLUSH"
                elif htype.type == libqp.TEXAS_ROYAL:
                    htstr = "TEXAS_ROYAL"
                else:
                    htstr = "%d" % htype.type
                dc.DrawText(htstr, ht_x, ht_y)
                libqp.hand_free(htresult)
                libqp.hand_free(hand_all)

        # draw five common card
        num = 0
        if self.texas.game_state == 2:
            num = 3
        if self.texas.game_state == 3:
            num = 4
        if self.texas.game_state == 4:
            num = 5
        x = (width - (num * pokerW + (num - 1) * 2)) / 2
        for i in range(0, num):
            card = libqp.texas_get_board(self.texas, i)
            keyname = libqp.card_text(card)
            dc.DrawBitmap(self.bmpPoker[keyname], x, 0, 0)
            x = x + pokerW + 2

        # info
        info = "state:%d\n" % (self.texas.game_state)
        if num >= 3:
            info += "max player:%d\n" % max_no

        # info += "curr player:%d\n" % (self.texas.curr_player_no)
        dc.DrawText(info, 0, 0)
コード例 #10
0
ファイル: test_ddz.py プロジェクト: github188/qipai
    def OnPaint(self, e):
        width, height = self.GetClientSize()
        
        if USE_BUFFERED_DC:
            dc = wx.BufferedPaintDC(self, self._Buffer)
        else:
            dc = wx.PaintDC(self)
        brBack = wx.Brush('#053154', wx.SOLID);
        dc.SetBackground(brBack)
        dc.Clear()
        
        pokerW, pokerH = self.bmpPoker['0'].GetSize()
        x = 0
        y = 0
           
        # draw player's hand cards
        dc.SetTextForeground(wx.WHITE)
        for i in range(0, 3):
            x = 0
            cp_no = self.ddz.curr_player_no
            playerid = "player%d" % (2 - i)
            dc.DrawText(playerid, x, self.rcHand[2-i].GetY())
            if cp_no == (2 - i):
                # draw arrow
                arlist = [(0,0), (8,8), (0,16)]
                dc.DrawPolygon(arlist, self.rcHand[2-i].GetX() - 10,
                    self.rcHand[2-i].GetY() + pokerH / 2 - 8)

            player = libqp.ddz_get_player(self.ddz, 2 - i)
            hand = libqp.ddz_get_player_hand(player)
            num = libqp.hand_num(hand)
            x = self.rcHand[2-i].GetX()
            y = self.rcHand[2-i].GetY()
            for j in range(0, num):
                card = libqp.hand_get(hand, j)
                keyname = libqp.card_text(card)
                if self.flag_up[j] > 0 and cp_no == (2 - i):
                    dc.DrawBitmap(self.bmpPoker[keyname], x, y - self.upH, 0)
                else:
                    dc.DrawBitmap(self.bmpPoker[keyname], x, y, 0)
                x = x + self.pokerOffsetW
        
        # draw 3 di
        x = width - 3 * pokerW - 2 * 2
        for i in range(0, 3):
            card = libqp.ddz_get_di(self.ddz, i)
            keyname = libqp.card_text(card)
            dc.DrawBitmap(self.bmpPoker[keyname],
                x, self.rcHand[0].GetY(), 0)
            x = x + pokerW + 1
        
        # draw last hand
        num = self.ddz.last_hand.num
        x = (width - ((num - 1) * self.pokerOffsetW + pokerW)) / 2
        for i in range(0, num):
            card = libqp.hand_get(self.ddz.last_hand, i)
            keyname = libqp.card_text(card)
            dc.DrawBitmap(self.bmpPoker[keyname], x, 0, 0)
            x = x + self.pokerOffsetW
        
        # info
        dz_no = self.ddz.landlord_no
        dz_call = libqp.ddz_landlord_call(self.ddz)
        info = "landlord:player%d\n" % (dz_no)
        info += "call:%d\n" % (dz_call)
        info += "state:%d\n" % (self.ddz.game_state)
        info += "last hand:%d" % (self.ddz.last_htype.type)
        info += ",%d\n" % (self.ddz.last_htype.logic_value1)
        dc.DrawText(info, 0, 0)
コード例 #11
0
ファイル: test_texas.py プロジェクト: isoundy000/qipai-2
    def OnPaint(self, e):
        width, height = self.GetClientSize()

        if USE_BUFFERED_DC:
            dc = wx.BufferedPaintDC(self, self._Buffer)
        else:
            dc = wx.PaintDC(self)
        brBack = wx.Brush('#053154', wx.SOLID)
        dc.SetBackground(brBack)
        dc.Clear()

        pokerW, pokerH = self.bmpPoker['0'].GetSize()
        x = 0
        y = 0

        max_no = 0
        max_handtype = libqp.hand_type()

        # draw player's hand cards
        dc.SetTextForeground(wx.WHITE)
        for i in range(0, 2):
            x = 0
            cp_no = self.texas.curr_player_no
            playerid = "player%d" % (1 - i)
            dc.DrawText(playerid, x, self.rcHand[1 - i].GetY())
            if cp_no == (1 - i):
                # draw arrow
                arlist = [(0, 0), (8, 8), (0, 16)]
                dc.DrawPolygon(arlist, self.rcHand[1 - i].GetX() - 10,
                               self.rcHand[1 - i].GetY() + pokerH / 2 - 8)

            player = libqp.texas_get_player(self.texas, 1 - i)
            hand = libqp.texas_get_player_hand(player)
            num = libqp.hand_num(hand)
            x = self.rcHand[1 - i].GetX()
            y = self.rcHand[1 - i].GetY()
            for j in range(0, num):
                card = libqp.hand_get(hand, j)
                keyname = libqp.card_text(card)
                if self.flag_up[j] > 0 and cp_no == (1 - i):
                    dc.DrawBitmap(self.bmpPoker[keyname], x, y - self.upH, 0)
                else:
                    dc.DrawBitmap(self.bmpPoker[keyname], x, y, 0)
                x = x + pokerW + 2

            if libqp.texas_get_state(self.texas) >= 2:
                rx = x + 10
                htresult = libqp.hand_new(5)
                hand_all = libqp.hand_new(7)
                libqp.texas_group(self.texas, 1 - i, hand_all)
                #libqp.hand_dump(hand_all, 7)
                htype = libqp.hand_type()
                libqp.hand_zero(htresult)
                r = libqp.texas_handtype(hand_all, htype, htresult)
                #print r,htype.logic_value1
                #libqp.hand_dump(htresult, 5)
                if i == 0:
                    max_handtype.type = htype.type
                    max_handtype.logic_value1 = htype.logic_value1
                    max_handtype.logic_value2 = htype.logic_value2
                    max_handtype.logic_value3 = htype.logic_value3
                    max_no = 1 - i
                else:
                    #print "ht1=%d,ht2=%d" % (max_handtype.type,htype.type)
                    mflag = libqp.texas_compare(max_handtype, htype)
                    if mflag < 0:
                        max_handtype.type = htype.type
                        max_handtype.logic_value1 = htype.logic_value1
                        max_handtype.logic_value2 = htype.logic_value2
                        max_handtype.logic_value3 = htype.logic_value3
                        max_no = 1 - i

                for j in range(0, libqp.hand_num(htresult)):
                    card = libqp.hand_get(htresult, j)
                    keyname = libqp.card_text(card)
                    dc.DrawBitmap(self.bmpPoker[keyname], rx, y, 0)
                    rx = rx + self.pokerOffsetW
                ht_x = rx + 10 + pokerW
                ht_y = y
                if htype.type == libqp.TEXAS_HIGHCARD:
                    htstr = "TEXAS_HIGHCARD"
                elif htype.type == libqp.TEXAS_PAIR1:
                    htstr = "TEXAS_PAIR1"
                elif htype.type == libqp.TEXAS_PAIR2:
                    htstr = "TEXAS_PAIR2"
                elif htype.type == libqp.TEXAS_THREE:
                    htstr = "TEXAS_THREE"
                elif htype.type == libqp.TEXAS_STRAIGHT:
                    htstr = "TEXAS_STRAIGHT"
                elif htype.type == libqp.TEXAS_FLUSH:
                    htstr = "TEXAS_FLUSH"
                elif htype.type == libqp.TEXAS_FULLHOUSE:
                    htstr = "TEXAS_FULLHOUSE"
                elif htype.type == libqp.TEXAS_FOUR:
                    htstr = "TEXAS_FOUR"
                elif htype.type == libqp.TEXAS_STRAIGHT_FLUSH:
                    htstr = "TEXAS_STRAIGHT_FLUSH"
                elif htype.type == libqp.TEXAS_ROYAL:
                    htstr = "TEXAS_ROYAL"
                else:
                    htstr = "%d" % htype.type
                dc.DrawText(htstr, ht_x, ht_y)
                libqp.hand_free(htresult)
                libqp.hand_free(hand_all)

        # draw five common card
        num = 0
        if self.texas.game_state == 2:
            num = 3
        if self.texas.game_state == 3:
            num = 4
        if self.texas.game_state == 4:
            num = 5
        x = (width - (num * pokerW + (num - 1) * 2)) / 2
        for i in range(0, num):
            card = libqp.texas_get_board(self.texas, i)
            keyname = libqp.card_text(card)
            dc.DrawBitmap(self.bmpPoker[keyname], x, 0, 0)
            x = x + pokerW + 2

        # info
        info = "state:%d\n" % (self.texas.game_state)
        if num >= 3:
            info += "max player:%d\n" % max_no

        #info += "curr player:%d\n" % (self.texas.curr_player_no)
        dc.DrawText(info, 0, 0)
コード例 #12
0
    def OnPaint(self, e):
        width, height = self.GetClientSize()

        if USE_BUFFERED_DC:
            dc = wx.BufferedPaintDC(self, self._Buffer)
        else:
            dc = wx.PaintDC(self)
        brBack = wx.Brush('#053154', wx.SOLID)
        dc.SetBackground(brBack)
        dc.Clear()

        pokerW, pokerH = self.bmpPoker['0'].GetSize()
        x = 0
        y = 0

        # draw player's hand cards
        dc.SetTextForeground(wx.WHITE)
        for i in range(0, 3):
            x = 0
            cp_no = self.ddz.curr_player_no
            playerid = "player%d" % (2 - i)
            dc.DrawText(playerid, x, self.rcHand[2 - i].GetY())
            if cp_no == (2 - i):
                # draw arrow
                arlist = [(0, 0), (8, 8), (0, 16)]
                dc.DrawPolygon(arlist, self.rcHand[2 - i].GetX() - 10,
                               self.rcHand[2 - i].GetY() + pokerH / 2 - 8)

            player = libqp.ddz_get_player(self.ddz, 2 - i)
            hand = libqp.ddz_get_player_hand(player)
            num = libqp.hand_num(hand)
            x = self.rcHand[2 - i].GetX()
            y = self.rcHand[2 - i].GetY()
            for j in range(0, num):
                card = libqp.hand_get(hand, j)
                keyname = libqp.card_text(card)
                if self.flag_up[j] > 0 and cp_no == (2 - i):
                    dc.DrawBitmap(self.bmpPoker[keyname], x, y - self.upH, 0)
                else:
                    dc.DrawBitmap(self.bmpPoker[keyname], x, y, 0)
                x = x + self.pokerOffsetW

        # draw 3 di
        x = width - 3 * pokerW - 2 * 2
        for i in range(0, 3):
            card = libqp.ddz_get_di(self.ddz, i)
            keyname = libqp.card_text(card)
            dc.DrawBitmap(self.bmpPoker[keyname], x, self.rcHand[0].GetY(), 0)
            x = x + pokerW + 1

        # draw last hand
        num = self.ddz.last_hand.num
        x = (width - ((num - 1) * self.pokerOffsetW + pokerW)) / 2
        for i in range(0, num):
            card = libqp.hand_get(self.ddz.last_hand, i)
            keyname = libqp.card_text(card)
            dc.DrawBitmap(self.bmpPoker[keyname], x, 0, 0)
            x = x + self.pokerOffsetW

        # info
        dz_no = self.ddz.landlord_no
        dz_call = libqp.ddz_landlord_call(self.ddz)
        info = "landlord:player%d\n" % (dz_no)
        info += "call:%d\n" % (dz_call)
        info += "state:%d\n" % (self.ddz.game_state)
        info += "last hand:%d" % (self.ddz.last_htype.type)
        info += ",%d\n" % (self.ddz.last_htype.logic_value1)
        dc.DrawText(info, 0, 0)