当前位置: 首页>>代码示例>>Python>>正文


Python Card类代码示例

本文整理汇总了Python中Card的典型用法代码示例。如果您正苦于以下问题:Python Card类的具体用法?Python Card怎么用?Python Card使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Card类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

 def __init__(self, interface):
     self.player = Card()
     self.computer = Card()
     self.pscore = 0    #player's score
     self.cscore = 0    #computer's score
     self.interface = interface
     self.hit = 0      # times of player's hitme
开发者ID:ethanhan2014,项目名称:BlackJack,代码行数:7,代码来源:blackjackapp.py

示例2: assembleHandsPlayers

    def assembleHandsPlayers(self, hand):
        #street0VPI/vpip already called in Hand
        # sawShowdown is calculated in playersAtStreetX, as that calculation gives us a convenient list of names

        #hand.players = [[seat, name, chips],[seat, name, chips]]
        for player in hand.players:
            self.handsplayers[player[1]]['seatNo'] = player[0]
            self.handsplayers[player[1]]['startCash'] = int(100 * Decimal(player[2]))
            self.handsplayers[player[1]]['sitout'] = False #TODO: implement actual sitout detection
            if hand.gametype["type"]=="tour":
                self.handsplayers[player[1]]['tourneyTypeId']=hand.tourneyTypeId
                self.handsplayers[player[1]]['tourneysPlayersIds'] = hand.tourneysPlayersIds[player[1]]
            else:
                self.handsplayers[player[1]]['tourneysPlayersIds'] = None

        # XXX: enumerate(list, start=x) is python 2.6 syntax; 'start'
        #for i, street in enumerate(hand.actionStreets[2:], start=1):
        for i, street in enumerate(hand.actionStreets[2:]):
            self.seen(self.hand, i+1)

        for i, street in enumerate(hand.actionStreets[1:]):
            self.aggr(self.hand, i)
            self.calls(self.hand, i)
            self.bets(self.hand, i)
            if i>0:
                self.folds(self.hand, i)

        # Winnings is a non-negative value of money collected from the pot, which already includes the
        # rake taken out. hand.collectees is Decimal, database requires cents
        for player in hand.collectees:
            self.handsplayers[player]['winnings'] = int(100 * hand.collectees[player])
            #FIXME: This is pretty dodgy, rake = hand.rake/#collectees
            # You can really only pay rake when you collect money, but
            # different sites calculate rake differently.
            # Should be fine for split-pots, but won't be accurate for multi-way pots
            self.handsplayers[player]['rake'] = int(100* hand.rake)/len(hand.collectees)
            if self.handsplayers[player]['street1Seen'] == True:
                self.handsplayers[player]['wonWhenSeenStreet1'] = 1.0
            if self.handsplayers[player]['sawShowdown'] == True:
                self.handsplayers[player]['wonAtSD'] = 1.0

        for player in hand.pot.committed:
            self.handsplayers[player]['totalProfit'] = int(self.handsplayers[player]['winnings'] - (100*hand.pot.committed[player])- (100*hand.pot.common[player]))

        self.calcCBets(hand)

        for player in hand.players:
            hcs = hand.join_holecards(player[1], asList=True)
            hcs = hcs + [u'0x', u'0x', u'0x', u'0x', u'0x']
            #for i, card in enumerate(hcs[:7], 1): #Python 2.6 syntax
            #    self.handsplayers[player[1]]['card%s' % i] = Card.encodeCard(card)
            for i, card in enumerate(hcs[:7]):
                self.handsplayers[player[1]]['card%s' % (i+1)] = Card.encodeCard(card)
            self.handsplayers[player[1]]['startCards'] = Card.calcStartCards(hand, player[1])

        self.setPositions(hand)
        self.calcCheckCallRaise(hand)
        self.calc34BetStreet0(hand)
        self.calcSteals(hand)
开发者ID:lastpoet,项目名称:fpdb-lastpoet,代码行数:59,代码来源:DerivedStats.py

示例3: createCard

