本文整理汇总了Python中Card.cardFromValueSuit方法的典型用法代码示例。如果您正苦于以下问题:Python Card.cardFromValueSuit方法的具体用法?Python Card.cardFromValueSuit怎么用?Python Card.cardFromValueSuit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Card
的用法示例。
在下文中一共展示了Card.cardFromValueSuit方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: init_card_images
# 需要导入模块: import Card [as 别名]
# 或者: from Card import cardFromValueSuit [as 别名]
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
示例2: get_card_images
# 需要导入模块: import Card [as 别名]
# 或者: from Card import cardFromValueSuit [as 别名]
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)
示例3: get_card_images
# 需要导入模块: import Card [as 别名]
# 或者: from Card import cardFromValueSuit [as 别名]
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)
示例4: area_expose
# 需要导入模块: import Card [as 别名]
# 或者: from Card import cardFromValueSuit [as 别名]
def area_expose(self, area, event):
self.style = self.area.get_style()
self.gc = self.style.fg_gc[gtk.STATE_NORMAL]
if self.tableImage is None or self.playerBackdrop is None:
try:
self.playerBackdrop = gtk.gdk.pixbuf_new_from_file(os.path.join(self.conf.graphics_path, u"playerbackdrop.png"))
self.tableImage = gtk.gdk.pixbuf_new_from_file(os.path.join(self.conf.graphics_path, u"Table.png"))
self.area.set_size_request(self.tableImage.get_width(), self.tableImage.get_height())
except:
return
if self.cardImages is None:
self.cardwidth = CARD_WIDTH
self.cardheight = CARD_HEIGHT
self.cardImages = [gtk.gdk.Pixmap(self.area.window, self.cardwidth, self.cardheight) for i in range(53)]
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):
index = Card.cardFromValueSuit(ranks[j], suits[i])
image = self.deck_inst.card(suits[i], ranks[j])
self.cardImages[index].draw_pixbuf(self.gc, image, 0, 0, 0, 0, -1, -1)
back_im = self.deck_inst.back()
self.cardImages[0].draw_pixbuf(self.gc, back_im, 0, 0, 0, 0, -1,-1)
self.area.window.draw_pixbuf(self.gc, self.tableImage, 0, 0, 0, 0)
if len(self.states) == 0:
return
state = self.states[int(self.state.get_value())]
padding = 6
communityLeft = int(self.tableImage.get_width() / 2 - 2.5 * self.cardwidth - 2 * padding)
communityTop = int(self.tableImage.get_height() / 2 - 1.5 * self.cardheight)
cm = self.gc.get_colormap() #create colormap toi be able to play with colours
color = cm.alloc_color("white") #defaults to black
self.gc.set_foreground(color)
convertx = lambda x: int(x * self.tableImage.get_width() * 0.8) + self.tableImage.get_width() / 2
converty = lambda y: int(y * self.tableImage.get_height() * 0.6) + self.tableImage.get_height() / 2
for player in state.players.values():
playerx = convertx(player.x)
playery = converty(player.y)
self.area.window.draw_pixbuf(self.gc, self.playerBackdrop, 0, 0, playerx - self.playerBackdrop.get_width() / 2, playery - padding / 2)
if player.action=="folds":
color = cm.alloc_color("grey") #player has folded => greyed out
self.gc.set_foreground(color)
else:
color = cm.alloc_color("white") #player is live
self.gc.set_foreground(color)
if state.gametype == 'holdem':
cardIndex = Card.encodeCard(player.holecards[0:2])
self.area.window.draw_drawable(self.gc, self.cardImages[cardIndex], 0, 0, playerx - self.cardwidth - padding / 2, playery - self.cardheight, -1, -1)
cardIndex = Card.encodeCard(player.holecards[3:5])
self.area.window.draw_drawable(self.gc, self.cardImages[cardIndex], 0, 0, playerx + padding / 2, playery - self.cardheight, -1, -1)
elif state.gametype in ('omahahi', 'omahahilo'):
cardIndex = Card.encodeCard(player.holecards[0:2])
self.area.window.draw_drawable(self.gc, self.cardImages[cardIndex], 0, 0, playerx - 2 * self.cardwidth - 3 * padding / 2, playery - self.cardheight, -1, -1)
cardIndex = Card.encodeCard(player.holecards[3:5])
self.area.window.draw_drawable(self.gc, self.cardImages[cardIndex], 0, 0, playerx - self.cardwidth - padding / 2, playery - self.cardheight, -1, -1)
cardIndex = Card.encodeCard(player.holecards[6:8])
self.area.window.draw_drawable(self.gc, self.cardImages[cardIndex], 0, 0, playerx + padding / 2, playery - self.cardheight, -1, -1)
cardIndex = Card.encodeCard(player.holecards[9:11])
self.area.window.draw_drawable(self.gc, self.cardImages[cardIndex], 0, 0, playerx + self.cardwidth + 3 * padding / 2, playery - self.cardheight, -1, -1)
color_string = '#FFFFFF'
background_color = ''
self.pangolayout.set_markup('<span foreground="%s" size="medium">%s %s%.2f</span>' % (color_string, player.name, self.currency, player.stack))
self.area.window.draw_layout(self.gc, playerx - self.pangolayout.get_pixel_size()[0] / 2, playery, self.pangolayout)
if player.justacted:
color_string = '#FF0000'
background_color = 'background="#000000" '
self.pangolayout.set_markup('<span foreground="%s" size="medium">%s</span>' % (color_string, player.action))
self.area.window.draw_layout(self.gc, playerx - self.pangolayout.get_pixel_size()[0] / 2, playery + self.pangolayout.get_pixel_size()[1], self.pangolayout)
else:
color_string = '#FFFF00'
background_color = ''
if player.chips != 0: #displays amount
self.pangolayout.set_markup('<span foreground="%s" %s weight="heavy" size="large">%s%.2f</span>' % (color_string, background_color, self.currency, player.chips))
self.area.window.draw_layout(self.gc, convertx(player.x * .65) - self.pangolayout.get_pixel_size()[0] / 2, converty(player.y * 0.65), self.pangolayout)
color_string = '#FFFFFF'
self.pangolayout.set_markup('<span foreground="%s" size="large">%s%.2f</span>' % (color_string, self.currency, state.pot)) #displays pot
self.area.window.draw_layout(self.gc,self.tableImage.get_width() / 2 - self.pangolayout.get_pixel_size()[0] / 2, self.tableImage.get_height() / 2, self.pangolayout)
if state.showFlop:
cardIndex = Card.encodeCard(state.flop[0])
self.area.window.draw_drawable(self.gc, self.cardImages[cardIndex], 0, 0, communityLeft, communityTop, -1, -1)
cardIndex = Card.encodeCard(state.flop[1])
self.area.window.draw_drawable(self.gc, self.cardImages[cardIndex], 0, 0, communityLeft + self.cardwidth + padding, communityTop, -1, -1)
cardIndex = Card.encodeCard(state.flop[2])
self.area.window.draw_drawable(self.gc, self.cardImages[cardIndex], 0, 0, communityLeft + 2 * (self.cardwidth + padding), communityTop, -1, -1)
if state.showTurn:
cardIndex = Card.encodeCard(state.turn[0])
#.........这里部分代码省略.........