From 0898ddf8a15700f01cdf43f3ac8d73207daeefcd Mon Sep 17 00:00:00 2001 From: Worros Date: Tue, 22 Dec 2009 17:20:07 +0800 Subject: [PATCH] [NEWIMPORT] HandsPlayers.startCards Dodgy function just to get things kinda working again. --- pyfpdb/Card.py | 21 ++++++++++++++++++++- pyfpdb/DerivedStats.py | 4 ++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/pyfpdb/Card.py b/pyfpdb/Card.py index 287a0f6a..8639fd35 100755 --- a/pyfpdb/Card.py +++ b/pyfpdb/Card.py @@ -16,6 +16,25 @@ #agpl-3.0.txt in the docs folder of the package. +# From fpdb_simple +card_map = { "0": 0, "2": 2, "3" : 3, "4" : 4, "5" : 5, "6" : 6, "7" : 7, "8" : 8, + "9" : 9, "T" : 10, "J" : 11, "Q" : 12, "K" : 13, "A" : 14} + +# FIXME: the following is a workaround until switching to newimport. +# This should be moved into DerivedStats +# I'd also like to change HandsPlayers.startCards to a different datatype +# so we can 'trivially' add different start card classifications + +def calcStartCards(hand, player): + if hand.gametype['category'] == 'holdem': + hcs = hand.join_holecards(player, asList=True) + #print "DEBUG: hcs: %s" % hcs + value1 = card_map[hcs[0][0]] + value2 = card_map[hcs[1][0]] + return twoStartCards(value1, hcs[0][1], value2, hcs[1][1]) + else: + # FIXME: Only do startCards value for holdem at the moment + return 0 def twoStartCards(value1, suit1, value2, suit2): @@ -127,4 +146,4 @@ if __name__ == '__main__': (i, valueSuitFromCard(i), i+13, valueSuitFromCard(i+13), i+26, valueSuitFromCard(i+26), i+39, valueSuitFromCard(i+39)) print - print encodeCard('7c') \ No newline at end of file + print encodeCard('7c') diff --git a/pyfpdb/DerivedStats.py b/pyfpdb/DerivedStats.py index dbd655a3..b65b0d05 100644 --- a/pyfpdb/DerivedStats.py +++ b/pyfpdb/DerivedStats.py @@ -47,6 +47,7 @@ class DerivedStats(): self.handsplayers[player[1]]['wonWhenSeenStreet1'] = 0.0 self.handsplayers[player[1]]['sawShowdown'] = False self.handsplayers[player[1]]['wonAtSD'] = 0.0 + self.handsplayers[player[1]]['startCards'] = 0 for i in range(5): self.handsplayers[player[1]]['street%dCalls' % i] = 0 self.handsplayers[player[1]]['street%dBets' % i] = 0 @@ -57,7 +58,6 @@ class DerivedStats(): #FIXME - Everything below this point is incomplete. self.handsplayers[player[1]]['position'] = 2 self.handsplayers[player[1]]['tourneyTypeId'] = 1 - self.handsplayers[player[1]]['startCards'] = 0 self.handsplayers[player[1]]['street0_3BChance'] = False self.handsplayers[player[1]]['street0_3BDone'] = False self.handsplayers[player[1]]['stealAttemptChance'] = False @@ -172,7 +172,7 @@ class DerivedStats(): # self.handsplayers[player[1]]['card%s' % i] = Card.encodeCard(card) for i, card in enumerate(hcs[:7]): self.handsplayers[player[1]]['card%s' % (i+1)] = Card.encodeCard(card) - + self.handsplayers[player[1]]['startCards'] = Card.calcStartCards(hand, player[1]) # position, #Stud 3rd street card test