def createCard(cardId):
    card = CardById(cardId)
    cardtype = cardType(card)
    _card = Card(id(card), name(card), cardtype, manaCost(card))
    if cardtype == Cardtype.MINION:
        _card._attack = attackValue(card)
        _card._health = healthValue(card)
    if cardtype == Cardtype.HERO:
        _card._health = healthValue(card)
    return _card
开发者ID:Emsibil,项目名称:Bachelor,代码行数:10,代码来源:Util.py

示例4: assembleHands

    def assembleHands(self, hand):
        self.hands['tableName']     = hand.tablename
        self.hands['siteHandNo']    = hand.handid
        self.hands['gametypeId']    = None                    # Leave None, handled later after checking db
        self.hands['sessionId']     = None                    # Leave None, added later if caching sessions
        self.hands['gameSessionId'] = None                    # Leave None, added later if caching sessions
        self.hands['startTime']     = hand.startTime          # format this!
        self.hands['importTime']    = None
        self.hands['seats']         = self.countPlayers(hand) 
        #self.hands['maxSeats']      = hand.maxseats
        self.hands['texture']       = None                    # No calculation done for this yet.
        self.hands['tourneyId']     = hand.tourneyId

        # This (i think...) is correct for both stud and flop games, as hand.board['street'] disappears, and
        # those values remain default in stud.
        boardcards = []
        for street in hand.communityStreets:
            boardcards += hand.board[street]
        boardcards += [u'0x', u'0x', u'0x', u'0x', u'0x']
        cards = [Card.encodeCard(c) for c in boardcards[0:5]]
        self.hands['boardcard1'] = cards[0]
        self.hands['boardcard2'] = cards[1]
        self.hands['boardcard3'] = cards[2]
        self.hands['boardcard4'] = cards[3]
        self.hands['boardcard5'] = cards[4]
        
        self.hands['boards']     = []
        self.hands['runIt']      = False           
        for i in range(hand.runItTimes):
            self.hands['runIt']  = True
            boardcards = []
            for street in hand.communityStreets:
                boardId = i+1
                street_i = street + str(boardId)
                if street_i in hand.board:
                    boardcards += hand.board[street_i]
            boardcards = [u'0x', u'0x', u'0x', u'0x', u'0x'] + boardcards
            cards = [Card.encodeCard(c) for c in boardcards[-5:]]
            self.hands['boards'] += [[boardId] + cards]

        #print "DEBUG: self.getStreetTotals = (%s, %s, %s, %s, %s)" %  hand.getStreetTotals()
        totals = hand.getStreetTotals()
        totals = [int(100*i) for i in totals]
        self.hands['street1Pot']  = totals[0]
        self.hands['street2Pot']  = totals[1]
        self.hands['street3Pot']  = totals[2]
        self.hands['street4Pot']  = totals[3]
        self.hands['showdownPot'] = totals[4]

        self.vpip(hand) # Gives playersVpi (num of players vpip)
        #print "DEBUG: vpip: %s" %(self.hands['playersVpi'])
        self.playersAtStreetX(hand) # Gives playersAtStreet1..4 and Showdown
        #print "DEBUG: playersAtStreet 1:'%s' 2:'%s' 3:'%s' 4:'%s'" %(self.hands['playersAtStreet1'],self.hands['playersAtStreet2'],self.hands['playersAtStreet3'],self.hands['playersAtStreet4'])
        self.streetXRaises(hand)
开发者ID:kangaderoo,项目名称:fpdb-kangaderoo,代码行数:54,代码来源:DerivedStats.py

示例5: get_hero_cards

    def get_hero_cards(self, hero, cards):
        """Formats the hero cards for inclusion in the tree."""
        trans = ('0', 'A', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A')
        if hero == '':
            return "xxxxxx"
        else:
#    find the hero's seat from the stat_dict
            for stat in self.parent.hud.stat_dict.itervalues():
                if stat['screen_name'] == hero:
                    return Card.valueSuitFromCard(self.parent.hud.cards[stat['seat']][0]) +\
                           Card.valueSuitFromCard(self.parent.hud.cards[stat['seat']][1]) +\
                           Card.valueSuitFromCard(self.parent.hud.cards[stat['seat']][2])
        return "xxxxxx"
开发者ID:Fulvio75,项目名称:fpdb,代码行数:13,代码来源:Mucked.py

示例6: card_renderer_cell_func

def card_renderer_cell_func(tree_column, cell, model, tree_iter, data):
    card_width  = 30
    card_height = 42
    col = data
    coldata = model.get_value(tree_iter, col)
    if coldata == None or coldata == '':
        coldata = "0x"
    coldata = coldata.replace("'","")
    coldata = coldata.replace("[","")
    coldata = coldata.replace("]","")
    coldata = coldata.replace("'","")
    coldata = coldata.replace(",","")
    #print "DEBUG: coldata: %s" % (coldata)
    cards = [Card.encodeCard(c) for c in coldata.split(' ')]
    n_cards = len(cards)

    #print "DEBUG: cards: %s" % cards
    pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True, 8, card_width * n_cards, card_height)
    if pixbuf:
        x = 0 # x coord where the next card starts in scratch
        for card in cards:
            if card == None or card ==0:
                card_images[0].copy_area(0, 0, card_width, card_height, pixbuf, x, 0)

            card_images[card].copy_area(0, 0, card_width, card_height, pixbuf, x, 0)
            x = x + card_width
    cell.set_property('pixbuf', pixbuf)
开发者ID:Fulvio75,项目名称:fpdb,代码行数:27,代码来源:GuiHandViewer.py

示例7: process_bind_param

 def process_bind_param(self, value, dialect):
     if value is None or isinstance(value, int):
         return value
     elif isinstance(value, basestring) and len(value) == 2:
         return Card.encodeCard(str(value))
     else:
         raise Exception, "Incorrect card value: " + repr(value)
开发者ID:sigmike,项目名称:fpdb,代码行数:7,代码来源:AlchemyFacilities.py

示例8: is_row_in_card_filter

    def is_row_in_card_filter(self, row):
        """ Returns true if the cards of the given row are in the card filter """
        #Does work but all cards that should NOT be displayed have to be clicked.
        card_filter = self.filters.getCards() 
        hcs = row[self.colnum['Street0']].split(' ')
        
        if '0x' in hcs:      #if cards are unknown return True
            return True
        
        gt = row[self.colnum['Game']]

        if gt not in ('holdem', 'omahahi', 'omahahilo'): return True
        # Holdem: Compare the real start cards to the selected filter (ie. AhKh = AKs)
        value1 = Card.card_map[hcs[0][0]]
        value2 = Card.card_map[hcs[1][0]]
        idx = Card.twoStartCards(value1, hcs[0][1], value2, hcs[1][1])
        abbr = Card.twoStartCardString(idx)
        return False if card_filter[abbr] == False else True
开发者ID:Fulvio75,项目名称:fpdb,代码行数:18,代码来源:GuiHandViewer.py

示例9: __init__

    def __init__(self, deck):
        """A hand is simply the first five cards in the deck, if there are
        five cards available. If not, return None."""

        
        hand = 5              # Number of cards in a hand (int)
        self._mysuits = [0] * 4     # a list of 4 zeros used for evaluation
        self._myranks = [0] * 13    # a list of 13 zeros used for evaluation

        #checks if there are enough cards in deck for a hand
        if len(deck) >= hand:
            
            #list to contain cards in hand
            self._cards = []

            #for each card in hand
            for cards in range(hand):

                #deal a new card
                newCard = deck.deal()
                self._cards.append(newCard)

                #Get suit and rank for each card in hand
                suit = Card.getSuit(newCard)
                rank = Card.getRank(newCard)

                #increase rank count for evaluation
                rank -= 1
                self._myranks[rank] += 1

                #increase suit count for evaluation
                if suit == "Spades":
                    self._mysuits[0] += 1
                if suit == "Diamonds":
                    self._mysuits[1] += 1
                if suit == "Hearts":
                    self._mysuits[2] += 1
                if suit == "Clubs":
                    self._mysuits[3] += 1               

        else:
            return None
开发者ID:Taylor4484,项目名称:CS-313E---Elements-of-Software-Design,代码行数:42,代码来源:Hand.py

