-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.py
executable file
·61 lines (44 loc) · 1.12 KB
/
template.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
#!venv/bin/python
# coding=UTF-8
# -*- coding: UTF-8 -*-
# vim: set fileencoding=UTF-8 :
"""
Module-level docstring here
This file (template.py) is marked +x for copying to new game files
"""
from cardstock import *
"""
The lines between here and the end of px need to be copied to your
game file or else output logging won't work.
"""
debug: Optional[bool] = False
o: Optional[TextIO] = None
log_dir: str = game_out_dir(os.path.basename(__file__).split(".py")[0])
def p(msg):
global o
click.echo(msg, o)
def px(msg) -> None:
global debug
if debug:
p(msg)
class SomeGame(BaseGame):
"""
Implement all the abstract methods, gameplay, etc…
"""
pass
@click.command()
@common_options
# other click options go here
def main(**kwargs):
global o
global debug
global log_dir
if kwargs.get("all_bots"):
o = open(
os.path.join(log_dir, f"{str(datetime.now()).split('.')[0]}.gameplay"), "w"
)
debug = True
make_and_play_game(SomeGame, log_dir, **kwargs)
if __name__ == "__main__":
Path(log_dir).mkdir(parents=True, exist_ok=True)
main()