本文整理汇总了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)
示例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)
示例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'
示例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
示例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)
示例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
示例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
示例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)
示例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
示例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"
示例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
示例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)
示例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))
示例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)
示例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()