From 5dfa5061cf02e9a5756d4ca1bc7304b1ec73f2db Mon Sep 17 00:00:00 2001 From: steffen123 Date: Thu, 9 Oct 2008 05:30:09 +0100 Subject: [PATCH] p128 - corrected 2 bugs in PrintHand.py. finished stud blackbox testdata. --- pyfpdb/fpdb_parse_logic.py | 1 + pyfpdb/fpdb_save_to_db.py | 1 + pyfpdb/fpdb_simple.py | 10 +++--- regression-test/PrintHand.py | 4 +-- regression-test/ps.15043388146.expected.txt | 38 ++++++++++----------- regression-test/regression-test.sh | 21 +++++++----- 6 files changed, 41 insertions(+), 34 deletions(-) diff --git a/pyfpdb/fpdb_parse_logic.py b/pyfpdb/fpdb_parse_logic.py index c6e9ad9f..2408516e 100644 --- a/pyfpdb/fpdb_parse_logic.py +++ b/pyfpdb/fpdb_parse_logic.py @@ -112,6 +112,7 @@ def mainParser(db, cursor, site, category, hand): tableResult=fpdb_simple.parseTableLine(site, base, hand[0]) maxSeats=tableResult['maxSeats'] tableName=tableResult['tableName'] + #print "before part5, antes:", antes #part 5: final preparations, then call fpdb_save_to_db.saveHoldem with # the arrays as they are - that file will fill them. diff --git a/pyfpdb/fpdb_save_to_db.py b/pyfpdb/fpdb_save_to_db.py index 5a06b1aa..9033c2bb 100644 --- a/pyfpdb/fpdb_save_to_db.py +++ b/pyfpdb/fpdb_save_to_db.py @@ -26,6 +26,7 @@ def ring_stud(cursor, base, category, site_hand_no, gametype_id, hand_start_time hands_id=fpdb_simple.storeHands(cursor, site_hand_no, gametype_id, hand_start_time, names, tableName, maxSeats) + #print "before calling store_hands_players_stud, antes:", antes hands_players_ids=fpdb_simple.store_hands_players_stud(cursor, hands_id, player_ids, start_cashes, antes, card_values, card_suits, winnings, rakes, seatNos) diff --git a/pyfpdb/fpdb_simple.py b/pyfpdb/fpdb_simple.py index 6187d536..ea9a4ee4 100644 --- a/pyfpdb/fpdb_simple.py +++ b/pyfpdb/fpdb_simple.py @@ -579,6 +579,7 @@ def parseActionAmount(line, atype, site, isTourney): else: if not isTourney: pos=line.rfind("$")+1 + #print "parseActionAmount, line:", line, "line[pos:]:", line[pos:] amount=float2int(line[pos:]) else: #print "line:"+line+"EOL" @@ -676,7 +677,6 @@ 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): - #print "parseAnteLine line: ",line for i in range(len(names)): if (line.startswith(names[i].encode("latin-1"))): #found the ante'er pos=line.rfind("$")+1 @@ -690,6 +690,7 @@ def parseAnteLine(line, site, isTourney, names, antes): pos1=line.rfind("ante")+5 pos2=line.find(" ",pos1) antes[i]+=int(line[pos1:pos2]) + #print "parseAnteLine line: ", line, "antes[i]", antes[i], "antes", antes #end def parseAntes #returns the buyin of a tourney in cents @@ -743,7 +744,7 @@ def parseCardLine(site, category, street, line, names, cardValues, cardSuits, bo cardValues[playerNo][street+2]=line[pos+6:pos+7] cardSuits[playerNo][street+2]=line[pos+7:pos+8] else: - print "parseCardLine(in stud else), street:", street + #print "parseCardLine(in stud else), street:", street cardValues[playerNo][0]=line[pos:pos+1] cardSuits[playerNo][0]=line[pos+1:pos+2] pos+=3 @@ -753,8 +754,8 @@ def parseCardLine(site, category, street, line, names, cardValues, cardSuits, bo pos=pos=line.rfind("]")-2 cardValues[playerNo][6]=line[pos:pos+1] cardSuits[playerNo][6]=line[pos+1:pos+2] - print "cardValues:", cardValues - print "cardSuits:", cardSuits + #print "cardValues:", cardValues + #print "cardSuits:", cardSuits else: print "line:",line,"street:",street raise FpdbError("invalid category") @@ -1280,6 +1281,7 @@ def store_hands_players_stud(cursor, hands_id, player_ids, start_cashes, antes, card_values, card_suits, winnings, rakes, seatNos): #stores hands_players rows for stud/razz games. returns an array of the resulting IDs result=[] + #print "before inserts in store_hands_players_stud, antes:", antes for i in range (len(player_ids)): cursor.execute ("""INSERT INTO HandsPlayers (handId, playerId, startCash, ante, diff --git a/regression-test/PrintHand.py b/regression-test/PrintHand.py index e29414ba..c8ecf67f 100755 --- a/regression-test/PrintHand.py +++ b/regression-test/PrintHand.py @@ -148,7 +148,7 @@ for i in range (len(handsPlayers)): else: printstr+=ful.cards2String(line[5:13]) elif (category=="razz" or category=="studhi" or category=="studhilo"): - printstr+=" ante:"+str(line[3])+" cards:" + printstr+=" ante:"+str(line[4])+" cards:" printstr+=ful.cards2String(line[5:19]) else: print "TODO: raise error, print_hand.py" @@ -167,7 +167,7 @@ for i in range (len(handsPlayers)): line=handsActions[j][2:] printstr="playerName:"+playerNames[i] printstr+=" street:"+ful.street_int2String(category, line[0])+" streetActionNo:"+str(line[1])+" action:"+line[2] - printstr+=" amount:"+str(line[3]) + printstr+=" amount:"+str(line[4]) print printstr cursor.close() diff --git a/regression-test/ps.15043388146.expected.txt b/regression-test/ps.15043388146.expected.txt index 639baa1f..300af5ed 100644 --- a/regression-test/ps.15043388146.expected.txt +++ b/regression-test/ps.15043388146.expected.txt @@ -3,7 +3,7 @@ options.site: PokerStars siteId: 2 From Table Hands ================ -handId: 4 tableName: Lydia siteHandNo: 15043388146 gametypeId: 2 handStart: 2008-02-04 03:04:15 seats: 6 maxSeats: 8 +handId: 5 tableName: Lydia siteHandNo: 15043388146 gametypeId: 3 handStart: 2008-02-04 03:04:15 seats: 6 maxSeats: 8 From Table Gametypes ==================== @@ -17,27 +17,27 @@ From Table HandsPlayers ======================= playerName:olimpicon99 playerStartcash:531 ante:2 cards:?? ?? 8c ?? ?? ?? ?? winnings:0 rake:0 playerName:PokerPig55 playerStartcash:158 ante:2 cards:?? ?? Kh ?? ?? ?? ?? winnings:0 rake:0 -playerName:VISTA GIRL playerStartcash:83 ante:2 cards:?? ?? 8 ?? ?? ?? ??h winnings:0 rake:0 +playerName:VISTA GIRL playerStartcash:83 ante:2 cards:?? ?? 8h ?? ?? ?? ?? winnings:0 rake:0 playerName:br1an playerStartcash:510 ante:2 cards:4c 7d 2d Qh 6d 6h 2h winnings:0 rake:0 playerName:steffen780 playerStartcash:400 ante:2 cards:Kc 9h 9c 5c 8s ?? ?? winnings:0 rake:0 playerName:willowdale playerStartcash:392 ante:2 cards:3s 4d 5s 4s Ad 5h 2c winnings:102 rake:5 From Table HandsActions ======================= -#playerName:olimpicon99 street:0 streetActionNo:3 action:fold amount:0 -#playerName:PokerPig55 street:0 streetActionNo:4 action:fold amount:0 -#playerName:VISTA GIRL street:0 streetActionNo:5 action:fold amount:0 -#playerName:br1an street:0 streetActionNo:0 action:blind amount:0 -#playerName:br1an street:1 streetActionNo:0 action:check amount:0 -#playerName:br1an street:2 streetActionNo:1 action:call amount:0 -#playerName:br1an street:3 streetActionNo:0 action:check amount:0 -#playerName:br1an street:4 streetActionNo:0 action:check amount:0 -#playerName:br1an street:4 streetActionNo:2 action:call amount:0 -#playerName:steffen780 street:0 streetActionNo:1 action:call amount:0 -#playerName:steffen780 street:1 streetActionNo:1 action:check amount:0 -#playerName:steffen780 street:2 streetActionNo:2 action:fold amount:0 -#playerName:willowdale street:0 streetActionNo:2 action:call amount:0 -#playerName:willowdale street:1 streetActionNo:2 action:check amount:0 -#playerName:willowdale street:2 streetActionNo:0 action:bet amount:0 -#playerName:willowdale street:3 streetActionNo:1 action:check amount:0 -#playerName:willowdale street:4 streetActionNo:1 action:bet amount:0 +playerName:olimpicon99 street:0 streetActionNo:3 action:fold amount:0 +playerName:PokerPig55 street:0 streetActionNo:4 action:fold amount:0 +playerName:VISTA GIRL street:0 streetActionNo:5 action:fold amount:0 +playerName:br1an street:0 streetActionNo:0 action:blind amount:5 +playerName:br1an street:1 streetActionNo:0 action:check amount:0 +playerName:br1an street:2 streetActionNo:1 action:call amount:20 +playerName:br1an street:3 streetActionNo:0 action:check amount:0 +playerName:br1an street:4 streetActionNo:0 action:check amount:0 +playerName:br1an street:4 streetActionNo:2 action:call amount:20 +playerName:steffen780 street:0 streetActionNo:1 action:call amount:5 +playerName:steffen780 street:1 streetActionNo:1 action:check amount:0 +playerName:steffen780 street:2 streetActionNo:2 action:fold amount:0 +playerName:willowdale street:0 streetActionNo:2 action:call amount:5 +playerName:willowdale street:1 streetActionNo:2 action:check amount:0 +playerName:willowdale street:2 streetActionNo:0 action:bet amount:20 +playerName:willowdale street:3 streetActionNo:1 action:check amount:0 +playerName:willowdale street:4 streetActionNo:1 action:bet amount:20 diff --git a/regression-test/regression-test.sh b/regression-test/regression-test.sh index 1609b8b8..6ef45066 100755 --- a/regression-test/regression-test.sh +++ b/regression-test/regression-test.sh @@ -20,22 +20,25 @@ echo "Please note for this to work you need to work on an empty database, otherw rm *.found.txt ../pyfpdb/fpdb_import.py -p$1 --file=ps-lhe-ring-3hands.txt -x ../pyfpdb/fpdb_import.py -p$1 --file=ps-lhe-ring-3hands.txt -x -../pyfpdb/fpdb_import.py -p$1 --file=ps-studhilo-ring-showdown.txt -x echo "it should've reported first that it stored 3, then that it had 3 duplicates" -echo " then 1 stored" -#./PrintHand.py -p$1 --hand=14519394979 > ps.14519394979.found.txt && colordiff ps.14519394979.found.txt ps.14519394979.expected.txt -#./PrintHand.py -p$1 --hand=14519420999 > ps.14519420999.found.txt && colordiff ps.14519420999.found.txt ps.14519420999.expected.txt -#./PrintHand.py -p$1 --hand=14519433154 > ps.14519433154.found.txt && colordiff ps.14519433154.found.txt ps.14519433154.expected.txt -./PrintHand.py -p$1 --hand=15043388146 > ps.15043388146.found.txt && colordiff ps.15043388146.found.txt ps.15043388146.expected.txt +./PrintHand.py -p$1 --hand=14519394979 > ps.14519394979.found.txt && colordiff ps.14519394979.found.txt ps.14519394979.expected.txt +./PrintHand.py -p$1 --hand=14519420999 > ps.14519420999.found.txt && colordiff ps.14519420999.found.txt ps.14519420999.expected.txt +./PrintHand.py -p$1 --hand=14519433154 > ps.14519433154.found.txt && colordiff ps.14519433154.found.txt ps.14519433154.expected.txt -#./PrintPlayerHudData.py -p$1 -oM > ps-flags-M-2hands.found.txt && colordiff ps-flags-M-2hands.found.txt ps-flags-M-2hands.expected.txt -#./PrintPlayerHudData.py -p$1 -nPlayer_5 -oB > ps-flags-B-1hands.found.txt && colordiff ps-flags-B-1hands.found.txt ps-flags-B-1hands.expected.txt +./PrintPlayerHudData.py -p$1 -oM > ps-flags-M-2hands.found.txt && colordiff ps-flags-M-2hands.found.txt ps-flags-M-2hands.expected.txt +./PrintPlayerHudData.py -p$1 -nPlayer_5 -oB > ps-flags-B-1hands.found.txt && colordiff ps-flags-B-1hands.found.txt ps-flags-B-1hands.expected.txt ../pyfpdb/fpdb_import.py -p$1 --file=ps-lhe-ring-call-3B-preflop-cb-no2b.txt -x echo "it should've now reported another successful store of 1 hand" -#./PrintPlayerHudData.py -p$1 -nplayer3 -oE -e10 -b25 > ps-flags-CBflop.found.txt && colordiff ps-flags-CBflop.found.txt ps-flags-CBflop.expected.txt +./PrintPlayerHudData.py -p$1 -nplayer3 -oE -e10 -b25 > ps-flags-CBflop.found.txt && colordiff ps-flags-CBflop.found.txt ps-flags-CBflop.expected.txt + + +../pyfpdb/fpdb_import.py -p$1 --file=ps-studhilo-ring-showdown.txt -x +echo "it should've now reported another successful store of 1 hand" +./PrintHand.py -p$1 --hand=15043388146 > ps.15043388146.found.txt && colordiff ps.15043388146.found.txt ps.15043388146.expected.txt + echo "if everything was printed as expected this worked"