示例10: update_contents

    def update_contents(self, container, i):

        if not self.hud.cards.has_key(i): return
        
        cards = self.hud.cards[i]
        # Here we want to know how many cards the given seat showed;
        # board is considered a seat, and has the id 'common'
        # 'cards' on the other hand is a tuple. The format is:
        # (card_num, card_num, ...)
        n_cards = valid_cards(cards)
        if n_cards > 1:
#    scratch is a working pixbuf, used to assemble the image
            scratch = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB,
                                        has_alpha=True, bits_per_sample=8,
                                        width=int(self.card_width)*n_cards,
                                        height=int(self.card_height))
            x = 0 # x coord where the next card starts in scratch
            for card in cards:
#    concatenate each card image to scratch
                # flop game never(?) has unknown cards.
                # FIXME: if "show one and fold" ever becomes an option,
                # this needs to be changed
                if card == None or card ==0:
                    break

                # This gives us the card symbol again
                (_rank, _suit) = Card.valueSuitFromCard(card)
                _rank = Card.card_map[_rank]
                # We copy the image data. Technically we __could__ use
                # the pixmap directly but it seems there are some subtle
                # races and explicitly creating a new pixbuf seems to
                # work around most of them.
                #
                # We also should not use copy_area() but it is far
                # easier to work with than _render_to_drawable()
                px = self.card_images[_suit][_rank].copy()
                px.copy_area(0, 0,
                        px.get_width(), px.get_height(),
                        scratch, x, 0)
                x += px.get_width()
                
            if container is not None:
                container.seen_cards.set_from_pixbuf(scratch)
                container.resize(1,1)
                container.move(self.positions[i][0] + self.hud.table.x,
                            self.positions[i][1] + self.hud.table.y)   # here is where I move back
                container.show()

            self.displayed = True
            if i != "common":
                id = self.get_id_from_seat(i)
                # sc: had KeyError here with new table so added id != None test as a guess:
                if id is not None:
                    self.m_windows[i].eb.set_tooltip_text(self.hud.stat_dict[id]['screen_name'])
开发者ID:Fulvio75,项目名称:fpdb,代码行数:54,代码来源:Mucked.py

示例11: init_card_images

    def init_card_images(self, config):
        suits = ('s', 'h', 'd', 'c')
        ranks = (14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2)

        for j in range(0, 13):
            for i in range(0, 4):
                loc = Card.cardFromValueSuit(ranks[j], suits[i])
                card_im = self.deck_inst.card(suits[i], ranks[j])
                #must use copy(), method_instance not usable in global variable
                card_images[loc] = card_im.copy()
        back_im = self.deck_inst.back()
        card_images[0] = back_im.copy()
        return card_images
开发者ID:Fulvio75,项目名称:fpdb,代码行数:13,代码来源:GuiReplayer.py

示例12: get_card_images

    def get_card_images(self):

        card_images = 53 * [0]
        suits = ('s', 'h', 'd', 'c')
        ranks = (14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2)
        deckimg = self.params['deck']
        try:
            pb = gtk.gdk.pixbuf_new_from_file(self.config.execution_path(deckimg))
        except:
            stockpath = '/usr/share/python-fpdb/' + deckimg
            pb = gtk.gdk.pixbuf_new_from_file(stockpath)
        
        for j in range(0, 13):
            for i in range(0, 4):
                card_images[Card.cardFromValueSuit(ranks[j], suits[i])] = self.cropper(pb, i, j)
        temp_pb = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, pb.get_has_alpha(), pb.get_bits_per_sample(),  30,  42)
#    also pick out a card back and store in [0]
        card_images[0] = self.cropper(pb, 2, 13)
        return(card_images)
开发者ID:kangaderoo,项目名称:fpdb-grindi,代码行数:19,代码来源:Mucked.py

示例13: get_card_images

    def get_card_images(self, card_width=30, card_height=42):

        card_images = 53 * [0]
        suits = ('s', 'h', 'd', 'c')
        ranks = (14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2)
        deckimg = self.params['deck']
        try:
            pb = gtk.gdk.pixbuf_new_from_file(self.config.execution_path(deckimg))
        except:
            #FIXME: this can't be right? /usr will not exist on windows
            stockpath = '/usr/share/python-fpdb/' + deckimg
            pb = gtk.gdk.pixbuf_new_from_file(stockpath)
        
        for j in range(0, 13):
            for i in range(0, 4):
                card_images[Card.cardFromValueSuit(ranks[j], suits[i])] = self.cropper(pb, i, j, card_width, card_height)
