Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some pokerstars HH errors #40

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions poker/room/pokerstars.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
@implementer(hh.IStreet)
class _Street(hh._BaseStreet):
def _parse_cards(self, boardline):
self.cards = (Card(boardline[1:3]), Card(boardline[4:6]), Card(boardline[7:9]))
try:
self.cards = (Card(boardline[1:3]), Card(boardline[4:6]), Card(boardline[7:9]))
except:
self.cards = ()

def _parse_actions(self, actionlines):
actions = []
Expand All @@ -31,6 +34,12 @@ def _parse_actions(self, actionlines):
action = self._parse_muck(line)
elif ' said, "' in line: # skip chat lines
continue
elif "disconnected" in line: # skip disconnects
continue
elif "returned" in line: # skip return from sitouts
continue
elif "sitting out" in line: # skip goes to sitout
continue
elif ":" in line:
action = self._parse_player_action(line)
else:
Expand All @@ -48,9 +57,9 @@ def _parse_uncalled(self, line):
return name, Action.RETURN, Decimal(amount)

def _parse_collected(self, line):
first_space_index = line.find(" ")
first_space_index = line.find(" collected"))
name = line[:first_space_index]
second_space_index = line.find(" ", first_space_index + 1)
second_space_index = line.find(" ", first_space_index + len(" collected"))
third_space_index = line.find(" ", second_space_index + 1)
amount = line[second_space_index + 1 : third_space_index]
self.pot = Decimal(amount)
Expand Down Expand Up @@ -226,6 +235,8 @@ def _parse_preflop(self):
start = self._sections[0] + 3
stop = self._sections[1]
self.preflop_actions = tuple(self._splitted[start:stop])
prefloplines = self._splitted[start:stop]
self.preflop = _Street(prefloplines)

def _parse_flop(self):
try:
Expand Down