forked from varunrau/ResistanceSolver
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresistance.py
More file actions
54 lines (37 loc) · 1.15 KB
/
resistance.py
File metadata and controls
54 lines (37 loc) · 1.15 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
50
51
52
53
54
import solver
import time
class Game:
def __init__(self):
self.file_name = time.strftime('%H-%M-%d-%m-%Y.txt')
self.solver = None
def set_file_name(self, file_name):
"""Setter method for game file"""
self.file_name = file_name
self.solver = solver.Solver(solver.Parser(open(file_name)).args)
def new_game(self, resistance_count, spy_count, players):
"""Sets up new game"""
f = open(self.file_name, 'a+')
setup_string = "Spies %(spy)d\nResistance %(res)d\n%(player)s" %{'spy':spy_count, 'res':resistance_count, 'player':', '.join(players)}
f.write(setup_string)
f.close
self.set_file_name(self.file_name)
game = Game()
def start_game():
print '\nWelcome to the game of Resistance!\n\n'
print '(L)oad game from file.\n'
print '(N)ew game.\n'
start_option = raw_input('Choose starting option: ')
start_option = start_option.upper()
if start_option == 'N':
start_new_game()
elif start_option == "L":
file_name = raw_input('\nEnter filename: ')
game.set_file_name(file_name)
else:
print 'Sorry. I didn\'t recognize that. Please try again.\n'
start_game()
def play_game(solver):
pass
def start_new_game():
pass
start_game()