Merge branch 'master' of git://git.assembla.com/free_poker_tools
This commit is contained in:
commit
e66c73ca14
|
@ -57,6 +57,21 @@ def fourStartCards(value1, suit1, value2, suit2, value3, suit3, value4, suit4):
|
||||||
#AAKKs
|
#AAKKs
|
||||||
#AAKKr
|
#AAKKr
|
||||||
# Is probably what we are looking for
|
# Is probably what we are looking for
|
||||||
|
|
||||||
|
# mct:
|
||||||
|
# my maths says there are 4 classes of suitedness
|
||||||
|
# SSSS SSSx SSxy SSHH
|
||||||
|
# encode them as follows:
|
||||||
|
# SSSS (K, J, 6, 3)
|
||||||
|
# - 13C4 = 715 possibilities
|
||||||
|
# SSSx (K, J, 6),(3)
|
||||||
|
# - 13C3 * 13 = 3718 possibilities
|
||||||
|
# SSxy (K, J),(6),(3)
|
||||||
|
# - 13C2 * 13*13 = 13182 possibilities
|
||||||
|
# SSHH (K, J),(6, 3)
|
||||||
|
# - 13C2 * 13C2 = 6084 possibilities
|
||||||
|
# Needless to say they won't fit on a 13x13 grid.
|
||||||
|
# The actual number of hands in each class is far greater
|
||||||
return(0)
|
return(0)
|
||||||
|
|
||||||
def cardFromValueSuit(value, suit):
|
def cardFromValueSuit(value, suit):
|
||||||
|
@ -70,7 +85,7 @@ def cardFromValueSuit(value, suit):
|
||||||
def valueSuitFromCard(card):
|
def valueSuitFromCard(card):
|
||||||
""" Function to convert a card stored in the database (int 0-52) into value
|
""" Function to convert a card stored in the database (int 0-52) into value
|
||||||
and suit like 9s, 4c etc """
|
and suit like 9s, 4c etc """
|
||||||
if card < 0 or card > 52:
|
if card < 0 or card > 52 or not card:
|
||||||
return('')
|
return('')
|
||||||
else:
|
else:
|
||||||
return( ['', '2h', '3h', '4h', '5h', '6h', '7h', '8h', '9h', 'Th', 'Jh', 'Qh', 'Kh', 'Ah'
|
return( ['', '2h', '3h', '4h', '5h', '6h', '7h', '8h', '9h', 'Th', 'Jh', 'Qh', 'Kh', 'Ah'
|
||||||
|
|
|
@ -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):
|
||||||
|
|
|
@ -34,10 +34,6 @@ import Options
|
||||||
|
|
||||||
(options, sys.argv) = Options.fpdb_options()
|
(options, sys.argv) = Options.fpdb_options()
|
||||||
|
|
||||||
print "HUD: dbname =", options.dbname
|
|
||||||
print "HUD: config =", options.config
|
|
||||||
print "HUD: logging =", options.errorsToConsole
|
|
||||||
|
|
||||||
if not options.errorsToConsole:
|
if not options.errorsToConsole:
|
||||||
print "Note: error output is being diverted to fpdb-error-log.txt and HUD-error.txt. Any major error will be reported there _only_."
|
print "Note: error output is being diverted to fpdb-error-log.txt and HUD-error.txt. Any major error will be reported there _only_."
|
||||||
errorFile = open('fpdb-error-log.txt', 'w', 0)
|
errorFile = open('fpdb-error-log.txt', 'w', 0)
|
||||||
|
|
237
pyfpdb/Hand.py
237
pyfpdb/Hand.py
|
@ -39,15 +39,14 @@ class Hand:
|
||||||
self.starttime = 0
|
self.starttime = 0
|
||||||
self.handText = handText
|
self.handText = handText
|
||||||
self.handid = 0
|
self.handid = 0
|
||||||
self.tablename = "Slartibartfast"
|
self.tablename = ""
|
||||||
self.hero = "Hiro"
|
self.hero = ""
|
||||||
self.maxseats = 10
|
self.maxseats = 10
|
||||||
self.counted_seats = 0
|
self.counted_seats = 0
|
||||||
self.buttonpos = 0
|
self.buttonpos = 0
|
||||||
self.seating = []
|
self.seating = []
|
||||||
self.players = []
|
self.players = []
|
||||||
self.posted = []
|
self.posted = []
|
||||||
self.involved = True
|
|
||||||
|
|
||||||
# Collections indexed by street names
|
# Collections indexed by street names
|
||||||
self.bets = {}
|
self.bets = {}
|
||||||
|
@ -55,23 +54,26 @@ class Hand:
|
||||||
self.streets = {}
|
self.streets = {}
|
||||||
self.actions = {} # [['mct','bets','$10'],['mika','folds'],['carlg','raises','$20']]
|
self.actions = {} # [['mct','bets','$10'],['mika','folds'],['carlg','raises','$20']]
|
||||||
self.board = {} # dict from street names to community cards
|
self.board = {} # dict from street names to community cards
|
||||||
for street in self.streetList:
|
self.holecards = {}
|
||||||
|
for street in self.allStreets:
|
||||||
self.streets[street] = "" # portions of the handText, filled by markStreets()
|
self.streets[street] = "" # portions of the handText, filled by markStreets()
|
||||||
self.bets[street] = {}
|
self.bets[street] = {}
|
||||||
self.lastBet[street] = 0
|
self.lastBet[street] = 0
|
||||||
self.actions[street] = []
|
self.actions[street] = []
|
||||||
self.board[street] = []
|
self.board[street] = []
|
||||||
|
self.holecards[street] = {} # dict from player names to holecards
|
||||||
|
|
||||||
# Collections indexed by player names
|
# Collections indexed by player names
|
||||||
self.holecards = {} # dict from player names to dicts by street ... of tuples ... of holecards
|
# self.holecards = {} # dict from player names to dicts by street ... of tuples ... of holecards
|
||||||
self.discards = {} # dict from player names to dicts by street ... of tuples ... of discarded holecards
|
self.discards = {} # dict from player names to dicts by street ... of tuples ... of discarded holecards
|
||||||
self.stacks = {}
|
self.stacks = {}
|
||||||
self.collected = [] #list of ?
|
self.collected = [] #list of ?
|
||||||
self.collectees = {} # dict from player names to amounts collected (?)
|
self.collectees = {} # dict from player names to amounts collected (?)
|
||||||
|
|
||||||
# Sets of players
|
# Sets of players
|
||||||
self.shown = set()
|
|
||||||
self.folded = set()
|
self.folded = set()
|
||||||
|
self.dealt = set() # 'dealt to' line to be printed
|
||||||
|
self.shown = set() # cards were shown
|
||||||
|
|
||||||
# self.action = []
|
# self.action = []
|
||||||
# Things to do with money
|
# Things to do with money
|
||||||
|
@ -94,7 +96,7 @@ db: a connected fpdb_db object"""
|
||||||
sqlids = db.getSqlPlayerIDs([p[1] for p in self.players], self.siteId)
|
sqlids = db.getSqlPlayerIDs([p[1] for p in self.players], self.siteId)
|
||||||
# HudCache data to come from DerivedStats class
|
# HudCache data to come from DerivedStats class
|
||||||
# HandsActions - all actions for all players for all streets - self.actions
|
# HandsActions - all actions for all players for all streets - self.actions
|
||||||
# BoardCards - Skip - no longer necessary?
|
# BoardCards - Skip - no longer necessary
|
||||||
# Hands - Summary information of hand indexed by handId - gameinfo
|
# Hands - Summary information of hand indexed by handId - gameinfo
|
||||||
#hh['siteHandNo'] = self.handid
|
#hh['siteHandNo'] = self.handid
|
||||||
# gametypeId SMALLINT UNSIGNED NOT NULL, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id),
|
# gametypeId SMALLINT UNSIGNED NOT NULL, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id),
|
||||||
|
@ -167,12 +169,10 @@ If a player has None chips he won't be added."""
|
||||||
if chips is not None:
|
if chips is not None:
|
||||||
self.players.append([seat, name, chips])
|
self.players.append([seat, name, chips])
|
||||||
self.stacks[name] = Decimal(chips)
|
self.stacks[name] = Decimal(chips)
|
||||||
self.holecards[name] = []
|
|
||||||
self.discards[name] = []
|
|
||||||
self.pot.addPlayer(name)
|
self.pot.addPlayer(name)
|
||||||
for street in self.streetList:
|
for street in self.allStreets:
|
||||||
self.bets[street][name] = []
|
self.bets[street][name] = []
|
||||||
self.holecards[name] = {} # dict from street names.
|
#self.holecards[name] = {} # dict from street names.
|
||||||
self.discards[name] = {} # dict from street names.
|
self.discards[name] = {} # dict from street names.
|
||||||
|
|
||||||
|
|
||||||
|
@ -411,32 +411,32 @@ Map the tuple self.gametype onto the pokerstars string describing it
|
||||||
def printHand(self):
|
def printHand(self):
|
||||||
self.writeHand(sys.stdout)
|
self.writeHand(sys.stdout)
|
||||||
|
|
||||||
def printActionLine(self, act, fh):
|
def actionString(self, act):
|
||||||
if act[1] == 'folds':
|
if act[1] == 'folds':
|
||||||
print >>fh, ("%s: folds " %(act[0]))
|
return ("%s: folds " %(act[0]))
|
||||||
elif act[1] == 'checks':
|
elif act[1] == 'checks':
|
||||||
print >>fh, ("%s: checks " %(act[0]))
|
return ("%s: checks " %(act[0]))
|
||||||
elif act[1] == 'calls':
|
elif act[1] == 'calls':
|
||||||
print >>fh, ("%s: calls $%s%s" %(act[0], act[2], ' and is all-in' if act[3] else ''))
|
return ("%s: calls $%s%s" %(act[0], act[2], ' and is all-in' if act[3] else ''))
|
||||||
elif act[1] == 'bets':
|
elif act[1] == 'bets':
|
||||||
print >>fh, ("%s: bets $%s%s" %(act[0], act[2], ' and is all-in' if act[3] else ''))
|
return ("%s: bets $%s%s" %(act[0], act[2], ' and is all-in' if act[3] else ''))
|
||||||
elif act[1] == 'raises':
|
elif act[1] == 'raises':
|
||||||
print >>fh, ("%s: raises $%s to $%s%s" %(act[0], act[2], act[3], ' and is all-in' if act[5] else ''))
|
return ("%s: raises $%s to $%s%s" %(act[0], act[2], act[3], ' and is all-in' if act[5] else ''))
|
||||||
elif act[1] == 'completea':
|
elif act[1] == 'completea':
|
||||||
print >>fh, ("%s: completes to $%s%s" %(act[0], act[2], ' and is all-in' if act[3] else ''))
|
return ("%s: completes to $%s%s" %(act[0], act[2], ' and is all-in' if act[3] else ''))
|
||||||
elif act[1] == 'posts':
|
elif act[1] == 'posts':
|
||||||
if(act[2] == "small blind"):
|
if(act[2] == "small blind"):
|
||||||
print >>fh, ("%s: posts small blind $%s%s" %(act[0], act[3], ' and is all-in' if act[4] else ''))
|
return ("%s: posts small blind $%s%s" %(act[0], act[3], ' and is all-in' if act[4] else ''))
|
||||||
elif(act[2] == "big blind"):
|
elif(act[2] == "big blind"):
|
||||||
print >>fh, ("%s: posts big blind $%s%s" %(act[0], act[3], ' and is all-in' if act[4] else ''))
|
return ("%s: posts big blind $%s%s" %(act[0], act[3], ' and is all-in' if act[4] else ''))
|
||||||
elif(act[2] == "both"):
|
elif(act[2] == "both"):
|
||||||
print >>fh, ("%s: posts small & big blinds $%s%s" %(act[0], act[3], ' and is all-in' if act[4] else ''))
|
return ("%s: posts small & big blinds $%s%s" %(act[0], act[3], ' and is all-in' if act[4] else ''))
|
||||||
elif act[1] == 'bringin':
|
elif act[1] == 'bringin':
|
||||||
print >>fh, ("%s: brings in for $%s%s" %(act[0], act[2], ' and is all-in' if act[3] else ''))
|
return ("%s: brings in for $%s%s" %(act[0], act[2], ' and is all-in' if act[3] else ''))
|
||||||
elif act[1] == 'discards':
|
elif act[1] == 'discards':
|
||||||
print >>fh, ("%s: discards %s %s%s" %(act[0], act[2], 'card' if act[2] == 1 else 'cards' , " [" + " ".join(self.discards[act[0]]['DRAWONE']) + "]" if self.hero == act[0] else ''))
|
return ("%s: discards %s %s%s" %(act[0], act[2], 'card' if act[2] == 1 else 'cards' , " [" + " ".join(self.discards[act[0]]['DRAWONE']) + "]" if self.hero == act[0] else ''))
|
||||||
elif act[1] == 'stands pat':
|
elif act[1] == 'stands pat':
|
||||||
print >>fh, ("%s: stands pat" %(act[0]))
|
return ("%s: stands pat" %(act[0]))
|
||||||
|
|
||||||
|
|
||||||
class HoldemOmahaHand(Hand):
|
class HoldemOmahaHand(Hand):
|
||||||
|
@ -444,9 +444,10 @@ class HoldemOmahaHand(Hand):
|
||||||
if gametype['base'] != 'hold':
|
if gametype['base'] != 'hold':
|
||||||
pass # or indeed don't pass and complain instead
|
pass # or indeed don't pass and complain instead
|
||||||
logging.debug("HoldemOmahaHand")
|
logging.debug("HoldemOmahaHand")
|
||||||
self.streetList = ['BLINDSANTES', 'DEAL', 'PREFLOP','FLOP','TURN','RIVER'] # a list of the observed street names in order
|
self.allStreets = ['BLINDSANTES', 'PREFLOP','FLOP','TURN','RIVER']
|
||||||
|
self.holeStreets = ['PREFLOP']
|
||||||
self.communityStreets = ['FLOP', 'TURN', 'RIVER']
|
self.communityStreets = ['FLOP', 'TURN', 'RIVER']
|
||||||
self.actionStreets = ['PREFLOP','FLOP','TURN','RIVER']
|
self.actionStreets = ['BLINDSANTES','PREFLOP','FLOP','TURN','RIVER']
|
||||||
Hand.__init__(self, sitename, gametype, handText, builtFrom = "HHC")
|
Hand.__init__(self, sitename, gametype, handText, builtFrom = "HHC")
|
||||||
self.sb = gametype['sb']
|
self.sb = gametype['sb']
|
||||||
self.bb = gametype['bb']
|
self.bb = gametype['bb']
|
||||||
|
@ -484,24 +485,32 @@ class HoldemOmahaHand(Hand):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def addHoleCards(self, cards, player, shown=False):
|
def addHoleCards(self, cards, player, shown=False, dealt=False):
|
||||||
"""\
|
"""\
|
||||||
Assigns observed holecards to a player.
|
Assigns observed holecards to a player.
|
||||||
cards list of card bigrams e.g. ['2h','Jc']
|
cards list of card bigrams e.g. ['2h','Jc']
|
||||||
player (string) name of player
|
player (string) name of player
|
||||||
|
shown whether they were revealed at showdown
|
||||||
|
dealt whether they were seen in a 'dealt to' line
|
||||||
"""
|
"""
|
||||||
logging.debug("addHoleCards %s %s" % (cards, player))
|
logging.debug("addHoleCards %s %s" % (cards, player))
|
||||||
try:
|
try:
|
||||||
self.checkPlayerExists(player)
|
self.checkPlayerExists(player)
|
||||||
cardset = set(self.card(c) for c in cards)
|
|
||||||
if shown and len(cardset) > 0:
|
|
||||||
self.shown.add(player)
|
|
||||||
if 'PREFLOP' in self.holecards[player]:
|
|
||||||
self.holecards[player]['PREFLOP'].update(cardset)
|
|
||||||
else:
|
|
||||||
self.holecards[player]['PREFLOP'] = cardset
|
|
||||||
except FpdbParseError, e:
|
except FpdbParseError, e:
|
||||||
print "[ERROR] Tried to add holecards for unknown player: %s" % (player,)
|
print "[ERROR] Tried to add holecards for unknown player: %s" % (player,)
|
||||||
|
return
|
||||||
|
|
||||||
|
cardset = set((self.card(c) for c in cards))
|
||||||
|
if len(cardset) == 0:
|
||||||
|
return
|
||||||
|
if dealt:
|
||||||
|
self.dealt.add(player)
|
||||||
|
if shown:
|
||||||
|
self.shown.add(player)
|
||||||
|
if player in self.holecards['PREFLOP']:
|
||||||
|
self.holecards['PREFLOP'][player].update(cardset)
|
||||||
|
else:
|
||||||
|
self.holecards['PREFLOP'][player] = cardset
|
||||||
|
|
||||||
def addShownCards(self, cards, player, holeandboard=None):
|
def addShownCards(self, cards, player, holeandboard=None):
|
||||||
"""\
|
"""\
|
||||||
|
@ -510,8 +519,7 @@ Card ranks will be uppercased
|
||||||
"""
|
"""
|
||||||
logging.debug("addShownCards %s hole=%s all=%s" % (player, cards, holeandboard))
|
logging.debug("addShownCards %s hole=%s all=%s" % (player, cards, holeandboard))
|
||||||
if cards is not None:
|
if cards is not None:
|
||||||
self.shown.add(player)
|
self.addHoleCards(cards,player,shown=True)
|
||||||
self.addHoleCards(cards,player)
|
|
||||||
elif holeandboard is not None:
|
elif holeandboard is not None:
|
||||||
holeandboard = set([self.card(c) for c in holeandboard])
|
holeandboard = set([self.card(c) for c in holeandboard])
|
||||||
board = set([c for s in self.board.values() for c in s])
|
board = set([c for s in self.board.values() for c in s])
|
||||||
|
@ -523,7 +531,6 @@ Card ranks will be uppercased
|
||||||
from nevow import flat
|
from nevow import flat
|
||||||
players_who_act_preflop = (([x[0] for x in self.actions['PREFLOP']]+[x[0] for x in self.actions['BLINDSANTES']]))
|
players_who_act_preflop = (([x[0] for x in self.actions['PREFLOP']]+[x[0] for x in self.actions['BLINDSANTES']]))
|
||||||
players_stacks = [x for x in self.players if x[1] in players_who_act_preflop]
|
players_stacks = [x for x in self.players if x[1] in players_who_act_preflop]
|
||||||
|
|
||||||
action_streets = [x for x in self.actionStreets if len(self.actions[x]) > 0]
|
action_streets = [x for x in self.actionStreets if len(self.actions[x]) > 0]
|
||||||
def render_stack(context,data):
|
def render_stack(context,data):
|
||||||
pat = context.tag.patternGenerator('list_item')
|
pat = context.tag.patternGenerator('list_item')
|
||||||
|
@ -536,39 +543,82 @@ Card ranks will be uppercased
|
||||||
def render_street(context,data):
|
def render_street(context,data):
|
||||||
pat = context.tag.patternGenerator('list_item')
|
pat = context.tag.patternGenerator('list_item')
|
||||||
for street in data:
|
for street in data:
|
||||||
actions = [
|
lines = []
|
||||||
T.h3['%s' % street],
|
if street in self.holeStreets and self.holecards[street]:
|
||||||
T.ol(class_='actions', data=self.actions[street],
|
lines.append(
|
||||||
render=render_action)[
|
T.ol(class_='dealclosed', data=street,
|
||||||
T.li(pattern='list_item')[ T.slot(name='action')]
|
render=render_deal) [
|
||||||
|
T.li(pattern='list_item')[ T.slot(name='deal') ]
|
||||||
]
|
]
|
||||||
|
)
|
||||||
|
if street in self.communityStreets and self.board[street]:
|
||||||
|
lines.append(
|
||||||
|
T.ol(class_='community', data=street,
|
||||||
|
render=render_deal_community)[
|
||||||
|
T.li(pattern='list_item')[ T.slot(name='deal') ]
|
||||||
]
|
]
|
||||||
context.tag[ pat().fillSlots('street', actions)]
|
)
|
||||||
|
if street in self.actionStreets and self.actions[street]:
|
||||||
|
lines.append(
|
||||||
|
T.ol(class_='actions', data=self.actions[street], render=render_action) [
|
||||||
|
T.li(pattern='list_item')[ T.slot(name='action') ]
|
||||||
|
]
|
||||||
|
)
|
||||||
|
if lines:
|
||||||
|
context.tag[ pat().fillSlots('street', [ T.h3[ street ] ]+lines)]
|
||||||
return context.tag
|
return context.tag
|
||||||
|
|
||||||
|
def render_deal(context,data):
|
||||||
|
# data is streetname
|
||||||
|
# we can have open+closed, or just open, or just closed.
|
||||||
|
|
||||||
|
if self.holecards[data]:
|
||||||
|
for player in self.holecards[data]:
|
||||||
|
somestuff = 'dealt to %s %s' % (player, self.holecards[data][player])
|
||||||
|
pat = context.tag.patternGenerator('list_item')
|
||||||
|
context.tag[ pat().fillSlots('deal', somestuff)]
|
||||||
|
return context.tag
|
||||||
|
|
||||||
|
def render_deal_community(context,data):
|
||||||
|
# data is streetname
|
||||||
|
if self.board[data]:
|
||||||
|
somestuff = '[' + ' '.join(self.board[data]) + ']'
|
||||||
|
pat = context.tag.patternGenerator('list_item')
|
||||||
|
context.tag[ pat().fillSlots('deal', somestuff)]
|
||||||
|
return context.tag
|
||||||
def render_action(context,data):
|
def render_action(context,data):
|
||||||
pat = context.tag.patternGenerator('list_item')
|
pat = context.tag.patternGenerator('list_item')
|
||||||
for act in data:
|
for act in data:
|
||||||
x = "%s %s" % (act[0],act[1])
|
x = self.actionString(act)
|
||||||
context.tag[ pat().fillSlots('action', x)]
|
context.tag[ pat().fillSlots('action', x)]
|
||||||
return context.tag
|
return context.tag
|
||||||
|
|
||||||
s = T.p[
|
s = T.p[
|
||||||
T.h1[ "%s Game #%s: %s ($%s/$%s) - %s" %("PokerStars", self.handid,
|
T.h1[
|
||||||
self.getGameTypeAsString(), self.sb, self.bb,
|
T.span(class_='site')["%s Game #%s]" % ('PokerStars', self.handid)],
|
||||||
datetime.datetime.strftime(self.starttime,'%Y/%m/%d - %H:%M:%S ET'))
|
T.span(class_='type_limit')[ "%s ($%s/$%s)" %(self.getGameTypeAsString(), self.sb, self.bb) ],
|
||||||
|
T.span(class_='date')[ datetime.datetime.strftime(self.starttime,'%Y/%m/%d - %H:%M:%S ET') ]
|
||||||
],
|
],
|
||||||
T.h2[ "Table '%s' %d-max Seat #%s is the button" %(self.tablename,
|
T.h2[ "Table '%s' %d-max Seat #%s is the button" %(self.tablename,
|
||||||
self.maxseats, self.buttonpos)],
|
self.maxseats, self.buttonpos)],
|
||||||
T.ol(class_='stacks', data = players_stacks, render=render_stack)[
|
T.ol(class_='stacks', data = players_stacks, render=render_stack)[
|
||||||
T.li(pattern='list_item')[ T.slot(name='playerStack') ]
|
T.li(pattern='list_item')[ T.slot(name='playerStack') ]
|
||||||
],
|
],
|
||||||
T.ol(class_='streets', data = action_streets,
|
T.ol(class_='streets', data = self.allStreets,
|
||||||
render=render_street)[
|
render=render_street)[
|
||||||
T.li(pattern='list_item')[ T.slot(name='street')]
|
T.li(pattern='list_item')[ T.slot(name='street')]
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
return flat.flatten(s)
|
import tidy
|
||||||
|
|
||||||
|
options = dict(input_xml=True,
|
||||||
|
output_xhtml=True,
|
||||||
|
add_xml_decl=False,
|
||||||
|
doctype='omit',
|
||||||
|
indent='auto',
|
||||||
|
tidy_mark=False)
|
||||||
|
|
||||||
|
return str(tidy.parseString(flat.flatten(s), **options))
|
||||||
|
|
||||||
|
|
||||||
def writeHand(self, fh=sys.__stdout__):
|
def writeHand(self, fh=sys.__stdout__):
|
||||||
|
@ -584,33 +634,36 @@ Card ranks will be uppercased
|
||||||
|
|
||||||
if self.actions['BLINDSANTES']:
|
if self.actions['BLINDSANTES']:
|
||||||
for act in self.actions['BLINDSANTES']:
|
for act in self.actions['BLINDSANTES']:
|
||||||
self.printActionLine(act, fh)
|
print >>fh, self.actionString(act)
|
||||||
|
|
||||||
print >>fh, ("*** HOLE CARDS ***")
|
print >>fh, ("*** HOLE CARDS ***")
|
||||||
if self.involved:
|
for player in self.dealt:
|
||||||
print >>fh, ("Dealt to %s [%s]" %(self.hero , " ".join(self.holecards[self.hero]['PREFLOP'])))
|
print >>fh, ("Dealt to %s [%s]" %(player, " ".join(self.holecards['PREFLOP'][player])))
|
||||||
|
if self.hero == "":
|
||||||
|
for player in self.shown.difference(self.dealt):
|
||||||
|
print >>fh, ("Dealt to %s [%s]" %(player, " ".join(self.holecards['PREFLOP'][player])))
|
||||||
|
|
||||||
if self.actions['PREFLOP']:
|
if self.actions['PREFLOP']:
|
||||||
for act in self.actions['PREFLOP']:
|
for act in self.actions['PREFLOP']:
|
||||||
self.printActionLine(act, fh)
|
print >>fh, self.actionString(act)
|
||||||
|
|
||||||
if self.board['FLOP']:
|
if self.board['FLOP']:
|
||||||
print >>fh, ("*** FLOP *** [%s]" %( " ".join(self.board['FLOP'])))
|
print >>fh, ("*** FLOP *** [%s]" %( " ".join(self.board['FLOP'])))
|
||||||
if self.actions['FLOP']:
|
if self.actions['FLOP']:
|
||||||
for act in self.actions['FLOP']:
|
for act in self.actions['FLOP']:
|
||||||
self.printActionLine(act, fh)
|
print >>fh, self.actionString(act)
|
||||||
|
|
||||||
if self.board['TURN']:
|
if self.board['TURN']:
|
||||||
print >>fh, ("*** TURN *** [%s] [%s]" %( " ".join(self.board['FLOP']), " ".join(self.board['TURN'])))
|
print >>fh, ("*** TURN *** [%s] [%s]" %( " ".join(self.board['FLOP']), " ".join(self.board['TURN'])))
|
||||||
if self.actions['TURN']:
|
if self.actions['TURN']:
|
||||||
for act in self.actions['TURN']:
|
for act in self.actions['TURN']:
|
||||||
self.printActionLine(act, fh)
|
print >>fh, self.actionString(act)
|
||||||
|
|
||||||
if self.board['RIVER']:
|
if self.board['RIVER']:
|
||||||
print >>fh, ("*** RIVER *** [%s] [%s]" %(" ".join(self.board['FLOP']+self.board['TURN']), " ".join(self.board['RIVER']) ))
|
print >>fh, ("*** RIVER *** [%s] [%s]" %(" ".join(self.board['FLOP']+self.board['TURN']), " ".join(self.board['RIVER']) ))
|
||||||
if self.actions['RIVER']:
|
if self.actions['RIVER']:
|
||||||
for act in self.actions['RIVER']:
|
for act in self.actions['RIVER']:
|
||||||
self.printActionLine(act, fh)
|
print >>fh, self.actionString(act)
|
||||||
|
|
||||||
|
|
||||||
#Some sites don't have a showdown section so we have to figure out if there should be one
|
#Some sites don't have a showdown section so we have to figure out if there should be one
|
||||||
|
@ -626,8 +679,8 @@ Card ranks will be uppercased
|
||||||
numOfHoleCardsNeeded = 4
|
numOfHoleCardsNeeded = 4
|
||||||
elif self.gametype['category'] in ('holdem'):
|
elif self.gametype['category'] in ('holdem'):
|
||||||
numOfHoleCardsNeeded = 2
|
numOfHoleCardsNeeded = 2
|
||||||
if len(self.holecards[name]['PREFLOP']) == numOfHoleCardsNeeded:
|
if len(self.holecards['PREFLOP'][name]) == numOfHoleCardsNeeded:
|
||||||
print >>fh, ("%s shows [%s] (a hand...)" % (name, " ".join(self.holecards[name]['PREFLOP'])))
|
print >>fh, ("%s shows [%s] (a hand...)" % (name, " ".join(self.holecards['PREFLOP'][name])))
|
||||||
|
|
||||||
# Current PS format has the lines:
|
# Current PS format has the lines:
|
||||||
# Uncalled bet ($111.25) returned to s0rrow
|
# Uncalled bet ($111.25) returned to s0rrow
|
||||||
|
@ -654,7 +707,7 @@ Card ranks will be uppercased
|
||||||
seatnum = player[0]
|
seatnum = player[0]
|
||||||
name = player[1]
|
name = player[1]
|
||||||
if name in self.collectees and name in self.shown:
|
if name in self.collectees and name in self.shown:
|
||||||
print >>fh, ("Seat %d: %s showed [%s] and won ($%s)" % (seatnum, name, " ".join(self.holecards[name]['PREFLOP']), self.collectees[name]))
|
print >>fh, ("Seat %d: %s showed [%s] and won ($%s)" % (seatnum, name, " ".join(self.holecards['PREFLOP'][name]), self.collectees[name]))
|
||||||
elif name in self.collectees:
|
elif name in self.collectees:
|
||||||
print >>fh, ("Seat %d: %s collected ($%s)" % (seatnum, name, self.collectees[name]))
|
print >>fh, ("Seat %d: %s collected ($%s)" % (seatnum, name, self.collectees[name]))
|
||||||
#~ elif name in self.shown:
|
#~ elif name in self.shown:
|
||||||
|
@ -663,7 +716,7 @@ Card ranks will be uppercased
|
||||||
print >>fh, ("Seat %d: %s folded" % (seatnum, name))
|
print >>fh, ("Seat %d: %s folded" % (seatnum, name))
|
||||||
else:
|
else:
|
||||||
if name in self.shown:
|
if name in self.shown:
|
||||||
print >>fh, ("Seat %d: %s showed [%s] and lost with..." % (seatnum, name, " ".join(self.holecards[name]['PREFLOP'])))
|
print >>fh, ("Seat %d: %s showed [%s] and lost with..." % (seatnum, name, " ".join(self.holecards['PREFLOP'][name])))
|
||||||
else:
|
else:
|
||||||
print >>fh, ("Seat %d: %s mucked" % (seatnum, name))
|
print >>fh, ("Seat %d: %s mucked" % (seatnum, name))
|
||||||
|
|
||||||
|
@ -796,12 +849,12 @@ Card ranks will be uppercased
|
||||||
(nc,oc) = self.holecards[player]['DEAL']
|
(nc,oc) = self.holecards[player]['DEAL']
|
||||||
print >>fh, _("Dealt to %s: [%s]") % (player, " ".join(nc))
|
print >>fh, _("Dealt to %s: [%s]") % (player, " ".join(nc))
|
||||||
for act in self.actions['DEAL']:
|
for act in self.actions['DEAL']:
|
||||||
self.printActionLine(act, fh)
|
print >>fh, self.actionString(act)
|
||||||
|
|
||||||
if 'DRAWONE' in self.actions:
|
if 'DRAWONE' in self.actions:
|
||||||
print >>fh, _("*** FIRST DRAW ***")
|
print >>fh, _("*** FIRST DRAW ***")
|
||||||
for act in self.actions['DRAWONE']:
|
for act in self.actions['DRAWONE']:
|
||||||
self.printActionLine(act, fh)
|
print >>fh, self.actionString(act)
|
||||||
if act[0] == self.hero and act[1] == 'discards':
|
if act[0] == self.hero and act[1] == 'discards':
|
||||||
(nc,oc) = self.holecards[act[0]]['DRAWONE']
|
(nc,oc) = self.holecards[act[0]]['DRAWONE']
|
||||||
dc = self.discards[act[0]]['DRAWONE']
|
dc = self.discards[act[0]]['DRAWONE']
|
||||||
|
@ -811,7 +864,7 @@ Card ranks will be uppercased
|
||||||
if 'DRAWTWO' in self.actions:
|
if 'DRAWTWO' in self.actions:
|
||||||
print >>fh, _("*** SECOND DRAW ***")
|
print >>fh, _("*** SECOND DRAW ***")
|
||||||
for act in self.actions['DRAWTWO']:
|
for act in self.actions['DRAWTWO']:
|
||||||
self.printActionLine(act, fh)
|
print >>fh, self.actionString(act)
|
||||||
if act[0] == self.hero and act[1] == 'discards':
|
if act[0] == self.hero and act[1] == 'discards':
|
||||||
(nc,oc) = self.holecards[act[0]]['DRAWTWO']
|
(nc,oc) = self.holecards[act[0]]['DRAWTWO']
|
||||||
dc = self.discards[act[0]]['DRAWTWO']
|
dc = self.discards[act[0]]['DRAWTWO']
|
||||||
|
@ -821,7 +874,7 @@ Card ranks will be uppercased
|
||||||
if 'DRAWTHREE' in self.actions:
|
if 'DRAWTHREE' in self.actions:
|
||||||
print >>fh, _("*** THIRD DRAW ***")
|
print >>fh, _("*** THIRD DRAW ***")
|
||||||
for act in self.actions['DRAWTHREE']:
|
for act in self.actions['DRAWTHREE']:
|
||||||
self.printActionLine(act, fh)
|
print >>fh, self.actionString(act)
|
||||||
if act[0] == self.hero and act[1] == 'discards':
|
if act[0] == self.hero and act[1] == 'discards':
|
||||||
(nc,oc) = self.holecards[act[0]]['DRAWTHREE']
|
(nc,oc) = self.holecards[act[0]]['DRAWTHREE']
|
||||||
dc = self.discards[act[0]]['DRAWTHREE']
|
dc = self.discards[act[0]]['DRAWTHREE']
|
||||||
|
@ -961,7 +1014,7 @@ Add a complete on [street] by [player] to [amountTo]
|
||||||
print >>fh, _("Dealt to %s:%s%s") % (player, " [" + " ".join(closed) + "] " if closed else " ", "[" + " ".join(open) + "]" if open else "")
|
print >>fh, _("Dealt to %s:%s%s") % (player, " [" + " ".join(closed) + "] " if closed else " ", "[" + " ".join(open) + "]" if open else "")
|
||||||
for act in self.actions['THIRD']:
|
for act in self.actions['THIRD']:
|
||||||
#FIXME: Need some logic here for bringin vs completes
|
#FIXME: Need some logic here for bringin vs completes
|
||||||
self.printActionLine(act, fh)
|
print >>fh, self.actionString(act)
|
||||||
|
|
||||||
if 'FOURTH' in self.actions:
|
if 'FOURTH' in self.actions:
|
||||||
dealt = 0
|
dealt = 0
|
||||||
|
@ -978,7 +1031,7 @@ Add a complete on [street] by [player] to [amountTo]
|
||||||
print >>fh, _("*** 4TH STREET ***")
|
print >>fh, _("*** 4TH STREET ***")
|
||||||
print >>fh, _("Dealt to %s:%s%s") % (player, " [" + " ".join(old) + "] " if old else " ", "[" + " ".join(new) + "]" if new else "")
|
print >>fh, _("Dealt to %s:%s%s") % (player, " [" + " ".join(old) + "] " if old else " ", "[" + " ".join(new) + "]" if new else "")
|
||||||
for act in self.actions['FOURTH']:
|
for act in self.actions['FOURTH']:
|
||||||
self.printActionLine(act, fh)
|
print >>fh, self.actionString(act)
|
||||||
|
|
||||||
if 'FIFTH' in self.actions:
|
if 'FIFTH' in self.actions:
|
||||||
dealt = 0
|
dealt = 0
|
||||||
|
@ -996,7 +1049,7 @@ Add a complete on [street] by [player] to [amountTo]
|
||||||
print >>fh, _("*** 5TH STREET ***")
|
print >>fh, _("*** 5TH STREET ***")
|
||||||
print >>fh, _("Dealt to %s:%s%s") % (player, " [" + " ".join(old) + "] " if old else " ", "[" + " ".join(new) + "]" if new else "")
|
print >>fh, _("Dealt to %s:%s%s") % (player, " [" + " ".join(old) + "] " if old else " ", "[" + " ".join(new) + "]" if new else "")
|
||||||
for act in self.actions['FIFTH']:
|
for act in self.actions['FIFTH']:
|
||||||
self.printActionLine(act, fh)
|
print >>fh, self.actionString(act)
|
||||||
|
|
||||||
if 'SIXTH' in self.actions:
|
if 'SIXTH' in self.actions:
|
||||||
dealt = 0
|
dealt = 0
|
||||||
|
@ -1014,7 +1067,7 @@ Add a complete on [street] by [player] to [amountTo]
|
||||||
print >>fh, _("*** 6TH STREET ***")
|
print >>fh, _("*** 6TH STREET ***")
|
||||||
print >>fh, _("Dealt to %s:%s%s") % (player, " [" + " ".join(old) + "] " if old else " ", "[" + " ".join(new) + "]" if new else "")
|
print >>fh, _("Dealt to %s:%s%s") % (player, " [" + " ".join(old) + "] " if old else " ", "[" + " ".join(new) + "]" if new else "")
|
||||||
for act in self.actions['SIXTH']:
|
for act in self.actions['SIXTH']:
|
||||||
self.printActionLine(act, fh)
|
print >>fh, self.actionString(act)
|
||||||
|
|
||||||
if 'SEVENTH' in self.actions:
|
if 'SEVENTH' in self.actions:
|
||||||
# OK. It's possible that they're all in at an earlier street, but only closed cards are dealt.
|
# OK. It's possible that they're all in at an earlier street, but only closed cards are dealt.
|
||||||
|
@ -1033,7 +1086,7 @@ Add a complete on [street] by [player] to [amountTo]
|
||||||
if new:
|
if new:
|
||||||
print >>fh, _("Dealt to %s:%s%s") % (player, " [" + " ".join(old) + "] " if old else " ", "[" + " ".join(new) + "]" if new else "")
|
print >>fh, _("Dealt to %s:%s%s") % (player, " [" + " ".join(old) + "] " if old else " ", "[" + " ".join(new) + "]" if new else "")
|
||||||
for act in self.actions['SEVENTH']:
|
for act in self.actions['SEVENTH']:
|
||||||
self.printActionLine(act, fh)
|
print >>fh, self.actionString(act)
|
||||||
|
|
||||||
#Some sites don't have a showdown section so we have to figure out if there should be one
|
#Some sites don't have a showdown section so we have to figure out if there should be one
|
||||||
# The logic for a showdown is: at the end of river action there are at least two players in the hand
|
# The logic for a showdown is: at the end of river action there are at least two players in the hand
|
||||||
|
@ -1164,7 +1217,8 @@ class Pot(object):
|
||||||
def assemble(cnxn, handid):
|
def assemble(cnxn, handid):
|
||||||
c = cnxn.cursor()
|
c = cnxn.cursor()
|
||||||
|
|
||||||
# We need the following for the Hand.__init__
|
# We need at least sitename, gametype, handid
|
||||||
|
# for the Hand.__init__
|
||||||
c.execute("""
|
c.execute("""
|
||||||
select
|
select
|
||||||
s.name,
|
s.name,
|
||||||
|
@ -1178,22 +1232,19 @@ select
|
||||||
round(g.smallBet / 100.0,2),
|
round(g.smallBet / 100.0,2),
|
||||||
round(g.bigBet / 100.0,2),
|
round(g.bigBet / 100.0,2),
|
||||||
s.currency,
|
s.currency,
|
||||||
bc.card1value,
|
h.boardcard1,
|
||||||
bc.card1suit,
|
h.boardcard2,
|
||||||
bc.card2value,bc.card2suit,
|
h.boardcard3,
|
||||||
bc.card3value,bc.card3suit,
|
h.boardcard4,
|
||||||
bc.card4value,bc.card4suit,
|
h.boardcard5
|
||||||
bc.card5value,bc.card5suit
|
|
||||||
from
|
from
|
||||||
hands as h,
|
hands as h,
|
||||||
boardcards as bc,
|
|
||||||
sites as s,
|
sites as s,
|
||||||
gametypes as g,
|
gametypes as g,
|
||||||
handsplayers as hp,
|
handsplayers as hp,
|
||||||
players as p
|
players as p
|
||||||
where
|
where
|
||||||
h.id = %(handid)s
|
h.id = %(handid)s
|
||||||
and bc.handid = h.id
|
|
||||||
and g.id = h.gametypeid
|
and g.id = h.gametypeid
|
||||||
and hp.handid = h.id
|
and hp.handid = h.id
|
||||||
and p.id = hp.playerid
|
and p.id = hp.playerid
|
||||||
|
@ -1203,24 +1254,15 @@ limit 1""", {'handid':handid})
|
||||||
res = c.fetchone()
|
res = c.fetchone()
|
||||||
gametype = {'category':res[1],'base':res[2],'type':res[3],'limitType':res[4],'hilo':res[5],'sb':res[6],'bb':res[7], 'currency':res[10]}
|
gametype = {'category':res[1],'base':res[2],'type':res[3],'limitType':res[4],'hilo':res[5],'sb':res[6],'bb':res[7], 'currency':res[10]}
|
||||||
h = HoldemOmahaHand(hhc = None, sitename=res[0], gametype = gametype, handText=None, builtFrom = "DB", handid=handid)
|
h = HoldemOmahaHand(hhc = None, sitename=res[0], gametype = gametype, handText=None, builtFrom = "DB", handid=handid)
|
||||||
rank = {0:'X',1:'1',2:'2',3:'3',4:'4',
|
cards = map(Card.valueSuitFromCard, res[11:16] )
|
||||||
5:'5',6:'6',7:'7',8:'8',9:'9',
|
if cards[0]:
|
||||||
10:'T',11:'J',12:'Q',13:'K',14:'A'}
|
|
||||||
ranks = [rank[r] for r in res[11:21:2]]
|
|
||||||
cards = map("".join, zip(ranks, res[12:21:2]))
|
|
||||||
|
|
||||||
if cards[0] != "Xx":
|
|
||||||
h.setCommunityCards('FLOP', cards[0:3])
|
h.setCommunityCards('FLOP', cards[0:3])
|
||||||
if cards[3] != "Xx":
|
if cards[3]:
|
||||||
h.setCommunityCards('TURN', [cards[3]])
|
h.setCommunityCards('TURN', [cards[3]])
|
||||||
if cards[4] != "Xx":
|
if cards[4]:
|
||||||
h.setCommunityCards('RIVER', [cards[4]])
|
h.setCommunityCards('RIVER', [cards[4]])
|
||||||
#[Card.valueSuitFromCard(x) for x in cards]
|
#[Card.valueSuitFromCard(x) for x in cards]
|
||||||
|
|
||||||
|
|
||||||
#TODO : doesn't look like this is in the database; don't like the way Hand requires it
|
|
||||||
h.hero = 'mcturnbull'
|
|
||||||
|
|
||||||
# HandInfo : HID, TABLE
|
# HandInfo : HID, TABLE
|
||||||
# BUTTON - why is this treated specially in Hand?
|
# BUTTON - why is this treated specially in Hand?
|
||||||
# answer: it is written out in hand histories
|
# answer: it is written out in hand histories
|
||||||
|
@ -1246,7 +1288,8 @@ SELECT
|
||||||
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.position
|
||||||
FROM
|
FROM
|
||||||
handsplayers as hp,
|
handsplayers as hp,
|
||||||
players as p
|
players as p
|
||||||
|
@ -1254,11 +1297,15 @@ WHERE
|
||||||
hp.handid = %(handid)s
|
hp.handid = %(handid)s
|
||||||
and p.id = hp.playerid
|
and p.id = hp.playerid
|
||||||
""", {'handid':handid})
|
""", {'handid':handid})
|
||||||
for (seat, winnings, name, chips, card1,card2) in c.fetchall():
|
for (seat, winnings, name, chips, card1,card2, position) in c.fetchall():
|
||||||
h.addPlayer(seat,name,chips)
|
h.addPlayer(seat,name,chips)
|
||||||
h.addHoleCards(map(Card.valueSuitFromCard, (card1,card2)),name)
|
if card1 and card2:
|
||||||
|
h.addHoleCards(map(Card.valueSuitFromCard, (card1,card2)), name, dealt=True)
|
||||||
if winnings > 0:
|
if winnings > 0:
|
||||||
h.addCollectPot(name, winnings)
|
h.addCollectPot(name, winnings)
|
||||||
|
if position == 'B':
|
||||||
|
h.buttonpos = seat
|
||||||
|
|
||||||
|
|
||||||
# actions
|
# actions
|
||||||
c.execute("""
|
c.execute("""
|
||||||
|
@ -1283,7 +1330,7 @@ ORDER BY
|
||||||
res = c.fetchall()
|
res = c.fetchall()
|
||||||
for (actnum,player, streetnum, act, allin, amount) in res:
|
for (actnum,player, streetnum, act, allin, amount) in res:
|
||||||
act=act.strip()
|
act=act.strip()
|
||||||
street = h.streetList[streetnum+2]
|
street = h.allStreets[streetnum+1]
|
||||||
if act==u'blind':
|
if act==u'blind':
|
||||||
h.addBlind(player, 'big blind', amount)
|
h.addBlind(player, 'big blind', amount)
|
||||||
# TODO: The type of blind is not recorded in the DB.
|
# TODO: The type of blind is not recorded in the DB.
|
||||||
|
|
|
@ -35,6 +35,7 @@ import gobject
|
||||||
# FreePokerTools modules
|
# FreePokerTools modules
|
||||||
import Configuration
|
import Configuration
|
||||||
import Database
|
import Database
|
||||||
|
import Card
|
||||||
|
|
||||||
class Aux_Window:
|
class Aux_Window:
|
||||||
def __init__(self, hud, params, config):
|
def __init__(self, hud, params, config):
|
||||||
|
@ -67,19 +68,27 @@ class Aux_Window:
|
||||||
# Some utility routines useful for Aux_Windows
|
# Some utility routines useful for Aux_Windows
|
||||||
#
|
#
|
||||||
def get_card_images(self):
|
def get_card_images(self):
|
||||||
card_images = {}
|
|
||||||
suits = ('S', 'H', 'D', 'C')
|
card_images = 53 * [0]
|
||||||
ranks = ('A', 'K', 'Q', 'J', 'T', '9', '8', '7', '6', '5', '4', '3', '2', 'B')
|
suits = ('s', 'h', 'd', 'c')
|
||||||
|
ranks = (14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2)
|
||||||
pb = gtk.gdk.pixbuf_new_from_file(self.config.execution_path(self.params['deck']))
|
pb = gtk.gdk.pixbuf_new_from_file(self.config.execution_path(self.params['deck']))
|
||||||
|
|
||||||
for j in range(0, 14):
|
for j in range(0, 13):
|
||||||
for i in range(0, 4):
|
for i in range(0, 4):
|
||||||
|
card_images[Card.cardFromValueSuit(ranks[j], suits[i])] = self.cropper(pb, i, j)
|
||||||
temp_pb = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, pb.get_has_alpha(), pb.get_bits_per_sample(), 30, 42)
|
temp_pb = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, pb.get_has_alpha(), pb.get_bits_per_sample(), 30, 42)
|
||||||
pb.copy_area(30*j, 42*i, 30, 42, temp_pb, 0, 0)
|
# also pick out a card back and store in [0]
|
||||||
card_images[(ranks[j], suits[i])] = temp_pb
|
card_images[0] = self.cropper(pb, 2, 13)
|
||||||
return(card_images)
|
return(card_images)
|
||||||
# cards are 30 wide x 42 high
|
# cards are 30 wide x 42 high
|
||||||
|
|
||||||
|
def cropper(self, pb, i, j):
|
||||||
|
"""Crop out a card image given an FTP deck and the i, j position."""
|
||||||
|
temp_pb = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, pb.get_has_alpha(), pb.get_bits_per_sample(), 30, 42)
|
||||||
|
pb.copy_area(30*j, 42*i, 30, 42, temp_pb, 0, 0)
|
||||||
|
return temp_pb
|
||||||
|
|
||||||
def split_cards(self, card):
|
def split_cards(self, card):
|
||||||
if card == 'xx': return ('B', 'S')
|
if card == 'xx': return ('B', 'S')
|
||||||
return (card[0], card[1].upper())
|
return (card[0], card[1].upper())
|
||||||
|
@ -108,9 +117,10 @@ class Stud_mucked(Aux_Window):
|
||||||
|
|
||||||
def create(self):
|
def create(self):
|
||||||
|
|
||||||
self.container =gtk.Window()
|
self.container = gtk.Window()
|
||||||
self.vbox = gtk.VBox()
|
self.vbox = gtk.VBox()
|
||||||
self.container.add(self.vbox)
|
self.container.add(self.vbox)
|
||||||
|
self.container.set_title(self.hud.table.name)
|
||||||
|
|
||||||
self.mucked_list.create(self.vbox)
|
self.mucked_list.create(self.vbox)
|
||||||
self.mucked_cards.create(self.vbox)
|
self.mucked_cards.create(self.vbox)
|
||||||
|
@ -207,7 +217,9 @@ class Stud_list:
|
||||||
# find the hero's seat from the stat_dict
|
# find the hero's seat from the stat_dict
|
||||||
for stat in self.parent.hud.stat_dict.itervalues():
|
for stat in self.parent.hud.stat_dict.itervalues():
|
||||||
if stat['screen_name'] == hero:
|
if stat['screen_name'] == hero:
|
||||||
return self.parent.hud.cards[stat['seat']][0:6]
|
return Card.valueSuitFromCard(self.parent.hud.cards[stat['seat']][0]) +\
|
||||||
|
Card.valueSuitFromCard(self.parent.hud.cards[stat['seat']][1]) +\
|
||||||
|
Card.valueSuitFromCard(self.parent.hud.cards[stat['seat']][2])
|
||||||
return "xxxxxx"
|
return "xxxxxx"
|
||||||
|
|
||||||
def update_gui(self, new_hand_id):
|
def update_gui(self, new_hand_id):
|
||||||
|
@ -240,7 +252,7 @@ class Stud_cards:
|
||||||
|
|
||||||
for r in range(0, self.rows):
|
for r in range(0, self.rows):
|
||||||
for c in range(0, self.cols):
|
for c in range(0, self.cols):
|
||||||
self.seen_cards[(c, r)] = gtk.image_new_from_pixbuf(self.card_images[('B', 'S')])
|
self.seen_cards[(c, r)] = gtk.image_new_from_pixbuf(self.card_images[(0)])
|
||||||
self.eb[(c, r)]= gtk.EventBox()
|
self.eb[(c, r)]= gtk.EventBox()
|
||||||
|
|
||||||
# set up the contents for the cells
|
# set up the contents for the cells
|
||||||
|
@ -287,11 +299,11 @@ class Stud_cards:
|
||||||
self.clear()
|
self.clear()
|
||||||
for c, cards in self.parent.hud.cards.iteritems():
|
for c, cards in self.parent.hud.cards.iteritems():
|
||||||
self.grid_contents[(1, c - 1)].set_text(self.get_screen_name(c))
|
self.grid_contents[(1, c - 1)].set_text(self.get_screen_name(c))
|
||||||
for i in ((0, cards[0:2]), (1, cards[2:4]), (2, cards[4:6]), (3, cards[6:8]),
|
for i in ((0, cards[0]), (1, cards[1]), (2, cards[2]), (3, cards[3]),
|
||||||
(4, cards[8:10]), (5, cards[10:12]), (6, cards[12:14])):
|
(4, cards[4]), (5, cards[5]), (6, cards[6])):
|
||||||
if not i[1] == "xx":
|
if not i[1] == 0:
|
||||||
self.seen_cards[(i[0], c - 1)]. \
|
self.seen_cards[(i[0], c - 1)]. \
|
||||||
set_from_pixbuf(self.card_images[self.parent.split_cards(i[1])])
|
set_from_pixbuf(self.card_images[i[1]])
|
||||||
## action in tool tips for 3rd street cards
|
## action in tool tips for 3rd street cards
|
||||||
for c in (0, 1, 2):
|
for c in (0, 1, 2):
|
||||||
for r in range(0, self.rows):
|
for r in range(0, self.rows):
|
||||||
|
@ -314,7 +326,7 @@ class Stud_cards:
|
||||||
for r in range(0, self.rows):
|
for r in range(0, self.rows):
|
||||||
self.grid_contents[(1, r)].set_text(" ")
|
self.grid_contents[(1, r)].set_text(" ")
|
||||||
for c in range(0, 7):
|
for c in range(0, 7):
|
||||||
self.seen_cards[(c, r)].set_from_pixbuf(self.card_images[('B', 'S')])
|
self.seen_cards[(c, r)].set_from_pixbuf(self.card_images[0])
|
||||||
self.eb[(c, r)].set_tooltip_text('')
|
self.eb[(c, r)].set_tooltip_text('')
|
||||||
|
|
||||||
class Flop_Mucked(Aux_Window):
|
class Flop_Mucked(Aux_Window):
|
||||||
|
@ -459,29 +471,31 @@ class Flop_Mucked(Aux_Window):
|
||||||
new_locs[i] = (pos[0] - self.hud.table.x, pos[1] - self.hud.table.y)
|
new_locs[i] = (pos[0] - self.hud.table.x, pos[1] - self.hud.table.y)
|
||||||
self.config.edit_aux_layout(self.params['name'], self.hud.max, locations = new_locs)
|
self.config.edit_aux_layout(self.params['name'], self.hud.max, locations = new_locs)
|
||||||
|
|
||||||
if __name__== "__main__":
|
# This test program doesn't work
|
||||||
|
|
||||||
def destroy(*args): # call back for terminating the main eventloop
|
#if __name__== "__main__":
|
||||||
gtk.main_quit() # used only for testing
|
#
|
||||||
|
# def destroy(*args): # call back for terminating the main eventloop
|
||||||
def process_new_hand(source, condition, db_connection): #callback from stdin watch -- testing only
|
# gtk.main_quit() # used only for testing
|
||||||
# there is a new hand_id to be processed
|
#
|
||||||
# just read it and pass it to update
|
# def process_new_hand(source, condition, db_connection): #callback from stdin watch -- testing only
|
||||||
new_hand_id = sys.stdin.readline()
|
## there is a new hand_id to be processed
|
||||||
new_hand_id = new_hand_id.rstrip() # remove trailing whitespace
|
## just read it and pass it to update
|
||||||
m.update_data(new_hand_id, db_connection)
|
# new_hand_id = sys.stdin.readline()
|
||||||
m.update_gui(new_hand_id)
|
# new_hand_id = new_hand_id.rstrip() # remove trailing whitespace
|
||||||
return(True)
|
# m.update_data(new_hand_id, db_connection)
|
||||||
|
# m.update_gui(new_hand_id)
|
||||||
config = Configuration.Config()
|
# return(True)
|
||||||
db_connection = Database.Database(config, 'fpdb', '')
|
#
|
||||||
main_window = gtk.Window()
|
# config = Configuration.Config()
|
||||||
main_window.set_keep_above(True)
|
# db_connection = Database.Database(config, 'fpdbTEST', '')
|
||||||
main_window.connect("destroy", destroy)
|
# main_window = gtk.Window()
|
||||||
|
# main_window.set_keep_above(True)
|
||||||
aux_to_call = "stud_mucked"
|
# main_window.connect("destroy", destroy)
|
||||||
aux_params = config.get_aux_parameters(aux_to_call)
|
#
|
||||||
m = eval("%s(main_window, None, config, aux_params)" % aux_params['class'])
|
# aux_to_call = "stud_mucked"
|
||||||
|
# aux_params = config.get_aux_parameters(aux_to_call)
|
||||||
s_id = gobject.io_add_watch(sys.stdin, gobject.IO_IN, process_new_hand, db_connection)
|
# m = eval("%s(None, config, aux_params)" % aux_params['class'])
|
||||||
gtk.main()
|
#
|
||||||
|
# s_id = gobject.io_add_watch(sys.stdin, gobject.IO_IN, process_new_hand, db_connection)
|
||||||
|
# gtk.main()
|
||||||
|
|
|
@ -209,7 +209,7 @@ follow : whether to tail -f the input"""
|
||||||
for a in self.re_PostBB.finditer(hand.handText):
|
for a in self.re_PostBB.finditer(hand.handText):
|
||||||
hand.addBlind(a.group('PNAME'), 'big blind', a.group('BB'))
|
hand.addBlind(a.group('PNAME'), 'big blind', a.group('BB'))
|
||||||
for a in self.re_PostBoth.finditer(hand.handText):
|
for a in self.re_PostBoth.finditer(hand.handText):
|
||||||
hand.addBlind(a.group('PNAME'), 'small & big blinds', a.group('SBBB'))
|
hand.addBlind(a.group('PNAME'), 'both', a.group('SBBB'))
|
||||||
|
|
||||||
def readHeroCards(self, hand):
|
def readHeroCards(self, hand):
|
||||||
m = self.re_HeroCards.search(hand.handText)
|
m = self.re_HeroCards.search(hand.handText)
|
||||||
|
|
|
@ -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, */
|
||||||
|
|
|
@ -82,7 +82,8 @@ def ring_holdem_omaha(config, backend, db, cursor, base, category, site_hand_no,
|
||||||
t2 = time()
|
t2 = time()
|
||||||
|
|
||||||
hands_id = fpdb_simple.storeHands(backend, db, cursor, site_hand_no, gametype_id
|
hands_id = fpdb_simple.storeHands(backend, db, cursor, site_hand_no, gametype_id
|
||||||
,hand_start_time, names, tableName, maxSeats, hudImportData)
|
,hand_start_time, names, tableName, maxSeats,
|
||||||
|
hudImportData, board_values, board_suits)
|
||||||
t3 = time()
|
t3 = time()
|
||||||
hands_players_ids = fpdb_simple.store_hands_players_holdem_omaha(
|
hands_players_ids = fpdb_simple.store_hands_players_holdem_omaha(
|
||||||
backend, db, cursor, category, hands_id, player_ids, start_cashes
|
backend, db, cursor, category, hands_id, player_ids, start_cashes
|
||||||
|
|
|
@ -1147,10 +1147,13 @@ card5Value, card5Suit) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)""",
|
||||||
#end def store_board_cards
|
#end def store_board_cards
|
||||||
|
|
||||||
def storeHands(backend, conn, cursor, site_hand_no, gametype_id
|
def storeHands(backend, conn, cursor, site_hand_no, gametype_id
|
||||||
,hand_start_time, names, tableName, maxSeats, hudCache):
|
,hand_start_time, names, tableName, maxSeats, hudCache,
|
||||||
|
board_values, board_suits):
|
||||||
|
cards = [Card.cardFromValueSuit(v,s) for v,s in zip(board_values,board_suits)]
|
||||||
#stores into table hands:
|
#stores into table hands:
|
||||||
cursor.execute ("""INSERT INTO Hands
|
cursor.execute ("""INSERT INTO Hands
|
||||||
(siteHandNo, gametypeId, handStart, seats, tableName, importTime, maxSeats
|
(siteHandNo, gametypeId, handStart, seats, tableName, importTime, maxSeats
|
||||||
|
,boardcard1,boardcard2,boardcard3,boardcard4,boardcard5
|
||||||
,playersVpi, playersAtStreet1, playersAtStreet2
|
,playersVpi, playersAtStreet1, playersAtStreet2
|
||||||
,playersAtStreet3, playersAtStreet4, playersAtShowdown
|
,playersAtStreet3, playersAtStreet4, playersAtShowdown
|
||||||
,street0Raises, street1Raises, street2Raises
|
,street0Raises, street1Raises, street2Raises
|
||||||
|
@ -1159,9 +1162,11 @@ def storeHands(backend, conn, cursor, site_hand_no, gametype_id
|
||||||
,showdownPot
|
,showdownPot
|
||||||
)
|
)
|
||||||
VALUES
|
VALUES
|
||||||
(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
|
(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,
|
||||||
|
%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
|
||||||
"""
|
"""
|
||||||
, (site_hand_no, gametype_id, hand_start_time, len(names), tableName, datetime.datetime.today(), maxSeats
|
, (site_hand_no, gametype_id, hand_start_time, len(names), tableName, datetime.datetime.today(), maxSeats
|
||||||
|
,cards[0], cards[1], cards[2], cards[3], cards[4]
|
||||||
,hudCache['playersVpi'], hudCache['playersAtStreet1'], hudCache['playersAtStreet2']
|
,hudCache['playersVpi'], hudCache['playersAtStreet1'], hudCache['playersAtStreet2']
|
||||||
,hudCache['playersAtStreet3'], hudCache['playersAtStreet4'], hudCache['playersAtShowdown']
|
,hudCache['playersAtStreet3'], hudCache['playersAtStreet4'], hudCache['playersAtShowdown']
|
||||||
,hudCache['street0Raises'], hudCache['street1Raises'], hudCache['street2Raises']
|
,hudCache['street0Raises'], hudCache['street1Raises'], hudCache['street2Raises']
|
||||||
|
|
Loading…
Reference in New Issue
Block a user