Uncommented guard clauses and updated history output
This commit is contained in:
parent
c50d085372
commit
1a14e4908d
24
oberon
24
oberon
|
@ -8,7 +8,7 @@ import json
|
|||
from gomoku import Gomoku
|
||||
from isola import Isola
|
||||
|
||||
version = '0.7.1'
|
||||
version = '0.8.0'
|
||||
home_folder = os.path.expanduser('~')
|
||||
username = os.path.split(home_folder)[-1]
|
||||
database = '/var/lib/oberon/oberon.sqlite'
|
||||
|
@ -26,16 +26,16 @@ def print_header():
|
|||
|
||||
# Binds to the HISTORY command
|
||||
def show_game_record():
|
||||
q = "SELECT rowid, p1, p2, winner FROM games WHERE winner is not NULL and (p1 = ? or p2 = ?)"
|
||||
q = "SELECT rowid, p1, p2, winner, game_type FROM games WHERE winner is not NULL and (p1 = ? or p2 = ?)"
|
||||
v = (username, username)
|
||||
res = db_do(q, v)
|
||||
if res == False:
|
||||
print('Database error. Contact the sysadmin or try another time')
|
||||
print_header()
|
||||
print('{:^8} {:^10} {:^10} {:^10}'.format('ID', 'Player 1', 'Player 2', 'Winner'))
|
||||
print('-------- ---------- ---------- ----------')
|
||||
print('{:^8} {:^10} {:^10} {:^10} {:^12}'.format('ID', 'Player 1', 'Player 2', 'Winner', 'Game Type'))
|
||||
print('-------- ---------- ---------- ---------- ------------')
|
||||
for x in res:
|
||||
print('{:^8} {:^10} {:^10} {:^10}'.format(x[0], x[1], x[2], x[3]))
|
||||
print('{:^8} {:^10} {:^10} {:^10} {:^12}'.format(x[0], x[1], x[2], x[3], x[4]))
|
||||
if not len(res):
|
||||
print('You have not completed any games yet...')
|
||||
print('\nTo view a historical game, run "oberon play [game_id]"')
|
||||
|
@ -133,14 +133,14 @@ def display_help():
|
|||
|
||||
# Binds to the CREATE command
|
||||
def create_game(enemy):
|
||||
# if enemy == username:
|
||||
# print('This system is designed for multiuser games. You cannot create a game against yourself.')
|
||||
# return False
|
||||
# enemies = get_user_list()
|
||||
if enemy == username:
|
||||
print('This system is designed for multiuser games. You cannot create a game against yourself.')
|
||||
return False
|
||||
enemies = get_user_list()
|
||||
|
||||
# if not enemy in enemies:
|
||||
# print('There is no avialable player with the name {}.\nGame not created.'.format(enemy))
|
||||
# return False
|
||||
if not enemy in enemies:
|
||||
print('There is no avialable player with the name {}.\nGame not created.'.format(enemy))
|
||||
return False
|
||||
|
||||
print_header()
|
||||
print('Which game would you like to play?\n\n(1) Gomoku/Five In a Row\n(2) Isola\n\nor (Q)uit')
|
||||
|
|
Loading…
Reference in New Issue