From 579b44450ce770f2230d3daa13e3e8789916dc72 Mon Sep 17 00:00:00 2001 From: steffen123 Date: Sun, 17 Aug 2008 04:44:53 +0100 Subject: [PATCH] p45 - implemented HandsPlayers.seatNo --- docs/known-bugs-and-planned-features.txt | 4 +-- pyfpdb/fpdb.py | 6 ++--- pyfpdb/fpdb_db.py | 4 +-- pyfpdb/fpdb_parse_logic.py | 8 +++--- pyfpdb/fpdb_save_to_db.py | 5 ++-- pyfpdb/fpdb_simple.py | 34 ++++++++++++------------ 6 files changed, 31 insertions(+), 30 deletions(-) diff --git a/docs/known-bugs-and-planned-features.txt b/docs/known-bugs-and-planned-features.txt index 76b74c78..d48a2a49 100644 --- a/docs/known-bugs-and-planned-features.txt +++ b/docs/known-bugs-and-planned-features.txt @@ -3,7 +3,7 @@ Everything is subject to change and especially the order will often change. Patc alpha2 (release by 17Aug) ====== - HandsPlayers.seatNo +implement HandsPlayers.seatNo change tabledesign VALIGN seperate and improve instructions for update @@ -14,7 +14,7 @@ delete old mailing list and create fpdb-announce finish updating filelist update abbreviations.txt ebuild: symlink doesnt work, USE gtk, more automation, update install-in-gentoo.txt, set permissions in it, copy docs to correct place, use games eclass or whatever to get games group notice, print notice about install-in-gentoo.txt and mysql --config - +add minimal instructions for developing to git-instructions alpha3 ====== diff --git a/pyfpdb/fpdb.py b/pyfpdb/fpdb.py index 9eb0eed8..77ea08a1 100755 --- a/pyfpdb/fpdb.py +++ b/pyfpdb/fpdb.py @@ -350,7 +350,7 @@ class fpdb: For howto information please see docs"""+os.sep+"""readme-user.txt The abbrevations in the table viewer are explained in docs"""+os.sep+"""abbrevations.txt This program is licensed under the AGPL3, see docs"""+os.sep+"agpl-3.0.txt") - self.add_and_display_tab(mh_tab, "main help") + self.add_and_display_tab(mh_tab, "Help") #end def tab_main_help def tab_table_viewer(self, widget, data): @@ -359,7 +359,7 @@ This program is licensed under the AGPL3, see docs"""+os.sep+"agpl-3.0.txt") new_tv_thread=GuiTableViewer.GuiTableViewer(self.db, self.settings) self.threads.append(new_tv_thread) tv_tab=new_tv_thread.get_vbox() - self.add_and_display_tab(tv_tab, "table viewer") + self.add_and_display_tab(tv_tab, "Table Viewer") #end def tab_table_viewer def __init__(self): @@ -370,7 +370,7 @@ This program is licensed under the AGPL3, see docs"""+os.sep+"agpl-3.0.txt") self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.connect("delete_event", self.delete_event) self.window.connect("destroy", self.destroy) - self.window.set_title("Free Poker DB - version: alpha1+, p44") + self.window.set_title("Free Poker DB - version: alpha1+, p45") self.window.set_border_width(1) self.window.set_size_request(1020,400) self.window.set_resizable(True) diff --git a/pyfpdb/fpdb_db.py b/pyfpdb/fpdb_db.py index bef32616..3fb62f30 100644 --- a/pyfpdb/fpdb_db.py +++ b/pyfpdb/fpdb_db.py @@ -47,7 +47,7 @@ class fpdb_db: try: self.cursor.execute("SELECT * FROM Settings") settings=self.cursor.fetchone() - if settings[0]!=44: + if settings[0]!=45: print "outdated or too new database version - please recreate tables" except:# _mysql_exceptions.ProgrammingError: print "failed to read settings table - please recreate tables" @@ -337,7 +337,7 @@ class fpdb_db: riverCheckCallRaiseChance INT, riverCheckCallRaiseDone INT)""") - self.cursor.execute("INSERT INTO Settings VALUES (44);") + self.cursor.execute("INSERT INTO Settings VALUES (45);") self.cursor.execute("INSERT INTO Sites VALUES (DEFAULT, \"Full Tilt Poker\", 'USD');") self.cursor.execute("INSERT INTO Sites VALUES (DEFAULT, \"PokerStars\", 'USD');") self.cursor.execute("INSERT INTO TourneysGametypes (id) VALUES (DEFAULT);") diff --git a/pyfpdb/fpdb_parse_logic.py b/pyfpdb/fpdb_parse_logic.py index ee98ac4a..8912fc07 100644 --- a/pyfpdb/fpdb_parse_logic.py +++ b/pyfpdb/fpdb_parse_logic.py @@ -57,7 +57,9 @@ def mainParser(db, cursor, site, category, hand): seatLines.append(hand[i]) names=fpdb_simple.parseNames(seatLines) playerIDs = fpdb_simple.recognisePlayerIDs(cursor, names, siteID) - startCashes=fpdb_simple.parseCashes(seatLines, site) + tmp=fpdb_simple.parseCashesAndSeatNos(seatLines, site) + startCashes=tmp['startCashes'] + seatNos=tmp['seatNos'] fpdb_simple.createArrays(category, len(names), cardValues, cardSuits, antes, winnings, rakes, actionTypes, actionAmounts, actionNos, actionTypeByNo) @@ -118,7 +120,7 @@ def mainParser(db, cursor, site, category, hand): prizepool=-1 if (category=="holdem" or category=="omahahi" or category=="omahahilo"): result = fpdb_save_to_db.tourney_holdem_omaha(cursor, category, siteTourneyNo, buyin, fee, knockout, entries, prizepool, tourneyStartTime, payin_amounts, ranks, - siteHandNo, gametypeID, handStartTime, names, playerIDs, startCashes, positions, cardValues, cardSuits, boardValues, boardSuits, winnings, rakes, actionTypes, actionAmounts, actionNos, hudImportData, maxSeats, tableName) + siteHandNo, gametypeID, handStartTime, names, playerIDs, startCashes, positions, cardValues, cardSuits, boardValues, boardSuits, winnings, rakes, actionTypes, actionAmounts, actionNos, hudImportData, maxSeats, tableName, seatNos) elif (category=="razz" or category=="studhi" or category=="studhilo"): raise fpdb_simple.FpdbError ("stud/razz are currently broken") result = fpdb_save_to_db.tourney_stud(cursor, category, siteTourneyNo, buyin, fee, @@ -128,7 +130,7 @@ def mainParser(db, cursor, site, category, hand): actionTypes, actionAmounts, hudImportData) else: if (category=="holdem" or category=="omahahi" or category=="omahahilo"): - result = fpdb_save_to_db.ring_holdem_omaha(cursor, category, siteHandNo, gametypeID, handStartTime, names, playerIDs, startCashes, positions, cardValues, cardSuits, boardValues, boardSuits, winnings, rakes, actionTypes, actionAmounts, actionNos, hudImportData, maxSeats, tableName) + result = fpdb_save_to_db.ring_holdem_omaha(cursor, category, siteHandNo, gametypeID, handStartTime, names, playerIDs, startCashes, positions, cardValues, cardSuits, boardValues, boardSuits, winnings, rakes, actionTypes, actionAmounts, actionNos, hudImportData, maxSeats, tableName, seatNos) elif (category=="razz" or category=="studhi" or category=="studhilo"): raise fpdb_simple.FpdbError ("stud/razz are currently broken") result = fpdb_save_to_db.ring_stud(cursor, category, siteHandNo, gametypeID, diff --git a/pyfpdb/fpdb_save_to_db.py b/pyfpdb/fpdb_save_to_db.py index 09ff1e66..1526049b 100644 --- a/pyfpdb/fpdb_save_to_db.py +++ b/pyfpdb/fpdb_save_to_db.py @@ -37,7 +37,7 @@ def ring_stud(cursor, category, site_hand_no, gametype_id, hand_start_time, return site_hand_no #end def ring_stud -def ring_holdem_omaha(cursor, category, site_hand_no, gametype_id, hand_start_time, names, player_ids, start_cashes, positions, card_values, card_suits, board_values, board_suits, winnings, rakes, action_types, action_amounts, actionNos, hudImportData, maxSeats, tableName): +def ring_holdem_omaha(cursor, category, site_hand_no, gametype_id, hand_start_time, names, player_ids, start_cashes, positions, card_values, card_suits, board_values, board_suits, winnings, rakes, action_types, action_amounts, actionNos, hudImportData, maxSeats, tableName, seatNos): """stores a holdem/omaha hand into the database""" #fill up the two player card arrays @@ -52,8 +52,7 @@ def ring_holdem_omaha(cursor, category, site_hand_no, gametype_id, hand_start_ti hands_id=fpdb_simple.storeHands(cursor, site_hand_no, gametype_id, hand_start_time, names, tableName) - hands_players_ids=fpdb_simple.store_hands_players_holdem_omaha(cursor, category, hands_id, player_ids, - start_cashes, positions, card_values, card_suits, winnings, rakes) + hands_players_ids=fpdb_simple.store_hands_players_holdem_omaha(cursor, category, hands_id, player_ids, start_cashes, positions, card_values, card_suits, winnings, rakes, seatNos) fpdb_simple.storeHudData(cursor, category, gametype_id, player_ids, hudImportData) diff --git a/pyfpdb/fpdb_simple.py b/pyfpdb/fpdb_simple.py index 32592e2d..89a90a7b 100644 --- a/pyfpdb/fpdb_simple.py +++ b/pyfpdb/fpdb_simple.py @@ -718,24 +718,24 @@ def parseCardLine(site, category, street, line, names, cardValues, cardSuits, bo raise FpdbError ("unrecognised line:"+line) #end def parseCardLine -#parses the start cash of each player out of the given lines and returns them as an array -def parseCashes(lines, site): - result = [] +def parseCashesAndSeatNos(lines, site): + """parses the startCashes and seatNos of each player out of the given lines and returns them as a dictionary of two arrays""" + cashes = [] + seatNos = [] for i in range (len(lines)): + pos2=lines[i].rfind(":") + seatNos.append(int(lines[i][5:pos2])) + pos1=lines[i].rfind("($")+2 if pos1==1: #for tourneys - it's 1 instead of -1 due to adding 2 above pos1=lines[i].rfind("(")+1 - #print "parseCashes, lines[i]:",lines[i] - #print "parseCashes, pos1:",pos1 if (site=="ftp"): pos2=lines[i].rfind(")") elif (site=="ps"): - #print "in parseCashes, line:", lines[i] pos2=lines[i].find(" in chips") - #print "in parseCashes, line:", lines[i], "pos1:",pos1,"pos2:",pos2 - result.append(float2int(lines[i][pos1:pos2])) - return result -#end def parseCashes + cashes.append(float2int(lines[i][pos1:pos2])) + return {'startCashes':cashes, 'seatNos':seatNos} +#end def parseCashesAndSeatNos #returns the buyin of a tourney in cents def parseFee(topline): @@ -1132,18 +1132,18 @@ def storeHands(cursor, site_hand_no, gametype_id, hand_start_time, names, tableN #end def storeHands def store_hands_players_holdem_omaha(cursor, category, hands_id, player_ids, - start_cashes, positions, card_values, card_suits, winnings, rakes): + start_cashes, positions, card_values, card_suits, winnings, rakes, seatNos): result=[] if (category=="holdem"): for i in range (len(player_ids)): cursor.execute (""" INSERT INTO HandsPlayers (handId, playerId, startCash, position, - card1Value, card1Suit, card2Value, card2Suit, winnings, rake) - VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)""", + card1Value, card1Suit, card2Value, card2Suit, winnings, rake, seatNo) + VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)""", (hands_id, player_ids[i], start_cashes[i], positions[i], card_values[i][0], card_suits[i][0], card_values[i][1], card_suits[i][1], - winnings[i], rakes[i])) + winnings[i], rakes[i], seatNos[i])) cursor.execute("SELECT id FROM HandsPlayers WHERE handId=%s AND playerId=%s", (hands_id, player_ids[i])) result.append(cursor.fetchall()[0][0]) elif (category=="omahahi" or category=="omahahilo"): @@ -1151,12 +1151,12 @@ def store_hands_players_holdem_omaha(cursor, category, hands_id, player_ids, cursor.execute ("""INSERT INTO HandsPlayers (handId, playerId, startCash, position, card1Value, card1Suit, card2Value, card2Suit, - card3Value, card3Suit, card4Value, card4Suit, winnings, rake) - VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)""", + card3Value, card3Suit, card4Value, card4Suit, winnings, rake, seatNo) + VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)""", (hands_id, player_ids[i], start_cashes[i], positions[i], card_values[i][0], card_suits[i][0], card_values[i][1], card_suits[i][1], card_values[i][2], card_suits[i][2], card_values[i][3], card_suits[i][3], - winnings[i], rakes[i])) + winnings[i], rakes[i], seatNo[i])) cursor.execute("SELECT id FROM hands_players WHERE hand_id=%s AND player_id=%s", (hands_id, player_ids[i])) result.append(cursor.fetchall()[0][0]) else: