Skip to content

Commit

Permalink
changed admin enabling, fixed Sensitivity bugs, added two more sensit…
Browse files Browse the repository at this point in the history
…ivity levels
  • Loading branch information
adangert committed May 6, 2019
1 parent 3c97c49 commit bc13bc7
Show file tree
Hide file tree
Showing 9 changed files with 397 additions and 462 deletions.
32 changes: 20 additions & 12 deletions common.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,31 @@
SETTINGSFILE = 'joustsettings.yaml'

#Human speeds[slow, mid, fast]
SLOW_WARNING = [0.1, 0.15, 0.28]
SLOW_MAX = [0.25, 0.8, 1]
FAST_WARNING = [0.5, 0.6, 0.8]
FAST_MAX = [1, 1.4, 1.8]

#SLOW_WARNING = [0.1, 0.15, 0.28]
#SLOW_MAX = [0.5, 0.8, 1]
#SLOW_MAX = [0.25, 0.8, 1]
#FAST_WARNING = [0.5, 0.6, 0.8]
#FAST_MAX = [1, 1.4, 1.8]

WERE_SLOW_WARNING = [0.2, 0.3, 0.4]
WERE_SLOW_MAX = [0.7, 0.9, 1.1]
WERE_FAST_WARNING = [0.6, 0.7, 0.9]
WERE_FAST_MAX = [1.1, 1.5, 2.0]
SLOW_WARNING = [1.0, 1.3, 1.6, 2.0, 2.5]
SLOW_MAX = [1.1, 1.5, 1.8, 2.5, 3.2]
FAST_WARNING = [1.3, 1.6, 1.9, 2.7, 2.8]
FAST_MAX = [1.5, 1.8, 2.8, 3.2, 3.5]

#WERE_SLOW_WARNING = [0.2, 0.3, 0.4]
#WERE_SLOW_MAX = [0.7, 0.9, 1.1]
#WERE_FAST_WARNING = [0.6, 0.7, 0.9]
#WERE_FAST_MAX = [1.1, 1.5, 2.0]

WERE_SLOW_WARNING = [1.1, 1.4, 1.7, 2.1, 2.9]
WERE_SLOW_MAX = [1.2, 1.6, 1.9, 2.6, 3.9]
WERE_FAST_WARNING = [1.4, 1.7, 2.0, 2.8, 3.5]
WERE_FAST_MAX = [1.6, 1.9, 2.9, 3.3, 4.9]

#ZOMBIE_WARNING = [0.5, 0.6, 0.8]
#ZOMBIE_MAX = [0.8, 1, 1.4]

ZOMBIE_WARNING = [0.5, 0.6, 0.8]
ZOMBIE_MAX = [0.8, 1, 1.4]
ZOMBIE_WARNING = [1.2, 1.5, 1.8, 2.6, 2.7]
ZOMBIE_MAX = [1.4, 1.7, 2.7, 3.1, 3.4]


