webgo/playgame.py

35 lines
893 B
Python
Raw Normal View History

import goban,helper,psql
def main(req,form):
"""
display selected goban and manage user input.
"""
req.write(str(form.keys())+"<hr>")
try:
gamename = form["game"]
except:
gamename = ""
if gamename != "":
#do stuff
data = helper.header()
#read goban table from database
tmplist = psql.read_table(gamename)
#make a dictionary out of the list
gobandict = psql.fetchall_list_to_goban_dict(tmplist)
#print goban
#data += "<p> Turn number: %s, %s Player's Move.</p>" % (gobandict["turn_number"],("White","Black")[gobandict["turn_number"] % 2]) #eleet ;>
#check whether its our turn
#if yes: print 'your move' and display goban and process move
#if not: print '...s move' and display goban.
data += goban.display_goban(gobandict,req,form)
data += helper.footer()
req.write(data)
else:
req.write('Error: You have to select a game to play it!')