Merge branch 'master' of git://git.assembla.com/fpdb-eric

Conflicts:

	pyfpdb/Configuration.py
	pyfpdb/Database.py
This commit is contained in:
Ray 2009-03-11 22:46:28 -04:00
commit 6bf7be6ae5
6 changed files with 155 additions and 133 deletions

52
pyfpdb/Configuration.py Executable file → Normal file
View File

@ -43,7 +43,6 @@ class Layout:
self.location = []
self.location = map(lambda x: None, range(self.max+1)) # there must be a better way to do this?
for location_node in node.getElementsByTagName('location'):
if location_node.getAttribute('seat') != "":
self.location[int( location_node.getAttribute('seat') )] = (int( location_node.getAttribute('x') ), int( location_node.getAttribute('y')))
@ -57,7 +56,7 @@ class Layout:
if hasattr(self, "common"):
temp = temp + " Common = (%d, %d)\n" % (self.common[0], self.common[1])
temp = temp + " Locations = "
for i in xrange(1, len(self.location)):
for i in range(1, len(self.location)):
temp = temp + "(%d,%d)" % self.location[i]
return temp + "\n"
@ -86,17 +85,16 @@ class Site:
self.layout[lo.max] = lo
def __str__(self):
temp = "Site = %s\n" % self.site_name
temp = "Site = " + self.site_name + "\n"
for key in dir(self):
if key.startswith('__'): continue
if key == 'layout': continue
value = getattr(self, key)
if callable(value): continue
temp = "%s %s = %s\n" % (temp, key, str(value))
temp = temp + ' ' + key + " = " + str(value) + "\n"
for layout in self.layout:
temp = "%s%s" % (temp, self.layout[layout])
temp = temp + "%s" % self.layout[layout]
return temp
@ -137,10 +135,14 @@ class Game:
self.stats[stat.stat_name] = stat
def __str__(self):
temp = "Game = %s\n db = %s\n rows = %d\n cols = %d\n aux = %s\n" % (self.game_name, self.db, self.rows, self.cols, self.aux)
temp = "Game = " + self.game_name + "\n"
temp = temp + " db = %s\n" % self.db
temp = temp + " rows = %d\n" % self.rows
temp = temp + " cols = %d\n" % self.cols
temp = temp + " aux = %s\n" % self.aux
for stat in self.stats.keys():
temp = "%s%s" % (temp, self.stats[stat])
temp = temp + "%s" % self.stats[stat]
return temp
@ -409,7 +411,7 @@ class Config:
site_node = self.get_site_node(site_name)
layout_node = self.get_layout_node(site_node, max)
if layout_node == None: return
for i in xrange(1, max + 1):
for i in range(1, max + 1):
location_node = self.get_location_node(layout_node, i)
location_node.setAttribute("x", str( locations[i-1][0] ))
location_node.setAttribute("y", str( locations[i-1][1] ))
@ -499,17 +501,35 @@ class Config:
def get_default_colors(self, site = "PokerStars"):
colors = {}
colors['hudopacity'] = float(self.supported_sites[site].hudopacity) if self.supported_sites[site].hudopacity != "" else 0.90
colors['hudbgcolor'] = self.supported_sites[site].hudbgcolor if self.supported_sites[site].hudbgcolor != "" else "#FFFFFF"
colors['hudfgcolor'] = self.supported_sites[site].hudfgcolor if self.supported_sites[site].hudfgcolor != "" else "#000000"
if self.supported_sites[site].hudopacity == "":
colors['hudopacity'] = 0.90
else:
colors['hudopacity'] = float(self.supported_sites[site].hudopacity)
if self.supported_sites[site].hudbgcolor == "":
colors['hudbgcolor'] = "#FFFFFF"
else:
colors['hudbgcolor'] = self.supported_sites[site].hudbgcolor
if self.supported_sites[site].hudfgcolor == "":
colors['hudfgcolor'] = "#000000"
else:
colors['hudfgcolor'] = self.supported_sites[site].hudfgcolor
return colors
def get_default_font(self, site = 'PokerStars'):
font = self.supported_sites[site].font if self.supported_sites[site].font != "" else "Sans"
font_size = self.supported_sites[site].font_size if self.supported_sites[site].font != "" else "8"
(font, font_size) = ("Sans", "8")
if self.supported_sites[site].font == "":
font = "Sans"
else:
font = self.supported_sites[site].font
if self.supported_sites[site].font_size == "":
font_size = "8"
else:
font_size = self.supported_sites[site].font_size
return (font, font_size)
def get_locations(self, site = "PokerStars", max = "8"):
try:
locations = self.supported_sites[site].layout[max].location
except:
@ -586,7 +606,7 @@ class Config:
def get_aux_parameters(self, name):
"""Gets a dict of mucked window parameters from the named mw."""
param = {}
if name in self.aux_windows:
if self.aux_windows.has_key(name):
for key in dir(self.aux_windows[name]):
if key.startswith('__'): continue
value = getattr(self.aux_windows[name], key)
@ -599,7 +619,7 @@ class Config:
def get_game_parameters(self, name):
"""Get the configuration parameters for the named game."""
param = {}
if name in self.supported_games:
if self.supported_games.has_key(name):
param['game_name'] = self.supported_games[name].game_name
param['db'] = self.supported_games[name].db
param['rows'] = self.supported_games[name].rows
@ -610,7 +630,7 @@ class Config:
def get_supported_games(self):
"""Get the list of supported games."""
sg = []
for game in c.supported_games:
for game in c.supported_games.keys():
sg.append(c.supported_games[game].game_name)
return sg

