Add logic for communicating end games to users
This commit is contained in:
parent
286e591ee0
commit
21443189ac
7
oberon
7
oberon
|
@ -95,6 +95,13 @@ def play_game(gid):
|
|||
q2 = "UPDATE games SET game_board = ?, turn = ?, winner = ? WHERE rowid = ?"
|
||||
v2 = (json.dumps(play['board']), state['turn_number'] + 1, play['winner'], gid)
|
||||
res2 = db_do(q2, v2, True)
|
||||
if play['winner']:
|
||||
msg_path = '/home/{}/.oberon'.format(enemy)
|
||||
enemy = state['p1'] if state['p1'] != username else state['p2']
|
||||
writemode = 'a' if fileexists(msg_path) else 'w'
|
||||
with open(msg_path, writemode) as f:
|
||||
f.write('{} defeated you in {} game {}\n'.format(username, state['game_type'], gid))
|
||||
|
||||
if not res2:
|
||||
print('Error updating database, sorry.\nTry again later?\n...or contact the sysadmin.')
|
||||
return False
|
||||
|
|
Loading…
Reference in New Issue