From 6e1499fb69798f10877744c934efe85fb59f554f Mon Sep 17 00:00:00 2001 From: eblade Date: Mon, 15 Dec 2008 23:07:37 -0500 Subject: [PATCH 01/13] reposition_windows() after bringing one forward that has been hidden previously, even though they should already be relocating while hidden.. suspect gtk bug --- pyfpdb/Hud.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pyfpdb/Hud.py b/pyfpdb/Hud.py index 3bcb3bf1..4b5d5fc1 100644 --- a/pyfpdb/Hud.py +++ b/pyfpdb/Hud.py @@ -263,6 +263,7 @@ class Hud: self.stat_windows[stat_dict[s]['seat']].label[r][c].set_text(statstring) if statstring != "xxx": self.stat_windows[stat_dict[s]['seat']].window.show_all() + self.reposition_windows() tip = stat_dict[s]['screen_name'] + "\n" + number[5] + "\n" + \ number[3] + ", " + number[4] Stats.do_tip(self.stat_windows[stat_dict[s]['seat']].e_box[r][c], tip) From 9263aa998ecce29024a6bb4356f5d625f9e9c328 Mon Sep 17 00:00:00 2001 From: eblade Date: Thu, 18 Dec 2008 15:40:28 -0500 Subject: [PATCH 02/13] redo changes to parsePositions --- pyfpdb/fpdb_simple.py | 138 +++++++++++++++++++++++------------------- 1 file changed, 77 insertions(+), 61 deletions(-) diff --git a/pyfpdb/fpdb_simple.py b/pyfpdb/fpdb_simple.py index 625ce642..4f18114a 100644 --- a/pyfpdb/fpdb_simple.py +++ b/pyfpdb/fpdb_simple.py @@ -1204,67 +1204,83 @@ def parseNames(lines): #returns an array with the positions of the respective players def parsePositions (hand, names): - #prep array - positions=[] - for i in range(len(names)): - positions.append(-1) - - #find blinds - sb,bb=-1,-1 - for i in range (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 - if (bb==-1 and hand[i].find("big blind")!=-1 and hand[i].find("dead big blind")==-1): - bb=hand[i] - #print "bb:",bb - - #identify blinds - #print "parsePositions before recognising sb/bb. names:",names - sbExists=True - if (sb!=-1): - sb=recognisePlayerNo(sb, names, "bet") - else: - sbExists=False - if (bb!=-1): - bb=recognisePlayerNo(bb, names, "bet") - - #write blinds into array - if (sbExists): - positions[sb]="S" - positions[bb]="B" - - #fill up rest of array - if (sbExists): - arraypos=sb-1 - else: - arraypos=bb-1 - distFromBtn=0 - while (arraypos>=0 and arraypos != bb): - #print "parsePositions first while, arraypos:",arraypos,"positions:",positions - positions[arraypos]=distFromBtn - arraypos-=1 - distFromBtn+=1 - - ### RHH - Changed to set the null seats before BB to "9" - i=bb-1 - while positions[i] < 0: - positions[i]=9 - i-=1 - - arraypos=len(names)-1 - if (bb!=0 or (bb==0 and sbExists==False)): - while (arraypos>bb): - positions[arraypos]=distFromBtn - arraypos-=1 - distFromBtn+=1 - - for i in range (len(names)): - if positions[i]==-1: - print "parsePositions names:",names - print "result:",positions - raise FpdbError ("failed to read positions") - return positions + #prep array + positions=[] + for i in range(len(names)): + positions.append(-1) + + #find blinds + sb,bb=-1,-1 + for i in range (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 + if (bb==-1 and hand[i].find("big blind")!=-1 and hand[i].find("dead big blind")==-1): + bb=hand[i] + #print "bb:",bb + + #identify blinds + #print "parsePositions before recognising sb/bb. names:",names + sbExists=True + if (sb!=-1): + sb=recognisePlayerNo(sb, names, "bet") + else: + sbExists=False + if (bb!=-1): + bb=recognisePlayerNo(bb, names, "bet") + +# print "sb = ", sb, "bb = ", bb + if bb == sb: + sbExists = False + sb = -1 + + #write blinds into array + if (sbExists): + positions[sb]="S" + positions[bb]="B" + + + #fill up rest of array + if (sbExists): + arraypos=sb-1 + else: + arraypos=bb-1 + distFromBtn=0 + while (arraypos>=0 and arraypos != bb): + #print "parsePositions first while, arraypos:",arraypos,"positions:",positions + positions[arraypos]=distFromBtn + arraypos-=1 + distFromBtn+=1 + + # eric - this takes into account dead seats between blinds + if sbExists: + i = bb - 1 + while positions[i] < 0 and i != sb: + positions[i] = 9 + i -= 1 + ### RHH - Changed to set the null seats before BB to "9" + if sbExists: + i = sb-1 + else: + i = bb-1 + while positions[i] < 0: + positions[i]=9 + i-=1 + + arraypos=len(names)-1 + if (bb!=0 or (bb==0 and sbExists==False) or (bb == 1 and sb != arraypos) ): + while (arraypos>bb and arraypos > sb): + positions[arraypos]=distFromBtn + arraypos-=1 + distFromBtn+=1 + + for i in range (len(names)): + if positions[i]==-1: + print "parsePositions names:",names + print "result:",positions + raise FpdbError ("failed to read positions") +# print str(positions), "\n" + return positions #end def parsePositions #simply parses the rake amount and returns it as an int From 2ccd00d3fdce00616f8c563db57081d44f16ad61 Mon Sep 17 00:00:00 2001 From: eblade Date: Thu, 18 Dec 2008 15:42:46 -0500 Subject: [PATCH 03/13] redo changes to checkPositions, and such --- pyfpdb/fpdb_import.py | 34 +-- pyfpdb/fpdb_simple.py | 592 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 597 insertions(+), 29 deletions(-) diff --git a/pyfpdb/fpdb_import.py b/pyfpdb/fpdb_import.py index 2d35a97a..009ebb3c 100644 --- a/pyfpdb/fpdb_import.py +++ b/pyfpdb/fpdb_import.py @@ -284,24 +284,24 @@ class Importer: return handsId #end def import_file_dict - def parseTourneyHistory(self): - print "Tourney history parser stub" - #Find tournament boundaries. - #print self.foabs - + def parseTourneyHistory(self): + print "Tourney history parser stub" + #Find tournament boundaries. + #print self.foabs + - def printEmailErrorMessage(self, errors, filename, line): - traceback.print_exc(file=sys.stderr) - print "Error No.",errors,", please send the hand causing this to steffen@sycamoretest.info so I can fix it." - print "Filename:", filename - print "Here is the first line so you can identify it. Please mention that the error was a ValueError:" - print self.hand[0] - print "Hand logged to hand-errors.txt" - logfile = open('hand-errors.txt', 'a') - for s in self.hand: - logfile.write(str(s) + "\n") - logfile.write("\n") - logfile.close() + def printEmailErrorMessage(self, errors, filename, line): + traceback.print_exc(file=sys.stderr) + print "Error No.",errors,", please send the hand causing this to steffen@sycamoretest.info so I can fix it." + print "Filename:", filename + print "Here is the first line so you can identify it. Please mention that the error was a ValueError:" + print self.hand[0] + print "Hand logged to hand-errors.txt" + logfile = open('hand-errors.txt', 'a') + for s in self.hand: + logfile.write(str(s) + "\n") + logfile.write("\n") + logfile.close() if __name__ == "__main__": print "CLI for fpdb_import is now available as CliFpdb.py" diff --git a/pyfpdb/fpdb_simple.py b/pyfpdb/fpdb_simple.py index 4f18114a..2a610155 100644 --- a/pyfpdb/fpdb_simple.py +++ b/pyfpdb/fpdb_simple.py @@ -381,18 +381,19 @@ def calcPayin(count, buyin, fee): #end def calcPayin def checkPositions(positions): - """verifies that these positions are valid""" - for i in range (len(positions)): - pos=positions[i] - try:#todo: use type recognition instead of error - if (len(pos)!=1): - raise FpdbError("invalid position found in checkPositions. i: "+str(i)+" position: "+pos) #dont need to str() here - except TypeError:#->not string->is int->fine - pass - - ### RHH modified to allow for "position 9" here (pos==9 is when you're a dead hand before the BB - if (pos!="B" and pos!="S" and pos!=0 and pos!=1 and pos!=2 and pos!=3 and pos!=4 and pos!=5 and pos!=6 and pos!=7 and pos!=9): - raise FpdbError("invalid position found in checkPositions. i: "+str(i)+" position: "+str(pos)) + """verifies that these positions are valid""" + for i in range (len(positions)): + pos=positions[i] + try:#todo: use type recognition instead of error + if (len(pos)!=1): + raise FpdbError("invalid position found in checkPositions. i: "+str(i)+" position: "+pos) #dont need to str() here + except TypeError:#->not string->is int->fine + pass + + ### RHH modified to allow for "position 9" here (pos==9 is when you're a dead hand before the BB + ### eric - position 8 could be valid - if only one blind is posted, but there's still 10 people, ie a sitout is present, and the small is dead... + if not (pos == "B" or pos == "S" or (pos >= 0 and pos <= 9)): + raise FpdbError("invalid position found in checkPositions. i: "+str(i)+" position: "+str(pos)) #end def fpdb_simple.checkPositions #classifies each line for further processing in later code. Manipulates the passed arrays. @@ -1229,7 +1230,11 @@ def parsePositions (hand, names): if (bb!=-1): bb=recognisePlayerNo(bb, names, "bet") +<<<<<<< HEAD:pyfpdb/fpdb_simple.py # print "sb = ", sb, "bb = ", bb +======= + print "sb = ", sb, "bb = ", bb +>>>>>>> 1de3446... remove spurious window realize from popup_window as well:pyfpdb/fpdb_simple.py if bb == sb: sbExists = False sb = -1 @@ -1279,7 +1284,11 @@ def parsePositions (hand, names): print "parsePositions names:",names print "result:",positions raise FpdbError ("failed to read positions") +<<<<<<< HEAD:pyfpdb/fpdb_simple.py # print str(positions), "\n" +======= + print str(positions), "\n" +>>>>>>> 1de3446... remove spurious window realize from popup_window as well:pyfpdb/fpdb_simple.py return positions #end def parsePositions @@ -1749,6 +1758,7 @@ VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, result.append( getLastInsertId(backend, conn, cursor) ) # mysql only return result #end def store_hands_players_stud_tourney +<<<<<<< HEAD:pyfpdb/fpdb_simple.py def generateHudCacheData(player_ids, base, category, action_types, allIns, actionTypeByNo ,winnings, totalWinnings, positions, actionTypes, actionAmounts, antes): @@ -2320,6 +2330,564 @@ sure to also change the following storage method and table_viewer.prepare_data i result['street4CheckCallRaiseChance']=street4CheckCallRaiseChance result['street4CheckCallRaiseDone']=street4CheckCallRaiseDone return result +======= + +def generateHudCacheData(player_ids, base, category, action_types, allIns, actionTypeByNo, winnings, totalWinnings, positions): + """calculates data for the HUD during import. IMPORTANT: if you change this method make sure to also change the following storage method and table_viewer.prepare_data if necessary""" + #setup subarrays of the result dictionary. + street0VPI=[] + street0Aggr=[] + street0_3B4BChance=[] + street0_3B4BDone=[] + street1Seen=[] + street2Seen=[] + street3Seen=[] + street4Seen=[] + sawShowdown=[] + street1Aggr=[] + street2Aggr=[] + street3Aggr=[] + street4Aggr=[] + otherRaisedStreet1=[] + otherRaisedStreet2=[] + otherRaisedStreet3=[] + otherRaisedStreet4=[] + foldToOtherRaisedStreet1=[] + foldToOtherRaisedStreet2=[] + foldToOtherRaisedStreet3=[] + foldToOtherRaisedStreet4=[] + wonWhenSeenStreet1=[] + + wonAtSD=[] + stealAttemptChance=[] + stealAttempted=[] + hudDataPositions=[] + + firstPfRaiseByNo=-1 + firstPfRaiserId=-1 + firstPfRaiserNo=-1 + firstPfCallByNo=-1 + firstPfCallerId=-1 + for i in range(len(actionTypeByNo[0])): + if actionTypeByNo[0][i][1]=="bet": + firstPfRaiseByNo=i + firstPfRaiserId=actionTypeByNo[0][i][0] + for j in range(len(player_ids)): + if player_ids[j]==firstPfRaiserId: + firstPfRaiserNo=j + break + break + for i in range(len(actionTypeByNo[0])): + if actionTypeByNo[0][i][1]=="call": + firstPfCallByNo=i + firstPfCallerId=actionTypeByNo[0][i][0] + break + + cutoffId=-1 + buttonId=-1 + sbId=-1 + bbId=-1 + if base=="hold": + for player in range(len(positions)): + if positions==1: + cutoffId=player_ids[player] + if positions==0: + buttonId=player_ids[player] + if positions=='S': + sbId=player_ids[player] + if positions=='B': + bbId=player_ids[player] + + 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)): + #set default values + myStreet0VPI=False + myStreet0Aggr=False + myStreet0_3B4BChance=False + myStreet0_3B4BDone=False + myStreet1Seen=False + myStreet2Seen=False + myStreet3Seen=False + myStreet4Seen=False + mySawShowdown=False + myStreet1Aggr=False + myStreet2Aggr=False + myStreet3Aggr=False + myStreet4Aggr=False + myOtherRaisedStreet1=False + myOtherRaisedStreet2=False + myOtherRaisedStreet3=False + myOtherRaisedStreet4=False + myFoldToOtherRaisedStreet1=False + myFoldToOtherRaisedStreet2=False + myFoldToOtherRaisedStreet3=False + myFoldToOtherRaisedStreet4=False + myWonWhenSeenStreet1=0.0 + myWonAtSD=0.0 + myStealAttemptChance=False + myStealAttempted=False + + #calculate VPIP and PFR + street=0 + heroPfRaiseCount=0 + for count in range (len(action_types[street][player])):#finally individual actions + currentAction=action_types[street][player][count] + if currentAction=="bet": + myStreet0Aggr=True + if (currentAction=="bet" or currentAction=="call"): + myStreet0VPI=True + + #PF3B4BChance and PF3B4B + pfFold=-1 + pfRaise=-1 + if firstPfRaiseByNo!=-1: + for i in range(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 + if actionTypeByNo[0][i][1]=="fold" and pfFold==-1: + pfFold=i + if pfFold==-1 or pfFold>firstPfRaiseByNo: + myStreet0_3B4BChance=True + if pfRaise>firstPfRaiseByNo: + myStreet0_3B4BDone=True + + #steal calculations + if base=="hold": + if len(player_ids)>=5: #no point otherwise + if positions[player]==1: + if firstPfRaiserId==player_ids[player]: + myStealAttemptChance=True + myStealAttempted=True + elif firstPfRaiserId==buttonId or firstPfRaiserId==sbId or firstPfRaiserId==bbId or firstPfRaiserId==-1: + myStealAttemptChance=True + if positions[player]==0: + if firstPfRaiserId==player_ids[player]: + myStealAttemptChance=True + myStealAttempted=True + elif firstPfRaiserId==sbId or firstPfRaiserId==bbId or firstPfRaiserId==-1: + myStealAttemptChance=True + if positions[player]=='S': + if firstPfRaiserId==player_ids[player]: + myStealAttemptChance=True + myStealAttempted=True + elif firstPfRaiserId==bbId or firstPfRaiserId==-1: + myStealAttemptChance=True + if positions[player]=='B': + pass + + if myStealAttempted: + someoneStole=True + + + #calculate saw* values + isAllIn=False + for i in range(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])): + 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])): + if allIns[2][player][i]: + isAllIn=True + if (len(action_types[3][player])>0 or isAllIn): + myStreet3Seen=True + + #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 + if myStreet1Seen: + for count in range(len(action_types[street][player])): + if action_types[street][player][count]=="bet": + myStreet1Aggr=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": + myOtherRaisedStreet1=True + for countOtherFold in range (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])): + if action_types[street][player][count]=="bet": + myStreet2Aggr=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": + myOtherRaisedStreet2=True + for countOtherFold in range (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])): + if action_types[street][player][count]=="bet": + myStreet3Aggr=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": + myOtherRaisedStreet3=True + for countOtherFold in range (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])): + 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) + if mySawShowdown: + myWonAtSD=myWonWhenSeenStreet1 + + #add each value to the appropriate array + street0VPI.append(myStreet0VPI) + street0Aggr.append(myStreet0Aggr) + street0_3B4BChance.append(myStreet0_3B4BChance) + street0_3B4BDone.append(myStreet0_3B4BDone) + street1Seen.append(myStreet1Seen) + street2Seen.append(myStreet2Seen) + street3Seen.append(myStreet3Seen) + street4Seen.append(myStreet4Seen) + sawShowdown.append(mySawShowdown) + street1Aggr.append(myStreet1Aggr) + street2Aggr.append(myStreet2Aggr) + street3Aggr.append(myStreet3Aggr) + street4Aggr.append(myStreet4Aggr) + otherRaisedStreet1.append(myOtherRaisedStreet1) + otherRaisedStreet2.append(myOtherRaisedStreet2) + otherRaisedStreet3.append(myOtherRaisedStreet3) + otherRaisedStreet4.append(myOtherRaisedStreet4) + foldToOtherRaisedStreet1.append(myFoldToOtherRaisedStreet1) + foldToOtherRaisedStreet2.append(myFoldToOtherRaisedStreet2) + foldToOtherRaisedStreet3.append(myFoldToOtherRaisedStreet3) + foldToOtherRaisedStreet4.append(myFoldToOtherRaisedStreet4) + wonWhenSeenStreet1.append(myWonWhenSeenStreet1) + wonAtSD.append(myWonAtSD) + stealAttemptChance.append(myStealAttemptChance) + stealAttempted.append(myStealAttempted) + if base=="hold": + pos=positions[player] + if pos=='B': + hudDataPositions.append('B') + elif pos=='S': + hudDataPositions.append('S') + elif pos==0: + hudDataPositions.append('D') + elif pos==1: + hudDataPositions.append('C') + elif pos>=2 and pos<=4: + hudDataPositions.append('M') + elif pos>=5 and pos<=8: + hudDataPositions.append('E') + ### RHH Added this elif to handle being a dead hand before the BB (pos==9) + elif pos==9: + hudDataPositions.append('X') + else: + raise FpdbError("invalid position") + elif base=="stud": + #todo: stud positions and steals + pass + + #add each array to the to-be-returned dictionary + result={'street0VPI':street0VPI} + result['street0Aggr']=street0Aggr + result['street0_3B4BChance']=street0_3B4BChance + result['street0_3B4BDone']=street0_3B4BDone + result['street1Seen']=street1Seen + result['street2Seen']=street2Seen + result['street3Seen']=street3Seen + result['street4Seen']=street4Seen + result['sawShowdown']=sawShowdown + + result['street1Aggr']=street1Aggr + result['otherRaisedStreet1']=otherRaisedStreet1 + result['foldToOtherRaisedStreet1']=foldToOtherRaisedStreet1 + result['street2Aggr']=street2Aggr + result['otherRaisedStreet2']=otherRaisedStreet2 + result['foldToOtherRaisedStreet2']=foldToOtherRaisedStreet2 + result['street3Aggr']=street3Aggr + result['otherRaisedStreet3']=otherRaisedStreet3 + result['foldToOtherRaisedStreet3']=foldToOtherRaisedStreet3 + result['street4Aggr']=street4Aggr + result['otherRaisedStreet4']=otherRaisedStreet4 + result['foldToOtherRaisedStreet4']=foldToOtherRaisedStreet4 + result['wonWhenSeenStreet1']=wonWhenSeenStreet1 + result['wonAtSD']=wonAtSD + result['stealAttemptChance']=stealAttemptChance + result['stealAttempted']=stealAttempted + + #now the various steal values + foldBbToStealChance=[] + foldedBbToSteal=[] + foldSbToStealChance=[] + foldedSbToSteal=[] + for player in range (len(player_ids)): + myFoldBbToStealChance=False + myFoldedBbToSteal=False + myFoldSbToStealChance=False + myFoldedSbToSteal=False + + 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 + if positions[player]=='B': + myFoldBbToStealChance=True + if action_types[street][player][count]=="fold": + myFoldedBbToSteal=True + if positions[player]=='S': + myFoldSbToStealChance=True + if action_types[street][player][count]=="fold": + myFoldedSbToSteal=True + + + foldBbToStealChance.append(myFoldBbToStealChance) + foldedBbToSteal.append(myFoldedBbToSteal) + foldSbToStealChance.append(myFoldSbToStealChance) + foldedSbToSteal.append(myFoldedSbToSteal) + result['foldBbToStealChance']=foldBbToStealChance + result['foldedBbToSteal']=foldedBbToSteal + result['foldSbToStealChance']=foldSbToStealChance + result['foldedSbToSteal']=foldedSbToSteal + + #now CB + street1CBChance=[] + street1CBDone=[] + didStreet1CB=[] + for player in range (len(player_ids)): + myStreet1CBChance=False + myStreet1CBDone=False + + if street0VPI[player]: + myStreet1CBChance=True + if street1Aggr[player]: + myStreet1CBDone=True + didStreet1CB.append(player_ids[player]) + + street1CBChance.append(myStreet1CBChance) + street1CBDone.append(myStreet1CBDone) + result['street1CBChance']=street1CBChance + result['street1CBDone']=street1CBDone + + #now 2B + street2CBChance=[] + street2CBDone=[] + didStreet2CB=[] + for player in range (len(player_ids)): + myStreet2CBChance=False + myStreet2CBDone=False + + if street1CBDone[player]: + myStreet2CBChance=True + if street2Aggr[player]: + myStreet2CBDone=True + didStreet2CB.append(player_ids[player]) + + street2CBChance.append(myStreet2CBChance) + street2CBDone.append(myStreet2CBDone) + result['street2CBChance']=street2CBChance + result['street2CBDone']=street2CBDone + + #now 3B + street3CBChance=[] + street3CBDone=[] + didStreet3CB=[] + for player in range (len(player_ids)): + myStreet3CBChance=False + myStreet3CBDone=False + + if street2CBDone[player]: + myStreet3CBChance=True + if street3Aggr[player]: + myStreet3CBDone=True + didStreet3CB.append(player_ids[player]) + + street3CBChance.append(myStreet3CBChance) + street3CBDone.append(myStreet3CBDone) + result['street3CBChance']=street3CBChance + result['street3CBDone']=street3CBDone + + #and 4B + street4CBChance=[] + street4CBDone=[] + didStreet4CB=[] + for player in range (len(player_ids)): + myStreet4CBChance=False + myStreet4CBDone=False + + if street3CBDone[player]: + myStreet4CBChance=True + if street4Aggr[player]: + myStreet4CBDone=True + didStreet4CB.append(player_ids[player]) + + street4CBChance.append(myStreet4CBChance) + street4CBDone.append(myStreet4CBDone) + result['street4CBChance']=street4CBChance + result['street4CBDone']=street4CBDone + + + result['position']=hudDataPositions + + foldToStreet1CBChance=[] + foldToStreet1CBDone=[] + foldToStreet2CBChance=[] + foldToStreet2CBDone=[] + foldToStreet3CBChance=[] + foldToStreet3CBDone=[] + foldToStreet4CBChance=[] + foldToStreet4CBDone=[] + + for player in range (len(player_ids)): + myFoldToStreet1CBChance=False + myFoldToStreet1CBDone=False + foldToStreet1CBChance.append(myFoldToStreet1CBChance) + foldToStreet1CBDone.append(myFoldToStreet1CBDone) + + myFoldToStreet2CBChance=False + myFoldToStreet2CBDone=False + foldToStreet2CBChance.append(myFoldToStreet2CBChance) + foldToStreet2CBDone.append(myFoldToStreet2CBDone) + + myFoldToStreet3CBChance=False + myFoldToStreet3CBDone=False + foldToStreet3CBChance.append(myFoldToStreet3CBChance) + foldToStreet3CBDone.append(myFoldToStreet3CBDone) + + myFoldToStreet4CBChance=False + myFoldToStreet4CBDone=False + foldToStreet4CBChance.append(myFoldToStreet4CBChance) + foldToStreet4CBDone.append(myFoldToStreet4CBDone) + + if len(didStreet1CB)>=1: + generateFoldToCB(1, player_ids, didStreet1CB, street1CBDone, foldToStreet1CBChance, foldToStreet1CBDone, actionTypeByNo) + + if len(didStreet2CB)>=1: + generateFoldToCB(2, player_ids, didStreet2CB, street2CBDone, foldToStreet2CBChance, foldToStreet2CBDone, actionTypeByNo) + + if len(didStreet3CB)>=1: + generateFoldToCB(3, player_ids, didStreet3CB, street3CBDone, foldToStreet3CBChance, foldToStreet3CBDone, actionTypeByNo) + + if len(didStreet4CB)>=1: + generateFoldToCB(4, player_ids, didStreet4CB, street4CBDone, foldToStreet4CBChance, foldToStreet4CBDone, actionTypeByNo) + + result['foldToStreet1CBChance']=foldToStreet1CBChance + result['foldToStreet1CBDone']=foldToStreet1CBDone + result['foldToStreet2CBChance']=foldToStreet2CBChance + result['foldToStreet2CBDone']=foldToStreet2CBDone + result['foldToStreet3CBChance']=foldToStreet3CBChance + result['foldToStreet3CBDone']=foldToStreet3CBDone + result['foldToStreet4CBChance']=foldToStreet4CBChance + result['foldToStreet4CBDone']=foldToStreet4CBDone + + + totalProfit=[] + + street1CheckCallRaiseChance=[] + street1CheckCallRaiseDone=[] + street2CheckCallRaiseChance=[] + street2CheckCallRaiseDone=[] + street3CheckCallRaiseChance=[] + street3CheckCallRaiseDone=[] + street4CheckCallRaiseChance=[] + street4CheckCallRaiseDone=[] + for player in range (len(player_ids)): + myTotalProfit=0 + + myStreet1CheckCallRaiseChance=False + myStreet1CheckCallRaiseDone=False + myStreet2CheckCallRaiseChance=False + myStreet2CheckCallRaiseDone=False + myStreet3CheckCallRaiseChance=False + myStreet3CheckCallRaiseDone=False + myStreet4CheckCallRaiseChance=False + myStreet4CheckCallRaiseDone=False + + totalProfit.append(myTotalProfit) + + street1CheckCallRaiseChance.append(myStreet1CheckCallRaiseChance) + street1CheckCallRaiseDone.append(myStreet1CheckCallRaiseDone) + street2CheckCallRaiseChance.append(myStreet2CheckCallRaiseChance) + street2CheckCallRaiseDone.append(myStreet2CheckCallRaiseDone) + street3CheckCallRaiseChance.append(myStreet3CheckCallRaiseChance) + street3CheckCallRaiseDone.append(myStreet3CheckCallRaiseDone) + street4CheckCallRaiseChance.append(myStreet4CheckCallRaiseChance) + street4CheckCallRaiseDone.append(myStreet4CheckCallRaiseDone) + + result['totalProfit']=totalProfit + + result['street1CheckCallRaiseChance']=street1CheckCallRaiseChance + result['street1CheckCallRaiseDone']=street1CheckCallRaiseDone + result['street2CheckCallRaiseChance']=street2CheckCallRaiseChance + result['street2CheckCallRaiseDone']=street2CheckCallRaiseDone + result['street3CheckCallRaiseChance']=street3CheckCallRaiseChance + result['street3CheckCallRaiseDone']=street3CheckCallRaiseDone + result['street4CheckCallRaiseChance']=street4CheckCallRaiseChance + result['street4CheckCallRaiseDone']=street4CheckCallRaiseDone + return result +>>>>>>> 1de3446... remove spurious window realize from popup_window as well:pyfpdb/fpdb_simple.py #end def generateHudCacheData def generateFoldToCB(street, playerIDs, didStreetCB, streetCBDone, foldToStreetCBChance, foldToStreetCBDone, actionTypeByNo): From 42113f301f34a5090cab2bc1de159d4a0127a502 Mon Sep 17 00:00:00 2001 From: eblade Date: Thu, 18 Dec 2008 15:45:13 -0500 Subject: [PATCH 04/13] finish conflict resolution on those patches to check/parsePositions .. git really sucks. --- pyfpdb/fpdb_simple.py | 567 ------------------------------------------ 1 file changed, 567 deletions(-) diff --git a/pyfpdb/fpdb_simple.py b/pyfpdb/fpdb_simple.py index 2a610155..ca7d6903 100644 --- a/pyfpdb/fpdb_simple.py +++ b/pyfpdb/fpdb_simple.py @@ -1230,11 +1230,7 @@ def parsePositions (hand, names): if (bb!=-1): bb=recognisePlayerNo(bb, names, "bet") -<<<<<<< HEAD:pyfpdb/fpdb_simple.py # print "sb = ", sb, "bb = ", bb -======= - print "sb = ", sb, "bb = ", bb ->>>>>>> 1de3446... remove spurious window realize from popup_window as well:pyfpdb/fpdb_simple.py if bb == sb: sbExists = False sb = -1 @@ -1284,11 +1280,7 @@ def parsePositions (hand, names): print "parsePositions names:",names print "result:",positions raise FpdbError ("failed to read positions") -<<<<<<< HEAD:pyfpdb/fpdb_simple.py # print str(positions), "\n" -======= - print str(positions), "\n" ->>>>>>> 1de3446... remove spurious window realize from popup_window as well:pyfpdb/fpdb_simple.py return positions #end def parsePositions @@ -1758,7 +1750,6 @@ VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, result.append( getLastInsertId(backend, conn, cursor) ) # mysql only return result #end def store_hands_players_stud_tourney -<<<<<<< HEAD:pyfpdb/fpdb_simple.py def generateHudCacheData(player_ids, base, category, action_types, allIns, actionTypeByNo ,winnings, totalWinnings, positions, actionTypes, actionAmounts, antes): @@ -2330,564 +2321,6 @@ sure to also change the following storage method and table_viewer.prepare_data i result['street4CheckCallRaiseChance']=street4CheckCallRaiseChance result['street4CheckCallRaiseDone']=street4CheckCallRaiseDone return result -======= - -def generateHudCacheData(player_ids, base, category, action_types, allIns, actionTypeByNo, winnings, totalWinnings, positions): - """calculates data for the HUD during import. IMPORTANT: if you change this method make sure to also change the following storage method and table_viewer.prepare_data if necessary""" - #setup subarrays of the result dictionary. - street0VPI=[] - street0Aggr=[] - street0_3B4BChance=[] - street0_3B4BDone=[] - street1Seen=[] - street2Seen=[] - street3Seen=[] - street4Seen=[] - sawShowdown=[] - street1Aggr=[] - street2Aggr=[] - street3Aggr=[] - street4Aggr=[] - otherRaisedStreet1=[] - otherRaisedStreet2=[] - otherRaisedStreet3=[] - otherRaisedStreet4=[] - foldToOtherRaisedStreet1=[] - foldToOtherRaisedStreet2=[] - foldToOtherRaisedStreet3=[] - foldToOtherRaisedStreet4=[] - wonWhenSeenStreet1=[] - - wonAtSD=[] - stealAttemptChance=[] - stealAttempted=[] - hudDataPositions=[] - - firstPfRaiseByNo=-1 - firstPfRaiserId=-1 - firstPfRaiserNo=-1 - firstPfCallByNo=-1 - firstPfCallerId=-1 - for i in range(len(actionTypeByNo[0])): - if actionTypeByNo[0][i][1]=="bet": - firstPfRaiseByNo=i - firstPfRaiserId=actionTypeByNo[0][i][0] - for j in range(len(player_ids)): - if player_ids[j]==firstPfRaiserId: - firstPfRaiserNo=j - break - break - for i in range(len(actionTypeByNo[0])): - if actionTypeByNo[0][i][1]=="call": - firstPfCallByNo=i - firstPfCallerId=actionTypeByNo[0][i][0] - break - - cutoffId=-1 - buttonId=-1 - sbId=-1 - bbId=-1 - if base=="hold": - for player in range(len(positions)): - if positions==1: - cutoffId=player_ids[player] - if positions==0: - buttonId=player_ids[player] - if positions=='S': - sbId=player_ids[player] - if positions=='B': - bbId=player_ids[player] - - 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)): - #set default values - myStreet0VPI=False - myStreet0Aggr=False - myStreet0_3B4BChance=False - myStreet0_3B4BDone=False - myStreet1Seen=False - myStreet2Seen=False - myStreet3Seen=False - myStreet4Seen=False - mySawShowdown=False - myStreet1Aggr=False - myStreet2Aggr=False - myStreet3Aggr=False - myStreet4Aggr=False - myOtherRaisedStreet1=False - myOtherRaisedStreet2=False - myOtherRaisedStreet3=False - myOtherRaisedStreet4=False - myFoldToOtherRaisedStreet1=False - myFoldToOtherRaisedStreet2=False - myFoldToOtherRaisedStreet3=False - myFoldToOtherRaisedStreet4=False - myWonWhenSeenStreet1=0.0 - myWonAtSD=0.0 - myStealAttemptChance=False - myStealAttempted=False - - #calculate VPIP and PFR - street=0 - heroPfRaiseCount=0 - for count in range (len(action_types[street][player])):#finally individual actions - currentAction=action_types[street][player][count] - if currentAction=="bet": - myStreet0Aggr=True - if (currentAction=="bet" or currentAction=="call"): - myStreet0VPI=True - - #PF3B4BChance and PF3B4B - pfFold=-1 - pfRaise=-1 - if firstPfRaiseByNo!=-1: - for i in range(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 - if actionTypeByNo[0][i][1]=="fold" and pfFold==-1: - pfFold=i - if pfFold==-1 or pfFold>firstPfRaiseByNo: - myStreet0_3B4BChance=True - if pfRaise>firstPfRaiseByNo: - myStreet0_3B4BDone=True - - #steal calculations - if base=="hold": - if len(player_ids)>=5: #no point otherwise - if positions[player]==1: - if firstPfRaiserId==player_ids[player]: - myStealAttemptChance=True - myStealAttempted=True - elif firstPfRaiserId==buttonId or firstPfRaiserId==sbId or firstPfRaiserId==bbId or firstPfRaiserId==-1: - myStealAttemptChance=True - if positions[player]==0: - if firstPfRaiserId==player_ids[player]: - myStealAttemptChance=True - myStealAttempted=True - elif firstPfRaiserId==sbId or firstPfRaiserId==bbId or firstPfRaiserId==-1: - myStealAttemptChance=True - if positions[player]=='S': - if firstPfRaiserId==player_ids[player]: - myStealAttemptChance=True - myStealAttempted=True - elif firstPfRaiserId==bbId or firstPfRaiserId==-1: - myStealAttemptChance=True - if positions[player]=='B': - pass - - if myStealAttempted: - someoneStole=True - - - #calculate saw* values - isAllIn=False - for i in range(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])): - 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])): - if allIns[2][player][i]: - isAllIn=True - if (len(action_types[3][player])>0 or isAllIn): - myStreet3Seen=True - - #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 - if myStreet1Seen: - for count in range(len(action_types[street][player])): - if action_types[street][player][count]=="bet": - myStreet1Aggr=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": - myOtherRaisedStreet1=True - for countOtherFold in range (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])): - if action_types[street][player][count]=="bet": - myStreet2Aggr=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": - myOtherRaisedStreet2=True - for countOtherFold in range (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])): - if action_types[street][player][count]=="bet": - myStreet3Aggr=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": - myOtherRaisedStreet3=True - for countOtherFold in range (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])): - 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) - if mySawShowdown: - myWonAtSD=myWonWhenSeenStreet1 - - #add each value to the appropriate array - street0VPI.append(myStreet0VPI) - street0Aggr.append(myStreet0Aggr) - street0_3B4BChance.append(myStreet0_3B4BChance) - street0_3B4BDone.append(myStreet0_3B4BDone) - street1Seen.append(myStreet1Seen) - street2Seen.append(myStreet2Seen) - street3Seen.append(myStreet3Seen) - street4Seen.append(myStreet4Seen) - sawShowdown.append(mySawShowdown) - street1Aggr.append(myStreet1Aggr) - street2Aggr.append(myStreet2Aggr) - street3Aggr.append(myStreet3Aggr) - street4Aggr.append(myStreet4Aggr) - otherRaisedStreet1.append(myOtherRaisedStreet1) - otherRaisedStreet2.append(myOtherRaisedStreet2) - otherRaisedStreet3.append(myOtherRaisedStreet3) - otherRaisedStreet4.append(myOtherRaisedStreet4) - foldToOtherRaisedStreet1.append(myFoldToOtherRaisedStreet1) - foldToOtherRaisedStreet2.append(myFoldToOtherRaisedStreet2) - foldToOtherRaisedStreet3.append(myFoldToOtherRaisedStreet3) - foldToOtherRaisedStreet4.append(myFoldToOtherRaisedStreet4) - wonWhenSeenStreet1.append(myWonWhenSeenStreet1) - wonAtSD.append(myWonAtSD) - stealAttemptChance.append(myStealAttemptChance) - stealAttempted.append(myStealAttempted) - if base=="hold": - pos=positions[player] - if pos=='B': - hudDataPositions.append('B') - elif pos=='S': - hudDataPositions.append('S') - elif pos==0: - hudDataPositions.append('D') - elif pos==1: - hudDataPositions.append('C') - elif pos>=2 and pos<=4: - hudDataPositions.append('M') - elif pos>=5 and pos<=8: - hudDataPositions.append('E') - ### RHH Added this elif to handle being a dead hand before the BB (pos==9) - elif pos==9: - hudDataPositions.append('X') - else: - raise FpdbError("invalid position") - elif base=="stud": - #todo: stud positions and steals - pass - - #add each array to the to-be-returned dictionary - result={'street0VPI':street0VPI} - result['street0Aggr']=street0Aggr - result['street0_3B4BChance']=street0_3B4BChance - result['street0_3B4BDone']=street0_3B4BDone - result['street1Seen']=street1Seen - result['street2Seen']=street2Seen - result['street3Seen']=street3Seen - result['street4Seen']=street4Seen - result['sawShowdown']=sawShowdown - - result['street1Aggr']=street1Aggr - result['otherRaisedStreet1']=otherRaisedStreet1 - result['foldToOtherRaisedStreet1']=foldToOtherRaisedStreet1 - result['street2Aggr']=street2Aggr - result['otherRaisedStreet2']=otherRaisedStreet2 - result['foldToOtherRaisedStreet2']=foldToOtherRaisedStreet2 - result['street3Aggr']=street3Aggr - result['otherRaisedStreet3']=otherRaisedStreet3 - result['foldToOtherRaisedStreet3']=foldToOtherRaisedStreet3 - result['street4Aggr']=street4Aggr - result['otherRaisedStreet4']=otherRaisedStreet4 - result['foldToOtherRaisedStreet4']=foldToOtherRaisedStreet4 - result['wonWhenSeenStreet1']=wonWhenSeenStreet1 - result['wonAtSD']=wonAtSD - result['stealAttemptChance']=stealAttemptChance - result['stealAttempted']=stealAttempted - - #now the various steal values - foldBbToStealChance=[] - foldedBbToSteal=[] - foldSbToStealChance=[] - foldedSbToSteal=[] - for player in range (len(player_ids)): - myFoldBbToStealChance=False - myFoldedBbToSteal=False - myFoldSbToStealChance=False - myFoldedSbToSteal=False - - 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 - if positions[player]=='B': - myFoldBbToStealChance=True - if action_types[street][player][count]=="fold": - myFoldedBbToSteal=True - if positions[player]=='S': - myFoldSbToStealChance=True - if action_types[street][player][count]=="fold": - myFoldedSbToSteal=True - - - foldBbToStealChance.append(myFoldBbToStealChance) - foldedBbToSteal.append(myFoldedBbToSteal) - foldSbToStealChance.append(myFoldSbToStealChance) - foldedSbToSteal.append(myFoldedSbToSteal) - result['foldBbToStealChance']=foldBbToStealChance - result['foldedBbToSteal']=foldedBbToSteal - result['foldSbToStealChance']=foldSbToStealChance - result['foldedSbToSteal']=foldedSbToSteal - - #now CB - street1CBChance=[] - street1CBDone=[] - didStreet1CB=[] - for player in range (len(player_ids)): - myStreet1CBChance=False - myStreet1CBDone=False - - if street0VPI[player]: - myStreet1CBChance=True - if street1Aggr[player]: - myStreet1CBDone=True - didStreet1CB.append(player_ids[player]) - - street1CBChance.append(myStreet1CBChance) - street1CBDone.append(myStreet1CBDone) - result['street1CBChance']=street1CBChance - result['street1CBDone']=street1CBDone - - #now 2B - street2CBChance=[] - street2CBDone=[] - didStreet2CB=[] - for player in range (len(player_ids)): - myStreet2CBChance=False - myStreet2CBDone=False - - if street1CBDone[player]: - myStreet2CBChance=True - if street2Aggr[player]: - myStreet2CBDone=True - didStreet2CB.append(player_ids[player]) - - street2CBChance.append(myStreet2CBChance) - street2CBDone.append(myStreet2CBDone) - result['street2CBChance']=street2CBChance - result['street2CBDone']=street2CBDone - - #now 3B - street3CBChance=[] - street3CBDone=[] - didStreet3CB=[] - for player in range (len(player_ids)): - myStreet3CBChance=False - myStreet3CBDone=False - - if street2CBDone[player]: - myStreet3CBChance=True - if street3Aggr[player]: - myStreet3CBDone=True - didStreet3CB.append(player_ids[player]) - - street3CBChance.append(myStreet3CBChance) - street3CBDone.append(myStreet3CBDone) - result['street3CBChance']=street3CBChance - result['street3CBDone']=street3CBDone - - #and 4B - street4CBChance=[] - street4CBDone=[] - didStreet4CB=[] - for player in range (len(player_ids)): - myStreet4CBChance=False - myStreet4CBDone=False - - if street3CBDone[player]: - myStreet4CBChance=True - if street4Aggr[player]: - myStreet4CBDone=True - didStreet4CB.append(player_ids[player]) - - street4CBChance.append(myStreet4CBChance) - street4CBDone.append(myStreet4CBDone) - result['street4CBChance']=street4CBChance - result['street4CBDone']=street4CBDone - - - result['position']=hudDataPositions - - foldToStreet1CBChance=[] - foldToStreet1CBDone=[] - foldToStreet2CBChance=[] - foldToStreet2CBDone=[] - foldToStreet3CBChance=[] - foldToStreet3CBDone=[] - foldToStreet4CBChance=[] - foldToStreet4CBDone=[] - - for player in range (len(player_ids)): - myFoldToStreet1CBChance=False - myFoldToStreet1CBDone=False - foldToStreet1CBChance.append(myFoldToStreet1CBChance) - foldToStreet1CBDone.append(myFoldToStreet1CBDone) - - myFoldToStreet2CBChance=False - myFoldToStreet2CBDone=False - foldToStreet2CBChance.append(myFoldToStreet2CBChance) - foldToStreet2CBDone.append(myFoldToStreet2CBDone) - - myFoldToStreet3CBChance=False - myFoldToStreet3CBDone=False - foldToStreet3CBChance.append(myFoldToStreet3CBChance) - foldToStreet3CBDone.append(myFoldToStreet3CBDone) - - myFoldToStreet4CBChance=False - myFoldToStreet4CBDone=False - foldToStreet4CBChance.append(myFoldToStreet4CBChance) - foldToStreet4CBDone.append(myFoldToStreet4CBDone) - - if len(didStreet1CB)>=1: - generateFoldToCB(1, player_ids, didStreet1CB, street1CBDone, foldToStreet1CBChance, foldToStreet1CBDone, actionTypeByNo) - - if len(didStreet2CB)>=1: - generateFoldToCB(2, player_ids, didStreet2CB, street2CBDone, foldToStreet2CBChance, foldToStreet2CBDone, actionTypeByNo) - - if len(didStreet3CB)>=1: - generateFoldToCB(3, player_ids, didStreet3CB, street3CBDone, foldToStreet3CBChance, foldToStreet3CBDone, actionTypeByNo) - - if len(didStreet4CB)>=1: - generateFoldToCB(4, player_ids, didStreet4CB, street4CBDone, foldToStreet4CBChance, foldToStreet4CBDone, actionTypeByNo) - - result['foldToStreet1CBChance']=foldToStreet1CBChance - result['foldToStreet1CBDone']=foldToStreet1CBDone - result['foldToStreet2CBChance']=foldToStreet2CBChance - result['foldToStreet2CBDone']=foldToStreet2CBDone - result['foldToStreet3CBChance']=foldToStreet3CBChance - result['foldToStreet3CBDone']=foldToStreet3CBDone - result['foldToStreet4CBChance']=foldToStreet4CBChance - result['foldToStreet4CBDone']=foldToStreet4CBDone - - - totalProfit=[] - - street1CheckCallRaiseChance=[] - street1CheckCallRaiseDone=[] - street2CheckCallRaiseChance=[] - street2CheckCallRaiseDone=[] - street3CheckCallRaiseChance=[] - street3CheckCallRaiseDone=[] - street4CheckCallRaiseChance=[] - street4CheckCallRaiseDone=[] - for player in range (len(player_ids)): - myTotalProfit=0 - - myStreet1CheckCallRaiseChance=False - myStreet1CheckCallRaiseDone=False - myStreet2CheckCallRaiseChance=False - myStreet2CheckCallRaiseDone=False - myStreet3CheckCallRaiseChance=False - myStreet3CheckCallRaiseDone=False - myStreet4CheckCallRaiseChance=False - myStreet4CheckCallRaiseDone=False - - totalProfit.append(myTotalProfit) - - street1CheckCallRaiseChance.append(myStreet1CheckCallRaiseChance) - street1CheckCallRaiseDone.append(myStreet1CheckCallRaiseDone) - street2CheckCallRaiseChance.append(myStreet2CheckCallRaiseChance) - street2CheckCallRaiseDone.append(myStreet2CheckCallRaiseDone) - street3CheckCallRaiseChance.append(myStreet3CheckCallRaiseChance) - street3CheckCallRaiseDone.append(myStreet3CheckCallRaiseDone) - street4CheckCallRaiseChance.append(myStreet4CheckCallRaiseChance) - street4CheckCallRaiseDone.append(myStreet4CheckCallRaiseDone) - - result['totalProfit']=totalProfit - - result['street1CheckCallRaiseChance']=street1CheckCallRaiseChance - result['street1CheckCallRaiseDone']=street1CheckCallRaiseDone - result['street2CheckCallRaiseChance']=street2CheckCallRaiseChance - result['street2CheckCallRaiseDone']=street2CheckCallRaiseDone - result['street3CheckCallRaiseChance']=street3CheckCallRaiseChance - result['street3CheckCallRaiseDone']=street3CheckCallRaiseDone - result['street4CheckCallRaiseChance']=street4CheckCallRaiseChance - result['street4CheckCallRaiseDone']=street4CheckCallRaiseDone - return result ->>>>>>> 1de3446... remove spurious window realize from popup_window as well:pyfpdb/fpdb_simple.py #end def generateHudCacheData def generateFoldToCB(street, playerIDs, didStreetCB, streetCBDone, foldToStreetCBChance, foldToStreetCBDone, actionTypeByNo): From 685abee8b16a7c689f34ab7f5afc98602c94d05b Mon Sep 17 00:00:00 2001 From: eblade Date: Thu, 18 Dec 2008 17:39:43 -0500 Subject: [PATCH 05/13] re-indent function --- pyfpdb/fpdb_import.py | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/pyfpdb/fpdb_import.py b/pyfpdb/fpdb_import.py index 009ebb3c..a793e3ad 100644 --- a/pyfpdb/fpdb_import.py +++ b/pyfpdb/fpdb_import.py @@ -282,26 +282,24 @@ class Importer: self.fdb.db.commit() self.handsId=handsId return handsId -#end def import_file_dict - def parseTourneyHistory(self): - print "Tourney history parser stub" - #Find tournament boundaries. - #print self.foabs - - - def printEmailErrorMessage(self, errors, filename, line): - traceback.print_exc(file=sys.stderr) - print "Error No.",errors,", please send the hand causing this to steffen@sycamoretest.info so I can fix it." - print "Filename:", filename - print "Here is the first line so you can identify it. Please mention that the error was a ValueError:" - print self.hand[0] - print "Hand logged to hand-errors.txt" - logfile = open('hand-errors.txt', 'a') - for s in self.hand: - logfile.write(str(s) + "\n") - logfile.write("\n") - logfile.close() + def parseTourneyHistory(self): + print "Tourney history parser stub" + #Find tournament boundaries. + #print self.foabs + + def printEmailErrorMessage(self, errors, filename, line): + traceback.print_exc(file=sys.stderr) + print "Error No.",errors,", please send the hand causing this to steffen@sycamoretest.info so I can fix it." + print "Filename:", filename + print "Here is the first line so you can identify it. Please mention that the error was a ValueError:" + print self.hand[0] + print "Hand logged to hand-errors.txt" + logfile = open('hand-errors.txt', 'a') + for s in self.hand: + logfile.write(str(s) + "\n") + logfile.write("\n") + logfile.close() if __name__ == "__main__": print "CLI for fpdb_import is now available as CliFpdb.py" From 653cf9847de1bee4767e75d267e7369cb4b1dcb7 Mon Sep 17 00:00:00 2001 From: eblade Date: Thu, 18 Dec 2008 20:38:43 -0500 Subject: [PATCH 06/13] allow position 8 in hud cache --- pyfpdb/fpdb_simple.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyfpdb/fpdb_simple.py b/pyfpdb/fpdb_simple.py index ca7d6903..7029027e 100644 --- a/pyfpdb/fpdb_simple.py +++ b/pyfpdb/fpdb_simple.py @@ -2062,7 +2062,7 @@ sure to also change the following storage method and table_viewer.prepare_data i hudDataPositions.append('C') elif pos>=2 and pos<=4: hudDataPositions.append('M') - elif pos>=5 and pos<=7: + elif pos>=5 and pos<=8: hudDataPositions.append('E') ### RHH Added this elif to handle being a dead hand before the BB (pos==9) elif pos==9: From a6c2152be47bb39e79c45a7e82dec0698bdad117 Mon Sep 17 00:00:00 2001 From: Matt Turnbull Date: Sat, 20 Dec 2008 22:52:47 +0000 Subject: [PATCH 07/13] break less badly on a hand which I can't handle at the moment --- pyfpdb/Hand.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pyfpdb/Hand.py b/pyfpdb/Hand.py index 09f52065..24ccbe3f 100644 --- a/pyfpdb/Hand.py +++ b/pyfpdb/Hand.py @@ -576,5 +576,7 @@ class Pot(object): elif len(self.pots) == 3: return "Total pot $%.2f Main pot $%.2f. Side pot-1 $%2.2f. Side pot-2 $%.2f." % (self.total, self.pots[0], self.pots[1], self.pots[2]) else: - return "too many pots.. fix me.", self.pots + return "maybe no pot.. or too many pots.. no small blind and walk in bb?." + # I don't know stars format for a walk in the bb when sb doesn't post. + # The thing to do here is raise a Hand error like fpdb import does and file it into errors.txt From 24069d607be8f416413f18dd7ae9b9e69940956a Mon Sep 17 00:00:00 2001 From: eblade Date: Sun, 21 Dec 2008 06:49:34 -0500 Subject: [PATCH 08/13] code/comment cleanup in Hud --- pyfpdb/Hud.py | 83 +++++++++++++++------------------------------------ 1 file changed, 24 insertions(+), 59 deletions(-) diff --git a/pyfpdb/Hud.py b/pyfpdb/Hud.py index 1e29c017..e49e8f23 100644 --- a/pyfpdb/Hud.py +++ b/pyfpdb/Hud.py @@ -68,28 +68,31 @@ class Hud: else: print "Setting font to ", font + " " + font_size self.font = pango.FontDescription(font + " " + font_size) + + # do we need to add some sort of condition here for dealing with a request for a font that doesn't exist? # Set up a main window for this this instance of the HUD self.main_window = gtk.Window() -# self.window.set_decorated(0) self.main_window.set_gravity(gtk.gdk.GRAVITY_STATIC) self.main_window.set_title(table.name + " FPDBHUD") self.main_window.connect("destroy", self.kill_hud) self.main_window.set_decorated(False) self.main_window.set_opacity(self.colors["hudopacity"]) - #self.main_window.set_transient_for(parent.get_toplevel()) self.ebox = gtk.EventBox() -# self.label = gtk.Label("Right click to close HUD for %s\nor Save Stat Positions." % (table.name)) self.label = gtk.Label("FPDB Menu (Right Click)\nLeft-drag to move") - self.label.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(self.colors['hudbgcolor'])) - self.label.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse(self.colors['hudfgcolor'])) + self.backgroundcolor = gtk.gdk.color_parse(self.colors['hudbgcolor']) + self.foregroundcolor = gtk.gdk.color_parse(self.colors['hudfgcolor']) + + self.label.modify_bg(gtk.STATE_NORMAL, self.backgroundcolor) + self.label.modify_fg(gtk.STATE_NORMAL, self.foregroundcolor) self.main_window.add(self.ebox) self.ebox.add(self.label) - self.ebox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(self.colors['hudbgcolor'])) - self.ebox.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse(self.colors['hudfgcolor'])) + + self.ebox.modify_bg(gtk.STATE_NORMAL, self.backgroundcolor) + self.ebox.modify_fg(gtk.STATE_NORMAL, self.foregroundcolor) self.main_window.move(self.table.x, self.table.y) @@ -118,24 +121,21 @@ class Hud: self.ebox.connect_object("button-press-event", self.on_button_press, self.menu) self.main_window.show_all() -# set_keep_above(1) for windows + if os.name == 'nt': self.topify_window(self.main_window) else: self.main_window.parentgdkhandle = gtk.gdk.window_foreign_new(self.table.number) # gets a gdk handle for poker client 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.main_window.set_destroy_with_parent(True) - + def update_table_position(self): -# self.main_window.parentgdkhandle = gtk.gdk.window_foreign_new(self.table.number) -# if self.main_window.parentgdkhandle == None: if os.name == 'nt': if not win32gui.IsWindow(self.table.number): self.kill_hud() return False - + # anyone know how to do this in unix, or better yet, trap the X11 error that is triggered when executing the get_origin() for a closed window? + (x, y) = self.main_window.parentgdkhandle.get_origin() if self.table.x != x or self.table.y != y: self.table.x = x @@ -175,7 +175,6 @@ class Hud: def save_layout(self, *args): new_layout = [(0, 0)] * self.max -# todo: have the hud track the poker table's window position regularly, don't forget to update table.x and table.y. for sw in self.stat_windows: loc = self.stat_windows[sw].window.get_position() new_loc = (loc[0] - self.table.x, loc[1] - self.table.y) @@ -291,29 +290,13 @@ class Hud: for w in tl_windows: if w[1] == unique_name: - #win32gui.ShowWindow(w[0], win32con.SW_HIDE) self.main_window.parentgdkhandle = gtk.gdk.window_foreign_new(long(self.table.number)) self.main_window.gdkhandle = gtk.gdk.window_foreign_new(w[0]) self.main_window.gdkhandle.set_transient_for(self.main_window.parentgdkhandle) - #win32gui.ShowWindow(w[0], win32con.SW_SHOW) style = win32gui.GetWindowLong(self.table.number, win32con.GWL_EXSTYLE) - #style |= win32con.WS_EX_TOOLWINDOW - #style &= ~win32con.WS_EX_APPWINDOW style |= win32con.WS_CLIPCHILDREN win32gui.SetWindowLong(self.table.number, win32con.GWL_EXSTYLE, style) - - - #win32gui.SetWindowPos(w[0], win32con.HWND_TOPMOST, 0, 0, 0, 0, win32con.SWP_NOMOVE|win32con.SWP_NOSIZE) - -# notify_id = (w[0], -# 0, -# win32gui.NIF_ICON | win32gui.NIF_MESSAGE | win32gui.NIF_TIP, -# win32con.WM_USER+20, -# 0, -# '') -# win32gui.Shell_NotifyIcon(win32gui.NIM_DELETE, notify_id) -# window.set_title(real_name) class Stat_Window: @@ -335,7 +318,6 @@ class Stat_Window: if event.button == 2: # middle button event self.window.hide() -# print "middle button clicked" pass if event.button == 1: # left button event @@ -404,15 +386,15 @@ class Stat_Window: for c in range(self.game.cols): self.e_box[r].append( gtk.EventBox() ) - self.e_box[r][c].modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(parent.colors['hudbgcolor'])) - self.e_box[r][c].modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse(parent.colors['hudfgcolor'])) + self.e_box[r][c].modify_bg(gtk.STATE_NORMAL, parent.backgroundcolor) + self.e_box[r][c].modify_fg(gtk.STATE_NORMAL, parent.foregroundcolor) Stats.do_tip(self.e_box[r][c], 'farts') self.grid.attach(self.e_box[r][c], c, c+1, r, r+1, xpadding = 0, ypadding = 0) self.label[r].append( gtk.Label('xxx') ) - self.label[r][c].modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(parent.colors['hudbgcolor'])) - self.label[r][c].modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse(parent.colors['hudfgcolor'])) + self.label[r][c].modify_bg(gtk.STATE_NORMAL, parent.backgroundcolor) + self.label[r][c].modify_fg(gtk.STATE_NORMAL, parent.foregroundcolor) self.e_box[r][c].add(self.label[r][c]) self.e_box[r][c].connect("button_press_event", self.button_press_cb) @@ -436,7 +418,6 @@ class Popup_window: self.window = gtk.Window() self.window.set_decorated(0) self.window.set_gravity(gtk.gdk.GRAVITY_STATIC) -# self.window.set_keep_above(1) self.window.set_title("popup") self.window.set_property("skip-taskbar-hint", True) self.window.set_transient_for(parent.get_toplevel()) @@ -451,15 +432,13 @@ class Popup_window: self.window.add(self.ebox) self.ebox.add(self.lab) - self.ebox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(stat_window.parent.colors['hudbgcolor'])) - self.ebox.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse(stat_window.parent.colors['hudfgcolor'])) - self.window.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(stat_window.parent.colors['hudbgcolor'])) - self.window.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse(stat_window.parent.colors['hudfgcolor'])) - self.lab.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(stat_window.parent.colors['hudbgcolor'])) - self.lab.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse(stat_window.parent.colors['hudfgcolor'])) + self.ebox.modify_bg(gtk.STATE_NORMAL, stat_window.parent.backgroundcolor) + self.ebox.modify_fg(gtk.STATE_NORMAL, stat_window.parent.foregroundcolor) + self.window.modify_bg(gtk.STATE_NORMAL, stat_window.parent.backgroundcolor) + self.window.modify_fg(gtk.STATE_NORMAL, stat_window.parent.foregroundcolor) + self.lab.modify_bg(gtk.STATE_NORMAL, stat_window.parent.backgroundcolor) + self.lab.modify_fg(gtk.STATE_NORMAL, stat_window.parent.foregroundcolor) -# self.window.realize() - # figure out the row, col address of the click that activated the popup row = 0 col = 0 @@ -564,22 +543,8 @@ class Popup_window: for w in tl_windows: if w[1] == unique_name: -# win32gui.ShowWindow(w[0], win32con.SW_HIDE) -# style = win32gui.GetWindowLong(w[0], win32con.GWL_EXSTYLE) -# style |= win32con.WS_EX_TOOLWINDOW -# style &= ~win32con.WS_EX_APPWINDOW -# win32gui.SetWindowLong(w[0], win32con.GWL_EXSTYLE, style) -# win32gui.ShowWindow(w[0], win32con.SW_SHOW) win32gui.SetWindowPos(w[0], win32con.HWND_TOPMOST, 0, 0, 0, 0, win32con.SWP_NOMOVE|win32con.SWP_NOSIZE) -# notify_id = (w[0], -# 0, -# win32gui.NIF_ICON | win32gui.NIF_MESSAGE | win32gui.NIF_TIP, -# win32con.WM_USER+20, -# 0, -# '') -# win32gui.Shell_NotifyIcon(win32gui.NIM_DELETE, notify_id) -# window.set_title(real_name) if __name__== "__main__": From d4e16b9b0534901855d32caebb32cb233f717ee8 Mon Sep 17 00:00:00 2001 From: eblade Date: Sun, 21 Dec 2008 17:14:57 -0500 Subject: [PATCH 09/13] code/comment cleanup --- pyfpdb/Hud.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/pyfpdb/Hud.py b/pyfpdb/Hud.py index e49e8f23..74245d33 100644 --- a/pyfpdb/Hud.py +++ b/pyfpdb/Hud.py @@ -265,7 +265,7 @@ class Hud: self.stat_windows[stat_dict[s]['seat']].label[r][c].modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse(this_stat.hudcolor)) self.stat_windows[stat_dict[s]['seat']].label[r][c].set_text(statstring) - if statstring != "xxx": + if statstring != "xxx": # is there a way to tell if this particular stat window is visible already, or no? self.stat_windows[stat_dict[s]['seat']].window.show_all() self.reposition_windows() tip = stat_dict[s]['screen_name'] + "\n" + number[5] + "\n" + \ @@ -331,7 +331,6 @@ class Stat_Window: # Callback from the timeout in the single-click finding part of the # button press call back. This needs to be modified to get all the # arguments from the call. -# print "left button clicked" self.sb_click = 0 Popup_window(widget, self) return False @@ -398,7 +397,6 @@ class Stat_Window: self.e_box[r][c].add(self.label[r][c]) self.e_box[r][c].connect("button_press_event", self.button_press_cb) -# font = pango.FontDescription(self.font) self.label[r][c].modify_font(font) self.window.set_opacity(parent.colors['hudopacity']) @@ -481,8 +479,8 @@ class Popup_window: self.window.set_transient_for(stat_window.window) -# set_keep_above(1) for windows - if os.name == 'nt': self.topify_window(self.window) + if os.name == 'nt': + self.topify_window(self.window) def button_press_cb(self, widget, event, *args): # This handles all callbacks from button presses on the event boxes in @@ -500,11 +498,9 @@ class Popup_window: if event.button == 2: # middle button event pass -# print "middle button clicked" if event.button == 3: # right button event pass -# print "right button clicked" def single_click(self, widget): # Callback from the timeout in the single-click finding part of the From fc4671fc981e73bf268d7f92a49279631536aa6c Mon Sep 17 00:00:00 2001 From: eblade Date: Sun, 21 Dec 2008 18:42:21 -0500 Subject: [PATCH 10/13] add NA for attempted steal % --- pyfpdb/Stats.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/pyfpdb/Stats.py b/pyfpdb/Stats.py index 80b3c7f1..3f55c7fc 100644 --- a/pyfpdb/Stats.py +++ b/pyfpdb/Stats.py @@ -281,13 +281,7 @@ def steal(stat_dict, player): '% steal attempted' ) except: - return (stat, - '%3.1f' % (0) + '%', - 'st=%3.1f' % (0) + '%', - 'steal=%3.1f' % (0) + '%', - '(%d/%d)' % (0, 0), - '% steal attempted' - ) + return (stat, 'NA', 'st=NA', 'steal=NA', '(0/0)', '% steal attempted') def f_SB_steal(stat_dict, player): """ Folded SB to steal.""" @@ -306,7 +300,7 @@ def f_SB_steal(stat_dict, player): 'NA', 'fSB=NA', 'fSB_s=NA', - '0/0', + '(0/0)', '% folded SB to steal') def f_BB_steal(stat_dict, player): @@ -326,7 +320,7 @@ def f_BB_steal(stat_dict, player): 'NA', 'fBB=NA', 'fBB_s=NA', - '0/0', + '(0/0)', '% folded BB to steal') def three_B_0(stat_dict, player): From a76442f67ed99e12f7ac2b64c5a39794b4bc78e1 Mon Sep 17 00:00:00 2001 From: Matt Turnbull Date: Mon, 22 Dec 2008 20:17:29 +0000 Subject: [PATCH 11/13] Poll if HUD window is already terminated before attempting to communicate the \n character to tell it to terminate. --- pyfpdb/GuiAutoImport.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pyfpdb/GuiAutoImport.py b/pyfpdb/GuiAutoImport.py index 820642e4..ceb3da0d 100644 --- a/pyfpdb/GuiAutoImport.py +++ b/pyfpdb/GuiAutoImport.py @@ -154,8 +154,11 @@ class GuiAutoImport (threading.Thread): else: # toggled off self.doAutoImportBool = False # do_import will return this and stop the gobject callback timer print "Stopping autoimport" - print >>self.pipe_to_hud.stdin, "\n" - #self.pipe_to_hud.communicate('\n') # waits for process to terminate + if self.pipe_to_hud.poll() is not None: + print "HUD already terminated" + else: + #print >>self.pipe_to_hud.stdin, "\n" + self.pipe_to_hud.communicate('\n') # waits for process to terminate self.pipe_to_hud = None self.startButton.set_label(u'Start Autoimport') From 6de2607505c3799cf935f6c8cdd88e221f15ef64 Mon Sep 17 00:00:00 2001 From: eblade Date: Wed, 24 Dec 2008 07:56:32 -0500 Subject: [PATCH 12/13] create_hud adds to the main_hud window, a list of tables that are being monitored (it is culled in read_stdin(), so i'll need to do some thinking on that to remove lag time between removal of hud and removal from list) i can see using this for table info, debug info, buy-in info maybe, but i wanted some place i could write to directly and see things in real time rather than depending on the logs --- pyfpdb/HUD_main.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pyfpdb/HUD_main.py b/pyfpdb/HUD_main.py index 12417a23..9bf630b6 100755 --- a/pyfpdb/HUD_main.py +++ b/pyfpdb/HUD_main.py @@ -52,6 +52,7 @@ import Hud # global dict for keeping the huds hud_dict = {} +eb = 0 # our former event-box db_connection = 0; config = 0; @@ -61,11 +62,18 @@ def destroy(*args): # call back for terminating the main eventloop def create_HUD(new_hand_id, table, db_name, table_name, max, poker_game, db_connection, config, stat_dict): global hud_dict + global eb def idle_func(): global hud_dict + global eb gtk.gdk.threads_enter() try: + newlabel = gtk.Label(table_name) + eb.add(newlabel) + newlabel.show() + hud_dict[table_name] = Hud.Hud(table, max, poker_game, config, db_connection) + hud_dict[table_name].tablehudlabel = newlabel hud_dict[table_name].create(new_hand_id, config) for m in hud_dict[table_name].aux_windows: m.update_data(new_hand_id, db_connection) @@ -92,6 +100,7 @@ def update_HUD(new_hand_id, table_name, config, stat_dict): def read_stdin(): # This is the thread function global hud_dict + global eb db_connection = Database.Database(config, db_name, 'temp') tourny_finder = re.compile('(\d+) (\d+)') @@ -105,6 +114,7 @@ def read_stdin(): # This is the thread function # delete hud_dict entries for any HUD destroyed since last iteration for h in hud_dict.keys(): if hud_dict[h].deleted: + eb.remove(hud_dict[h].tablehudlabel) del(hud_dict[h]) # get basic info about the new hand from the db @@ -162,10 +172,11 @@ if __name__== "__main__": main_window = gtk.Window() main_window.connect("destroy", destroy) - eb = gtk.EventBox() + eb = gtk.VBox() label = gtk.Label('Closing this window will exit from the HUD.') eb.add(label) main_window.add(eb) + main_window.set_title("HUD Main Window") main_window.show_all() From 26a549d7d2218cf6cd56eb0031f6416028747ab3 Mon Sep 17 00:00:00 2001 From: eblade Date: Wed, 31 Dec 2008 13:13:35 -0500 Subject: [PATCH 13/13] discover functions all return None, instead of False --- pyfpdb/Tables.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pyfpdb/Tables.py b/pyfpdb/Tables.py index 54079425..6d88d079 100755 --- a/pyfpdb/Tables.py +++ b/pyfpdb/Tables.py @@ -152,7 +152,7 @@ def discover_posix_by_name(c, tablename): info = decode_xwininfo(c, listing) if not info['name'] == tablename: continue return info - return False + return None def discover_posix_tournament(c, t_number, s_number): """Finds the X window for a client, given tournament and table nos.""" @@ -160,7 +160,7 @@ def discover_posix_tournament(c, t_number, s_number): for listing in os.popen('xwininfo -root -tree').readlines(): if re.search(search_string, listing): return decode_xwininfo(c, listing) - return False + return None def decode_xwininfo(c, info_string): """Gets window parameters from xwinifo string--XWindows.""" @@ -231,7 +231,7 @@ def discover_nt_by_name(c, tablename): if titles[hwnd].find("HUD:") > -1: continue if titles[hwnd].find("Chat:") > -1: continue return decode_windows(c, titles[hwnd], hwnd) - return False + return None def discover_nt_tournament(c, tour_number, tab_number): """Finds the Windows window handle for the given tournament/table.""" @@ -242,7 +242,7 @@ def discover_nt_tournament(c, tour_number, tab_number): for hwnd in titles.keys(): if re.search(search_string, titles[hwnd]): return decode_windows(c, titles[hwnd], hwnd) - return False + return None def get_nt_exe(hwnd): """Finds the name of the executable that the given window handle belongs to."""