p74 - mostly recovered razz/stud support

removed obselete gentoo install instructions, added ubuntu instructions
This commit is contained in:
steffen123
2008-09-01 05:41:58 +01:00
parent 6fc13a970b
commit 817c227dcb
7 changed files with 117 additions and 137 deletions
-2
View File
@@ -100,8 +100,6 @@ def import_file_dict(options, settings, callHud=True):
hand=fpdb_simple.filterCrap(site, hand, isTourney)
try:
if (category=="razz" or category=="studhi" or category=="studhilo"):
raise fpdb_simple.FpdbError ("stud/razz currently out of order")
handsId=fpdb_parse_logic.mainParser(db, cursor, site, category, hand)
db.commit()
+25 -20
View File
@@ -22,7 +22,10 @@ import fpdb_save_to_db
#parses a holdem hand
def mainParser(db, cursor, site, category, hand):
#print "hand:",hand
if (category=="holdem" or category=="omahahi" or category=="omahahilo"):
base="hold"
else:
base="stud"
#part 0: create the empty arrays
lineTypes=[] #char, valid values: header, name, cards, action, win, rake, ignore
lineStreets=[] #char, valid values: (predeal, preflop, flop, turn, river)
@@ -53,7 +56,7 @@ def mainParser(db, cursor, site, category, hand):
#part 2: classify lines by type (e.g. cards, action, win, sectionchange) and street
fpdb_simple.classifyLines(hand, category, lineTypes, lineStreets)
#part 3: read basic player info
#3a read player names, startcashes
for i in range (len(hand)): #todo: use maxseats+1 here.
@@ -68,11 +71,8 @@ def mainParser(db, cursor, site, category, hand):
fpdb_simple.createArrays(category, len(names), cardValues, cardSuits, antes, winnings, rakes, actionTypes, actionAmounts, actionNos, actionTypeByNo)
#3b read positions
if (category=="holdem" or category=="omahahi" or category=="omahahilo"):
if base=="hold":
positions = fpdb_simple.parsePositions (hand, names)
base="hold"
else:
base="stud"
#part 4: take appropriate action for each line based on linetype
for i in range(len(hand)):
@@ -104,7 +104,7 @@ def mainParser(db, cursor, site, category, hand):
#part 5: final preparations, then call fpdb_save_to_db.saveHoldem with
# the arrays as they are - that file will fill them.
fpdb_simple.convertCardValues(cardValues)
if (category=="holdem" or category=="omahahi" or category=="omahahilo"):
if base=="hold":
fpdb_simple.convertCardValuesBoard(boardValues)
fpdb_simple.convertBlindBet(actionTypes, actionAmounts)
fpdb_simple.checkPositions(positions)
@@ -116,7 +116,12 @@ def mainParser(db, cursor, site, category, hand):
totalWinnings=0
for i in range(len(winnings)):
totalWinnings+=winnings[i]
hudImportData=fpdb_simple.generateHudCacheData(playerIDs, category, actionTypes, actionTypeByNo, winnings, totalWinnings, positions)
if base=="hold":
hudImportData=fpdb_simple.generateHudCacheData(playerIDs, category, actionTypes, actionTypeByNo, winnings, totalWinnings, positions)
else:
print "todo: stud HudCache"
hudImportData=None
if isTourney:
ranks=[]
@@ -124,24 +129,24 @@ def mainParser(db, cursor, site, category, hand):
ranks.append(0)
payin_amounts=fpdb_simple.calcPayin(len(names), buyin, fee)
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, tourneyTypeId, siteID,
if base=="hold":
result = fpdb_save_to_db.tourney_holdem_omaha(cursor, base, category, siteTourneyNo, buyin, fee, knockout, entries, prizepool, tourneyStartTime, payin_amounts, ranks, tourneyTypeId, siteID,
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,
elif base=="stud":
result = fpdb_save_to_db.tourney_stud(cursor, base, category, siteTourneyNo, buyin, fee,
knockout, entries, prizepool, tourneyStartTime, payin_amounts, ranks,
siteHandNo, siteID, gametypeID, handStartTime, names, playerIDs,
startCashes, antes, cardValues, cardSuits, winnings, rakes,
actionTypes, actionAmounts, hudImportData)
actionTypes, actionAmounts, actionNos, hudImportData, maxSeats, tableName, seatNos)
else:
raise fpdb_simple.FpdbError ("unrecognised category")
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, 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,
if base=="hold":
result = fpdb_save_to_db.ring_holdem_omaha(cursor, base, category, siteHandNo, gametypeID, handStartTime, names, playerIDs, startCashes, positions, cardValues, cardSuits, boardValues, boardSuits, winnings, rakes, actionTypes, actionAmounts, actionNos, hudImportData, maxSeats, tableName, seatNos)
elif base=="stud":
result = fpdb_save_to_db.ring_stud(cursor, base, category, siteHandNo, gametypeID,
handStartTime, names, playerIDs, startCashes, antes, cardValues,
cardSuits, winnings, rakes, actionTypes, actionAmounts, hudImportData)
cardSuits, winnings, rakes, actionTypes, actionAmounts, actionNos, hudImportData, maxSeats, tableName, seatNos)
else:
raise fpdb_simple.FpdbError ("unrecognised category")
db.commit()
+11 -13
View File
@@ -21,25 +21,23 @@
import fpdb_simple
#stores a stud/razz hand into the database
def ring_stud(cursor, category, site_hand_no, gametype_id, hand_start_time,
names, player_ids, start_cashes, antes, card_values, card_suits,
winnings, rakes, action_types, action_amounts, hudImportData):
fpdb_simple.fillCardArrays(len(names), 7, card_values, card_suits)
def ring_stud(cursor, base, category, site_hand_no, gametype_id, hand_start_time, names, player_ids, start_cashes, antes, card_values, card_suits, winnings, rakes, action_types, action_amounts, actionNos, hudImportData, maxSeats, tableName, seatNos):
fpdb_simple.fillCardArrays(len(names), base, category, card_values, card_suits)
hands_id=fpdb_simple.storeHands(cursor, site_hand_no, gametype_id, hand_start_time, names)
hands_id=fpdb_simple.storeHands(cursor, site_hand_no, gametype_id, hand_start_time, names, tableName, maxSeats)
hands_players_ids=fpdb_simple.store_hands_players_stud(cursor, hands_id, player_ids,
start_cashes, antes, card_values, card_suits, winnings, rakes)
fpdb_simple.storeHudData(cursor, category, player_ids, hudImportData)
fpdb_simple.storeHudCache(cursor, category, gametype_id, player_ids, hudImportData)
fpdb_simple.storeActions(cursor, hands_players_ids, action_types, action_amounts)
fpdb_simple.storeActions(cursor, hands_players_ids, action_types, action_amounts, actionNos)
return hands_id
#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, seatNos):
def ring_holdem_omaha(cursor, base, 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"""
fpdb_simple.fillCardArrays(len(names), category, card_values, card_suits)
fpdb_simple.fillCardArrays(len(names), base, category, card_values, card_suits)
fpdb_simple.fill_board_cards(board_values, board_suits)
hands_id=fpdb_simple.storeHands(cursor, site_hand_no, gametype_id, hand_start_time, names, tableName, maxSeats)
@@ -54,10 +52,10 @@ def ring_holdem_omaha(cursor, category, site_hand_no, gametype_id, hand_start_ti
return hands_id
#end def ring_holdem_omaha
def tourney_holdem_omaha(cursor, category, siteTourneyNo, buyin, fee, knockout, entries, prizepool, tourney_start, payin_amounts, ranks, tourneyTypeId, siteId, #end of tourney specific params
def tourney_holdem_omaha(cursor, base, category, siteTourneyNo, buyin, fee, knockout, entries, prizepool, tourney_start, payin_amounts, ranks, tourneyTypeId, siteId, #end of tourney specific params
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 tourney holdem/omaha hand into the database"""
fpdb_simple.fillCardArrays(len(names), category, card_values, card_suits)
fpdb_simple.fillCardArrays(len(names), base, category, card_values, card_suits)
fpdb_simple.fill_board_cards(board_values, board_suits)
tourney_id=fpdb_simple.store_tourneys(cursor, tourneyTypeId, siteTourneyNo, entries, prizepool, tourney_start)
@@ -75,13 +73,13 @@ def tourney_holdem_omaha(cursor, category, siteTourneyNo, buyin, fee, knockout,
return hands_id
#end def tourney_holdem_omaha
def tourney_stud(cursor, category, site_tourney_no, buyin, fee, knockout, entries, prizepool,
def tourney_stud(cursor, base, category, site_tourney_no, buyin, fee, knockout, entries, prizepool,
tourney_start, payin_amounts, ranks, #end of tourney specific params
site_hand_no, site_id, gametype_id, hand_start_time, names, player_ids,
start_cashes, antes, card_values, card_suits, winnings, rakes,
action_types, action_amounts, hudImportData):
#stores a tourney stud/razz hand into the database
fpdb_simple.fillCardArrays(len(names), 7, card_values, card_suits)
fpdb_simple.fillCardArrays(len(names), base, category, card_values, card_suits)
tourney_id=fpdb_simple.store_tourneys(cursor, site_id, site_tourney_no, buyin, fee, knockout, entries, prizepool, tourney_start)
+16 -23
View File
@@ -97,19 +97,19 @@ def classifyLines(hand, category, lineTypes, lineStreets):
currentStreet="river"
elif (hand[i].startswith("*** 3")):
lineTypes.append("ignore")
currentStreet=3
currentStreet=0
elif (hand[i].startswith("*** 4")):
lineTypes.append("ignore")
currentStreet=4
currentStreet=1
elif (hand[i].startswith("*** 5")):
lineTypes.append("ignore")
currentStreet=5
currentStreet=2
elif (hand[i].startswith("*** 6")):
lineTypes.append("ignore")
currentStreet=6
currentStreet=3
elif (hand[i].startswith("*** 7") or hand[i]=="*** RIVER ***"):
lineTypes.append("ignore")
currentStreet=7
currentStreet=4
elif (hand[i].find(" shows [")!=-1):
lineTypes.append("cards")
elif (hand[i].startswith("Table '")):
@@ -119,10 +119,8 @@ def classifyLines(hand, category, lineTypes, lineStreets):
lineStreets.append(currentStreet)
#end def classifyLines
#calculates the actual bet amounts in the given amount array and changes it accordingly.
def convert3B4B(site, category, limit_type, actionTypes, actionAmounts):
#print "convert3B4B: actionTypes:", actionTypes
#print "convert3B4B: actionAmounts pre_Convert",actionAmounts
"""calculates the actual bet amounts in the given amount array and changes it accordingly."""
for i in range (len(actionTypes)):
for j in range (len(actionTypes[i])):
bets=[]
@@ -253,14 +251,16 @@ def fill_board_cards(board_values, board_suits):
board_suits.append("x")
#end def fill_board_cards
def fillCardArrays(player_count, category, card_values, card_suits):
def fillCardArrays(player_count, base, category, card_values, card_suits):
"""fills up the two card arrays"""
if (category=="holdem"):
cardCount=2
elif (category=="omahahi" or category=="omahahilo"):
cardCount=4
elif base=="stud":
cardCount=7
else:
raise fpdb_simple.FpdbError ("invalid category: category")
raise fpdb_simple.FpdbError ("invalid category:", category)
for i in range (player_count):
while (len(card_values[i])<cardCount):
@@ -364,8 +364,8 @@ def filterCrap(site, hand, isTourney):
toRemove.append(hand[i])
elif (hand[i].find(" shows ")!=-1 and hand[i].find("[")==-1):
toRemove.append(hand[i])
elif (hand[i].startswith("Table '") and hand[i].endswith("-max")):
toRemove.append(hand[i])
#elif (hand[i].startswith("Table '") and hand[i].endswith("-max")):
# toRemove.append(hand[i])
elif (hand[i].startswith("The button is in seat #")):
toRemove.append(hand[i])
#above is alphabetic, reorder below if bored
@@ -587,11 +587,6 @@ def parseActionAmount(line, atype, site):
# 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, line, street, playerIDs, names, action_types, action_amounts, actionNos, actionTypeByNo):
#this only applies to stud
if (street<3):
text="invalid street ("+str(street)+") for line: "+line
raise FpdbError(text)
if (street=="predeal" or street=="preflop"):
street=0
elif (street=="flop"):
@@ -1223,7 +1218,7 @@ def store_hands_players_stud(cursor, hands_id, player_ids, start_cashes, antes,
card_values[i][2], card_suits[i][2], card_values[i][3], card_suits[i][3],
card_values[i][4], card_suits[i][4], card_values[i][5], card_suits[i][5],
card_values[i][6], card_suits[i][6], winnings[i], rakes[i]))
cursor.execute("SELECT id FROM hands_players WHERE hand_id=%s AND player_id=%s", (hands_id, player_ids[i]))
cursor.execute("SELECT id FROM HandsPlayers WHERE handId=%s AND playerId=%s", (hands_id, player_ids[i]))
result.append(cursor.fetchall()[0][0])
return result
#end def store_hands_players_stud
@@ -1714,8 +1709,6 @@ def generateHudCacheData(player_ids, category, action_types, actionTypeByNo, win
foldToStreet4CBChance.append(myFoldToStreet4CBChance)
foldToStreet4CBDone.append(myFoldToStreet4CBDone)
print "actionTypeByNo:", actionTypeByNo
if len(didStreet1CB)>=1:
generateFoldToCB(1, player_ids, didStreet1CB, street1CBDone, foldToStreet1CBChance, foldToStreet1CBDone, actionTypeByNo)
@@ -1786,8 +1779,8 @@ def generateHudCacheData(player_ids, category, action_types, actionTypeByNo, win
def generateFoldToCB(street, playerIDs, didStreetCB, streetCBDone, foldToStreetCBChance, foldToStreetCBDone, actionTypeByNo):
"""fills the passed foldToStreetCB* arrays appropriately depending on the given street"""
print "beginning of generateFoldToCB, street:", street, "len(actionTypeByNo):", len(actionTypeByNo)
print "len(actionTypeByNo[street]):",len(actionTypeByNo[street])
#print "beginning of generateFoldToCB, street:", street, "len(actionTypeByNo):", len(actionTypeByNo)
#print "len(actionTypeByNo[street]):",len(actionTypeByNo[street])
firstCBReaction=0
for action in range(len(actionTypeByNo[street])):
if actionTypeByNo[street][action][1]=="bet":
@@ -1946,7 +1939,7 @@ def storeHudCache(cursor, category, gametypeId, playerIds, hudImportData):
row[51], row[52], row[53], row[54], row[55], row[56], row[57], row[58], row[59], row[60],
row[1], row[2], row[3], row[4], row[5]))
else:
raise FpdbError("todo")
print "todo: implement storeHudCache for stud base"
#end def storeHudCache
def store_tourneys(cursor, tourneyTypeId, siteTourneyNo, entries, prizepool, startTime):