#    also pick out a card back and store in [0]
        card_images[0] = self.cropper(pb, 2, 13, card_width, card_height)
        return(card_images)
开发者ID:CountLuckula,项目名称:FPDB-for-OSX,代码行数:19,代码来源:Mucked.py

示例14: update_gui

    def update_gui(self, new_hand_id):
        self.clear()
        for c, cards in self.parent.hud.cards.iteritems():
            if c == 'common': continue
            self.grid_contents[(1, c - 1)].set_text(self.get_screen_name(c))
            for i in ((0, cards[0]), (1, cards[1]), (2, cards[2]), (3, cards[3]), 
                      (4, cards[4]), (5, cards[5]), (6, cards[6])):
                if not i[1] == 0:
                    # Pixmaps are stored in dict with rank+suit keys
                    (_rank, _suit) = Card.valueSuitFromCard(i[1])
                    _rank = Card.card_map[_rank]
                    px = self.card_images[_suit][_rank].copy()
                    self.seen_cards[(i[0], c - 1)].set_from_pixbuf(px)
##    action in tool tips for 3rd street cards
        for c in (0, 1, 2):
            for r in range(0, self.rows):
                #self.eb[(c, r)].set_tooltip_text(self.tips[0])
                pass

#    action in tools tips for later streets
        round_to_col = (0, 3, 4, 5, 6)
开发者ID:Fulvio75,项目名称:fpdb,代码行数:21,代码来源:Mucked.py

示例15: assembleHands

    def assembleHands(self, hand):
        self.hands['tableName']  = hand.tablename
        self.hands['siteHandNo'] = hand.handid
        self.hands['gametypeId'] = None                     # Leave None, handled later after checking db
        self.hands['handStart']  = hand.starttime           # format this!
        self.hands['importTime'] = None
        self.hands['seats']      = self.countPlayers(hand) 
        self.hands['maxSeats']   = hand.maxseats
        self.hands['texture']    = None                     # No calculation done for this yet.

        # This (i think...) is correct for both stud and flop games, as hand.board['street'] disappears, and
        # those values remain default in stud.
        boardcards = []
        for street in hand.communityStreets:
            boardcards += hand.board[street]
        boardcards += [u'0x', u'0x', u'0x', u'0x', u'0x']
        cards = [Card.encodeCard(c) for c in boardcards[0:5]]
        self.hands['boardcard1'] = cards[0]
        self.hands['boardcard2'] = cards[1]
        self.hands['boardcard3'] = cards[2]
        self.hands['boardcard4'] = cards[3]
        self.hands['boardcard5'] = cards[4]

        #print "DEBUG: self.getStreetTotals = (%s, %s, %s, %s, %s)" %  hand.getStreetTotals()
        totals = hand.getStreetTotals()
        totals = [int(100*i) for i in totals]
        self.hands['street1Pot']  = totals[0]
        self.hands['street2Pot']  = totals[1]
        self.hands['street3Pot']  = totals[2]
        self.hands['street4Pot']  = totals[3]
        self.hands['showdownPot'] = totals[4]

        self.vpip(hand) # Gives playersVpi (num of players vpip)
        #print "DEBUG: vpip: %s" %(self.hands['playersVpi'])
        self.playersAtStreetX(hand) # Gives playersAtStreet1..4 and Showdown
        #print "DEBUG: playersAtStreet 1:'%s' 2:'%s' 3:'%s' 4:'%s'" %(self.hands['playersAtStreet1'],self.hands['playersAtStreet2'],self.hands['playersAtStreet3'],self.hands['playersAtStreet4'])
        self.streetXRaises(hand) # Empty function currently
开发者ID:kangaderoo,项目名称:fpdb-grindi,代码行数:37,代码来源:DerivedStats.py


注:本文中的Card类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。