2010-07-04 03:05:16 +02:00
|
|
|
#!/usr/bin/python2
|
|
|
|
# -*- coding: utf-8 -*-
|
2008-08-04 05:44:28 +02:00
|
|
|
|
2010-07-04 03:05:16 +02:00
|
|
|
#Copyright 2008-2010 Steffen Schaumburg
|
2008-08-04 05:44:28 +02:00
|
|
|
#This program is free software: you can redistribute it and/or modify
|
|
|
|
#it under the terms of the GNU Affero General Public License as published by
|
|
|
|
#the Free Software Foundation, version 3 of the License.
|
|
|
|
#
|
|
|
|
#This program is distributed in the hope that it will be useful,
|
|
|
|
#but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
#GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
#You should have received a copy of the GNU Affero General Public License
|
|
|
|
#along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2010-07-04 03:05:16 +02:00
|
|
|
#In the "official" distribution you can find the license in agpl-3.0.txt.
|
2008-08-04 05:44:28 +02:00
|
|
|
|
|
|
|
import sys
|
|
|
|
|
|
|
|
def cards2String(arr):
|
|
|
|
if (len(arr)%2!=0):
|
|
|
|
print "TODO: raise error, cards2String failed, uneven length of arr"
|
|
|
|
sys.exit(1)
|
|
|
|
result = ""
|
|
|
|
for i in range (len(arr)/2):
|
|
|
|
if arr[i*2]==0:
|
|
|
|
result+="??"
|
|
|
|
else:
|
|
|
|
if arr[i*2]==14:
|
|
|
|
result+="A"
|
|
|
|
elif arr[i*2]==13:
|
|
|
|
result+="K"
|
|
|
|
elif arr[i*2]==12:
|
|
|
|
result+="Q"
|
|
|
|
elif arr[i*2]==11:
|
|
|
|
result+="J"
|
|
|
|
elif arr[i*2]==10:
|
|
|
|
result+="T"
|
|
|
|
elif (arr[i*2]>=2 and arr[i*2]<=9):
|
|
|
|
result+=str(arr[i*2])
|
|
|
|
else:
|
2008-08-22 23:39:43 +02:00
|
|
|
print "TODO: raise error, cards2String failed, arr[i*2]:", arr[i*2], "len(arr):", len(arr)
|
|
|
|
print "arr:",arr
|
2008-08-04 05:44:28 +02:00
|
|
|
sys.exit(1)
|
|
|
|
result+=arr[i*2+1]
|
|
|
|
result+=" "
|
|
|
|
return result[:-1]
|
|
|
|
|
|
|
|
def id_to_player_name(cursor, id):
|
2008-08-22 23:39:43 +02:00
|
|
|
cursor.execute("SELECT name FROM Players WHERE id=%s", (id, ))
|
2008-08-04 05:44:28 +02:00
|
|
|
return cursor.fetchone()[0]
|
|
|
|
|
|
|
|
def position2String(pos):
|
|
|
|
if pos=="B":
|
|
|
|
return "BB"
|
|
|
|
elif pos=="S":
|
|
|
|
return "SB"
|
|
|
|
elif pos=="0":
|
|
|
|
return "Btn"
|
|
|
|
else:
|
|
|
|
return (pos+" off Btn")
|
|
|
|
|
|
|
|
def street_int2String(category, street):
|
|
|
|
if (category=="holdem" or category=="omahahi" or category=="omahahilo"):
|
|
|
|
if street==0:
|
|
|
|
return "Preflop"
|
|
|
|
elif street==1:
|
2008-08-08 23:03:43 +02:00
|
|
|
return "Flop "
|
2008-08-04 05:44:28 +02:00
|
|
|
elif street==2:
|
2008-08-08 23:03:43 +02:00
|
|
|
return "Turn "
|
2008-08-04 05:44:28 +02:00
|
|
|
elif street==3:
|
2008-08-08 23:03:43 +02:00
|
|
|
return "River "
|
2008-08-04 05:44:28 +02:00
|
|
|
else:
|
|
|
|
print "TODO: raise error, fpdb_util_lib.py street_int2String invalid street no"
|
|
|
|
sys.exit(1)
|
|
|
|
elif (category=="razz" or category=="studhi" or category=="studhilo"):
|
|
|
|
return str(street)
|
|
|
|
else:
|
|
|
|
print "TODO: raise error, fpdb_util_lib.py street_int2String invalid category"
|
|
|
|
sys.exit(1)
|