more cleanup
This commit is contained in:
parent
c6179a1b85
commit
4830b72121
|
@ -854,13 +854,13 @@ def parseActionAmount(line, atype, site, isTourney):
|
|||
# action_amounts. For stud this expects numeric streets (3-7), for
|
||||
# holdem/omaha it expects predeal, preflop, flop, turn or river
|
||||
def parseActionLine(site, base, isTourney, line, street, playerIDs, names, action_types, allIns, action_amounts, actionNos, actionTypeByNo):
|
||||
if (street=="predeal" or street=="preflop"):
|
||||
if street == "predeal" or street == "preflop":
|
||||
street = 0
|
||||
elif (street=="flop"):
|
||||
elif street == "flop":
|
||||
street = 1
|
||||
elif (street=="turn"):
|
||||
elif street == "turn":
|
||||
street = 2
|
||||
elif (street=="river"):
|
||||
elif street == "river":
|
||||
street = 3
|
||||
|
||||
nextActionNo = 0
|
||||
|
@ -869,7 +869,7 @@ def parseActionLine(site, base, isTourney, line, street, playerIDs, names, actio
|
|||
if actionNos[street][player][count]>=nextActionNo:
|
||||
nextActionNo=actionNos[street][player][count]+1
|
||||
|
||||
line, allIn=goesAllInOnThisLine(line)
|
||||
(line, allIn) = goesAllInOnThisLine(line)
|
||||
atype = parseActionType(line)
|
||||
playerno = recognisePlayerNo(line, names, atype)
|
||||
amount = parseActionAmount(line, atype, site, isTourney)
|
||||
|
@ -934,13 +934,13 @@ 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 xrange(len(names)):
|
||||
if (line.startswith(names[i].encode("latin-1"))): #found the ante'er
|
||||
for i, name in enumerate(names):
|
||||
if line.startswith(name.encode("latin-1")):
|
||||
pos = line.rfind("$") + 1
|
||||
if not isTourney:
|
||||
antes[i] += float2int(line[pos:])
|
||||
else:
|
||||
if line.find("all-in")==-1:
|
||||
if "all-in" not in line:
|
||||
pos = line.rfind(" ") + 1
|
||||
antes[i] += int(line[pos:])
|
||||
else:
|
||||
|
@ -960,22 +960,22 @@ def parseBuyin(topline):
|
|||
#parses a card line and changes the passed arrays accordingly
|
||||
#todo: reorganise this messy method
|
||||
def parseCardLine(site, category, street, line, names, cardValues, cardSuits, boardValues, boardSuits):
|
||||
if (line.startswith("Dealt to ") or line.find(" shows [")!=-1 or line.find("mucked [")!=-1):
|
||||
if line.startswith("Dealt to") or " shows [" in line or "mucked [" in line:
|
||||
playerNo = recognisePlayerNo(line, names, "card") #anything but unbet will be ok for that string
|
||||
|
||||
pos = line.rfind("[")+1
|
||||
if (category=="holdem"):
|
||||
if category == "holdem":
|
||||
for i in (pos, pos+3):
|
||||
cardValues[playerNo].append(line[i:i+1])
|
||||
cardSuits[playerNo].append(line[i+1:i+2])
|
||||
if (len(cardValues[playerNo])!=2):
|
||||
if len(cardValues[playerNo]) !=2:
|
||||
if cardValues[playerNo][0]==cardValues[playerNo][2] and cardSuits[playerNo][1]==cardSuits[playerNo][3]: #two tests will do
|
||||
cardValues[playerNo]=cardValues[playerNo][0:2]
|
||||
cardSuits[playerNo]=cardSuits[playerNo][0:2]
|
||||
else:
|
||||
print "line:",line,"cardValues[playerNo]:",cardValues[playerNo]
|
||||
raise FpdbError("read too many/too few holecards in parseCardLine")
|
||||
elif (category=="omahahi" or category=="omahahilo"):
|
||||
elif category == "omahahi" or category == "omahahilo":
|
||||
for i in (pos, pos+3, pos+6, pos+9):
|
||||
cardValues[playerNo].append(line[i:i+1])
|
||||
cardSuits[playerNo].append(line[i+1:i+2])
|
||||
|
@ -986,8 +986,8 @@ def parseCardLine(site, category, street, line, names, cardValues, cardSuits, bo
|
|||
else:
|
||||
print "line:",line,"cardValues[playerNo]:",cardValues[playerNo]
|
||||
raise FpdbError("read too many/too few holecards in parseCardLine")
|
||||
elif (category=="razz" or category=="studhi" or category=="studhilo"):
|
||||
if (line.find("shows")==-1 and line.find("mucked")==-1):
|
||||
elif category=="razz" or category=="studhi" or category=="studhilo":
|
||||
if "shows" not in line and "mucked" not in line:
|
||||
#print "parseCardLine(in stud if), street:", street
|
||||
if line[pos+2]=="]": #-> not (hero and 3rd street)
|
||||
cardValues[playerNo][street+2]=line[pos:pos+1]
|
||||
|
@ -1126,12 +1126,8 @@ def parseNames(lines):
|
|||
return result
|
||||
#end def parseNames
|
||||
|
||||
#returns an array with the positions of the respective players
|
||||
def parsePositions(hand, names):
|
||||
#prep array
|
||||
positions=[]
|
||||
for i in xrange(len(names)):
|
||||
positions.append(-1)
|
||||
positions = map(lambda x: -1, names)
|
||||
|
||||
#find blinds
|
||||
sb,bb=-1,-1
|
||||
|
@ -1290,17 +1286,19 @@ def parseWinLine(line, site, names, winnings, isTourney):
|
|||
|
||||
#returns the category (as per database) string for the given line
|
||||
def recogniseCategory(line):
|
||||
if (line.find("Razz")!=-1):
|
||||
if "Razz" in line:
|
||||
return "razz"
|
||||
elif (line.find("Hold'em")!=-1):
|
||||
elif "Hold'em" in line:
|
||||
return "holdem"
|
||||
elif (line.find("Omaha")!=-1 and line.find("Hi/Lo")==-1 and line.find("H/L")==-1):
|
||||
elif "Omaha" in line:
|
||||
if "Hi/Lo" not in line and "H/L" not in line:
|
||||
return "omahahi"
|
||||
elif (line.find("Omaha")!=-1 and (line.find("Hi/Lo")!=-1 or line.find("H/L")!=-1)):
|
||||
else:
|
||||
return "omahahilo"
|
||||
elif (line.find("Stud")!=-1 and line.find("Hi/Lo")==-1 and line.find("H/L")==-1):
|
||||
elif "Stud" in line:
|
||||
if "Hi/Lo" not in line and "H/L" not in line:
|
||||
return "studhi"
|
||||
elif (line.find("Stud")!=-1 and (line.find("Hi/Lo")!=-1 or line.find("H/L")!=-1)):
|
||||
else:
|
||||
return "studhilo"
|
||||
else:
|
||||
raise FpdbError("failed to recognise category, line:"+line)
|
||||
|
|
Loading…
Reference in New Issue
Block a user