forked from kelpycreek/gitnomic
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathgame.py
More file actions
49 lines (44 loc) · 1.25 KB
/
Copy pathgame.py
File metadata and controls
49 lines (44 loc) · 1.25 KB
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
import git_repo
import server
import repository
from multiprocessing import Process
import subprocess
import time
import os
import random
import math
#Contains essential game logic.
def init_game():
#Sets up the game environment.
#Also a good place to put commands which should only be run once.
config = repository.get_config()
os.environ["GITHUB_USERNAME"] = config["git_login"]
os.environ["GITHUB_REPO"] = config["git_repo"]
os.environ["GITHUB_PASS"] = config["git_password"]
if not "db_setup" in config:
players = git_repo.get_players()
player1 = pick_next_player(players)
repository.init_db(player1)
#Save that weve set up the db
config['db_setup'] = "complete"
repository.set_config(config)
def play_round():
#Start the game server
game_server = Process(target = server.start_server)
game_server.start()
#Wait until the end of the round
while 1:
time.sleep(604800) #1 week
if __name__ == '__main__':
#Start the database
database_process = subprocess.Popen(["mongod"])
#give the database a chance to start up
time.sleep(5)
#Do first time setup/onetime commands
init_game()
#START THE GAME
play_round()
#Rounds over. Clean up time.
#Stop the db
database_process.terminate()
sleep(5)