get_cards query now works directly with the 0-52 card encoding scheme.

This commit is contained in:
Ray 2009-06-16 23:00:46 -04:00
parent bb633fd435
commit 4a6c257b0f
2 changed files with 4 additions and 13 deletions

View File

@ -156,21 +156,13 @@ class Database:
def get_cards(self, hand):
"""Get and return the cards for each player in the hand."""
cards = {} # dict of cards, the key is the seat number example: {1: 'AcQd9hTs5d'}
cards = {} # dict of cards, the key is the seat number,
# the value is a tuple of the players cards
# example: {1: (0, 0, 20, 21, 22, 0 , 0)}
c = self.connection.cursor()
c.execute(self.sql.query['get_cards'], [hand])
colnames = [desc[0] for desc in c.description]
cardnames = ['card1', 'card2', 'card3', 'card4', 'card5', 'card6', 'card7']
for row in c.fetchall():
cs = ['', '', '', '', '', '', '']
seat = -1
for col,name in enumerate(colnames):
if name in cardnames:
cs[cardnames.index(name)] = Card.valueSuitFromCard(row[col])
elif name == 'seat_number':
seat = row[col]
if seat != -1:
cards[seat] = ''.join(cs)
cards[row[0]] = row[1:]
return cards
def get_common_cards(self, hand):

View File

@ -528,7 +528,6 @@ class Sql:
self.query['get_cards'] = """
select
seatNo AS seat_number,
name AS screen_name,
card1, /*card1Value, card1Suit, */
card2, /*card2Value, card2Suit, */
card3, /*card3Value, card3Suit, */