Hand: First pass at select() for Hand
This commit is contained in:
parent
797c126318
commit
10fc52e96f
164
pyfpdb/Hand.py
164
pyfpdb/Hand.py
|
@ -289,99 +289,109 @@ db: a connected Database object"""
|
||||||
hp.seatno,
|
hp.seatno,
|
||||||
round(hp.winnings / 100.0,2) as winnings,
|
round(hp.winnings / 100.0,2) as winnings,
|
||||||
p.name,
|
p.name,
|
||||||
round(hp.startcash / 100.0,2) as chips,
|
round(hp.startCash / 100.0,2) as chips,
|
||||||
hp.card1,hp.card2,
|
hp.card1,hp.card2,hp.card3,hp.card4,
|
||||||
hp.position
|
hp.position
|
||||||
FROM
|
FROM
|
||||||
HandsPlayers as hp,
|
HandsPlayers as hp,
|
||||||
Players as p
|
Players as p
|
||||||
WHERE
|
WHERE
|
||||||
hp.handId = %s
|
hp.handId = %s
|
||||||
and p.id = hp.playerid
|
and p.id = hp.playerId
|
||||||
"""
|
"""
|
||||||
q = q.replace('%s', db.sql.query['placeholder'])
|
q = q.replace('%s', db.sql.query['placeholder'])
|
||||||
|
|
||||||
# PlayerStacks
|
# PlayerStacks
|
||||||
c.execute(q, (handId,))
|
c.execute(q, (handId,))
|
||||||
for (seat, winnings, name, chips, card1,card2, position) in c.fetchall():
|
for (seat, winnings, name, chips, card1, card2, card3, card4, position) in c.fetchall():
|
||||||
print "DEBUG: seat: '%s'\tname: '%s'\tchips: '%s'" % (seat, name, chips)
|
|
||||||
self.addPlayer(seat,name,str(chips))
|
self.addPlayer(seat,name,str(chips))
|
||||||
#if card1 and card2:
|
cardlist = map(Card.valueSuitFromCard, [card1, card2, card3, card4])
|
||||||
# self.addHoleCards(map(Card.valueSuitFromCard, (card1,card2)), name, dealt=True)
|
cardlist = [card1, card2, card3, card4]
|
||||||
#if winnings > 0:
|
self.addHoleCards('PREFLOP', name, closed=cardlist, shown=False, mucked=False, dealt=True)
|
||||||
# self.addCollectPot(name, winnings)
|
if winnings > 0:
|
||||||
#if position == 'B':
|
self.addCollectPot(name, str(winnings))
|
||||||
# self.buttonpos = seat
|
if position == 'B':
|
||||||
|
self.buttonpos = seat
|
||||||
|
|
||||||
|
|
||||||
# HandInfo : HID, TABLE
|
# HandInfo
|
||||||
# BUTTON - why is this treated specially in Hand?
|
q = """SELECT *
|
||||||
# answer: it is written out in hand histories
|
FROM Hands
|
||||||
# still, I think we should record all the active seat positions in a seat_order array
|
WHERE id = %s
|
||||||
#c.execute("""SELECT
|
"""
|
||||||
# h.sitehandno as hid,
|
q = q.replace('%s', db.sql.query['placeholder'])
|
||||||
# h.tablename as table,
|
c.execute(q, (handId,))
|
||||||
# h.startTime as startTime
|
|
||||||
# FROM
|
# NOTE: This relies on row_factory = sqlite3.Row (set in connect() params)
|
||||||
# Hands as h
|
# Need to find MySQL and Postgres equivalents
|
||||||
# WHERE h.id = %(handid)s
|
# MySQL maybe: cursorclass=MySQLdb.cursors.DictCursor
|
||||||
# """, {'handid':handid})
|
res = c.fetchone()
|
||||||
#res = c.fetchone()
|
self.tablename = res['tableName']
|
||||||
#h.handid = res[0]
|
self.startTime = res['startTime'] # automatically a datetime
|
||||||
#h.tablename = res[1]
|
#res['tourneyId']
|
||||||
#h.startTime = res[2] # automatically a datetime
|
#gametypeId
|
||||||
|
#res['importTime'] # Don't really care about this
|
||||||
|
#res['seats']
|
||||||
|
self.maxseats = res['maxSeats']
|
||||||
|
#res['rush']
|
||||||
|
cards = map(Card.valueSuitFromCard, [res['boardcard1'], res['boardcard2'], res['boardcard3'], res['boardcard4'], res['boardcard5']])
|
||||||
|
if cards[0]:
|
||||||
|
self.setCommunityCards('FLOP', cards[0:3])
|
||||||
|
if cards[3]:
|
||||||
|
self.setCommunityCards('TURN', [cards[3]])
|
||||||
|
if cards[4]:
|
||||||
|
self.setCommunityCards('RIVER', [cards[4]])
|
||||||
|
# playersVpi | playersAtStreet1 | playersAtStreet2 | playersAtStreet3 |
|
||||||
|
# playersAtStreet4 | playersAtShowdown | street0Raises | street1Raises |
|
||||||
|
# street2Raises | street3Raises | street4Raises | street1Pot | street2Pot |
|
||||||
|
# street3Pot | street4Pot | showdownPot | comment | commentTs | texture
|
||||||
|
|
||||||
|
|
||||||
#cards = map(Card.valueSuitFromCard, res[11:16] )
|
# Actions
|
||||||
#if cards[0]:
|
q = """SELECT
|
||||||
# h.setCommunityCards('FLOP', cards[0:3])
|
ha.actionNo,
|
||||||
#if cards[3]:
|
p.name,
|
||||||
# h.setCommunityCards('TURN', [cards[3]])
|
ha.street,
|
||||||
#if cards[4]:
|
ha.actionId,
|
||||||
# h.setCommunityCards('RIVER', [cards[4]])
|
ha.allIn,
|
||||||
#[Card.valueSuitFromCard(x) for x in cards]
|
round(ha.amount / 100.0,2) as bet
|
||||||
|
FROM
|
||||||
|
HandsActions as ha,
|
||||||
# actions
|
HandsPlayers as hp,
|
||||||
#c.execute("""SELECT
|
Players as p,
|
||||||
# (ha.street,ha.actionno) as actnum,
|
Hands as h
|
||||||
# p.name,
|
WHERE
|
||||||
# ha.street,
|
h.id = %s
|
||||||
# ha.action,
|
and ha.handsPlayerId = hp.id
|
||||||
# ha.allin,
|
and hp.playerId = p.id
|
||||||
# round(ha.amount / 100.0,2)
|
AND h.id = hp.handId
|
||||||
# FROM
|
ORDER BY
|
||||||
# handsplayers as hp,
|
ha.id ASC
|
||||||
# handsactions as ha,
|
; """
|
||||||
# players as p
|
q = q.replace('%s', db.sql.query['placeholder'])
|
||||||
# WHERE
|
c.execute(q, (handId,))
|
||||||
# hp.handid = %(handid)s
|
for row in c.fetchall():
|
||||||
# and ha.handsplayerid = hp.id
|
name = row['name']
|
||||||
# and p.id = hp.playerid
|
street = row['street']
|
||||||
# ORDER BY
|
act = row['actionId']
|
||||||
# ha.street,ha.actionno
|
# allin True/False if row['allIn'] == 0
|
||||||
# """, {'handid':handid})
|
bet = row['bet']
|
||||||
#res = c.fetchall()
|
print "DEBUG: name: '%s' street: '%s' act: '%s' bet: '%s'" %(name, street, act, bet)
|
||||||
#for (actnum,player, streetnum, act, allin, amount) in res:
|
street = self.allStreets[int(street)+1]
|
||||||
# act=act.strip()
|
if act == 2: # Small Blind
|
||||||
# street = h.allStreets[streetnum+1]
|
self.addBlind(name, 'small blind', str(bet))
|
||||||
# if act==u'blind':
|
elif act == 4: # Big Blind
|
||||||
# h.addBlind(player, 'big blind', amount)
|
self.addBlind(name, 'big blind', str(bet))
|
||||||
# # TODO: The type of blind is not recorded in the DB.
|
elif act == 6: # Call
|
||||||
# # TODO: preflop street name anomalies in Hand
|
self.addCall(street, name, str(bet))
|
||||||
# elif act==u'fold':
|
elif act == 8: # Bet
|
||||||
# h.addFold(street,player)
|
self.addBet(street, name, str(bet))
|
||||||
# elif act==u'call':
|
elif act == 10: # Fold
|
||||||
# h.addCall(street,player,amount)
|
self.addFold(street, name)
|
||||||
# elif act==u'bet':
|
elif act == 11: # Check
|
||||||
# h.addBet(street,player,amount)
|
self.addCheck(street, name)
|
||||||
# elif act==u'check':
|
else:
|
||||||
# h.addCheck(street,player)
|
print "DEBUG: unknown action: '%s'" % act
|
||||||
# elif act==u'unbet':
|
|
||||||
# pass
|
|
||||||
# else:
|
|
||||||
# print act, player, streetnum, allin, amount
|
|
||||||
# # TODO : other actions
|
|
||||||
|
|
||||||
#hhc.readShowdownActions(self)
|
#hhc.readShowdownActions(self)
|
||||||
#hc.readShownCards(self)
|
#hc.readShownCards(self)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user