Merge git://git.assembla.com/fpdb
This commit is contained in:
+2
-2
@@ -425,7 +425,7 @@ This program is licensed under the AGPL3, see docs"""+os.sep+"agpl-3.0.txt")
|
||||
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
|
||||
self.window.connect("delete_event", self.delete_event)
|
||||
self.window.connect("destroy", self.destroy)
|
||||
self.window.set_title("Free Poker DB - version: alpha6+, p118 or higher")
|
||||
self.window.set_title("Free Poker DB - version: alpha6+, p124 or higher")
|
||||
self.window.set_border_width(1)
|
||||
self.window.set_size_request(1020,400)
|
||||
self.window.set_resizable(True)
|
||||
@@ -449,7 +449,7 @@ This program is licensed under the AGPL3, see docs"""+os.sep+"agpl-3.0.txt")
|
||||
("/Viewers/_Player Stats (tabulated view) (todo)", None, self.not_implemented, 0, None ),
|
||||
("/Viewers/Starting _Hands (todo)", None, self.not_implemented, 0, None ),
|
||||
("/Viewers/_Session Replayer (todo)", None, self.not_implemented, 0, None ),
|
||||
("/Viewers/Poker_table Viewer (obselete)", "<control>T", self.tab_table_viewer, 0, None ),
|
||||
("/Viewers/Poker_table Viewer (mostly obselete)", "<control>T", self.tab_table_viewer, 0, None ),
|
||||
#( "/Viewers/Tourney Replayer
|
||||
( "/_Database", None, None, 0, "<Branch>" ),
|
||||
( "/Database/Create or Delete _Database (todo)", None, self.dia_create_del_database, 0, None ),
|
||||
|
||||
+11
-6
@@ -181,17 +181,22 @@ class Importer:
|
||||
startpos=endpos
|
||||
print "Total stored:", stored, "duplicates:", duplicates, "partial:", partial, "errors:", errors
|
||||
|
||||
if stored==0 and duplicates>0:
|
||||
for line_no in range(len(lines)):
|
||||
if lines[line_no].find("Game #")!=-1:
|
||||
final_game_line=lines[line_no]
|
||||
handsId=fpdb_simple.parseSiteHandNo(final_game_line)
|
||||
#todo: this will cause return of an unstored hand number if the last hadn was error or partial
|
||||
if stored==0:
|
||||
if duplicates>0:
|
||||
for line_no in range(len(lines)):
|
||||
if lines[line_no].find("Game #")!=-1:
|
||||
final_game_line=lines[line_no]
|
||||
handsId=fpdb_simple.parseSiteHandNo(final_game_line)
|
||||
else:
|
||||
print "failed to read a single hand from file:", inputFile
|
||||
handsId=0
|
||||
#todo: this will cause return of an unstored hand number if the last hand was error or partial
|
||||
db.commit()
|
||||
inputFile.close()
|
||||
cursor.close()
|
||||
db.close()
|
||||
return handsId
|
||||
#end def import_file_dict
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -86,6 +86,10 @@ def mainParser(db, cursor, site, category, hand):
|
||||
for i in range(len(hand)):
|
||||
if (lineTypes[i]=="cards"):
|
||||
fpdb_simple.parseCardLine (site, category, lineStreets[i], hand[i], names, cardValues, cardSuits, boardValues, boardSuits)
|
||||
#if category=="studhilo":
|
||||
# print "hand[i]:", hand[i]
|
||||
# print "cardValues:", cardValues
|
||||
# print "cardSuits:", cardSuits
|
||||
elif (lineTypes[i]=="action"):
|
||||
fpdb_simple.parseActionLine (site, base, isTourney, hand[i], lineStreets[i], playerIDs, names, actionTypes, allIns, actionAmounts, actionNos, actionTypeByNo)
|
||||
elif (lineTypes[i]=="win"):
|
||||
@@ -108,8 +112,9 @@ def mainParser(db, cursor, site, category, hand):
|
||||
tableResult=fpdb_simple.parseTableLine(site, base, hand[0])
|
||||
maxSeats=tableResult['maxSeats']
|
||||
tableName=tableResult['tableName']
|
||||
#print "before part5, antes:", antes
|
||||
|
||||
#part 5: final preparations, then call fpdb_save_to_db.saveHoldem with
|
||||
#part 5: final preparations, then call fpdb_save_to_db.* with
|
||||
# the arrays as they are - that file will fill them.
|
||||
fpdb_simple.convertCardValues(cardValues)
|
||||
if base=="hold":
|
||||
@@ -140,11 +145,8 @@ def mainParser(db, cursor, site, category, hand):
|
||||
result = fpdb_save_to_db.tourney_holdem_omaha(cursor, base, category, siteTourneyNo, buyin, fee, knockout, entries, prizepool, tourneyStartTime, payin_amounts, ranks, tourneyTypeId, siteID,
|
||||
siteHandNo, gametypeID, handStartTime, names, playerIDs, startCashes, positions, cardValues, cardSuits, boardValues, boardSuits, winnings, rakes, actionTypes, allIns, actionAmounts, actionNos, hudImportData, maxSeats, tableName, seatNos)
|
||||
elif base=="stud":
|
||||
result = fpdb_save_to_db.tourney_stud(cursor, base, category, siteTourneyNo, buyin, fee,
|
||||
knockout, entries, prizepool, tourneyStartTime, payin_amounts, ranks,
|
||||
siteHandNo, siteID, gametypeID, handStartTime, names, playerIDs,
|
||||
startCashes, antes, cardValues, cardSuits, winnings, rakes,
|
||||
actionTypes, allIns, actionAmounts, actionNos, hudImportData, maxSeats, tableName, seatNos)
|
||||
result = fpdb_save_to_db.tourney_stud(cursor, base, category, siteTourneyNo, buyin, fee, knockout, entries, prizepool, tourneyStartTime, payin_amounts, ranks, tourneyTypeId, siteID,
|
||||
siteHandNo, gametypeID, handStartTime, names, playerIDs, startCashes, antes, cardValues, cardSuits, winnings, rakes, actionTypes, allIns, actionAmounts, actionNos, hudImportData, maxSeats, tableName, seatNos)
|
||||
else:
|
||||
raise fpdb_simple.FpdbError ("unrecognised category")
|
||||
else:
|
||||
|
||||
+10
-13
@@ -26,6 +26,7 @@ def ring_stud(cursor, base, category, site_hand_no, gametype_id, hand_start_time
|
||||
|
||||
hands_id=fpdb_simple.storeHands(cursor, site_hand_no, gametype_id, hand_start_time, names, tableName, maxSeats)
|
||||
|
||||
#print "before calling store_hands_players_stud, antes:", antes
|
||||
hands_players_ids=fpdb_simple.store_hands_players_stud(cursor, hands_id, player_ids,
|
||||
start_cashes, antes, card_values, card_suits, winnings, rakes, seatNos)
|
||||
|
||||
@@ -73,25 +74,21 @@ def tourney_holdem_omaha(cursor, base, category, siteTourneyNo, buyin, fee, knoc
|
||||
return hands_id
|
||||
#end def tourney_holdem_omaha
|
||||
|
||||
def tourney_stud(cursor, base, category, site_tourney_no, buyin, fee, knockout, entries, prizepool,
|
||||
tourney_start, payin_amounts, ranks, #end of tourney specific params
|
||||
site_hand_no, site_id, gametype_id, hand_start_time, names, player_ids,
|
||||
start_cashes, antes, card_values, card_suits, winnings, rakes,
|
||||
action_types, allIns, action_amounts, hudImportData):
|
||||
def tourney_stud(cursor, base, category, siteTourneyNo, buyin, fee, knockout, entries, prizepool, tourneyStartTime, payin_amounts, ranks, tourneyTypeId, siteId,
|
||||
siteHandNo, gametypeId, handStartTime, names, playerIds, startCashes, antes, cardValues, cardSuits, winnings, rakes, actionTypes, allIns, actionAmounts, actionNos, hudImportData, maxSeats, tableName, seatNos):
|
||||
#stores a tourney stud/razz hand into the database
|
||||
fpdb_simple.fillCardArrays(len(names), base, category, card_values, card_suits)
|
||||
fpdb_simple.fillCardArrays(len(names), base, category, cardValues, cardSuits)
|
||||
|
||||
tourney_id=fpdb_simple.store_tourneys(cursor, site_id, site_tourney_no, buyin, fee, knockout, entries, prizepool, tourney_start)
|
||||
tourney_id=fpdb_simple.store_tourneys(cursor, tourneyTypeId, siteTourneyNo, entries, prizepool, tourneyStartTime)
|
||||
|
||||
tourneys_players_ids=fpdb_simple.store_tourneys_players(cursor, tourney_id, player_ids, payin_amounts, ranks, winnings)
|
||||
tourneys_players_ids=fpdb_simple.store_tourneys_players(cursor, tourney_id, playerIds, payin_amounts, ranks, winnings)
|
||||
|
||||
hands_id=fpdb_simple.storeHands(cursor, site_hand_no, gametype_id, hand_start_time, names)
|
||||
hands_id=fpdb_simple.storeHands(cursor, siteHandNo, gametypeId, handStartTime, names, tableName, maxSeats)
|
||||
|
||||
hands_players_ids=fpdb_simple.store_hands_players_stud_tourney(cursor, hands_id, player_ids,
|
||||
start_cashes, antes, card_values, card_suits, winnings, rakes, tourneys_players_ids)
|
||||
hands_players_ids=fpdb_simple.store_hands_players_stud_tourney(cursor, hands_id, playerIds, startCashes, antes, cardValues, cardSuits, winnings, rakes, seatNos, tourneys_players_ids)
|
||||
|
||||
fpdb_simple.storeHudData(cursor, base, category, player_ids, hudImportData)
|
||||
fpdb_simple.storeHudCache(cursor, base, category, gametypeId, playerIds, hudImportData)
|
||||
|
||||
fpdb_simple.storeActions(cursor, hands_players_ids, action_types, allIns, action_amounts)
|
||||
fpdb_simple.storeActions(cursor, hands_players_ids, actionTypes, allIns, actionAmounts, actionNos)
|
||||
return hands_id
|
||||
#end def tourney_stud
|
||||
|
||||
+67
-18
@@ -579,6 +579,7 @@ def parseActionAmount(line, atype, site, isTourney):
|
||||
else:
|
||||
if not isTourney:
|
||||
pos=line.rfind("$")+1
|
||||
#print "parseActionAmount, line:", line, "line[pos:]:", line[pos:]
|
||||
amount=float2int(line[pos:])
|
||||
else:
|
||||
#print "line:"+line+"EOL"
|
||||
@@ -676,7 +677,6 @@ def parseActionType(line):
|
||||
|
||||
#parses the ante out of the given line and checks which player paid it, updates antes accordingly.
|
||||
def parseAnteLine(line, site, isTourney, names, antes):
|
||||
#print "parseAnteLine line: ",line
|
||||
for i in range(len(names)):
|
||||
if (line.startswith(names[i].encode("latin-1"))): #found the ante'er
|
||||
pos=line.rfind("$")+1
|
||||
@@ -690,6 +690,7 @@ def parseAnteLine(line, site, isTourney, names, antes):
|
||||
pos1=line.rfind("ante")+5
|
||||
pos2=line.find(" ",pos1)
|
||||
antes[i]+=int(line[pos1:pos2])
|
||||
#print "parseAnteLine line: ", line, "antes[i]", antes[i], "antes", antes
|
||||
#end def parseAntes
|
||||
|
||||
#returns the buyin of a tourney in cents
|
||||
@@ -730,18 +731,31 @@ def parseCardLine(site, category, street, line, names, cardValues, cardSuits, bo
|
||||
raise FpdbError("read too many/too few holecards in parseCardLine")
|
||||
elif (category=="razz" or category=="studhi" or category=="studhilo"):
|
||||
if (line.find("shows")==-1):
|
||||
cardValues[playerNo][street-1]=line[pos:pos+1]
|
||||
cardSuits[playerNo][street-1]=line[pos+1:pos+2]
|
||||
#print "parseCardLine(in stud if), street:", street
|
||||
if line[pos+2]=="]": #-> not (hero and 3rd street)
|
||||
cardValues[playerNo][street+2]=line[pos:pos+1]
|
||||
cardSuits[playerNo][street+2]=line[pos+1:pos+2]
|
||||
else:
|
||||
#print "hero card1:", line[pos:pos+2], "hero card2:", line[pos+3:pos+5], "hero card3:", line[pos+6:pos+8],
|
||||
cardValues[playerNo][street]=line[pos:pos+1]
|
||||
cardSuits[playerNo][street]=line[pos+1:pos+2]
|
||||
cardValues[playerNo][street+1]=line[pos+3:pos+4]
|
||||
cardSuits[playerNo][street+1]=line[pos+4:pos+5]
|
||||
cardValues[playerNo][street+2]=line[pos+6:pos+7]
|
||||
cardSuits[playerNo][street+2]=line[pos+7:pos+8]
|
||||
else:
|
||||
#print "parseCardLine(in stud else), street:", street
|
||||
cardValues[playerNo][0]=line[pos:pos+1]
|
||||
cardSuits[playerNo][0]=line[pos+1:pos+2]
|
||||
pos+=3
|
||||
cardValues[playerNo][1]=line[pos:pos+1]
|
||||
cardSuits[playerNo][1]=line[pos+1:pos+2]
|
||||
if street==7:
|
||||
pos+=15
|
||||
if street==4:
|
||||
pos=pos=line.rfind("]")-2
|
||||
cardValues[playerNo][6]=line[pos:pos+1]
|
||||
cardSuits[playerNo][6]=line[pos+1:pos+2]
|
||||
#print "cardValues:", cardValues
|
||||
#print "cardSuits:", cardSuits
|
||||
else:
|
||||
print "line:",line,"street:",street
|
||||
raise FpdbError("invalid category")
|
||||
@@ -1267,6 +1281,7 @@ def store_hands_players_stud(cursor, hands_id, player_ids, start_cashes, antes,
|
||||
card_values, card_suits, winnings, rakes, seatNos):
|
||||
#stores hands_players rows for stud/razz games. returns an array of the resulting IDs
|
||||
result=[]
|
||||
#print "before inserts in store_hands_players_stud, antes:", antes
|
||||
for i in range (len(player_ids)):
|
||||
cursor.execute ("""INSERT INTO HandsPlayers
|
||||
(handId, playerId, startCash, ante,
|
||||
@@ -1319,24 +1334,24 @@ def store_hands_players_holdem_omaha_tourney(cursor, category, hands_id, player_
|
||||
#end def store_hands_players_holdem_omaha_tourney
|
||||
|
||||
def store_hands_players_stud_tourney(cursor, hands_id, player_ids, start_cashes,
|
||||
antes, card_values, card_suits, winnings, rakes, tourneys_players_ids):
|
||||
antes, card_values, card_suits, winnings, rakes, seatNos, tourneys_players_ids):
|
||||
#stores hands_players for tourney stud/razz hands
|
||||
result=[]
|
||||
for i in range (len(player_ids)):
|
||||
cursor.execute ("""INSERT INTO HandsPlayers
|
||||
(hand_id, player_id, player_startcash, ante,
|
||||
card1_value, card1_suit, card2_value, card2_suit,
|
||||
card3_value, card3_suit, card4_value, card4_suit,
|
||||
card5_value, card5_suit, card6_value, card6_suit,
|
||||
card7_value, card7_suit, winnings, rake, tourneys_players_id)
|
||||
(handId, playerId, startCash, ante,
|
||||
card1Value, card1Suit, card2Value, card2Suit,
|
||||
card3Value, card3Suit, card4Value, card4Suit,
|
||||
card5Value, card5Suit, card6Value, card6Suit,
|
||||
card7Value, card7Suit, winnings, rake, tourneysPlayersId, seatNo)
|
||||
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)""",
|
||||
(hands_id, player_ids[i], start_cashes[i], antes[i],
|
||||
card_values[i][0], card_suits[i][0], card_values[i][1], card_suits[i][1],
|
||||
card_values[i][2], card_suits[i][2], card_values[i][3], card_suits[i][3],
|
||||
card_values[i][4], card_suits[i][4], card_values[i][5], card_suits[i][5],
|
||||
card_values[i][6], card_suits[i][6], winnings[i], rakes[i], tourneys_players_ids[i]))
|
||||
cursor.execute("SELECT id FROM hands_players WHERE hand_id=%s AND player_id=%s", (hands_id, player_ids[i]))
|
||||
card_values[i][6], card_suits[i][6], winnings[i], rakes[i], tourneys_players_ids[i], seatNos[i]))
|
||||
cursor.execute("SELECT id FROM HandsPlayers WHERE handId=%s AND playerId=%s", (hands_id, player_ids[i]))
|
||||
result.append(cursor.fetchall()[0][0])
|
||||
return result
|
||||
#end def store_hands_players_stud_tourney
|
||||
@@ -1511,10 +1526,26 @@ def generateHudCacheData(player_ids, base, category, action_types, allIns, actio
|
||||
if (len(action_types[3][player])>0 or isAllIn):
|
||||
myStreet3Seen=True
|
||||
|
||||
mySawShowdown=True
|
||||
for count in range (len(action_types[3][player])):
|
||||
if action_types[3][player][count]=="fold":
|
||||
mySawShowdown=False
|
||||
#print "base:", base
|
||||
if base=="hold":
|
||||
mySawShowdown=True
|
||||
for count in range (len(action_types[3][player])):
|
||||
if action_types[3][player][count]=="fold":
|
||||
mySawShowdown=False
|
||||
else:
|
||||
#print "in else"
|
||||
for i in range(len(allIns[3][player])):
|
||||
if allIns[3][player][i]:
|
||||
isAllIn=True
|
||||
if (len(action_types[4][player])>0 or isAllIn):
|
||||
#print "in if"
|
||||
myStreet4Seen=True
|
||||
|
||||
mySawShowdown=True
|
||||
for count in range (len(action_types[4][player])):
|
||||
if action_types[4][player][count]=="fold":
|
||||
mySawShowdown=False
|
||||
|
||||
|
||||
#flop stuff
|
||||
street=1
|
||||
@@ -1570,6 +1601,24 @@ def generateHudCacheData(player_ids, base, category, action_types, allIns, actio
|
||||
if action_types[street][player][countOtherFold]=="fold":
|
||||
myFoldToOtherRaisedStreet3=True
|
||||
|
||||
#stud river stuff - copy of flop with different vars
|
||||
street=4
|
||||
if myStreet4Seen:
|
||||
for count in range(len(action_types[street][player])):
|
||||
if action_types[street][player][count]=="bet":
|
||||
myStreet4Aggr=True
|
||||
|
||||
for otherPlayer in range (len(player_ids)):
|
||||
if player==otherPlayer:
|
||||
pass
|
||||
else:
|
||||
for countOther in range (len(action_types[street][otherPlayer])):
|
||||
if action_types[street][otherPlayer][countOther]=="bet":
|
||||
myOtherRaisedStreet4=True
|
||||
for countOtherFold in range (len(action_types[street][player])):
|
||||
if action_types[street][player][countOtherFold]=="fold":
|
||||
myFoldToOtherRaisedStreet4=True
|
||||
|
||||
if winnings[player]!=0:
|
||||
if myStreet1Seen:
|
||||
myWonWhenSeenStreet1=winnings[player]/float(totalWinnings)
|
||||
|
||||
Reference in New Issue
Block a user