forked from adangert/JoustMania
-
Notifications
You must be signed in to change notification settings - Fork 0
/
joust.py
664 lines (569 loc) · 26.3 KB
/
joust.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
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
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
import common, colors
import psmove
import time
import psutil, os, glob
import random
import numpy
import json
from piaudio import Audio
from enum import Enum
from multiprocessing import Process, Value, Array, Queue
from math import sqrt
import statistics
# How fast/slow the music can go
SLOW_MUSIC_SPEED = 0.7
#this was 0.5
FAST_MUSIC_SPEED = 1.5
# The min and max timeframe in seconds for
# the speed change to trigger, randomly selected
MIN_MUSIC_FAST_TIME = 4
MAX_MUSIC_FAST_TIME = 8
MIN_MUSIC_SLOW_TIME = 10
MAX_MUSIC_SLOW_TIME = 23
END_MIN_MUSIC_FAST_TIME = 6
END_MAX_MUSIC_FAST_TIME = 10
END_MIN_MUSIC_SLOW_TIME = 8
END_MAX_MUSIC_SLOW_TIME = 12
#How long the speed change takes
INTERVAL_CHANGE = 1.5
#How long the winning moves shall sparkle
END_GAME_PAUSE = 6
KILL_GAME_PAUSE = 4
def track_move(move, game_mode, team, team_color_enum, dead_move, force_color, \
music_speed, werewolf_reveal, show_team_colors, red_on_kill, restart, menu, controller_sensitivity, dead_invince):
SLOW_MAX = controller_sensitivity[0]
SLOW_WARNING = controller_sensitivity[1]
FAST_MAX = controller_sensitivity[2]
FAST_WARNING = controller_sensitivity[3]
WERE_SLOW_MAX = controller_sensitivity[4]
WERE_SLOW_WARNING = controller_sensitivity[5]
WERE_FAST_MAX = controller_sensitivity[6]
WERE_FAST_WARNING = controller_sensitivity[7]
dead_invince.value = False
start = False
no_rumble = time.time() + 2
move_last_value = None
my_team_colors = team_color_enum
werewolf = False
vibrate = False
change_arr = [0]*8
vibration_time = time.time() + 1
flash_lights = True
flash_lights_timer = 0
previous_average = 0
change = 0
if team < 0:
team = (team + 1) * -1
werewolf = True
#keep on looping while move is not dead
while True:
if(restart.value == 1 or menu.value == 1):
return
if show_team_colors.value == 1:
move.set_leds(*my_team_colors)
move.update_leds()
elif sum(force_color) != 0:
no_rumble_time = time.time() + 5
time.sleep(0.01)
move.set_leds(*force_color)
if sum(force_color) > 75:
if werewolf:
move.set_rumble(80)
else:
if sum(force_color) == 30:
if werewolf:
move.set_leds(*colors.Colors.Blue40.value)
else:
move.set_leds(*colors.Colors.Black.value)
move.set_rumble(0)
move.update_leds()
no_rumble = time.time() + 0.5
elif dead_move.value == 1 and werewolf_reveal.value > 0:
if move.poll():
ax, ay, az = move.get_accelerometer_frame(psmove.Frame_SecondHalf)
total = sqrt(sum([ax**2, ay**2, az**2]))
change = (change * 4 + total)/5
speed_percent = (music_speed.value - SLOW_MUSIC_SPEED)/(FAST_MUSIC_SPEED - SLOW_MUSIC_SPEED)
if werewolf:
warning = common.lerp(WERE_SLOW_WARNING, WERE_FAST_WARNING, speed_percent)
threshold = common.lerp(WERE_SLOW_MAX, WERE_FAST_MAX, speed_percent)
else:
warning = common.lerp(SLOW_WARNING, FAST_WARNING, speed_percent)
threshold = common.lerp(SLOW_MAX, FAST_MAX, speed_percent)
if vibrate:
flash_lights_timer += 1
if flash_lights_timer > 7:
flash_lights_timer = 0
flash_lights = not flash_lights
if flash_lights:
if game_mode == common.Games.WereJoust.value:
move.set_leds(*colors.Colors.Black.value)
else:
move.set_leds(*colors.Colors.White40.value)
else:
if game_mode == common.Games.WereJoust.value:
if werewolf_reveal.value == 2 and werewolf:
move.set_leds(*colors.Colors.Blue40.value)
else:
move.set_leds(*colors.Colors.White40.value)
else:
move.set_leds(*my_team_colors)
if time.time() < vibration_time-0.25:
move.set_rumble(90)
else:
move.set_rumble(0)
if time.time() > vibration_time:
vibrate = False
else:
if game_mode == common.Games.WereJoust.value:
if werewolf_reveal.value == 2 and werewolf:
move.set_leds(*colors.Colors.Blue40.value)
else:
move.set_leds(*colors.Colors.White40.value)
else:
move.set_leds(*my_team_colors)
#move.set_rumble(0)
if change > threshold and not dead_invince.value:
if time.time() > no_rumble:
dead_invince.value = True
if red_on_kill:
move.set_leds(*colors.Colors.Red.value)
else:
move.set_leds(*colors.Colors.Black.value)
move.set_rumble(90)
dead_move.value = 0
move.update_leds()
time.sleep(0.5)
dead_invince.value = False
elif change > warning and not vibrate:
if time.time() > no_rumble:
vibrate = True
vibration_time = time.time() + 0.5
#move.set_leds(20,50,100)
#move_last_value = total
move.update_leds()
elif dead_move.value < 1:
time.sleep(0.5)
if dead_move.value == -1 and game_mode == common.Games.NonStop.value:
time.sleep(2)
move_last_value = 0
change_arr = [0,0,0]
no_rumble = time.time() + 1
vibration_time = time.time() + 1
dead_move.value = 2
class Joust():
def __init__(self, moves, command_queue, ns, music, teams, game_mode,controller_teams, controller_colors, dead_moves, force_move_colors,music_speed,werewolf_reveal, show_team_colors, red_on_kill, restart, num_teams=4):
self.command_queue = command_queue
self.ns = ns
self.voice = self.ns.settings['menu_voice']
print(self.ns.settings)
self.game_mode = game_mode
#save locally in case settings change from web
self.play_audio = self.ns.settings['play_audio']
self.sensitivity = self.ns.settings['sensitivity']
self.color_lock = self.ns.settings['color_lock']
self.color_lock_choices = self.ns.settings['color_lock_choices']
self.random_teams = self.ns.settings['random_teams']
self.red_on_kill = self.ns.settings['red_on_kill']
self.move_serials = moves
self.restart = restart
self.dead_moves = dead_moves
self.music_speed = music_speed
self.music_speed.value = SLOW_MUSIC_SPEED
self.controller_teams = controller_teams
self.controller_colors = controller_colors
self.running = True
self.force_move_colors = force_move_colors
self.teams = teams
self.num_teams = len(colors.team_color_list)
self.werewolf_timer = 35
self.start_timer = time.time()
self.audio_cue = 0
self.num_dead = 0
self.show_team_colors = show_team_colors
self.show_team_colors.value = 0
self.non_stop_deaths = {}
for move in self.move_serials:
self.non_stop_deaths[move] = 0
self.non_stop_time = time.time() + 150
self.update_time = 0
self.alive_moves = []
#self.update_status('starting')
self.werewolf_reveal = werewolf_reveal
self.werewolf_reveal.value = 2
if game_mode == common.Games.JoustFFA or game_mode == common.Games.NonStop:
self.num_teams = len(moves)
if game_mode == common.Games.JoustRandomTeams:
self.num_teams=num_teams
if game_mode == common.Games.Traitor:
if len(moves) <= 8:
self.num_teams = 2
else: #9 or more
self.num_teams = 3
self.werewolf_reveal.value = 0
if self.game_mode == common.Games.WereJoust:
self.werewolf_reveal.value = 0
self.num_teams = 1
if self.game_mode == common.Games.JoustTeams:
self.team_colors = colors.team_color_list
else:
self.team_colors = colors.generate_team_colors(self.num_teams,self.color_lock,self.color_lock_choices)
self.generate_random_teams(self.num_teams)
if self.game_mode == common.Games.WereJoust:
were_num = int((len(moves)*7)/16)
if were_num <= 0:
were_num = 1
self.choose_werewolf(were_num)
if self.play_audio:
self.start_beep = Audio('audio/Joust/sounds/start.wav')
self.start_game = Audio('audio/Joust/sounds/start3.wav')
self.explosion = Audio('audio/Joust/sounds/Explosion34.wav')
self.revive = Audio('audio/Commander/sounds/revive.wav')
end = False
self.audio = music
fast_resample = False
self.speed_up = False
self.currently_changing = False
self.game_end = False
self.winning_moves = []
self.game_loop()
def choose_werewolf(self, were_num):
for were in range(were_num):
werewolf = random.choice(self.move_serials)
while self.teams[werewolf] < 0:
werewolf = random.choice(self.move_serials)
self.teams[werewolf] = (self.teams[werewolf] * -1) - 1
def generate_random_teams(self, num_teams):
if self.random_teams == False and self.game_mode != common.Games.Traitor:
players_per_team = (len(self.move_serials)//num_teams)+1
team_num = [x for x in range(num_teams)]*players_per_team
for num,move in zip(team_num,self.move_serials):
self.teams[move] = num
else:
team_pick = list(range(num_teams))
traitor_pick = True
copy_serials = self.move_serials[:]
while len(copy_serials) >= 1:
#for serial in self.move_serials:
serial = random.choice(copy_serials)
copy_serials.remove(serial)
random_choice = random.choice(team_pick)
if self.game_mode == common.Games.Traitor and traitor_pick:
self.teams[serial] = (random_choice * -1) - 1
#Turn this off for 3 traitors vs 1
traitor_pick = False
else:
self.teams[serial] = random_choice
team_pick.remove(random_choice)
if not team_pick:
traitor_pick = False
team_pick = list(range(num_teams))
def track_moves(self):
for move_num, move_serial in enumerate(self.move_serials):
self.alive_moves.append(move_serial)
time.sleep(0.1)
self.controller_teams[move_serial].value = self.teams[move_serial]
self.controller_colors[move_serial][0] = self.team_colors[self.teams[move_serial]].value[0]
self.controller_colors[move_serial][1] = self.team_colors[self.teams[move_serial]].value[1]
self.controller_colors[move_serial][2] = self.team_colors[self.teams[move_serial]].value[2]
self.dead_moves[move_serial].value = 1
self.force_move_colors[move_serial][0] =1
self.force_move_colors[move_serial][1] =1
self.force_move_colors[move_serial][2] =1
def change_all_move_colors(self, r, g, b):
for color in self.force_move_colors.values():
colors.change_color(color, r, g, b)
#need to do the count_down here
def count_down(self):
self.change_all_move_colors(80, 0, 0)
if self.play_audio:
self.start_beep.start_effect()
time.sleep(0.75)
self.change_all_move_colors(70, 100, 0)
if self.play_audio:
self.start_beep.start_effect()
time.sleep(0.75)
self.change_all_move_colors(0, 70, 0)
if self.play_audio:
self.start_beep.start_effect()
time.sleep(0.75)
self.change_all_move_colors(0, 0, 0)
if self.play_audio:
self.start_game.start_effect()
def get_change_time(self, speed_up):
min_moves = len(self.move_serials) - 2
if min_moves <= 0:
min_moves = 1
game_percent = (self.num_dead/min_moves)
if game_percent > 1.0:
game_percent = 1.0
min_music_fast = common.lerp(MIN_MUSIC_FAST_TIME, END_MIN_MUSIC_FAST_TIME, game_percent)
max_music_fast = common.lerp(MAX_MUSIC_FAST_TIME, END_MAX_MUSIC_FAST_TIME, game_percent)
min_music_slow = common.lerp(MIN_MUSIC_SLOW_TIME, END_MIN_MUSIC_SLOW_TIME, game_percent)
max_music_slow = common.lerp(MAX_MUSIC_SLOW_TIME, END_MAX_MUSIC_SLOW_TIME, game_percent)
if speed_up:
added_time = random.uniform(min_music_fast, max_music_fast)
else:
added_time = random.uniform(min_music_slow, max_music_slow)
return time.time() + added_time
def change_music_speed(self, fast):
change_percent = numpy.clip((time.time() - self.change_time)/INTERVAL_CHANGE, 0, 1)
if fast:
self.music_speed.value = common.lerp(FAST_MUSIC_SPEED, SLOW_MUSIC_SPEED, change_percent)
elif not fast:
self.music_speed.value = common.lerp(SLOW_MUSIC_SPEED, FAST_MUSIC_SPEED, change_percent)
self.audio.change_ratio(self.music_speed.value)
def check_music_speed(self):
if time.time() > self.change_time and time.time() < self.change_time + INTERVAL_CHANGE:
self.change_music_speed(self.speed_up)
self.currently_changing = True
elif time.time() >= self.change_time + INTERVAL_CHANGE and self.currently_changing:
self.music_speed.value = SLOW_MUSIC_SPEED if self.speed_up else FAST_MUSIC_SPEED
self.speed_up = not self.speed_up
self.change_time = self.get_change_time(speed_up = self.speed_up)
self.audio.change_ratio(self.music_speed.value)
self.currently_changing = False
def get_real_team(self, team):
if team < 0:
return -1
else:
return team
def reveal(self):
self.werewolf_reveal.value = 2
def werewolf_audio_cue(self):
if self.game_mode == common.Games.WereJoust:
if self.werewolf_timer - (time.time() - self.start_timer) <= 30 and self.audio_cue == 0:
Audio('audio/Joust/vox/' + self.voice + '/30 werewolf.wav').start_effect()
self.audio_cue = 1
if self.werewolf_timer - (time.time() - self.start_timer) <= 10 and self.audio_cue == 1:
Audio('audio/Joust/vox/' + self.voice + '/10 werewolf.wav').start_effect()
self.audio_cue = 2
if self.werewolf_timer - (time.time() - self.start_timer) <= 0 and self.audio_cue == 2:
Audio('audio/Joust/vox/' + self.voice + '/werewolf reveal 2.wav').start_effect()
self.reveal()
self.audio_cue = 3
self.change_time = time.time()-0.001
elif self.audio_cue == 3:
self.check_music_speed()
def check_end_game(self):
winning_team = -100
team_win = True
for move_serial, dead in self.dead_moves.items():
#if we are alive
if dead.value == 1:
if winning_team == -100:
winning_team = self.get_real_team(self.teams[move_serial])
elif self.get_real_team(self.teams[move_serial]) != winning_team:
team_win = False
if dead.value == 0:
#This is to play the sound effect
self.num_dead += 1
dead.value = -1
self.non_stop_deaths[move_serial] += 1
if self.play_audio:
self.explosion.start_effect()
if dead.value == 2:
dead.value = 1
if self.play_audio:
self.revive.start_effect()
if self.game_mode == common.Games.NonStop:
if self.audio_cue == 0 and time.time() > self.non_stop_time - 60:
Audio('audio/Zombie/vox/' + self.voice + '/1 minute.wav').start_effect()
self.audio_cue += 1
if self.audio_cue == 1 and time.time() > self.non_stop_time - 30:
Audio('audio/Zombie/vox/' + self.voice + '/30 seconds.wav').start_effect()
self.audio_cue += 1
if time.time() > self.non_stop_time:
lowest_score = 100000
for move, score in self.non_stop_deaths.items():
self.dead_moves[move].value = 0
if score == lowest_score:
self.winning_moves.append(move)
if score < lowest_score:
lowest_score = score
self.winning_moves = []
self.winning_moves.append(move)
self.game_end = True
elif team_win:
self.update_status('ending',winning_team)
if self.play_audio:
self.end_game_sound(winning_team)
for move_serial in self.teams.keys():
if self.get_real_team(self.teams[move_serial]) == winning_team:
self.winning_moves.append(move_serial)
self.game_end = True
def stop_tracking_moves(self):
self.restart.value = 1
def end_game(self):
if self.play_audio:
self.audio.stop_audio()
end_time = time.time() + END_GAME_PAUSE
h_value = 0
while (time.time() < end_time):
time.sleep(0.01)
win_color = colors.hsv2rgb(h_value, 1, 1)
for win_move in self.winning_moves:
win_color_array = self.force_move_colors[win_move]
colors.change_color(win_color_array, *win_color)
h_value = (h_value + 0.01)
if h_value >= 1:
h_value = 0
self.running = False
def end_game_sound(self, winning_team):
if self.game_mode == common.Games.WereJoust:
if winning_team == -1:
team_win = Audio('audio/Joust/vox/' + self.voice + '/werewolf win.wav')
else:
team_win = Audio('audio/Joust/vox/' + self.voice + '/human win.wav')
team_win.start_effect()
elif self.game_mode != common.Games.JoustFFA and self.game_mode != common.Games.NonStop:
win_team_name = self.team_colors[winning_team].name
if winning_team == -1:
team_win = Audio('audio/Joust/vox/' + self.voice + '/traitor win.wav')
else:
if win_team_name == 'Pink':
if self.voice == 'aaron':
os.popen('espeak -ven -p 70 -a 200 "And the winner is ...Pink Team')
else:
team_win = Audio('audio/Joust/vox/' + self.voice + '/pink team win.wav')
if win_team_name == 'Magenta':
team_win = Audio('audio/Joust/vox/' + self.voice + '/magenta team win.wav')
if win_team_name == 'Orange':
if self.voice == 'aaron':
os.popen('espeak -ven -p 70 -a 200 "And the winner is ...Orange Team')
else:
team_win = Audio('audio/Joust/vox/' + self.voice + '/orange team win.wav')
if win_team_name == 'Yellow':
team_win = Audio('audio/Joust/vox/' + self.voice + '/yellow team win.wav')
if win_team_name == 'Green':
team_win = Audio('audio/Joust/vox/' + self.voice + '/green team win.wav')
if win_team_name == 'Turquoise':
team_win = Audio('audio/Joust/vox/' + self.voice + '/cyan team win.wav')
if win_team_name == 'Blue':
team_win = Audio('audio/Joust/vox/' + self.voice + '/blue team win.wav')
if win_team_name == 'Purple':
if self.voice == 'aaron':
os.popen('espeak -ven -p 70 -a 200 "And the winner is ...Purple Team')
else:
team_win = Audio('audio/Joust/vox/' + self.voice + '/purple team win.wav')
try:
team_win.start_effect()
except:
pass
def werewolf_intro(self):
#don't wait so colors change during prompts
Audio('audio/Joust/vox/' + self.voice + '/werewolf intro.wav').start_effect()
time.sleep(3)
self.change_all_move_colors(0,0,80)
time.sleep(2)
self.change_all_move_colors(0,0,30)
time.sleep(14)
self.change_all_move_colors(20, 20, 20)
time.sleep(6)
self.start_timer = time.time()
def game_loop(self):
self.track_moves()
self.restart.value = 0
if self.game_mode == common.Games.WereJoust:
self.werewolf_intro()
self.werewolf_reveal.value = 1
if self.game_mode == common.Games.JoustRandomTeams:
self.show_team_colors.value = 1
if self.play_audio:
Audio('audio/Joust/sounds/teams_form.wav').start_effect_and_wait()
self.show_team_colors.value = 0
self.count_down()
self.change_time = time.time() + 6
time.sleep(0.02)
if self.play_audio:
self.audio.start_audio_loop()
self.audio.change_ratio(self.music_speed.value)
else:
#when no audio is playing set the music speed to middle speed
self.music_speed.value = (FAST_MUSIC_SPEED + SLOW_MUSIC_SPEED) / 2
time.sleep(0.8)
if self.game_mode == common.Games.WereJoust:
self.music_speed.value = SLOW_MUSIC_SPEED
self.audio.change_ratio(self.music_speed.value)
self.speed_up = False
while self.running:
#I think the loop is so fast that this causes
#a crash if done every loop
if time.time() - 0.1 > self.update_time:
self.update_time = time.time()
self.check_command_queue()
self.update_status('in_game')
if self.game_mode != common.Games.WereJoust and self.play_audio:
self.check_music_speed()
self.check_end_game()
if self.play_audio:
self.werewolf_audio_cue()
if self.game_end:
self.end_game()
self.stop_tracking_moves()
def check_command_queue(self):
package = None
while not(self.command_queue.empty()):
package = self.command_queue.get()
command = package['command']
if not(package == None):
if command == 'killgame':
self.kill_game()
def update_status(self,game_status,winning_team=-1):
data ={'game_status' : game_status,
'game_mode' : self.game_mode.pretty_name,
'winning_team' : winning_team}
if self.game_mode == common.Games.JoustFFA or self.game_mode == common.Games.NonStop:
data['total_players'] = len(self.move_serials)
data['remaining_players'] = len([x[0] for x in self.dead_moves.items() if x[1].value==1])
else:
if self.game_mode in [common.Games.WereJoust, common.Games.Traitor]:
num = self.num_teams + 1
data['winning_team'] += 1
else:
num = self.num_teams
team_alive = [0]*num
team_total = [0]*num
for move in self.move_serials:
team = self.teams[move]
if self.game_mode in [common.Games.WereJoust, common.Games.Traitor]:
team += 1 #shift so bad guy team is 0
if team < 0:
team = 0
team_total[team] += 1
if self.dead_moves[move].value == 1:
team_alive[team] += 1
team_comp = list(zip(team_total,team_alive))
data['team_comp'] = team_comp
if self.game_mode == common.Games.WereJoust:
data['team_names'] = ['Werewolves', 'Humans']
elif self.game_mode == common.Games.Traitor:
data['team_names'] = ['Traitors'] + [color.name + ' Team' for color in self.team_colors]
elif self.game_mode != common.Games.JoustFFA or self.game_mode != common.Games.NonStop:
data['team_names'] = [color.name + ' Team' for color in self.team_colors]
if self.game_mode == common.Games.WereJoust:
thyme = int(self.werewolf_timer - (time.time() - self.start_timer))
if thyme < 0:
data['time_to_reveal'] = 0
else:
data['time_to_reveal'] = thyme
self.ns.status = data
def kill_game(self):
try:
self.audio.stop_audio()
except:
print('no audio loaded to stop')
self.update_status('killed')
all_moves = [x for x in self.dead_moves.keys()]
end_time = time.time() + KILL_GAME_PAUSE
bright = 255
while (time.time() < end_time):
time.sleep(0.01)
color = (bright,0,0)
for move in all_moves:
color_array = self.force_move_colors[move]
colors.change_color(color_array, *color)
bright = bright - 1
if bright < 10:
bright = 10
self.running = False