forked from tyspa1/Jeopardy
-
Notifications
You must be signed in to change notification settings - Fork 1
/
start.py
71 lines (59 loc) · 2.24 KB
/
start.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
64
65
66
67
68
69
70
71
"""
start.py
DESCRIPTION:
This script should be used to invoke the game. It allows optional
arguments to be passed to it that can override the settings in config.py
if desired.
USAGE:
To invoke the game with an option defined below, for example -w and
--debug, use `python start.py -w --debug'
To define a new option:
1) Create a new constant in constants.py. Best practice is to
incrememnt the value by 1 for each new flag.
Example: (in constants.py) NEW_FLAG = 4
2) Ensure this file imports the new flag
3) In this file, add one or more argv mappings to optionsMap
Example: optionsMap = { ..., '-n' : NEW_FLAG, '--new' : NEW_FLAG }
4) If thew new option can override a setting found in config.py,
it must do it prior to main being imported near the end of this file.
Copyright (C) 2013 Adam Beagle - All Rights Reserved
You may use, distribute, and modify this code under
the terms of the GNU General Public License,
viewable at http://opensource.org/licenses/GPL-3.0
This copyright notice must be retained with any use
of source code from this file.
"""
from sys import argv
from jeoparpy import config
from jeoparpy.constants import (DEBUG_FLAG, FULLSCREEN_FLAG, SKIP_INTRO_FLAG,
WINDOWED_FLAG, DRIVE_FLAG)
optionsMap = {
'-d' : DEBUG_FLAG,
'--debug' : DEBUG_FLAG,
'-f' : FULLSCREEN_FLAG,
'--fullscreen' : FULLSCREEN_FLAG,
'-s' : SKIP_INTRO_FLAG,
'--skip-intro' : SKIP_INTRO_FLAG,
'-w' : WINDOWED_FLAG,
'--windowed' : WINDOWED_FLAG,
'--drive' : DRIVE_FLAG,
}
if __name__ == '__main__':
flags = set(optionsMap[o] for o in argv if o in optionsMap)
# Override config options if args provided
if FULLSCREEN_FLAG in flags:
config.FULLSCREEN = 1
if WINDOWED_FLAG in flags:
config.FULLSCREEN = 0
if DEBUG_FLAG in flags:
config.DEBUG = 1
if DRIVE_FLAG in flags:
config.DRIVE = True
# main MUST be imported here, or config options may be imported
# (via 'from config import X') prior to being overridden by argv
# options.
from jeoparpy.selectMenu import *
select_game()
from jeoparpy.main import main
main(*flags)
print config.DRIVE