get_cards query now works directly with the 0-52 card encoding scheme.
This commit is contained in:
parent
bb633fd435
commit
4a6c257b0f
|
@ -156,21 +156,13 @@ class Database:
|
||||||
|
|
||||||
def get_cards(self, hand):
|
def get_cards(self, hand):
|
||||||
"""Get and return the cards for each player in the 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 = self.connection.cursor()
|
||||||
c.execute(self.sql.query['get_cards'], [hand])
|
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():
|
for row in c.fetchall():
|
||||||
cs = ['', '', '', '', '', '', '']
|
cards[row[0]] = row[1:]
|
||||||
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)
|
|
||||||
return cards
|
return cards
|
||||||
|
|
||||||
def get_common_cards(self, hand):
|
def get_common_cards(self, hand):
|
||||||
|
|
|
@ -528,7 +528,6 @@ class Sql:
|
||||||
self.query['get_cards'] = """
|
self.query['get_cards'] = """
|
||||||
select
|
select
|
||||||
seatNo AS seat_number,
|
seatNo AS seat_number,
|
||||||
name AS screen_name,
|
|
||||||
card1, /*card1Value, card1Suit, */
|
card1, /*card1Value, card1Suit, */
|
||||||
card2, /*card2Value, card2Suit, */
|
card2, /*card2Value, card2Suit, */
|
||||||
card3, /*card3Value, card3Suit, */
|
card3, /*card3Value, card3Suit, */
|
||||||
|
|
Loading…
Reference in New Issue
Block a user