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


Python card.Card类代码示例

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


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

示例1: _initiate_opening_hands

 def _initiate_opening_hands(self):
     for rank in Card.STR_RANKS:
         for suit,val in Card.CHAR_SUIT_TO_INT_SUIT.items():
             John._FULL_DECK.append(Card.new(rank + suit))
     for combo in itertools.combinations(John._FULL_DECK, 2):
         John._ALL_HOLE_CARDS.append(combo)
         cards = Card.int_to_str(combo[0]) + Card.int_to_str(combo[1])
         c1_rank, c1_suit, c2_rank, c2_suit = cards
         # Check for pairs
         if c1_rank == c2_rank:
             for rank in Card.STR_RANKS:
                 if c1_rank == rank:
                     if rank not in John._PAIRS:
                         John._PAIRS[rank] = set()
                     John._PAIRS[rank].add(combo)
         else:
             for rank_pair in itertools.combinations(Card.STR_RANKS[::-1], 2):
                 ranks = rank_pair[0] + rank_pair[1]
                 if rank_pair == (c2_rank, c1_rank) or rank_pair == (c1_rank, c2_rank):
                     if c1_suit == c2_suit:  # Suited!
                         if ranks not in John._SUITED:
                             John._SUITED[ranks] = set()
                         John._SUITED[ranks].add(combo)
                         if Card.STR_RANKS.index(rank_pair[0]) == 1 + Card.STR_RANKS.index(rank_pair[1]):
                             if ranks not in John._SUITED_CONNECTORS:
                                 John._SUITED_CONNECTORS[ranks] = set()
                             John._SUITED_CONNECTORS[ranks].add(combo)
                         # DEBUGGING
                         # print(ranks, Card.int_to_str(combo[0]), Card.int_to_str(combo[1]))
                     else:
                         if ranks not in John._UNSUITED:
                             John._UNSUITED[ranks] = set()
                         John._UNSUITED[ranks].add(combo)
开发者ID:simonbw,项目名称:poker-player,代码行数:33,代码来源:john.py

示例2: setup

 def setup(self):
     words = "abcdefghijklmnopqrstuvwxy"
     for i in range(25):
         card = Card()
         card.setWord(words[i])
         self.ids.grid.add_widget(card)
         self.cards.append(card)
开发者ID:raptorinsurance,项目名称:codenames,代码行数:7,代码来源:card_grid.py

示例3: __init__

 def __init__(self,channel_id,card_number):
     Card.__init__(self,channel_id,card_number)
     for port_id in range(14):
         self.in_ports.append(InPort(channel_id,card_number,port_id,0))
         self.out_ports.append(OutPort(channel_id,card_number,port_id,0))
     self.raw_out_ports = '00'
     self.raw_in_ports = '00'
开发者ID:juanchitot,项目名称:domo,代码行数:7,代码来源:digital.py

示例4: __parse_card_item

 def __parse_card_item(self, text):
     card = Card()
     card.multiverseid = int(multiverseid_re.search(text).group(1))
     card.name = name_re.search(text).group(1)
     card.language = LANG_DICT[language_re.search(text).group(1)]
     # other attributes are set by Card.add_translation()
     return card
开发者ID:nuxgu,项目名称:magic_db,代码行数:7,代码来源:languages.py

示例5: setCard

    def setCard(self, card):
        """
        Set card as dictionary

            card: (dict) -- Dictionary of card

        Format:
        {"name":      <card name>,
         "lines":    (line1,
                      line2,
                       ...),
         "arg":       <argument>}

        Example:
        {"name":      "k_points",
         "lines":     ("4 4 4 1 1 1",),
         "arg":       "automatic"}
        """
        if not card:    # Ignore empty card 
            return

        self._checkDictFormat(card, CARD_KEYS, CARD_REQ)
        
        c       = Card( card["name"],
                        arg = ifelse(card.has_key("arg"), card.get("arg"), None))
        if card.has_key("lines"):
            c.setLines(card["lines"])
            
        self._fcards.append(c)
开发者ID:danse-inelastic,项目名称:AbInitio,代码行数:29,代码来源:filter.py

示例6: __init__

    def __init__(self, name, 
                 imageFileName = None,
                 struggles = None,
                 *args, **kwargs):
        Card.__init__(self, name, imageFileName, *args, **kwargs)
        if imageFileName != None:
            self.image = StoryImage(imageFileName)
        self.committed = {}
        self.success = {}
        self.rect = {}
        self.game = None
        self.Player1 = None
        self.Player2 = None

        if struggles is None:
            struggles = []
            struggles.append(TerrorStruggle())
            struggles.append(CombatStruggle())
            struggles.append(ArcaneStruggle())
            struggles.append(InvestigationStruggle())
            struggles.append(SkillStruggle())

        for struggle in struggles:
            struggle.addToStory(self)
        self.struggles = struggles
