Skip to content

Commit

Permalink
correct bug when win format has a space on iPoker
Browse files Browse the repository at this point in the history
correct bug when win format has a space on iPoker
  • Loading branch information
jejellyroll-fr committed Jun 22, 2023
1 parent 0f717d3 commit b85cfb8
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 4 deletions.
4 changes: 2 additions & 2 deletions pyfpdb/iPokerToFpdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class iPoker(HandHistoryConverter):
summaryInFile = True

substitutions = {
'LS': u"\$|\xe2\x82\xac|\xe2\u201a\xac|\u20ac|\xc2\xa3|\£|RSD|", # Used to remove currency symbols from the hand history
'LS': r"\$|\xe2\x82\xac|\xe2\u201a\xac|\u20ac|\xc2\xa3|\£|RSD|", # Used to remove currency symbols from the hand history
'PLYR': r'(?P<PNAME>[^\"]+)', # Regex pattern for matching player names
'NUM': r'(.,\d+)|(\d+)', # Regex pattern for matching numbers
'NUM2': r'\b((?:\d{1,3}(?:\s\d{3})*)|(?:\d+))\b', # Regex pattern for matching numbers with spaces
Expand Down Expand Up @@ -173,7 +173,7 @@ class iPoker(HandHistoryConverter):
re_Buyin = re.compile(r"""(?P<BUYIN>[%(NUM)s]+)""" % substitutions, re.MULTILINE|re.VERBOSE)
re_TotalBuyin = re.compile(r"""(?P<BUYIN>(?P<BIAMT>[%(LS)s%(NUM)s]+)\s\+\s?(?P<BIRAKE>[%(LS)s%(NUM)s]+)?)""" % substitutions, re.MULTILINE|re.VERBOSE)
re_HandInfo = re.compile(r'code="(?P<HID>[0-9]+)">\s*?<general>\s*?<startdate>(?P<DATETIME>[\.a-zA-Z-/: 0-9]+)</startdate>', re.MULTILINE)
re_PlayerInfo = re.compile(r'<player( (seat="(?P<SEAT>[0-9]+)"|name="%(PLYR)s"|chips="(%(LS)s)?(?P<CASH>[%(NUM2)s]+)(%(LS)s)?"|dealer="(?P<BUTTONPOS>(0|1))"|win="(%(LS)s)?(?P<WIN>[%(NUM)s]+)(%(LS)s)?"|bet="(%(LS)s)?(?P<BET>[^"]+)(%(LS)s)?"|addon="\d*"|rebuy="\d*"|merge="\d*"|reg_code="[\d-]*"))+\s*/>' % substitutions, re.MULTILINE)
re_PlayerInfo = re.compile(r'<player( (seat="(?P<SEAT>[0-9]+)"|name="%(PLYR)s"|chips="(%(LS)s)?(?P<CASH>[%(NUM2)s]+)(%(LS)s)?"|dealer="(?P<BUTTONPOS>(0|1))"|win="(%(LS)s)?(?P<WIN>[%(NUM2)s]+)(%(LS)s)?"|bet="(%(LS)s)?(?P<BET>[^"]+)(%(LS)s)?"|addon="\d*"|rebuy="\d*"|merge="\d*"|reg_code="[\d-]*"))+\s*/>' % substitutions, re.MULTILINE)
re_Board = re.compile(r'<cards( (type="(?P<STREET>Flop|Turn|River)"|player=""))+>(?P<CARDS>.+?)</cards>', re.MULTILINE)
re_EndOfHand = re.compile(r'<round id="END_OF_GAME"', re.MULTILINE)
re_Hero = re.compile(r'<nickname>(?P<HERO>.+)</nickname>', re.MULTILINE)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="utf-8"?>
<session sessioncode="5105918454">
<general>
<client_version>23.3.1.4</client_version>
<mode>real</mode>
<gametype>Holdem NL</gametype>
<tablename>Sit’n’Go Twister 1€, 786601687</tablename>
<tournamentcurrency>EUR</tournamentcurrency>
<duration>00:07:47</duration>
<gamecount>37</gamecount>
<startdate>2023-04-28 10:38:18</startdate>
<currency>EUR</currency>
<nickname>Hero</nickname>
<bets>5 760</bets>
<wins>2 280</wins>
<chipsin>480</chipsin>
<chipsout>0</chipsout>
<statuspoints>0,56PB</statuspoints>
<awardpoints>0PB</awardpoints>
<ipoints>0,56PB</ipoints>
<tablesize>3</tablesize>
<tournamentcode>786601686</tournamentcode>
<tournamentname>Sit’n’Go Twister 1€</tournamentname>
<rewarddrawn>3€</rewarddrawn>
<place>2</place>
<buyin>0€ + 0,07€ + 0,93€</buyin>
<totalbuyin>1€</totalbuyin>
<win>0</win>
</general>
<game gamecode="6589415183">
<general>
<startdate>2023-04-28 10:45:35</startdate>
<smallblind>40</smallblind>
<bigblind>80</bigblind>
<players>
<player bet="740" reg_code="" win="1 480" seat="3" dealer="1" rebuy="0" chips="740" name="Player" addon="0"/>
<player bet="760" reg_code="5105918454" win="0" seat="10" dealer="0" rebuy="0" chips="760" name="Hero" addon="0"/>
</players>
</general>
<round no="0">
<action no="1" type="1" player="Player" sum="40"/>
<action no="2" type="2" player="Hero" sum="80"/>
</round>
<round no="1">
<cards type="Pocket" player="Player">DQ C8</cards>
<action no="3" type="23" player="Player" sum="360"/>
<cards type="Pocket" player="Hero">DA D7</cards>
<action no="4" type="23" player="Hero" sum="760"/>
<action no="5" type="7" player="Player" sum="380"/>
</round>
<round no="2">
<cards type="Flop">HQ S5 D10</cards>
</round>
<round no="3">
<cards type="Turn">S10</cards>
</round>
<round no="4">
<cards type="River">D3</cards>
</round>
</game>

15 changes: 13 additions & 2 deletions pyfpdb/test_ipokertofpdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@


substitutions = {
'LS': u"\$|\xe2\x82\xac|\xe2\u201a\xac|\u20ac|\xc2\xa3|\£|RSD|",
'LS': r"\$|\xe2\x82\xac|\xe2\u201a\xac|\u20ac|\xc2\xa3|\£|RSD|",

'PLYR': r'(?P<PNAME>[^\"]+)',
'NUM': r'(?:\d+)|(\d+\s\d+)',
Expand Down Expand Up @@ -39,4 +39,15 @@ def test_re_PlayerInfo3():
plist[a.group('PNAME')] = [int(a.group('SEAT')), (a.group('CASH')),
(a.group('WIN')), False]
assert len(plist) == 2



def test_re_PlayerInfo8():
text = '<player bet="740" reg_code="" win="1 480" seat="3" dealer="1" rebuy="0" chips="740" name="pergerd" addon="0"/>'
match = re_PlayerInfo.search(text)
assert match is not None
assert match.group('SEAT') == '3'
assert match.group('PNAME') == 'pergerd'
assert match.group('CASH') == '740'
assert match.group('BUTTONPOS') == '1'
assert match.group('WIN') == '1 480'
assert match.group('BET') == '740'

0 comments on commit b85cfb8

Please sign in to comment.