This repository has been archived by the owner on Feb 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
exerscise1.py
63 lines (56 loc) · 1.9 KB
/
exerscise1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env python3
"""
exercise1 file including game start
"""
# Importing needed modules
import othello
import argparse
def print_hi(name: str):
"""
Printing the welcoming message
:param name: The name of the player
:type name: str
:return: Nothing
:rtype: N/A
"""
print(f'Hi, {name}')
print()
def parse_arguments():
"""
Parsing the passed arguments
:return: Nothing
:rtype: N/A
"""
parser = argparse.ArgumentParser(description='Othello settings')
parser.add_argument('pf', metavar='play_first', help="Do you want to play first? (True to play first or "
"False to play second)")
parser.add_argument('po', metavar='print_output', help="Do you want to print the output? ('True' or "
"'False')")
parser.add_argument('df', metavar='difficulty', type=int, help="Difficulty level (max=10)")
return parser.parse_args()
if __name__ == '__main__':
"""
Initiating game play
"""
arguments = vars(parse_arguments())
if arguments['pf'] != 'False' and arguments['pf'] != 'True' and arguments['po'] != 'False' \
and arguments['po'] != 'True' and (arguments['df'] > 10 or arguments['df'] < 0
or not (isinstance(arguments['df'], int))):
print('Problem in one of the arguments passed.\nUsing standard arguments True True 5')
df = 5
pf = True
po = True
else:
pf = False
po = False
if arguments.get('pf') == 'True':
pf = True
if arguments.get('po') == 'True':
po = True
df: int = arguments.get('df')
name: str = input("Welcome, what's your name?\n")
print_hi(name)
# DEBUG MAIN (START)
game = othello.start_game(pf, po, int(df))
game.play()
# DEBUG MAIN (END)