20
pyfpdb/Database.py Executable file → Normal file
View File

@ -146,14 +146,22 @@ class Database:
ranks = ('', '', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A')
cards = ""
for i in xrange(1, 8):
key = 'card' + str(i) + 'Value'
if not d.has_key(key): continue
if d[key] == None:
# key = 'card' + str(i) + 'Value'
# if not d.has_key(key): continue
# if d[key] == None:
# break
# elif d[key] == 0:
# cards += "xx"
# else:
# cards += ranks[d['card' + str(i) + 'Value']] + d['card' +str(i) + 'Suit']
cv = "card%dValue" % i
if cv not in d or d[cv] == None:
break
elif d[key] == 0:
cards += "xx"
elif d[cv] == 0:
cards = "%sxx" % cards
else:
cards += ranks[d['card' + str(i) + 'Value']] + d['card' +str(i) + 'Suit']
cs = "card%dSuit" % i
cards = "%s%s%s" % (cards, ranks[d[cv]], d[cs])
return cards
def get_action_from_hand(self, hand_no):

View File

@ -152,9 +152,9 @@ class HUD_main(object):
(table_name, max, poker_game) = self.db_connection.get_table_name(new_hand_id)
stat_dict = self.db_connection.get_stats_from_hand(new_hand_id)
cards = self.db_connection.get_cards(new_hand_id)
except:
print "skipping ", new_hand_id
sys.stderr.write("Database error in hand %d. Skipping.\n" % int(new_hand_id))
except Exception, err:
print "db error: skipping ", new_hand_id, err
sys.stderr.write("Database error %s in hand %d. Skipping.\n" % (err, int(new_hand_id)))
continue
# find out if this hand is from a tournament

View File

@ -326,7 +326,10 @@ Map the tuple self.gametype onto the pokerstars string describing it
"Everleaf" : { "0.10" : ("0.02", "0.05"),
"0.20" : ("0.05", "0.10"),
"0.50" : ("0.10", "0.25"),
"1.00" : ("0.25", "0.50")
"1" : ("0.25", "0.50"),
"2" : ("0.50", "1.00"),
"4" : ("1.00", "2.00"),
"6" : ("1.00", "3.00")
},
"FullTilt" : { "0.10" : ("0.02", "0.05"),
"0.20" : ("0.05", "0.10"),

View File

@ -156,6 +156,8 @@ class Hud:
self.main_window.gdkhandle = gtk.gdk.window_foreign_new(self.main_window.window.xid) # gets a gdk handle for the hud table window
self.main_window.gdkhandle.set_transient_for(self.main_window.parentgdkhandle) #
self.update_table_position()
def update_table_position(self):
if os.name == 'nt':
if not win32gui.IsWindow(self.table.number):
@ -197,6 +199,7 @@ class Hud:
self.aux_windows = []
def reposition_windows(self, *args):
if self.stat_windows and len(self.stat_windows > 0):
map(lambda x: x.window.move(x.x, x.y), self.stat_windows)
return True
@ -248,6 +251,7 @@ class Hud:
#
# this method also manages the creating and destruction of stat
# windows via calls to the Stat_Window class
self.hand = hand
if not self.mw_created:
self.create_mw()

View File

@ -374,14 +374,14 @@ def getLastInsertId(backend, conn, cursor):
#returns an array of the total money paid. intending to add rebuys/addons here
def calcPayin(count, buyin, fee):
result=[]
for i in range(count):
for i in xrange(count):
result.append (buyin+fee)
return result
#end def calcPayin
def checkPositions(positions):
"""verifies that these positions are valid"""
for i in range (len(positions)):
for i in xrange(len(positions)):
pos=positions[i]
try:#todo: use type recognition instead of error
if (len(pos)!=1):
@ -460,10 +460,10 @@ def classifyLines(hand, category, lineTypes, lineStreets):
def convert3B4B(site, category, limit_type, actionTypes, actionAmounts):
"""calculates the actual bet amounts in the given amount array and changes it accordingly."""
for i in range (len(actionTypes)):
for j in range (len(actionTypes[i])):
for i in xrange(len(actionTypes)):
for j in xrange(len(actionTypes[i])):
bets=[]
for k in range (len(actionTypes[i][j])):
for k in xrange(len(actionTypes[i][j])):
if (actionTypes[i][j][k]=="bet"):
bets.append((i,j,k))
if (len(bets)==2):
@ -489,10 +489,10 @@ def convert3B4B(site, category, limit_type, actionTypes, actionAmounts):
#Corrects the bet amount if the player had to pay blinds
def convertBlindBet(actionTypes, actionAmounts):
i=0#setting street to pre-flop
for j in range (len(actionTypes[i])):#playerloop
for j in xrange(len(actionTypes[i])):#playerloop
blinds=[]
bets=[]
for k in range (len(actionTypes[i][j])):
for k in xrange(len(actionTypes[i][j])):
if (actionTypes[i][j][k]=="blind"):
blinds.append((i,j,k))
@ -507,25 +507,12 @@ def convertBlindBet(actionTypes, actionAmounts):
#converts the strings in the given array to ints (changes the passed array, no returning). see table design for conversion details
#todo: make this use convertCardValuesBoard
def convertCardValues(arr):
for i in range (len(arr)):
for j in range (len(arr[i])):
if (arr[i][j]=="A"):
arr[i][j]=14
elif (arr[i][j]=="K"):
arr[i][j]=13
elif (arr[i][j]=="Q"):
arr[i][j]=12
elif (arr[i][j]=="J"):
arr[i][j]=11
elif (arr[i][j]=="T"):
arr[i][j]=10
else:
arr[i][j]=int(arr[i][j])
map(convertCardValuesBoard, arr)
#end def convertCardValues
#converts the strings in the given array to ints (changes the passed array, no returning). see table design for conversion details
def convertCardValuesBoard(arr):
for i in range (len(arr)):
for i in xrange(len(arr)):
if (arr[i]=="A"):
arr[i]=14
elif (arr[i]=="K"):
@ -542,7 +529,7 @@ def convertCardValuesBoard(arr):
#this creates the 2D/3D arrays. manipulates the passed arrays instead of returning.
def createArrays(category, seats, card_values, card_suits, antes, winnings, rakes, action_types, allIns, action_amounts, actionNos, actionTypeByNo):
for i in range(seats):#create second dimension arrays
for i in xrange(seats):#create second dimension arrays
tmp=[]
card_values.append(tmp)
tmp=[]
@ -556,7 +543,7 @@ def createArrays(category, seats, card_values, card_suits, antes, winnings, rake
else:
streetCount=5
for i in range(streetCount): #build the first dimension array, for streets
for i in xrange(streetCount): #build the first dimension array, for streets
tmp=[]
action_types.append(tmp)
tmp=[]
@ -567,7 +554,7 @@ def createArrays(category, seats, card_values, card_suits, antes, winnings, rake
actionNos.append(tmp)
tmp=[]
actionTypeByNo.append(tmp)
for j in range (seats): #second dimension arrays: players
for j in xrange (seats): #second dimension arrays: players
tmp=[]
action_types[i].append(tmp)
tmp=[]
@ -579,8 +566,8 @@ def createArrays(category, seats, card_values, card_suits, antes, winnings, rake
if (category=="holdem" or category=="omahahi" or category=="omahahilo"):
pass
elif (category=="razz" or category=="studhi" or category=="studhilo"):#need to fill card arrays.
for i in range(seats):
for j in range (7):
for i in xrange(seats):
for j in xrange (7):
card_values[i].append(0)
card_suits[i].append("x")
else:
@ -605,7 +592,7 @@ def fillCardArrays(player_count, base, category, card_values, card_suits):
else:
raise fpdb_simple.FpdbError ("invalid category:", category)
for i in range (player_count):
for i in xrange (player_count):
while (len(card_values[i])<cardCount):
card_values[i].append(0)
card_suits[i].append("x")
@ -618,16 +605,16 @@ def filterAnteBlindFold(site,hand):
#todo: in tourneys this should not be removed but
#print "start of filterAnteBlindFold"
pre3rd=[]
for i in range (len(hand)):
for i in xrange (len(hand)):
if (hand[i].startswith("*** 3") or hand[i].startswith("*** HOLE")):
pre3rd=hand[0:i]
foldeeName=None
for i in range (len(pre3rd)):
for i in xrange (len(pre3rd)):
if (pre3rd[i].endswith("folds") or pre3rd[i].endswith("is sitting out") or pre3rd[i].endswith(" stands up")): #found ante fold or timeout
pos=pre3rd[i].find (" folds")
foldeeName=pre3rd[i][0:pos]
if pos==-1 and pre3rd[i].find(" in chips)")==-1:
if pos == -1 and " in chips)" not in pre3rd[i]:
pos=pre3rd[i].find (" is sitting out")
foldeeName=pre3rd[i][0:pos]
if pos==-1:
@ -641,19 +628,19 @@ def filterAnteBlindFold(site,hand):
if foldeeName!=None:
#print "filterAnteBlindFold, foldeeName:",foldeeName
toRemove=[]
for i in range (len(hand)): #using hand again to filter from all streets, just in case.
for i in xrange(len(hand)): #using hand again to filter from all streets, just in case.
#todo: this will break it if sittin out BB wins a hand
if (hand[i].find(foldeeName)!=-1):
toRemove.append(hand[i])
for i in range (len(toRemove)):
for i in xrange(len(toRemove)):
hand.remove(toRemove[i])
#end def filterAnteFold
#removes useless lines as well as trailing spaces
def filterCrap(site, hand, isTourney):
#remove two trailing spaces at end of line
for i in range (len(hand)):
for i in xrange (len(hand)):
if (hand[i][-1]==' '):
hand[i]=hand[i][:-1]
if (hand[i][-1]==' '):
@ -662,7 +649,7 @@ def filterCrap(site, hand, isTourney):
#print "hand after trailing space removal in filterCrap:",hand
#general variable position word filter/string filter
toRemove=[]
for i in range (len(hand)):
for i in xrange (len(hand)):
if (hand[i].startswith("Board [")):
toRemove.append(hand[i])
elif (hand[i].find(" out of hand ")!=-1):
@ -759,7 +746,7 @@ def filterCrap(site, hand, isTourney):
toRemove.append(hand[i])
for i in range (len(toRemove)):
for i in xrange (len(toRemove)):
#print "removing in filterCr:",toRemove[i]
hand.remove(toRemove[i])
@ -949,8 +936,8 @@ def parseActionLine(site, base, isTourney, line, street, playerIDs, names, actio
street=3
nextActionNo=0
for player in range(len(actionNos[street])):
for count in range(len(actionNos[street][player])):
for player in xrange(len(actionNos[street])):
for count in xrange(len(actionNos[street][player])):
if actionNos[street][player][count]>=nextActionNo:
nextActionNo=actionNos[street][player][count]+1
@ -1019,7 +1006,7 @@ 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):
for i in range(len(names)):
for i in xrange(len(names)):
if (line.startswith(names[i].encode("latin-1"))): #found the ante'er
pos=line.rfind("$")+1
if not isTourney:
@ -1122,7 +1109,7 @@ def parseCashesAndSeatNos(lines, site):
"""parses the startCashes and seatNos of each player out of the given lines and returns them as a dictionary of two arrays"""
cashes = []
seatNos = []
for i in range (len(lines)):
for i in xrange (len(lines)):
pos2=lines[i].find(":")
seatNos.append(int(lines[i][5:pos2]))
@ -1200,7 +1187,7 @@ def parseHandStartTime(topline, site):
#parses the names out of the given lines and returns them as an array
def parseNames(lines):
result = []
for i in range (len(lines)):
for i in xrange (len(lines)):
pos1=lines[i].find(":")+2
pos2=lines[i].rfind("(")-1
tmp=lines[i][pos1:pos2]
@ -1215,12 +1202,12 @@ def parseNames(lines):
def parsePositions (hand, names):
#prep array
positions=[]
for i in range(len(names)):
for i in xrange(len(names)):
positions.append(-1)
#find blinds
sb,bb=-1,-1
for i in range (len(hand)):
for i in xrange (len(hand)):
if (sb==-1 and hand[i].find("small blind")!=-1 and hand[i].find("dead small blind")==-1):
sb=hand[i]
#print "sb:",sb
@ -1283,7 +1270,7 @@ def parsePositions (hand, names):
arraypos-=1
distFromBtn+=1
for i in range (len(names)):
for i in xrange (len(names)):
if positions[i]==-1:
print "parsePositions names:",names
print "result:",positions
@ -1355,7 +1342,7 @@ def parseTourneyNo(topline):
#parses a win/collect line. manipulates the passed array winnings, no explicit return
def parseWinLine(line, site, names, winnings, isTourney):
#print "parseWinLine: line:",line
for i in range(len(names)):
for i in xrange(len(names)):
if (line.startswith(names[i].encode("latin-1"))): #found a winner
if isTourney:
pos1=line.rfind("collected ")+10
@ -1515,7 +1502,7 @@ def recogniseTourneyTypeId(cursor, siteId, buyin, fee, knockout, rebuyOrAddon):
#returns the SQL ids of the names given in an array
def recognisePlayerIDs(cursor, names, site_id):
result = []
for i in range (len(names)):
for i in xrange(len(names)):
cursor.execute ("SELECT id FROM Players WHERE name=%s", (names[i],))
tmp=cursor.fetchall()
if (len(tmp)==0): #new player
@ -1531,7 +1518,7 @@ def recognisePlayerIDs(cursor, names, site_id):
#recognises the name in the given line and returns its array position in the given array
def recognisePlayerNo(line, names, atype):
#print "recogniseplayerno, names:",names
for i in range (len(names)):
for i in xrange(len(names)):
if (atype=="unbet"):
if (line.endswith(names[i].encode("latin-1"))):
return (i)
@ -1581,7 +1568,7 @@ def recogniseSiteID(cursor, site):
#removes trailing \n from the given array
def removeTrailingEOL(arr):
for i in range(len(arr)):
for i in xrange(len(arr)):
if (arr[i].endswith("\n")):
#print "arr[i] before removetrailingEOL:", arr[i]
arr[i]=arr[i][:-1]
@ -1593,7 +1580,7 @@ def removeTrailingEOL(arr):
def splitRake(winnings, rakes, totalRake):
winnercnt=0
totalWin=0
for i in range(len(winnings)):
for i in xrange(len(winnings)):
if winnings[i]!=0:
winnercnt+=1
totalWin+=winnings[i]
@ -1602,7 +1589,7 @@ def splitRake(winnings, rakes, totalRake):
rakes[firstWinner]=totalRake
else:
totalWin=float(totalWin)
for i in range(len(winnings)):
for i in xrange(len(winnings)):
if winnings[i]!=0:
winPortion=winnings[i]/totalWin
rakes[i]=totalRake*winPortion
@ -1612,9 +1599,9 @@ def storeActions(cursor, handsPlayersIds, actionTypes, allIns, actionAmounts, ac
#stores into table hands_actions
#print "start of storeActions, actionNos:",actionNos
#print " action_amounts:",action_amounts
for i in range (len(actionTypes)): #iterate through streets
for j in range (len(actionTypes[i])): #iterate through names
for k in range (len(actionTypes[i][j])): #iterate through individual actions of that player on that street
for i in xrange(len(actionTypes)): #iterate through streets
for j in xrange(len(actionTypes[i])): #iterate through names
for k in xrange(len(actionTypes[i][j])): #iterate through individual actions of that player on that street
cursor.execute ("INSERT INTO HandsActions (handPlayerId, street, actionNo, action, allIn, amount) VALUES (%s, %s, %s, %s, %s, %s)"
, (handsPlayersIds[j], i, actionNos[i][j][k], actionTypes[i][j][k], allIns[i][j][k], actionAmounts[i][j][k]))
#end def storeActions
@ -1644,7 +1631,7 @@ def store_hands_players_holdem_omaha(backend, conn, cursor, category, hands_id,
,positions, card_values, card_suits, winnings, rakes, seatNos):
result=[]
if (category=="holdem"):
for i in range (len(player_ids)):
for i in xrange(len(player_ids)):
cursor.execute ("""
INSERT INTO HandsPlayers
(handId, playerId, startCash, position,
@ -1657,7 +1644,7 @@ VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)""",
#result.append(cursor.fetchall()[0][0])
result.append( getLastInsertId(backend, conn, cursor) ) # mysql only
elif (category=="omahahi" or category=="omahahilo"):
for i in range (len(player_ids)):
for i in xrange(len(player_ids)):
cursor.execute ("""INSERT INTO HandsPlayers
(handId, playerId, startCash, position,
card1Value, card1Suit, card2Value, card2Suit,
@ -1680,7 +1667,7 @@ def store_hands_players_stud(backend, conn, cursor, hands_id, player_ids, start_
#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)):
for i in xrange(len(player_ids)):
cursor.execute ("""INSERT INTO HandsPlayers
(handId, playerId, startCash, ante,
card1Value, card1Suit, card2Value, card2Suit,
@ -1705,7 +1692,7 @@ def store_hands_players_holdem_omaha_tourney(backend, conn, cursor, category, ha
, winnings, rakes, seatNos, tourneys_players_ids):
#stores hands_players for tourney holdem/omaha hands
result=[]
for i in range (len(player_ids)):
for i in xrange(len(player_ids)):
if len(card_values[0])==2:
cursor.execute ("""INSERT INTO HandsPlayers
(handId, playerId, startCash, position,
@ -1739,7 +1726,7 @@ def store_hands_players_stud_tourney(backend, conn, cursor, hands_id, player_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)):
for i in xrange(len(player_ids)):
cursor.execute ("""INSERT INTO HandsPlayers
(handId, playerId, startCash, ante,
card1Value, card1Suit, card2Value, card2Suit,
@ -1799,16 +1786,16 @@ sure to also change the following storage method and table_viewer.prepare_data i
firstPfRaiserNo=-1
firstPfCallByNo=-1
firstPfCallerId=-1
for i in range(len(actionTypeByNo[0])):
for i in xrange(len(actionTypeByNo[0])):
if actionTypeByNo[0][i][1]=="bet":
firstPfRaiseByNo=i
firstPfRaiserId=actionTypeByNo[0][i][0]
for j in range(len(player_ids)):
for j in xrange(len(player_ids)):
if player_ids[j]==firstPfRaiserId:
firstPfRaiserNo=j
break
break
for i in range(len(actionTypeByNo[0])):
for i in xrange(len(actionTypeByNo[0])):
if actionTypeByNo[0][i][1]=="call":
firstPfCallByNo=i
firstPfCallerId=actionTypeByNo[0][i][0]
@ -1819,7 +1806,7 @@ sure to also change the following storage method and table_viewer.prepare_data i
sbId=-1
bbId=-1
if base=="hold":
for player in range(len(positions)):
for player in xrange(len(positions)):
if positions==1:
cutoffId=player_ids[player]
if positions==0:
@ -1832,7 +1819,7 @@ sure to also change the following storage method and table_viewer.prepare_data i
someoneStole=False
#run a loop for each player preparing the actual values that will be commited to SQL
for player in range (len(player_ids)):
for player in xrange(len(player_ids)):
#set default values
myStreet0VPI=False
myStreet0Aggr=False
@ -1863,7 +1850,7 @@ sure to also change the following storage method and table_viewer.prepare_data i
#calculate VPIP and PFR
street=0
heroPfRaiseCount=0
for count in range (len(action_types[street][player])):#finally individual actions
for count in xrange(len(action_types[street][player])):#finally individual actions
currentAction=action_types[street][player][count]
if currentAction=="bet":
myStreet0Aggr=True
@ -1874,7 +1861,7 @@ sure to also change the following storage method and table_viewer.prepare_data i
pfFold=-1
pfRaise=-1
if firstPfRaiseByNo!=-1:
for i in range(len(actionTypeByNo[0])):
for i in xrange(len(actionTypeByNo[0])):
if actionTypeByNo[0][i][0]==player_ids[player]:
if actionTypeByNo[0][i][1]=="bet" and pfRaise==-1 and i>firstPfRaiseByNo:
pfRaise=i
@ -1915,19 +1902,19 @@ sure to also change the following storage method and table_viewer.prepare_data i
#calculate saw* values
isAllIn=False
for i in range(len(allIns[0][player])):
for i in xrange(len(allIns[0][player])):
if allIns[0][player][i]:
isAllIn=True
if (len(action_types[1][player])>0 or isAllIn):
myStreet1Seen=True
for i in range(len(allIns[1][player])):
for i in xrange(len(allIns[1][player])):
if allIns[1][player][i]:
isAllIn=True
if (len(action_types[2][player])>0 or isAllIn):
myStreet2Seen=True
for i in range(len(allIns[2][player])):
for i in xrange(len(allIns[2][player])):
if allIns[2][player][i]:
isAllIn=True
if (len(action_types[3][player])>0 or isAllIn):
@ -1936,12 +1923,12 @@ sure to also change the following storage method and table_viewer.prepare_data i
#print "base:", base
if base=="hold":
mySawShowdown=True
for count in range (len(action_types[3][player])):
for count in xrange(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])):
for i in xrange(len(allIns[3][player])):
if allIns[3][player][i]:
isAllIn=True
if (len(action_types[4][player])>0 or isAllIn):
@ -1949,7 +1936,7 @@ sure to also change the following storage method and table_viewer.prepare_data i
myStreet4Seen=True
mySawShowdown=True
for count in range (len(action_types[4][player])):
for count in xrange(len(action_types[4][player])):
if action_types[4][player][count]=="fold":
mySawShowdown=False
@ -1957,72 +1944,72 @@ sure to also change the following storage method and table_viewer.prepare_data i
#flop stuff
street=1
if myStreet1Seen:
for count in range(len(action_types[street][player])):
for count in xrange(len(action_types[street][player])):
if action_types[street][player][count]=="bet":
myStreet1Aggr=True
for otherPlayer in range (len(player_ids)):
for otherPlayer in xrange(len(player_ids)):
if player==otherPlayer:
pass
else:
for countOther in range (len(action_types[street][otherPlayer])):
for countOther in xrange(len(action_types[street][otherPlayer])):
if action_types[street][otherPlayer][countOther]=="bet":
myOtherRaisedStreet1=True
for countOtherFold in range (len(action_types[street][player])):
for countOtherFold in xrange(len(action_types[street][player])):
if action_types[street][player][countOtherFold]=="fold":
myFoldToOtherRaisedStreet1=True
#turn stuff - copy of flop with different vars
street=2
if myStreet2Seen:
for count in range(len(action_types[street][player])):
for count in xrange(len(action_types[street][player])):
if action_types[street][player][count]=="bet":
myStreet2Aggr=True
for otherPlayer in range (len(player_ids)):
for otherPlayer in xrange(len(player_ids)):
if player==otherPlayer:
pass
else:
for countOther in range (len(action_types[street][otherPlayer])):
for countOther in xrange(len(action_types[street][otherPlayer])):
if action_types[street][otherPlayer][countOther]=="bet":
myOtherRaisedStreet2=True
for countOtherFold in range (len(action_types[street][player])):
for countOtherFold in xrange(len(action_types[street][player])):
if action_types[street][player][countOtherFold]=="fold":
myFoldToOtherRaisedStreet2=True
#river stuff - copy of flop with different vars
street=3
if myStreet3Seen:
for count in range(len(action_types[street][player])):
for count in xrange(len(action_types[street][player])):
if action_types[street][player][count]=="bet":
myStreet3Aggr=True
for otherPlayer in range (len(player_ids)):
for otherPlayer in xrange(len(player_ids)):
if player==otherPlayer:
pass
else:
for countOther in range (len(action_types[street][otherPlayer])):
for countOther in xrange(len(action_types[street][otherPlayer])):
if action_types[street][otherPlayer][countOther]=="bet":
myOtherRaisedStreet3=True
for countOtherFold in range (len(action_types[street][player])):
for countOtherFold in xrange(len(action_types[street][player])):
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])):
for count in xrange(len(action_types[street][player])):
if action_types[street][player][count]=="bet":
myStreet4Aggr=True
for otherPlayer in range (len(player_ids)):
for otherPlayer in xrange(len(player_ids)):
if player==otherPlayer:
pass
else:
for countOther in range (len(action_types[street][otherPlayer])):
for countOther in xrange(len(action_types[street][otherPlayer])):
if action_types[street][otherPlayer][countOther]=="bet":
myOtherRaisedStreet4=True
for countOtherFold in range (len(action_types[street][player])):
for countOtherFold in xrange(len(action_types[street][player])):
if action_types[street][player][countOtherFold]=="fold":
myFoldToOtherRaisedStreet4=True
@ -2114,7 +2101,7 @@ sure to also change the following storage method and table_viewer.prepare_data i
foldedBbToSteal=[]
foldSbToStealChance=[]
foldedSbToSteal=[]
for player in range (len(player_ids)):
for player in xrange(len(player_ids)):
myFoldBbToStealChance=False
myFoldedBbToSteal=False
myFoldSbToStealChance=False
@ -2123,7 +2110,7 @@ sure to also change the following storage method and table_viewer.prepare_data i
if base=="hold":
if someoneStole and (positions[player]=='B' or positions[player]=='S') and firstPfRaiserId!=player_ids[player]:
street=0
for count in range (len(action_types[street][player])):#individual actions
for count in xrange(len(action_types[street][player])):#individual actions
if positions[player]=='B':
myFoldBbToStealChance=True
if action_types[street][player][count]=="fold":
@ -2147,7 +2134,7 @@ sure to also change the following storage method and table_viewer.prepare_data i
street1CBChance=[]
street1CBDone=[]
didStreet1CB=[]
for player in range (len(player_ids)):
for player in xrange(len(player_ids)):
myStreet1CBChance=False
myStreet1CBDone=False
@ -2166,7 +2153,7 @@ sure to also change the following storage method and table_viewer.prepare_data i
street2CBChance=[]
street2CBDone=[]
didStreet2CB=[]
for player in range (len(player_ids)):
for player in xrange(len(player_ids)):
myStreet2CBChance=False
myStreet2CBDone=False
@ -2185,7 +2172,7 @@ sure to also change the following storage method and table_viewer.prepare_data i
street3CBChance=[]
street3CBDone=[]
didStreet3CB=[]
for player in range (len(player_ids)):
for player in xrange(len(player_ids)):
myStreet3CBChance=False
myStreet3CBDone=False
@ -2204,7 +2191,7 @@ sure to also change the following storage method and table_viewer.prepare_data i
street4CBChance=[]
street4CBDone=[]
didStreet4CB=[]
for player in range (len(player_ids)):
for player in xrange(len(player_ids)):
myStreet4CBChance=False
myStreet4CBDone=False
@ -2231,7 +2218,7 @@ sure to also change the following storage method and table_viewer.prepare_data i
foldToStreet4CBChance=[]
foldToStreet4CBDone=[]
for player in range (len(player_ids)):
for player in xrange(len(player_ids)):
myFoldToStreet1CBChance=False
myFoldToStreet1CBDone=False
foldToStreet1CBChance.append(myFoldToStreet1CBChance)
@ -2285,14 +2272,14 @@ sure to also change the following storage method and table_viewer.prepare_data i
street4CheckCallRaiseChance=[]
street4CheckCallRaiseDone=[]
#print "b4 totprof calc, len(playerIds)=", len(player_ids)
for pl in range (len(player_ids)):
for pl in xrange(len(player_ids)):
#print "pl=", pl
myTotalProfit=winnings[pl] # still need to deduct other costs
if antes:
myTotalProfit=winnings[pl] - antes[pl]
for i in range (len(actionTypes)): #iterate through streets
#for j in range (len(actionTypes[i])): #iterate through names (using pl loop above)
for k in range (len(actionTypes[i][pl])): #iterate through individual actions of that player on that street
for i in xrange(len(actionTypes)): #iterate through streets
#for j in xrange(len(actionTypes[i])): #iterate through names (using pl loop above)
for k in xrange(len(actionTypes[i][pl])): #iterate through individual actions of that player on that street
myTotalProfit -= actionAmounts[i][pl][k]
myStreet1CheckCallRaiseChance=False
@ -2336,7 +2323,7 @@ def generateFoldToCB(street, playerIDs, didStreetCB, streetCBDone, foldToStreetC
#print "beginning of generateFoldToCB, street:", street, "len(actionTypeByNo):", len(actionTypeByNo)
#print "len(actionTypeByNo[street]):",len(actionTypeByNo[street])
firstCBReaction=0
for action in range(len(actionTypeByNo[street])):
for action in xrange(len(actionTypeByNo[street])):
if actionTypeByNo[street][action][1]=="bet":
for player in didStreetCB:
if player==actionTypeByNo[street][action][0] and firstCBReaction==0:
@ -2344,7 +2331,7 @@ def generateFoldToCB(street, playerIDs, didStreetCB, streetCBDone, foldToStreetC
break
for action in actionTypeByNo[street][firstCBReaction:]:
for player in range(len(playerIDs)):
for player in xrange(len(playerIDs)):
if playerIDs[player]==action[0]:
foldToStreetCBChance[player]=True
if action[1]=="fold":
@ -2356,7 +2343,7 @@ def storeHudCache(cursor, base, category, gametypeId, playerIds, hudImportData):
#print "storeHudCache, len(playerIds)=", len(playerIds), " len(vpip)=" \
#, len(hudImportData['street0VPI']), " len(totprof)=", len(hudImportData['totalProfit'])
for player in range (len(playerIds)):
for player in xrange(len(playerIds)):
if base=="hold":
cursor.execute("SELECT * FROM HudCache WHERE gametypeId+0=%s AND playerId=%s AND activeSeats=%s AND position=%s", (gametypeId, playerIds[player], len(playerIds), hudImportData['position'][player]))
else:
@ -2376,13 +2363,13 @@ def storeHudCache(cursor, base, category, gametypeId, playerIds, hudImportData):
row.append(gametypeId)
row.append(playerIds[player])
row.append(len(playerIds))#seats
for i in range(len(hudImportData)+2):
for i in xrange(len(hudImportData)+2):
row.append(0)
else:
doInsert=False
newrow=[]
for i in range(len(row)):
for i in xrange(len(row)):
newrow.append(row[i])
row=newrow
@ -2514,7 +2501,7 @@ def storeHudCache2(backend, cursor, base, category, gametypeId, playerIds, hudIm
#print "storeHudCache, len(playerIds)=", len(playerIds), " len(vpip)=" \
#, len(hudImportData['street0VPI']), " len(totprof)=", len(hudImportData['totalProfit'])
for player in range (len(playerIds)):
for player in xrange(len(playerIds)):
# Set up a clean row
row=[]
@ -2522,7 +2509,7 @@ def storeHudCache2(backend, cursor, base, category, gametypeId, playerIds, hudIm
row.append(gametypeId)
row.append(playerIds[player])
row.append(len(playerIds))#seats
for i in range(len(hudImportData)+2):
for i in xrange(len(hudImportData)+2):
row.append(0)
if base=="hold":
@ -2701,7 +2688,7 @@ def store_tourneys_players(cursor, tourney_id, player_ids, payin_amounts, ranks,
#print "payin_amounts:",payin_amounts
#print "ranks:",ranks
#print "winnings:",winnings
for i in range (len(player_ids)):
for i in xrange(len(player_ids)):
cursor.execute("SELECT id FROM TourneysPlayers WHERE tourneyId=%s AND playerId+0=%s", (tourney_id, player_ids[i]))
tmp=cursor.fetchone()
#print "tried SELECTing tourneys_players.id:",tmp