def get_move(serial, move_num):
Expand Down
14 changes: 7 additions & 7 deletions controller_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import common, colors, joust, webui, piparty
#this should all be refactored to use the same options per game
def main_track_move(menu, restart, move_serial, move_num, move_opts, force_color, battery, dead_count, game_mode, \
team, team_color_enum, dead_move, music_speed, werewolf_reveal, show_team_colors, red_on_kill, zombie_opt,\
team, team_color_enum, controller_sensitivity, dead_move, music_speed, werewolf_reveal, show_team_colors, red_on_kill, zombie_opt,\
commander_intro, commander_move_opt, commander_powers, commander_overdrive,five_controller_opt, swapper_team_colors,\
invincibility, fight_club_color, num_teams,bomb_color,game_start,false_color, faked, rumble, kill_proc):
print("starting Controller Process")
Expand All @@ -15,20 +15,20 @@ def main_track_move(menu, restart, move_serial, move_num, move_opts, force_color
elif (menu.value == 1):
piparty.track_move(move_serial, move_num, move, move_opts, force_color, battery, dead_count, restart, menu, kill_proc)
elif(game_mode.value == common.Games.Zombies.value):
zombie.track_controller(move, zombie_opt, restart, menu)
zombie.track_controller(move, zombie_opt, restart, menu, controller_sensitivity)
elif(game_mode.value == common.Games.Commander.value):
commander.track_move(move, team.value, dead_move, force_color, music_speed, commander_intro, \
commander_move_opt, commander_powers, commander_overdrive, restart, menu)
commander_move_opt, commander_powers, commander_overdrive, restart, menu, controller_sensitivity)
elif(game_mode.value == common.Games.Swapper.value):
swapper.track_move(move, team, 2, swapper_team_colors, \
dead_move, force_color, music_speed, five_controller_opt, restart, menu)
dead_move, force_color, music_speed, five_controller_opt, restart, menu, controller_sensitivity)
elif(game_mode.value == common.Games.FightClub.value):
fight_club.track_move(move, dead_move, force_color, music_speed, fight_club_color, invincibility, menu, restart)
fight_club.track_move(move, dead_move, force_color, music_speed, fight_club_color, invincibility, menu, restart, controller_sensitivity)
elif(game_mode.value == common.Games.Tournament.value):
tournament.track_move(move, team, num_teams.value, dead_move, force_color, music_speed, show_team_colors, invincibility, menu, restart)
tournament.track_move(move, team, num_teams.value, dead_move, force_color, music_speed, show_team_colors, invincibility, menu, restart, controller_sensitivity)
elif(game_mode.value == common.Games.Ninja.value):
speed_bomb.track_move(move, dead_move, force_color,bomb_color, five_controller_opt, game_start, false_color, faked, rumble, menu, restart)
else:
joust.track_move(move, game_mode.value, team.value, team_color_enum, dead_move, force_color, \
music_speed, werewolf_reveal, show_team_colors, red_on_kill, restart, menu)
music_speed, werewolf_reveal, show_team_colors, red_on_kill, restart, menu, controller_sensitivity)

118 changes: 50 additions & 68 deletions games/commander.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,7 @@
MIN_MUSIC_SLOW_TIME = 10
MAX_MUSIC_SLOW_TIME = 23

#Sensitivity of the contollers
#changes by the values in common
#TODO: make commander should be harder to kill
SLOW_MAX = 1.3
SLOW_WARNING = 0.28
FAST_MAX = 2.5
FAST_WARNING = 1.3



#How long the speed change takes
INTERVAL_CHANGE = 1.5
Expand Down Expand Up @@ -81,7 +73,7 @@ def calculate_flash_time(r,g,b, score):
new_b = int(common.lerp(255, b, flash_percent))
return (new_r, new_g, new_b)

