New query: get common cards for mucked card display.
This commit is contained in:
parent
7d7bf80024
commit
3d6bd0eb46
|
@ -129,13 +129,28 @@ class Database:
|
||||||
cards[s_dict['seat_number']] = (self.convert_cards(s_dict))
|
cards[s_dict['seat_number']] = (self.convert_cards(s_dict))
|
||||||
return cards
|
return cards
|
||||||
|
|
||||||
|
def get_common_cards(self, hand):
|
||||||
|
"""Get and return the community cards for the specified hand."""
|
||||||
|
cards = {}
|
||||||
|
c = self.connection.cursor()
|
||||||
|
c.execute(self.sql.query['get_common_cards'], hand)
|
||||||
|
colnames = [desc[0] for desc in c.description]
|
||||||
|
for row in c.fetchall():
|
||||||
|
s_dict = {}
|
||||||
|
for name, val in zip(colnames, row):
|
||||||
|
s_dict[name] = val
|
||||||
|
cards['common'] = (self.convert_cards(s_dict))
|
||||||
|
return cards
|
||||||
|
|
||||||
def convert_cards(self, d):
|
def convert_cards(self, d):
|
||||||
ranks = ('', '', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A')
|
ranks = ('', '', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A')
|
||||||
cards = ""
|
cards = ""
|
||||||
for i in range(1, 8):
|
for i in range(1, 8):
|
||||||
if d['card' + str(i) + 'Value'] == None:
|
key = 'card' + str(i) + 'Value'
|
||||||
|
if not d.has_key(key): continue
|
||||||
|
if d[key] == None:
|
||||||
break
|
break
|
||||||
elif d['card' + str(i) + 'Value'] == 0:
|
elif d[key] == 0:
|
||||||
cards += "xx"
|
cards += "xx"
|
||||||
else:
|
else:
|
||||||
cards += ranks[d['card' + str(i) + 'Value']] + d['card' +str(i) + 'Suit']
|
cards += ranks[d['card' + str(i) + 'Value']] + d['card' +str(i) + 'Suit']
|
||||||
|
|
|
@ -361,6 +361,17 @@ class Sql:
|
||||||
order by seatNo
|
order by seatNo
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
self.query['get_common_cards'] = """
|
||||||
|
select
|
||||||
|
card1Value, card1Suit,
|
||||||
|
card2Value, card2Suit,
|
||||||
|
card3Value, card3Suit,
|
||||||
|
card4Value, card4Suit,
|
||||||
|
card5Value, card5Suit
|
||||||
|
from BoardCards
|
||||||
|
where handId = %s
|
||||||
|
"""
|
||||||
|
|
||||||
self.query['get_action_from_hand'] = """
|
self.query['get_action_from_hand'] = """
|
||||||
SELECT street, Players.name, HandsActions.action, HandsActions.amount, actionno
|
SELECT street, Players.name, HandsActions.action, HandsActions.amount, actionno
|
||||||
FROM Players, HandsActions, HandsPlayers
|
FROM Players, HandsActions, HandsPlayers
|
||||||
|
|
Loading…
Reference in New Issue
Block a user