-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.py
More file actions
342 lines (287 loc) · 14 KB
/
Copy pathscript.py
File metadata and controls
342 lines (287 loc) · 14 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
import random
import copy
from time import sleep
#######################################
# Possible Roles:
# Werewolf Team:
# Werewolf, Minion
#
# Villager Team:
# Troublemaker, Robber, Seer, Insomniac, Devil's Advocate, Stoner,
# Rationalist, Podcaster, Inexplicable, Nut Job, Mason, Villager
#
# Flexible Team:
# Dog Whisperer, Tanner, Boy Nextdoor, Agent of Chaos
ALL_ROLES_IN_GAME = []
CENTER_ROLES = []
ORIGINAL_ROLE_MAPPING = {} # Maps each role to a list of players with that role at the beginning of the game
CURRENT_ASSIGNMENTS = {} # Maps each player to their current role at any given point
INEXPLICABLE_MODE = False
##################
# Helper Functions
##################
def handled_print(msg):
# Don't narrate role commands when executed by the inexplicable.
if not INEXPLICABLE_MODE:
print(msg)
def format_for_reveal(role):
# Sometimes we update roles that can potentially change in meaning, but anyone who
# inspects someone's card should only be able to see the original role.
if '->' in role:
return role.split(' ->')[0]
else:
return role
def get_eligible_inexplicable_roles():
eligible_roles = []
for r in set(ALL_ROLES_IN_GAME):
if r not in ['Devil\'s Advocate', 'Dog Whisperer', 'Mason']:
eligible_roles.append(r)
return eligible_roles
##################
# Role Specific Functions
##################
def do_werewolf_turn():
werewolves = ORIGINAL_ROLE_MAPPING['Werewolf']
if 'Dog Whisperer' in ALL_ROLES_IN_GAME:
print('Werewolves, wake up, and look for other werewolves. Choose one of yourselves to be revealed to the dog whisperer. If there is only one werewolf, you may look at a card from the center, and you must reveal yourself to the dog whisperer.')
else:
print('Werewolves, wake up, and look for other werewolves. If there is only one werewolf, you may look at a card from the center.')
if werewolves and len(werewolves) == 1:
card_to_reveal = random.sample(CENTER_ROLES, 1)
print(f'[ACTION] Reveal center card to werewolf: {card_to_reveal}')
sleep(15)
print('Werewolves, close your eyes.')
def do_minion_turn():
handled_print('Minion, wake up. Werewolves, stick out your thumbs, so that the minion can see who you are.')
sleep(10)
handled_print('Werewolves, put your thumbs down. Minion, close your eyes.')
def do_devils_advocate_turn():
print('Devil\'s Advocate, wake up. Werewolves, stick out your thumbs, so that the Devil\'s Advocate can see who you are.')
sleep(10)
print('Werewolves, put your thumbs down. Devil\'s Advocate, close your eyes.')
def do_mason_turn():
print('Masons, wake up and look for the other mason.')
sleep(10)
print('Masons, close your eyes.')
def do_dog_whisperer_turn():
print('Dog Whisperer, wake up. Designated werewolf, wake up, and identify each other. If you are the only werewolf, stick out your thumb.')
if ORIGINAL_ROLE_MAPPING['Dog Whisperer']:
dog_whisperer = ORIGINAL_ROLE_MAPPING['Dog Whisperer'][0]
werewolves = ORIGINAL_ROLE_MAPPING['Werewolf']
if werewolves and len(werewolves) < 2:
CURRENT_ASSIGNMENTS[dog_whisperer] = 'Dog Whisperer -> Werewolf'
sleep(10)
print('Dog Whisperer and designated werewolf, close your eyes.')
def do_stoner_turn():
handled_print('Stoner, wake up. Choose two players cards to shuffle, and then choose who to assign the revealed card to.')
if ORIGINAL_ROLE_MAPPING['Stoner']:
p1 = input('[ACTION] Enter a player\'s name: ')
p2 = input('[ACTION] Enter a player\'s name: ')
revealed = p1 if random.random() < 0.5 else p2
card_to_reveal = CURRENT_ASSIGNMENTS[revealed]
print(f'[ACTION] Reveal card to stoner: {format_for_reveal(card_to_reveal)}')
assigned = input('[ACTION] Enter assignee of revealed card\'s name: ')
if assigned != revealed:
CURRENT_ASSIGNMENTS[p1], CURRENT_ASSIGNMENTS[p2] = CURRENT_ASSIGNMENTS[p2], CURRENT_ASSIGNMENTS[p1]
sleep(5)
else:
sleep(15)
handled_print('Stoner, close your eyes.')
def do_seer_turn():
handled_print('Seer, wake up. You may look at another player’s card, or two of the center cards.')
if ORIGINAL_ROLE_MAPPING['Seer']:
choice = input('[ACTION] Enter a player\'s name, or the word center: ')
if choice == 'center':
cards_to_reveal = random.sample(CENTER_ROLES, 2)
print(f'[ACTION] Reveal center cards to seer: {cards_to_reveal}')
else:
card_to_reveal = CURRENT_ASSIGNMENTS[choice]
print(f'[ACTION] Reveal {choice}\'s role to seer: {format_for_reveal(card_to_reveal)}')
sleep(5)
else:
sleep(12)
handled_print('Seer, close your eyes.')
def do_rationalist_turn(player=None):
if player:
handled_print('Rationalist, wake up, and once again check the role of the player you previously checked.')
else:
handled_print('Rationalist, wake up, and inspect a player\'s card of your choosing.')
if ORIGINAL_ROLE_MAPPING['Rationalist']:
rationalist = ORIGINAL_ROLE_MAPPING['Rationalist'][-1]
if not player:
player = input('[ACTION] Enter a player\'s name: ')
if rationalist == player:
print(f'[ACTION] Reveal {player}\'s role to rationalist: {CURRENT_ASSIGNMENTS[player]}')
else:
print(f'[ACTION] Reveal {player}\'s role to rationalist: {format_for_reveal(CURRENT_ASSIGNMENTS[player])}')
sleep(5)
else:
sleep(12)
handled_print('Rationalist, close your eyes.')
return player
def do_aoc_turn():
handled_print('Agent of Chaos, wake up. Choose another player to exchange your card with, and then view your new card.')
if ORIGINAL_ROLE_MAPPING['Agent of Chaos']:
aoc = ORIGINAL_ROLE_MAPPING['Agent of Chaos'][-1]
swapped_player = input('[ACTION] Enter a player\'s name: ')
print(f'[ACTION] Reveal card to Agent of Chaos: {CURRENT_ASSIGNMENTS[swapped_player]}')
tmp = CURRENT_ASSIGNMENTS[aoc]
CURRENT_ASSIGNMENTS[aoc] = CURRENT_ASSIGNMENTS[swapped_player]
if CURRENT_ASSIGNMENTS[swapped_player] in ['Werewolf', 'Minion', 'Dog Whisperer -> Werewolf']:
CURRENT_ASSIGNMENTS[swapped_player] = f'{tmp} -> Villager'
elif 'Agent of Chaos' in CURRENT_ASSIGNMENTS[swapped_player]:
# This happens if the inexplicable is executing this turn and chooses to swap with the person
# who actually has the AOC card. We once again flip their role
if 'Villager' in CURRENT_ASSIGNMENTS[swapped_player]:
CURRENT_ASSIGNMENTS[swapped_player] = f'{tmp} -> Werewolf'
else:
CURRENT_ASSIGNMENTS[swapped_player] = f'{tmp} -> Villager'
elif CURRENT_ASSIGNMENTS[swapped_player] in ['Tanner', 'Boy Nextdoor']:
# These roles stay unchanged but we still note the fact that they technically possess the AOC version
# of their card now instead.
CURRENT_ASSIGNMENTS[swapped_player] = f'{tmp} -> {CURRENT_ASSIGNMENTS[swapped_player]}'
else:
CURRENT_ASSIGNMENTS[swapped_player] = f'{tmp} -> Werewolf'
sleep(5)
else:
sleep(12)
handled_print('Agent of Chaos, close your eyes.')
def do_robber_turn():
handled_print('Robber, wake up. Choose another player to exchange your card with, and then view your new card.')
if ORIGINAL_ROLE_MAPPING['Robber']:
robber = ORIGINAL_ROLE_MAPPING['Robber'][-1]
swapped_player = input('[ACTION] Enter a player\'s name: ')
print(f'[ACTION] Reveal card to Robber: {CURRENT_ASSIGNMENTS[swapped_player]}')
CURRENT_ASSIGNMENTS[robber], CURRENT_ASSIGNMENTS[swapped_player] = CURRENT_ASSIGNMENTS[swapped_player], CURRENT_ASSIGNMENTS[robber]
sleep(5)
else:
sleep(15)
handled_print('Robber, close your eyes.')
def do_troublemaker_turn():
handled_print('Troublemaker, wake up. Choose two players to exchange cards between.')
if ORIGINAL_ROLE_MAPPING['Troublemaker']:
p1 = input('[ACTION] Enter a player\'s name: ')
p2 = input('[ACTION] Enter a player\'s name: ')
CURRENT_ASSIGNMENTS[p1], CURRENT_ASSIGNMENTS[p2] = CURRENT_ASSIGNMENTS[p2], CURRENT_ASSIGNMENTS[p1]
sleep(3)
else:
sleep(12)
handled_print('Troublemaker, close your eyes.')
def do_insomniac_turn():
handled_print('Insomniac, wake up, and look at your card')
if ORIGINAL_ROLE_MAPPING['Insomniac']:
insomniac = ORIGINAL_ROLE_MAPPING['Insomniac'][-1]
print(f'[ACTION] Reveal card to Insomniac: {CURRENT_ASSIGNMENTS[insomniac]}')
sleep(5)
else:
sleep(12)
handled_print('Insomniac, close your eyes.')
def do_inexplicable_turn():
print('Inexplicable, wake up. This is the result of your coin flip. If it is heads, you may choose a new role, and perform the action for that role now.')
if ORIGINAL_ROLE_MAPPING['Inexplicable']:
inexplicable = ORIGINAL_ROLE_MAPPING['Inexplicable'][0]
rand_val = random.random()
coin_flip_result = 'Heads' if rand_val < 0.5 else 'Tails'
print(f'[ACTION] Reveal coin flip result: {coin_flip_result}')
if coin_flip_result == 'Heads':
print(f'[ACTION] Verify new role selection is in: {get_eligible_inexplicable_roles()}')
new_role = input('[ACTION] Enter new role for inexplicable: ')
if CURRENT_ASSIGNMENTS[inexplicable] == 'Inexplicable':
CURRENT_ASSIGNMENTS[inexplicable] = f'Inexplicable -> {new_role}'
ORIGINAL_ROLE_MAPPING.setdefault(new_role, []).append(inexplicable)
INEXPLICABLE_MODE = True
if new_role == 'Minion':
do_minion_turn()
elif new_role == 'Stoner':
do_stoner_turn()
elif new_role == 'Seer':
do_seer_turn()
elif new_role == 'Rationalist':
do_rationalist_turn()
elif new_role == 'Robber':
do_robber_turn()
elif new_role == 'Troublemaker':
do_troublemaker_turn()
elif new_role == 'Insomniac':
do_insomniac_turn()
elif new_role == 'Agent of Chaos':
do_aoc_turn()
else:
sleep(12)
else:
sleep(15)
print('Inexplicable, close your eyes.')
if __name__ == '__main__':
num_players = int(input('Please Enter the Number of Players: '))
players = []
for _ in range(num_players):
players.append(input('Please Enter a Player Name: '))
for _ in range(num_players + 3):
role = input('Please Enter a Role in Play: ')
ALL_ROLES_IN_GAME.append(role)
random.shuffle(ALL_ROLES_IN_GAME)
print("Player Assignments: ")
for i in range(num_players + 3):
if i < num_players:
CURRENT_ASSIGNMENTS[players[i]] = ALL_ROLES_IN_GAME[i]
print(f'{players[i]}: {CURRENT_ASSIGNMENTS[players[i]]}')
ORIGINAL_ROLE_MAPPING.setdefault(ALL_ROLES_IN_GAME[i], []).append(players[i])
else:
CENTER_ROLES.append(ALL_ROLES_IN_GAME[i])
print('Starting Game...Enter to Confirm')
input()
rationalist_selected_player = None
if 'Werewolf' in ALL_ROLES_IN_GAME:
print(f"[WEREWOLVES]: {ORIGINAL_ROLE_MAPPING.setdefault('Werewolf', [])}")
do_werewolf_turn()
if 'Minion' in ALL_ROLES_IN_GAME:
print(f"[MINION]: {ORIGINAL_ROLE_MAPPING.setdefault('Minion', [])}")
do_minion_turn()
if 'Devil\'s Advocate' in ALL_ROLES_IN_GAME:
da = ORIGINAL_ROLE_MAPPING.setdefault('Devil\'s Advocate', [])
print(f"[DEVILS ADVOCATE]: {da}")
do_devils_advocate_turn()
if 'Dog Whisperer' in ALL_ROLES_IN_GAME:
print(f"[DOG WHISPERER]: {ORIGINAL_ROLE_MAPPING.setdefault('Dog Whisperer', [])}")
do_dog_whisperer_turn()
if 'Mason' in ALL_ROLES_IN_GAME:
print(f"[MASONS]: {ORIGINAL_ROLE_MAPPING.setdefault('Mason', [])}")
do_mason_turn()
if 'Seer' in ALL_ROLES_IN_GAME:
print(f"[SEER]: {ORIGINAL_ROLE_MAPPING.setdefault('Seer', [])}")
do_seer_turn()
if 'Agent of Chaos' in ALL_ROLES_IN_GAME:
print(f"[AGENT OF CHAOS]: {ORIGINAL_ROLE_MAPPING.setdefault('Agent of Chaos', [])}")
do_aoc_turn()
if 'Rationalist' in ALL_ROLES_IN_GAME:
print(f"[RATIONALIST]: {ORIGINAL_ROLE_MAPPING.setdefault('Rationalist', [])}")
rationalist_selected_player = do_rationalist_turn(rationalist_selected_player)
if 'Stoner' in ALL_ROLES_IN_GAME:
print(f"[STONER]: {ORIGINAL_ROLE_MAPPING.setdefault('Stoner', [])}")
do_stoner_turn()
if 'Rationalist' in ALL_ROLES_IN_GAME:
print(f"[RATIONALIST]: {ORIGINAL_ROLE_MAPPING.setdefault('Rationalist', [])}")
rationalist_selected_player = do_rationalist_turn(rationalist_selected_player)
if 'Robber' in ALL_ROLES_IN_GAME:
print(f"[ROBBER]: {ORIGINAL_ROLE_MAPPING.setdefault('Robber', [])}")
do_robber_turn()
if 'Rationalist' in ALL_ROLES_IN_GAME:
print(f"[RATIONALIST]: {ORIGINAL_ROLE_MAPPING.setdefault('Rationalist', [])}")
rationalist_selected_player = do_rationalist_turn(rationalist_selected_player)
if 'Troublemaker' in ALL_ROLES_IN_GAME:
print(f"[TROUBLEMAKER]: {ORIGINAL_ROLE_MAPPING.setdefault('Troublemaker', [])}")
do_troublemaker_turn()
if 'Rationalist' in ALL_ROLES_IN_GAME:
print(f"[RATIONALIST]: {ORIGINAL_ROLE_MAPPING.setdefault('Rationalist', [])}")
rationalist_selected_player = do_rationalist_turn(rationalist_selected_player)
if 'Insomniac' in ALL_ROLES_IN_GAME:
print(f"[INSOMNIAC]: {ORIGINAL_ROLE_MAPPING.setdefault('Insomniac', [])}")
do_insomniac_turn()
if 'Inexplicable' in ALL_ROLES_IN_GAME:
print(f"[INEXPLICABLE]: {ORIGINAL_ROLE_MAPPING.setdefault('Inexplicable', [])}")
do_inexplicable_turn()
print('Everyone, wake up!')
print('#######################')
print('Current Assignments:')
print(CURRENT_ASSIGNMENTS)
print('#######################')