Added available move printout to help call

This commit is contained in:
sloumdrone 2019-01-21 10:18:32 -08:00
parent 1a14e4908d
commit 0d6bd528ba
1 changed files with 11 additions and 5 deletions

16
oberon
View File

@ -174,13 +174,18 @@ def create_game(enemy):
# Binds to the AVAILABLE command
def available_moves():
q = "SELECT p1, p2, turn FROM games WHERE winner is null and (p1 = ? or p2 = ?)"
q = "SELECT rowid, p1, p2, turn FROM games WHERE winner is null and (p1 = ? or p2 = ?)"
v = (username, username)
res = db_do(q, v)
p1 = len([x for x in res if x[0] == username and x[2] % 2 != 0])
p2 = len([x for x in res if x[1] == username and x[2] % 2 == 0])
if p1 + p2 > 0:
print('It is your turn in oberon!\n')
p1 = [x[0] for x in res if x[1] == username and x[3] % 2 != 0]
p2 = [x[0] for x in res if x[2] == username and x[3] % 2 == 0]
print('- - - -')
if len(p1) + len(p2) > 0:
p1 = ', '.join(str(x) for x in p1)
p2 = ', '.join(str(x) for x in p2)
print('\033[1;32mIt is your turn in the following game(s): {}{}\033[0m'.format(p1, p2))
else:
print('It is not your turn in any games...\n')
##############################
@ -193,6 +198,7 @@ def parse_args():
arg_len = len(args)
if arg_len == 1:
display_help()
available_moves()
sys.exit(0)
if arg_len == 2:
if args[1] == 'list':