From 286e591ee088ea7879b01820ecf6c209b7c78263 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Sat, 27 Apr 2019 16:24:38 -0700 Subject: [PATCH] Added kill option to game creation as well as play order choice --- __pycache__/brandubh.cpython-36.pyc | Bin 5966 -> 7633 bytes oberon | 23 +++++++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/__pycache__/brandubh.cpython-36.pyc b/__pycache__/brandubh.cpython-36.pyc index 70c9e5b14ba68bac860c600fbad8ea902d55d321..4245620234796e67c6b0ee2480d5c4c161f50bf2 100644 GIT binary patch delta 1814 zcmaJ?J%}Vl7`@u{78yKL&L1$44=&hUSbGFD*-gAVk6n>v7g-|(sp+bjuAA(ow}*J4J_GzPq1Y0dX=nT09a( z$g$KSpzMnMj6%!)s6Z!9rQ~=&oGLv*(Hns7vCl^LB}iY&j&lp)50luO8n)aId zfP|Up1E?PR1F~vTcnsk@%`@j(8&6dtU`;bA07&^2N#9XYU-JBrEZ~ygr(xCG4Tmk$N`M&O5y~fl{Dk?o(?SaG%mTGrXVD|P~1w| zbB%>nT436m{LGM30)q+wyE$&TXkWJ7^^ROv(hc?gYe{3g&qf z1QAhRYo&;|VSra)dFc!)S2hSzV^TikLCXg|go0Dr(v=y=>%&H1^)PqQ1G^?KpbBmP zDj3psjwIt67l;Mb9dcaOu~i5>HY62=IGU<1rC$?{pQMatbPqDa!oWpr{+t?@;;_mT zHr*G{feB@8On+RvTH3L(mFvlN3y?;Z#(?;Qj70pz2KOZ_(pQ`cY+^k+#JuVCDr|fk zRx#W^;dhKFhfuC}@jPCjXjo$VHTTfaSRD-wCWX5qF#zxQiW==zNiwMq9HJ};6}S(3 zRmfxiPP!H%u^AiF+z802!Ih_UaD|8bugMkO*Y0pQlscQKsj8(=JTrDO3{S%gJ}%#% zK+)RE@B!+D4R=c+W$8+;Y?hO$05Y^qDcz|1=abb%-P2us#eUtswX?NUTaPpL>e6oC zVeDx6!(*>Ac5m^|^)J}n<)=HJU1x7CZ$9zDHv43mJ^3PI-z-j_`ip(HeC_GuE%x*B iqnk&J{jvDznSa@ziyxo;n*F_a_qlJ`%Zr`oPyPcz3QP_F delta 133 zcmV;00DAw?JI*c&GYt(2$wMmAb8l~ME-o&U9tg_=0R{oH z><9<}0THwH2|@t@7_&GFKmh?FlX(n~0U)yq4T}WnlRF%u0m+lz9I62glZhQjNV6#; diff --git a/oberon b/oberon index 1a01e1d..e74bab9 100755 --- a/oberon +++ b/oberon @@ -3,13 +3,14 @@ import sys import sqlite3 as sql import os +from os.path import isfile as fileexists import subprocess import json from gomoku import Gomoku from isola import Isola from brandubh import Brandubh -version = '0.8.0' +version = '0.8.1' home_folder = os.path.expanduser('~') username = os.path.split(home_folder)[-1] database = '/var/lib/oberon/oberon.sqlite' @@ -131,6 +132,8 @@ def display_help(): print('{:20} {}'.format('create [user]', 'create a game against the user provided')) print('{:20} {}'.format('play [game_id]', 'make a move or view the board for the game id provided')) print('') + print('if you do not want to play games simply add a file named ".killoberon" to your home directory and users will not be able to create games with you') + print('') # Binds to the CREATE command @@ -144,6 +147,10 @@ def create_game(enemy): print('There is no avialable player with the name {}.\nGame not created.'.format(enemy)) return False + if fileexists('/home/{}/.killoberon'.format(enemy)): + print('{} does not wish to play games in oberon. Please try creating a game with a different user.'.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(3) Brandubh\n\nor (Q)uit') while True: @@ -179,9 +186,21 @@ def create_game(enemy): game_board[3][3] = ' D ' game_choice = 'brandubh' + player = '0' + print('') + while not player in ['1','2']: + print('Play as player 1 or player 2 (enter the number)') + player = input('> ') + + if player == '2': + temp = enemy + enemy = username + player = temp + else: + player = username q = "INSERT INTO games VALUES (?, ?, ?, ?, ?, ?, ?)" - v = (username, enemy, game_choice, 'playing', json.dumps(game_board), 1, None) + v = (player, enemy, game_choice, 'playing', json.dumps(game_board), 1, None) res = db_do(q, v, True) if res: print('Game between {} and {} created!'.format(username, enemy))