From 4a6c257b0fff8595650742cc917c4ea6e38983a8 Mon Sep 17 00:00:00 2001 From: Ray Date: Tue, 16 Jun 2009 23:00:46 -0400 Subject: [PATCH] get_cards query now works directly with the 0-52 card encoding scheme. --- pyfpdb/Database.py | 16 ++++------------ pyfpdb/SQL.py | 1 - 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/pyfpdb/Database.py b/pyfpdb/Database.py index 9582354a..b6c97a29 100755 --- a/pyfpdb/Database.py +++ b/pyfpdb/Database.py @@ -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): diff --git a/pyfpdb/SQL.py b/pyfpdb/SQL.py index a36f812d..1a9deb60 100644 --- a/pyfpdb/SQL.py +++ b/pyfpdb/SQL.py @@ -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, */