开发者ID:frrmack,项目名称:CallofCthulhu,代码行数:25,代码来源:story.py

示例7: _convertCards

    def _convertCards(self, cards):
        for cname in cards.keys():
            c   = Card(cname)
            c.setArg(cards[cname]["args"])
            for l in cards[cname]["values"]:
                c.addLine(l)

            self.cards[cname]    = c
开发者ID:danse-inelastic,项目名称:AbInitio,代码行数:8,代码来源:qeparser.py

示例8: __setattr__

 def __setattr__(self,name,value):
     port = re.match('^port_(\d+)', name) 
     if port  :
         port_pos = int((port.groups())[0])
         self.__pending_write = 1 
         self.__out_ports[port_pos] = str(value)
     else:
         Card.__setattr__(self,name,value)
开发者ID:juanchitot,项目名称:domo,代码行数:8,代码来源:digital.py

示例9: __init__

 def __init__(self,id,serial):
     Card.__init__(self,id,serial)
     self.id = id
     self.__in_ports = ['0']*14
     self.__out_ports = ['0']*14
     self.__raw_out_ports = ''
     self.__raw_in_ports = ''
     self.__pending_write = 0
开发者ID:juanchitot,项目名称:domo,代码行数:8,代码来源:digital.py

示例10: test_basicCardCreation

def test_basicCardCreation():
	"""
	Create some basic cards and make sure they come out ok.
	"""
	c = Card("A","Diamond")
	assert c.getName() == "A"
	assert c.getValue() == [1,11]
	assert c.getSuit() == "Diamond"
开发者ID:Owlz,项目名称:pyBlackJack,代码行数:8,代码来源:test_card.py

示例11: _validate

 def _validate(self):
     all_cards = set()
     for hand in self.hands:
         for suit in SUITS:
             for card in hand.cards_in_suit(suit):
                 card_identifier = Card.identifier_for_card(suit, card)
                 assert card_identifier not in all_cards, ("Already seen %s" % Card.card_name(suit, card))
                 all_cards.add(card_identifier)
     assert len(all_cards) == 52
开发者ID:abortz,项目名称:saycbridge,代码行数:9,代码来源:deal.py

示例12: draw

 def draw(self, pos):
     Card.draw(self, pos)
     x,y = pos
     for i in range(self.success[self.Player1]):
         pos = x + i*TOKENEDGE, y+CARDWIDTH-TOKENEDGE
         self.successTokenBag[i].draw(pos)
     for i in range(self.success[self.Player2]):
         pos = x + i*TOKENEDGE, y
         self.successTokenBag[i+5].draw(pos)
开发者ID:frrmack,项目名称:CallofCthulhu,代码行数:9,代码来源:story.py

示例13: test_value_setter_invalid

 def test_value_setter_invalid(self):
     invalid_values = ['Kings', 'Jack', 'Queen', '0', -1, 0, 14, random.randint(15,100), random.randint(-100, -1)]
     for value in invalid_values:
         card = Card(3, "diamonds")
         try:
             card.value = value
             self.assert_(False)
         except ValueError as e:
             self.assert_(isinstance(e, ValueError))
开发者ID:divyekapoor,项目名称:Court-Piece,代码行数:9,代码来源:card_tests.py

示例14: prompt_add_card

 def prompt_add_card(self):
     new_card = Card()
     for dimension in self.dimensions:
         state = ""
         while len(state) == 0:
             state = raw_input("Enter value for " + dimension + ">> ")
         # Adds state at dimension for the new card
         new_card.add_dimension(dimension, state.lower().strip())
     # Add the new card to the colleciton
     self.collection.append(new_card)
开发者ID:ryanml,项目名称:SetSolver,代码行数:10,代码来源:main.py

示例15: __init__

    def __init__(self):
        self.cardfile = bsddb.hashopen("./data/card_images.db", "c")
        self.back = pyglet.resource.texture("back.jpg")
        self.notfound = pyglet.resource.texture("notfound.jpg")
        self.combat = pyglet.resource.texture("combat.png")
        self.triggered = pyglet.resource.texture("triggered.png")
        self.activated = pyglet.resource.texture("activated.png")

        # XXX This is a hack
        Card.build_fbo()
开发者ID:Incantus,项目名称:incantus,代码行数:10,代码来源:CardLibrary.py


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