def track_move(move, team, dead_move, force_color, music_speed, commander_intro, move_opts, commander_powers, commander_overdrive, restart, menu):
def track_move(move, team, dead_move, force_color, music_speed, commander_intro, move_opts, commander_powers, commander_overdrive, restart, menu, controller_sensitivity):
if team == Team.alpha.value:
overdrive = commander_overdrive[0]
power = commander_powers[0]
Expand All @@ -102,7 +94,13 @@ def track_move(move, team, dead_move, force_color, music_speed, commander_intro,
vibration_time = time.time() + 1
flash_lights = True
flash_lights_timer = 0
change_arr = [0,0,0]
change = 0
#change_arr = [0,0,0]

SLOW_MAX = controller_sensitivity[0]
SLOW_WARNING = controller_sensitivity[1]
FAST_MAX = controller_sensitivity[2]
FAST_WARNING = controller_sensitivity[3]

death_time = 8
time_of_death = time.time()
Expand Down Expand Up @@ -145,66 +143,60 @@ def track_move(move, team, dead_move, force_color, music_speed, commander_intro,
elif dead_move.value == 1:
if move.poll():
ax, ay, az = move.get_accelerometer_frame(psmove.Frame_SecondHalf)
#total = sum([ax, ay, az])
total = sqrt(sum([ax**2, ay**2, az**2]))
if move_last_value is not None:
change_real = abs(move_last_value - total)
change_arr[0] = change_arr[1]
change_arr[1] = change_arr[2]
change_arr[2] = change_real
change = (change_arr[0] + change_arr[1]+change_arr[2])/3
change = (change * 4 + total)/5

if move_opts[Opts.is_commander.value] == Bool.no.value:
if overdrive.value == 0:
warning = SLOW_WARNING
threshold = SLOW_MAX
else:
warning = FAST_WARNING
threshold = FAST_MAX
else:
#if affected by overdrive, this could make the power better
if move_opts[Opts.is_commander.value] == Bool.no.value:
if overdrive.value == 0:
warning = SLOW_WARNING
threshold = SLOW_MAX

else:
warning = FAST_WARNING
threshold = FAST_MAX
else:
#if affected by overdrive, this could make the power better
warning = SLOW_WARNING
threshold = SLOW_MAX


if change > threshold:
if time.time() > no_rumble:
move.set_leds(0,0,0)
move.set_rumble(90)
dead_move.value = 0
time_of_death = time.time()
if change > threshold:
if time.time() > no_rumble:
move.set_leds(0,0,0)
move.set_rumble(90)
dead_move.value = 0
time_of_death = time.time()

elif change > warning and not vibrate:
if time.time() > no_rumble:
move.set_leds(20,50,100)
vibrate = True
vibration_time = time.time() + 0.5
elif change > warning and not vibrate:
if time.time() > no_rumble:
move.set_leds(20,50,100)
vibrate = True
vibration_time = time.time() + 0.5

else:
if move_opts[Opts.is_commander.value] == Bool.no.value:
if overdrive.value == 0:
move.set_leds(*Commander_colors[team])
else:
move.set_leds(*Overdrive_colors[team])
else:
if move_opts[Opts.is_commander.value] == Bool.no.value:
if overdrive.value == 0:
move.set_leds(*Commander_colors[team])
else:
move.set_leds(*calculate_flash_time(Current_commander_colors[team][0],Current_commander_colors[team][1],Current_commander_colors[team][2], power.value))
move.set_rumble(0)
move.set_leds(*Overdrive_colors[team])
else:
move.set_leds(*calculate_flash_time(Current_commander_colors[team][0],Current_commander_colors[team][1],Current_commander_colors[team][2], power.value))
move.set_rumble(0)


if move_opts[Opts.is_commander.value] == Bool.yes.value:
if (move.get_buttons() == 0 and move.get_trigger() < 10):
move_opts[Opts.holding.value] = Holding.not_holding.value
button = move.get_buttons()
#print str(power.value)
if power.value >= 1.0:
#press trigger for overdrive
if (move_opts[Opts.holding.value] == Holding.not_holding.value and move.get_trigger() > 100):
move_opts[Opts.selection.value] = Selections.trigger.value
move_opts[Opts.holding.value] = Holding.holding.value
if move_opts[Opts.is_commander.value] == Bool.yes.value:
if (move.get_buttons() == 0 and move.get_trigger() < 10):
move_opts[Opts.holding.value] = Holding.not_holding.value

button = move.get_buttons()
#print str(power.value)
if power.value >= 1.0:
#press trigger for overdrive
if (move_opts[Opts.holding.value] == Holding.not_holding.value and move.get_trigger() > 100):
move_opts[Opts.selection.value] = Selections.trigger.value
move_opts[Opts.holding.value] = Holding.holding.value


move_last_value = total
#move_last_value = total
if vibrate:
flash_lights_timer += 1
if flash_lights_timer > 7:
Expand Down Expand Up @@ -241,16 +233,6 @@ def __init__(self, moves, command_queue, ns, music, dead_moves, commander_intro,
self.sensitivity = self.ns.settings['sensitivity']
self.random_teams = self.ns.settings['random_teams']

global SLOW_MAX
global SLOW_WARNING
global FAST_MAX
global FAST_WARNING

SLOW_MAX = common.SLOW_MAX[self.sensitivity]
SLOW_WARNING = common.SLOW_WARNING[self.sensitivity]
FAST_MAX = common.FAST_MAX[self.sensitivity]
FAST_WARNING = common.FAST_WARNING[self.sensitivity]

self.update_time = 0

self.move_serials = moves
Expand Down
Loading

0 comments on commit bc13bc7

Please sign in to comment.