-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
53 lines (45 loc) · 1.23 KB
/
main.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
import argparse
from game import Game
def get_arguments() -> argparse.Namespace:
"""
Parse command line arguments.
Return:
args: Namespace containing user-defined arguments.
"""
parser = argparse.ArgumentParser(
description="Configure the settings for the Tic Tac Toe game"
)
parser.add_argument(
"-n",
"--num_players",
type=int,
choices=[1, 2],
default=1,
help="Set the number of players for the game",
)
parser.add_argument(
"-l",
"--language",
type=str,
choices=["en", "ko"],
default="ko",
help="Choose the language version for the game.'en' for English, 'ko' for Korean",
)
parser.add_argument(
"-f",
"--formatting",
type=int,
nargs="*",
default=None,
help="Customize formatting widths for messages: [line_width, name_display_width, score_display_width]",
)
args = parser.parse_args()
return args
def main() -> None:
args = get_arguments()
if args.formatting == None:
args.formatting = [60, 20, 10]
game = Game(args.num_players, args.language, args.formatting)
game.run()
if __name__ == "__main__":
main()