redo changes to parsePositions

This commit is contained in:
eblade 2008-12-18 15:40:28 -05:00
parent 6e1499fb69
commit 9263aa998e

View File

@ -1204,67 +1204,83 @@ def parseNames(lines):
#returns an array with the positions of the respective players #returns an array with the positions of the respective players
def parsePositions (hand, names): def parsePositions (hand, names):
#prep array #prep array
positions=[] positions=[]
for i in range(len(names)): for i in range(len(names)):
positions.append(-1) positions.append(-1)
#find blinds #find blinds
sb,bb=-1,-1 sb,bb=-1,-1
for i in range (len(hand)): for i in range (len(hand)):
if (sb==-1 and hand[i].find("small blind")!=-1 and hand[i].find("dead small blind")==-1): if (sb==-1 and hand[i].find("small blind")!=-1 and hand[i].find("dead small blind")==-1):
sb=hand[i] sb=hand[i]
#print "sb:",sb #print "sb:",sb
if (bb==-1 and hand[i].find("big blind")!=-1 and hand[i].find("dead big blind")==-1): if (bb==-1 and hand[i].find("big blind")!=-1 and hand[i].find("dead big blind")==-1):
bb=hand[i] bb=hand[i]
#print "bb:",bb #print "bb:",bb
#identify blinds #identify blinds
#print "parsePositions before recognising sb/bb. names:",names #print "parsePositions before recognising sb/bb. names:",names
sbExists=True sbExists=True
if (sb!=-1): if (sb!=-1):
sb=recognisePlayerNo(sb, names, "bet") sb=recognisePlayerNo(sb, names, "bet")
else: else:
sbExists=False sbExists=False
if (bb!=-1): if (bb!=-1):
bb=recognisePlayerNo(bb, names, "bet") bb=recognisePlayerNo(bb, names, "bet")
#write blinds into array # print "sb = ", sb, "bb = ", bb
if (sbExists): if bb == sb:
positions[sb]="S" sbExists = False
positions[bb]="B" sb = -1
#fill up rest of array #write blinds into array
if (sbExists): if (sbExists):
arraypos=sb-1 positions[sb]="S"
else: positions[bb]="B"
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 #fill up rest of array
if (bb!=0 or (bb==0 and sbExists==False)): if (sbExists):
while (arraypos>bb): arraypos=sb-1
positions[arraypos]=distFromBtn else:
arraypos-=1 arraypos=bb-1
distFromBtn+=1 distFromBtn=0
while (arraypos>=0 and arraypos != bb):
#print "parsePositions first while, arraypos:",arraypos,"positions:",positions
positions[arraypos]=distFromBtn
arraypos-=1
distFromBtn+=1
for i in range (len(names)): # eric - this takes into account dead seats between blinds
if positions[i]==-1: if sbExists:
print "parsePositions names:",names i = bb - 1
print "result:",positions while positions[i] < 0 and i != sb:
raise FpdbError ("failed to read positions") positions[i] = 9
return positions 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 #end def parsePositions
#simply parses the rake amount and returns it as an int #simply parses the rake amount and returns it as an int