本文整理汇总了Python中Card.twoStartCardString方法的典型用法代码示例。如果您正苦于以下问题:Python Card.twoStartCardString方法的具体用法?Python Card.twoStartCardString怎么用?Python Card.twoStartCardString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Card
的用法示例。
在下文中一共展示了Card.twoStartCardString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: is_row_in_card_filter
# 需要导入模块: import Card [as 别名]
# 或者: from Card import twoStartCardString [as 别名]
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
示例2: addGrid
# 需要导入模块: import Card [as 别名]
# 或者: from Card import twoStartCardString [as 别名]
def addGrid(self, vbox, query, flags, playerids, sitenos, limits, type, seats, groups, dates, games):
counter = 0
row = 0
sqlrow = 0
if not flags:
holecards, grid = False, 0
else:
holecards, grid = flags[0], flags[2]
tmp = self.sql.query[query]
tmp = self.refineQuery(tmp, flags, playerids, sitenos, limits, type, seats, groups, dates, games)
self.cursor.execute(tmp)
result = self.cursor.fetchall()
colnames = [desc[0].lower() for desc in self.cursor.description]
# pre-fetch some constant values:
colshow = colshowsumm
if groups["posn"]:
colshow = colshowposn
self.cols_to_show = [x for x in self.columns if x[colshow]]
hgametypeid_idx = colnames.index("hgametypeid")
assert len(self.liststore) == grid, "len(self.liststore)=" + str(len(self.liststore)) + " grid-1=" + str(grid)
self.liststore.append(gtk.ListStore(*([str] * len(self.cols_to_show))))
view = gtk.TreeView(model=self.liststore[grid])
view.set_grid_lines(gtk.TREE_VIEW_GRID_LINES_BOTH)
# vbox.pack_start(view, expand=False, padding=3)
vbox.add(view)
textcell = gtk.CellRendererText()
textcell50 = gtk.CellRendererText()
textcell50.set_property("xalign", 0.5)
numcell = gtk.CellRendererText()
numcell.set_property("xalign", 1.0)
assert len(self.listcols) == grid
self.listcols.append([])
# Create header row eg column: ("game", True, "Game", 0.0, "%s")
for col, column in enumerate(self.cols_to_show):
if column[colalias] == "game" and holecards:
s = [x for x in self.columns if x[colalias] == "hand"][0][colheading]
else:
s = column[colheading]
self.listcols[grid].append(gtk.TreeViewColumn(s))
view.append_column(self.listcols[grid][col])
if column[colformat] == "%s":
if column[colxalign] == 0.0:
self.listcols[grid][col].pack_start(textcell, expand=True)
self.listcols[grid][col].add_attribute(textcell, "text", col)
cellrend = textcell
else:
self.listcols[grid][col].pack_start(textcell50, expand=True)
self.listcols[grid][col].add_attribute(textcell50, "text", col)
cellrend = textcell50
self.listcols[grid][col].set_expand(True)
else:
self.listcols[grid][col].pack_start(numcell, expand=True)
self.listcols[grid][col].add_attribute(numcell, "text", col)
self.listcols[grid][col].set_expand(True)
cellrend = numcell
# self.listcols[grid][col].set_alignment(column[colxalign]) # no effect?
self.listcols[grid][col].set_clickable(True)
self.listcols[grid][col].connect("clicked", self.sortcols, (col, grid))
if col == 0:
self.listcols[grid][col].set_sort_order(gtk.SORT_DESCENDING)
self.listcols[grid][col].set_sort_indicator(True)
if column[coltype] == "cash":
self.listcols[grid][col].set_cell_data_func(numcell, self.ledger_style_render_func)
else:
self.listcols[grid][col].set_cell_data_func(cellrend, self.reset_style_render_func)
rows = len(result) # +1 for title row
while sqlrow < rows:
treerow = []
for col, column in enumerate(self.cols_to_show):
if column[colalias] in colnames:
value = result[sqlrow][colnames.index(column[colalias])]
if column[colalias] == "plposition":
if value == "B":
value = "BB"
elif value == "S":
value = "SB"
elif value == "0":
value = "Btn"
else:
if column[colalias] == "game":
if holecards:
value = Card.twoStartCardString(result[sqlrow][hgametypeid_idx])
else:
minbb = result[sqlrow][colnames.index("minbigblind")]
maxbb = result[sqlrow][colnames.index("maxbigblind")]
value = (
result[sqlrow][colnames.index("limittype")]
+ " "
+ result[sqlrow][colnames.index("category")].title()
+ " "
+ result[sqlrow][colnames.index("name")]
+ " $"
)
if 100 * int(minbb / 100.0) != minbb:
#.........这里部分代码省略.........
示例3: addGrid
# 需要导入模块: import Card [as 别名]
# 或者: from Card import twoStartCardString [as 别名]
def addGrid(self, vbox, query, flags, playerids, sitenos, limits, type, seats, groups, dates, games):
counter = 0
row = 0
sqlrow = 0
if not flags: holecards,grid = False,0
else: holecards,grid = flags[0],flags[2]
tmp = self.sql.query[query]
tmp = self.refineQuery(tmp, flags, playerids, sitenos, limits, type, seats, groups, dates, games)
self.cursor.execute(tmp)
result = self.cursor.fetchall()
colnames = [desc[0].lower() for desc in self.cursor.description]
# pre-fetch some constant values:
self.cols_to_show = [x for x in self.columns if x[colshow]]
hgametypeid_idx = colnames.index('hgametypeid')
assert len(self.liststore) == grid, "len(self.liststore)="+str(len(self.liststore))+" grid-1="+str(grid)
self.liststore.append( gtk.ListStore(*([str] * len(self.cols_to_show))) )
view = gtk.TreeView(model=self.liststore[grid])
view.set_grid_lines(gtk.TREE_VIEW_GRID_LINES_BOTH)
#vbox.pack_start(view, expand=False, padding=3)
vbox.add(view)
textcell = gtk.CellRendererText()
textcell50 = gtk.CellRendererText()
textcell50.set_property('xalign', 0.5)
numcell = gtk.CellRendererText()
numcell.set_property('xalign', 1.0)
assert len(self.listcols) == grid
self.listcols.append( [] )
# Create header row eg column: ("game", True, "Game", 0.0, "%s")
for col, column in enumerate(self.cols_to_show):
if column[colalias] == 'game' and holecards:
s = [x for x in self.columns if x[colalias] == 'hand'][0][colheading]
else:
s = column[colheading]
self.listcols[grid].append(gtk.TreeViewColumn(s))
view.append_column(self.listcols[grid][col])
if column[colformat] == '%s':
if column[colxalign] == 0.0:
self.listcols[grid][col].pack_start(textcell, expand=True)
self.listcols[grid][col].add_attribute(textcell, 'text', col)
cellrend = textcell
else:
self.listcols[grid][col].pack_start(textcell50, expand=True)
self.listcols[grid][col].add_attribute(textcell50, 'text', col)
cellrend = textcell50
self.listcols[grid][col].set_expand(True)
else:
self.listcols[grid][col].pack_start(numcell, expand=True)
self.listcols[grid][col].add_attribute(numcell, 'text', col)
self.listcols[grid][col].set_expand(True)
cellrend = numcell
#self.listcols[grid][col].set_alignment(column[colxalign]) # no effect?
self.listcols[grid][col].set_clickable(True)
self.listcols[grid][col].connect("clicked", self.sortcols, (col,grid))
if col == 0:
self.listcols[grid][col].set_sort_order(gtk.SORT_DESCENDING)
self.listcols[grid][col].set_sort_indicator(True)
if column[coltype] == 'cash':
self.listcols[grid][col].set_cell_data_func(numcell, self.ledger_style_render_func)
else:
self.listcols[grid][col].set_cell_data_func(cellrend, self.reset_style_render_func)
rows = len(result) # +1 for title row
while sqlrow < rows:
treerow = []
for col,column in enumerate(self.cols_to_show):
if column[colalias] in colnames:
value = result[sqlrow][colnames.index(column[colalias])]
if column[colalias] == 'plposition':
if value == 'B':
value = 'BB'
elif value == 'S':
value = 'SB'
elif value == '0':
value = 'Btn'
else:
if column[colalias] == 'game':
if holecards:
value = Card.twoStartCardString( result[sqlrow][hgametypeid_idx] )
else:
minbb = result[sqlrow][colnames.index('minbigblind')]
maxbb = result[sqlrow][colnames.index('maxbigblind')]
value = result[sqlrow][colnames.index('limittype')] + ' ' \
+ result[sqlrow][colnames.index('category')].title() + ' ' \
+ result[sqlrow][colnames.index('name')] + ' $'
if 100 * int(minbb/100.0) != minbb:
value += '%.2f' % (minbb/100.0)
else:
value += '%.0f' % (minbb/100.0)
if minbb != maxbb:
if 100 * int(maxbb/100.0) != maxbb:
value += ' - $' + '%.2f' % (maxbb/100.0)
else:
value += ' - $' + '%.0f' % (maxbb/100.0)
else:
continue
#.........这里部分代码省略.........