2008-08-04 05:44:28 +02:00
|
|
|
#!/usr/bin/python
|
|
|
|
|
|
|
|
#Copyright 2008 Steffen Jobbagy-Felso
|
|
|
|
#This program is free software: you can redistribute it and/or modify
|
|
|
|
#it under the terms of the GNU Affero General Public License as published by
|
|
|
|
#the Free Software Foundation, version 3 of the License.
|
|
|
|
#
|
|
|
|
#This program is distributed in the hope that it will be useful,
|
|
|
|
#but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
#GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
#You should have received a copy of the GNU Affero General Public License
|
|
|
|
#along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#In the "official" distribution you can find the license in
|
|
|
|
#agpl-3.0.txt in the docs folder of the package.
|
|
|
|
|
|
|
|
#This is intended mostly for regression testing
|
|
|
|
|
|
|
|
import sys
|
|
|
|
import MySQLdb
|
|
|
|
from optparse import OptionParser
|
|
|
|
import fpdb_util_lib as ful
|
|
|
|
|
|
|
|
parser = OptionParser()
|
2008-08-18 16:41:34 +02:00
|
|
|
parser.add_option("-n", "--handNumber", "--hand", type="int",
|
2008-08-04 05:44:28 +02:00
|
|
|
help="Number of the hand to print")
|
|
|
|
parser.add_option("-p", "--password", help="The password for the MySQL user")
|
|
|
|
parser.add_option("-s", "--site", default="PokerStars",
|
|
|
|
help="Name of the site (as written in the history files)")
|
|
|
|
|
|
|
|
(options, sys.argv) = parser.parse_args()
|
|
|
|
|
2008-08-18 16:41:34 +02:00
|
|
|
if options.handNumber==None or options.site==None:
|
2008-08-04 05:44:28 +02:00
|
|
|
print "please supply a hand number and site name. TODO: make this work"
|
|
|
|
|
|
|
|
db = MySQLdb.connect("localhost", "fpdb", options.password, "fpdb")
|
|
|
|
cursor = db.cursor()
|
|
|
|
print "Connected to MySQL on localhost. Print Hand Utility"
|
|
|
|
|
2008-08-18 16:41:34 +02:00
|
|
|
cursor.execute("SELECT id FROM Sites WHERE name=%s", (options.site,))
|
|
|
|
siteId=cursor.fetchone()[0]
|
|
|
|
print "options.site:",options.site,"siteId:",siteId
|
2008-08-04 05:44:28 +02:00
|
|
|
|
2008-08-18 16:41:34 +02:00
|
|
|
print ""
|
|
|
|
print "From Table Hands"
|
|
|
|
print "================"
|
|
|
|
|
|
|
|
cursor.execute("""SELECT Hands.* FROM Hands INNER JOIN Gametypes
|
|
|
|
ON Hands.gametypeId = Gametypes.id WHERE Gametypes.siteId=%s AND Hands.siteHandNo=%s""",
|
|
|
|
(siteId, options.handNumber))
|
|
|
|
handsResult=cursor.fetchone()
|
|
|
|
handId=handsResult[0]
|
|
|
|
tableName=handsResult[1]
|
|
|
|
siteHandNo=options.handNumber
|
|
|
|
gametypeId=handsResult[3]
|
|
|
|
handStart=handsResult[4]
|
|
|
|
#skip importTime
|
|
|
|
seats=handsResult[6]
|
|
|
|
maxSeats=handsResult[7]
|
|
|
|
print "handId:", handId, " tableName:", tableName, " siteHandNo:", siteHandNo, " gametypeId:", gametypeId, " handStart:", handStart, " seats:", seats, " maxSeats:", maxSeats
|
2008-08-04 05:44:28 +02:00
|
|
|
|
|
|
|
|
|
|
|
print ""
|
2008-08-18 16:41:34 +02:00
|
|
|
print "From Table Gametypes"
|
2008-08-04 05:44:28 +02:00
|
|
|
print "===================="
|
|
|
|
|
2008-08-18 16:41:34 +02:00
|
|
|
cursor.execute("""SELECT type, base, category, limitType, hiLo FROM Gametypes WHERE id=%s""", (gametypeId, ))
|
|
|
|
typeEtc=cursor.fetchone()
|
|
|
|
type=typeEtc[0]
|
|
|
|
base=typeEtc[1]
|
|
|
|
category=typeEtc[2]
|
|
|
|
limitType=typeEtc[3]
|
|
|
|
hiLo=typeEtc[4]
|
|
|
|
print "type:", type, " base:", base, " category:", category, " limitType:", limitType, " hiLo:", hiLo
|
2008-08-04 05:44:28 +02:00
|
|
|
|
2008-08-18 16:41:34 +02:00
|
|
|
gtString=""
|
|
|
|
doBets=False
|
|
|
|
if base=="hold":
|
|
|
|
cursor.execute("SELECT smallBlind FROM Gametypes WHERE id=%s", (gametypeId, ))
|
2008-08-04 05:44:28 +02:00
|
|
|
sb=cursor.fetchone()[0]
|
2008-08-18 16:41:34 +02:00
|
|
|
cursor.execute("SELECT bigBlind FROM Gametypes WHERE id=%s", (gametypeId, ))
|
2008-08-04 05:44:28 +02:00
|
|
|
bb=cursor.fetchone()[0]
|
2008-08-18 16:41:34 +02:00
|
|
|
gtString=("sb: "+str(sb)+" bb: "+str(bb))
|
|
|
|
if (limitType=="fl"):
|
|
|
|
doBets=True
|
|
|
|
elif base=="stud":
|
|
|
|
doBets=True
|
2008-08-04 05:44:28 +02:00
|
|
|
|
2008-08-22 23:39:43 +02:00
|
|
|
if doBets:
|
|
|
|
cursor.execute("SELECT smallBet FROM Gametypes WHERE id=%s", (gametypeId, ))
|
2008-08-04 05:44:28 +02:00
|
|
|
sbet=cursor.fetchone()[0]
|
2008-08-22 23:39:43 +02:00
|
|
|
cursor.execute("SELECT bigBet FROM Gametypes WHERE id=%s", (gametypeId, ))
|
2008-08-04 05:44:28 +02:00
|
|
|
bbet=cursor.fetchone()[0]
|
2008-08-22 23:39:43 +02:00
|
|
|
gtString+=(" sbet: "+str(sbet)+" bbet: "+str(bbet))
|
|
|
|
print gtString
|
2008-08-04 05:44:28 +02:00
|
|
|
|
|
|
|
if type=="ring":
|
|
|
|
pass
|
|
|
|
elif type=="tour":
|
|
|
|
#cursor.execute("SELECT tourneys_players_id FROM hands
|
2008-08-22 23:39:43 +02:00
|
|
|
cursor.execute("""SELECT DISTINCT TourneysPlayers.id
|
|
|
|
FROM Hands JOIN HandsPlayers ON HandsPlayers.handId=Hands.id
|
|
|
|
JOIN TourneysPlayers ON HandsPlayers.tourneysPlayersId=TourneysPlayers.id
|
|
|
|
WHERE Hands.id=%s""", (hand_id,))
|
|
|
|
handsPlayersIds=cursor.fetchall()
|
|
|
|
print "dbg hands_players_ids:",handsPlayersIds
|
2008-08-04 05:44:28 +02:00
|
|
|
|
|
|
|
print ""
|
2008-08-22 23:39:43 +02:00
|
|
|
print "From Table Tourneys"
|
2008-08-04 05:44:28 +02:00
|
|
|
print "==================="
|
|
|
|
print "TODO"
|
|
|
|
|
|
|
|
|
|
|
|
print ""
|
2008-08-22 23:39:43 +02:00
|
|
|
print "From Table TourneysPlayers"
|
|
|
|
print "=========================="
|
2008-08-04 05:44:28 +02:00
|
|
|
print "TODO"
|
|
|
|
else:
|
|
|
|
print "invalid type:",type
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
|
|
|
|
print ""
|
2008-08-22 23:39:43 +02:00
|
|
|
print "From Table BoardCards"
|
|
|
|
print "====================="
|
2008-08-04 05:44:28 +02:00
|
|
|
|
|
|
|
if (category=="holdem" or category=="omahahi" or category=="omahahilo"):
|
2008-08-22 23:39:43 +02:00
|
|
|
cursor.execute("""SELECT * FROM BoardCards WHERE handId=%s""",(handId, ))
|
2008-08-04 05:44:28 +02:00
|
|
|
bc=cursor.fetchone()
|
|
|
|
print "Board cards:", ful.cards2String(bc[2:])
|
|
|
|
|
|
|
|
|
|
|
|
print ""
|
2008-08-22 23:39:43 +02:00
|
|
|
print "From Table HandsPlayers"
|
|
|
|
print "======================="
|
|
|
|
cursor.execute("""SELECT * FROM HandsPlayers WHERE handId=%s""",(handId, ))
|
|
|
|
handsPlayers=cursor.fetchall()
|
|
|
|
playerNames=[]
|
|
|
|
for i in range (len(handsPlayers)):
|
|
|
|
line=handsPlayers[i][2:]
|
|
|
|
playerNames.append(ful.id_to_player_name(cursor, line[0]))
|
|
|
|
printstr="playerName:"+playerNames[i]+" playerStartcash:"+str(line[1])
|
2008-08-04 05:44:28 +02:00
|
|
|
if (category=="holdem" or category=="omahahi" or category=="omahahilo"):
|
|
|
|
printstr+=" position:"+ful.position2String(line[2])+" cards:"
|
|
|
|
if (category=="holdem"):
|
2008-08-22 23:39:43 +02:00
|
|
|
printstr+=ful.cards2String(line[5:9])
|
2008-08-04 05:44:28 +02:00
|
|
|
else:
|
2008-08-22 23:39:43 +02:00
|
|
|
printstr+=ful.cards2String(line[5:13])
|
2008-08-04 05:44:28 +02:00
|
|
|
elif (category=="razz" or category=="studhi" or category=="studhilo"):
|
|
|
|
printstr+=" ante:"+str(line[3])+" cards:"
|
2008-08-22 23:39:43 +02:00
|
|
|
printstr+=ful.cards2String(line[5:19])
|
2008-08-04 05:44:28 +02:00
|
|
|
else:
|
|
|
|
print "TODO: raise error, print_hand.py"
|
|
|
|
sys.exit(1)
|
2008-08-22 23:39:43 +02:00
|
|
|
printstr+=" winnings:"+str(line[19])+" rake:"+str(line[20])
|
2008-08-04 05:44:28 +02:00
|
|
|
print printstr
|
|
|
|
|
|
|
|
|
|
|
|
print ""
|
2008-08-22 23:39:43 +02:00
|
|
|
print "From Table HandsActions"
|
|
|
|
print "======================="
|
|
|
|
for i in range (len(handsPlayers)):
|
|
|
|
cursor.execute("""SELECT * FROM HandsActions WHERE handPlayerId=%s""",(handsPlayers[i][0], ))
|
|
|
|
handsActions=cursor.fetchall()
|
|
|
|
for j in range (len(handsActions)):
|
|
|
|
line=handsActions[j][2:]
|
|
|
|
printstr="playerName:"+playerNames[i]
|
2008-08-04 05:44:28 +02:00
|
|
|
printstr+=" street:"+ful.street_int2String(category, line[0])+" streetActionNo:"+str(line[1])+" action:"+line[2]
|
|
|
|
printstr+=" amount:"+str(line[3])
|
|
|
|
print printstr
|
|
|
|
|
|
|
|
cursor.close()
|
|
|
|
db.close()
|
|
|
|
sys.exit(0)
|