Permalink
Browse files

Can now toggle kill color between red and dark. Also werewolves are n…

…ow blue if kill color is red
  • Loading branch information...
ericbuzan committed Oct 6, 2017
1 parent 31fd09d commit b87651f667417f5e90ae60922003cd1e6646e726
Showing with 44 additions and 31 deletions.
  1. +1 −0 colors.py
  2. +28 −11 joust.py
  3. +12 −12 piparty.py
  4. +3 −8 webui.py
@@ -72,6 +72,7 @@ class Colors(Enum):
Red60 = (150,0,0)
Red80 = (200,0,0)
Green80 = (0,200,0)
Blue40 = (0,0,100)
LimeGreen = (100,255,0)
Zombie = (50,150,50)
Black = (0,0,0)
@@ -84,9 +84,12 @@ def track_move(move_serial, move_num, game_mode, team, team_color_enum, dead_mov
else:
if sum(force_color) == 30:
if werewolf:
move.set_leds(255, 0, 0)
if red_on_kill:
move.set_leds(*colors.Colors.Blue40.value)
else:
move.set_leds(*colors.Colors.Red60.value)
else:
move.set_leds(0, 0, 0)
move.set_leds(*colors.Colors.Black.value)
move.set_rumble(0)
move.update_leds()
no_rumble = time.time() + 0.5
@@ -118,15 +121,18 @@ def track_move(move_serial, move_num, game_mode, team, team_color_enum, dead_mov
flash_lights = not flash_lights
if flash_lights:
if game_mode == common.Games.WereJoust:
move.set_leds(*colors.Colors.Black)
move.set_leds(*colors.Colors.Black.value)
else:
move.set_leds(*colors.Colors.White40)
move.set_leds(*colors.Colors.White40.value)
else:
if game_mode == common.Games.WereJoust:
if werewolf_reveal.value == 2 and werewolf:
move.set_leds(*colors.Colors.Red)
if red_on_kill:
move.set_leds(*colors.Colors.Blue40.value)
else:
move.set_leds(*colors.Colors.Red60.value)
else:
move.set_leds(*colors.Colors.White40)
move.set_leds(*colors.Colors.White40.value)
else:
move.set_leds(*my_team_colors)
if time.time() < vibration_time - 0.22:
@@ -139,17 +145,23 @@ def track_move(move_serial, move_num, game_mode, team, team_color_enum, dead_mov
else:
if game_mode == common.Games.WereJoust:
if werewolf_reveal.value == 2 and werewolf:
move.set_leds(*colors.Colors.Red)
if red_on_kill:
move.set_leds(*colors.Colors.Blue40.value)
else:
move.set_leds(*colors.Colors.Blue40.value)
else:
move.set_leds(*colors.Colors.White40)
move.set_leds(*colors.Colors.White40.value)
else:
move.set_leds(*my_team_colors)
#move.set_rumble(0)
if change > threshold:
if time.time() > no_rumble:
move.set_leds(*colors.Colors.Black)
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
@@ -172,6 +184,8 @@ def __init__(self, moves, command_queue, ns, music, teams, game_mode):
self.command_queue = command_queue
self.ns = ns
print(self.ns.settings)
self.game_mode = game_mode
#save locally in case settings change from web
@@ -505,9 +519,12 @@ def werewolf_intro(self):
#don't wait so colors change during prompts
Audio('audio/Joust/sounds/werewolf intro.wav').start_effect()
time.sleep(3)
self.change_all_move_colors(80, 0, 0)
if self.red_on_kill:
self.change_all_move_colors(0,0,80)
else:
self.change_all_move_colors(80,0,0)
time.sleep(2)
self.change_all_move_colors(30, 0, 0)
self.change_all_move_colors(0,0,30)
time.sleep(14)
self.change_all_move_colors(20, 20, 20)
time.sleep(6)
@@ -131,9 +131,9 @@ def track_move(serial, move_num, move_opts, force_color, battery, dead_count):
elif game_mode == common.Games.WereJoust:
if move_num <= 0:
move.set_leds(*colors.Colors.Red60.value)
move.set_leds(*colors.Colors.Blue40.value)
else:
move.set_leds(*colors.Colors.White80.value)
move.set_leds(*colors.Colors.White40.value)
elif game_mode == common.Games.Zombies:
move.set_leds(*colors.Colors.Zombie.value)
@@ -467,7 +467,7 @@ def check_admin_controls(self):
self.force_color[self.admin_move][2] = 0
else:
#if game is in con mode, admin is green, otherwise admin is red
if self.game_mode.pretty_name in self.ns.settings['random_modes']:
if self.game_mode.name in self.ns.settings['random_modes']:
self.force_color[self.admin_move][0] = 0
self.force_color[self.admin_move][1] = 200
@@ -478,15 +478,15 @@ def check_admin_controls(self):
#add or remove game from con mode
if admin_opt[Opts.selection.value] == Selections.add_game.value:
admin_opt[Opts.selection.value] = Selections.nothing.value
if self.game_mode.pretty_name not in self.ns.settings['random_modes']:
if self.game_mode.name not in self.ns.settings['random_modes']:
temp_random_modes = self.ns.settings['random_modes']
temp_random_modes.append(self.game_mode.pretty_name)
temp_random_modes.append(self.game_mode.name)
self.update_setting('random_modes',temp_random_modes)
if self.ns.settings['play_audio']:
Audio('audio/Menu/game_on.wav').start_effect()
elif len(self.ns.settings['random_modes']) > 1:
temp_random_modes = self.ns.settings['random_modes']
temp_random_modes.remove(self.game_mode.pretty_name)
temp_random_modes.remove(self.game_mode.name)
self.update_setting('random_modes',temp_random_modes)
if self.ns.settings['play_audio']:
Audio('audio/Menu/game_off.wav').start_effect()
@@ -501,7 +501,7 @@ def initialize_settings(self):
'sensitivity': Sensitivity.mid.value,
'play_instructions': True,
#we store the name, not the enum, so the webui can process it more easily
'random_modes': [common.Games.JoustFFA.pretty_name],
'random_modes': [common.Games.JoustFFA.name],
'play_audio': True,
'move_can_be_admin': True,
'enforce_minimum': True,
@@ -526,14 +526,14 @@ def initialize_settings(self):
temp_settings.pop(setting)
#random mode games can't be empty
if temp_settings['random_modes'] == []:
temp_settings['random_modes'] = [common.Games.JoustFFA.pretty_name]
temp_settings['random_modes'] = [common.Games.JoustFFA.name]
#or these two modes
for game in [common.Games.JoustTeams,common.Games.Random]:
if game.pretty_name in temp_settings['random_modes']:
temp_settings['random_modes'].remove(game.pretty_name)
if game.name in temp_settings['random_modes']:
temp_settings['random_modes'].remove(game.name)
#or a non-existent mode
for game in temp_settings['random_modes']:
if game not in [game.pretty_name for game in common.Games]:
if game not in [game.name for game in common.Games]:
temp_settings['random_modes'].remove(game)
#force these settings
temp_settings.update({
@@ -653,7 +653,7 @@ def start_game(self, random_mode=False):
self.update_status('starting')
if random_mode:
good_random_modes = [game for game in common.Games if game.pretty_name in self.ns.settings['random_modes']]
good_random_modes = [game for game in common.Games if game.name in self.ns.settings['random_modes']]
good_random_modes = [common.Games[game] for game in self.ns.settings['random_modes']]
if self.ns.settings['enforce_minimum']:
good_random_modes = [game for game in good_random_modes if game.minimum_players <= len(game_moves)]
@@ -22,7 +22,7 @@ class SettingsForm(Form):
move_can_be_admin = BooleanField('Allow Move to change settings')
play_instructions = BooleanField('Play instructions before game start')
play_audio = BooleanField('Play audio')
red_on_kill = SelectField('Kill notification',choices=[(False,'Dark'),(True,'Red')],coerce=bool)
red_on_kill = SelectField('Kill notification',choices=[(True,'Red'),('','Dark')],coerce=bool)
sensitivity = SelectField('Move sensitivity',choices=[(0,'Slow'),(1,'Medium'),(2,'Fast')],coerce=int)
mode_options = [ game for game in common.Games if game not in [common.Games.Random, common.Games.JoustTeams]]
random_modes = MultiCheckboxField('Random Modes',choices=[(game.name, game.pretty_name) for game in mode_options])
@@ -116,21 +116,16 @@ def settings(self):
def web_settings_update(self,web_settings):
temp_settings = self.ns.settings
temp_settings.update(web_settings)
#secret setting, keep it True
#temp_settings['enforce_minimum'] = 'enforce_minimum' in web_settings.keys()
if temp_settings['random_modes'] == []:
temp_settings['random_modes'] = [common.Games.JoustFFA.pretty_name]
temp_settings['random_modes'] = [common.Games.JoustFFA.name]
temp_settings['color_lock_choices'] = {
2: temp_settings['color_lock_choices'][0:2],
3: temp_settings['color_lock_choices'][2:5],
4: temp_settings['color_lock_choices'][5:9],
}
print(temp_settings)
self.ns.settings = temp_settings

0 comments on commit b87651f

Please sign in to comment.