Exemplo n.º 1
0
    def start_game(self, random_mode=False):
        self.enable_bt_scanning(False)
        self.exclude_out_moves()
        self.stop_tracking_moves()
        time.sleep(0.2)
        game_moves = [move.get_serial() for move in self.moves if self.out_moves[move.get_serial()] == Alive.on.value]
        self.teams = {serial: self.move_opts[serial][Opts.team.value] for serial in self.tracked_moves.keys() if self.out_moves[serial] == Alive.on.value}


        if random_mode:
            if len(self.con_games) <= 1:
                selected_game = self.con_games[0]
            else:
                if len(self.rand_game_list) >= len(self.con_games):
                    #empty rand game list, append old game, to not play it twice
                    self.rand_game_list = [self.old_game_mode]

                selected_game = random.choice(self.con_games)
                while selected_game in self.rand_game_list:
                    selected_game = random.choice(self.con_games)

                self.old_game_mode = selected_game
                self.rand_game_list.append(selected_game)

            self.game_mode = selected_game

        if self.instructions:
            self.play_random_instructions()
        
        if self.game_mode == common.Games.Zombies.value:
            zombie.Zombie(game_moves, self.sensitivity)
            self.tracked_moves = {}
        elif self.game_mode == common.Games.Commander.value:
            commander.Commander(game_moves, self.sensitivity)
            self.tracked_moves = {}
        elif self.game_mode == common.Games.Ninja.value:
            speed_bomb.Bomb(game_moves)
            self.tracked_moves = {}
        elif self.game_mode == common.Games.Swapper.value:
            swapper.Swapper(game_moves, self.sensitivity)
            self.tracked_moves = {}
        elif self.game_mode == common.Games.KingoftheHill.value:
            kingofthehill.KingoftheHill(game_moves, self.sensitivity)
            self.tracked_moves = {}
        else:
            #may need to put in moves that have selected to not be in the game
            joust.Joust(self.game_mode, game_moves, self.teams, self.sensitivity)
            self.tracked_moves = {}
        if random_mode:
            self.game_mode = common.Games.Random.value
            if self.instructions:
                Audio('audio/Menu/tradeoff2.wav').start_effect()
                time.sleep(8)
            
        #turn off admin mode so someone can't accidentally press a button    
        self.admin_move = None
        self.random_added = []
Exemplo n.º 2
0
    def start_game(self, random_mode=False):
        self.enable_bt_scanning(False)
        self.exclude_out_moves()
        self.stop_tracking_moves()
        time.sleep(0.2)
        game_moves = [
            move.get_serial() for move in self.moves
            if self.out_moves[move.get_serial()] == Alive.on.value
        ]
        self.teams = {
            serial: self.move_opts[serial][Opts.team.value]
            for serial in self.tracked_moves.keys()
            if self.out_moves[serial] == Alive.on.value
        }
        old_game_mode = self.game_mode

        if random_mode:
            if len(self.rand_game_list) <= 0:
                self.rand_game_list = list(range(GAME_MODES))
                self.rand_game_list.remove(common.Games.JoustTeams.value)
                self.rand_game_list.remove(common.Games.Random.value)
                self.rand_game_list.remove(common.Games.Commander.value)
            self.game_mode = random.choice(self.rand_game_list)
            self.rand_game_list.remove(self.game_mode)
            self.play_random_instructions()

        if self.game_mode == common.Games.Zombies.value:
            zombie.Zombie(game_moves)
            self.tracked_moves = {}
        elif self.game_mode == common.Games.Commander.value:
            commander.Commander(game_moves)
            self.tracked_moves = {}
        else:
            #may need to put in moves that have selected to not be in the game
            joust.Joust(self.game_mode, game_moves, self.teams)
            self.tracked_moves = {}
        if random_mode:
            self.game_mode = old_game_mode
            Audio('audio/Menu/tradeoff2.wav').start_effect()
            time.sleep(8)
        self.random_added = []
Exemplo n.º 3
0
    def start_game(self, random_mode=False):
        self.enable_bt_scanning(False)
        self.exclude_out_moves()
        self.stop_tracking_moves()
        time.sleep(1)
        self.teams = {
            serial: self.move_opts[serial][Opts.team.value]
            for serial in self.tracked_moves.keys()
            if self.out_moves[serial] == Alive.on.value
        }
        game_moves = [
            move.get_serial() for move in self.moves
            if self.out_moves[move.get_serial()] == Alive.on.value
        ]
        try:
            self.menu_music.stop_audio()
        except:
            pass

        if len(game_moves
               ) < self.game_mode.minimum_players and self.ns.settings[
                   'enforce_minimum']:
            Audio('audio/Menu/notenoughplayers.wav').start_effect()
            self.tracked_moves = {}
            return
        self.update_status('starting')

        if random_mode:
            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)
                ]
            if len(good_random_modes) == 0:
                selected_game = common.Games.JoustFFA  #force Joust FFA
            elif len(good_random_modes) == 1:
                selected_game = good_random_modes[0]
            else:
                if len(self.rand_game_list) >= len(good_random_modes):
                    #empty rand game list, append old game, to not play it twice
                    self.rand_game_list = [self.old_game_mode]

                selected_game = random.choice(good_random_modes)
                while selected_game in self.rand_game_list:
                    selected_game = random.choice(good_random_modes)

                self.old_game_mode = selected_game
                self.rand_game_list.append(selected_game)

            self.game_mode = selected_game

        if self.ns.settings['play_instructions'] and self.ns.settings[
                'play_audio']:
            self.play_random_instructions()

        if self.game_mode == common.Games.Zombies:
            zombie.Zombie(game_moves, self.command_queue, self.ns,
                          self.zombie_music)
            self.tracked_moves = {}
        elif self.game_mode == common.Games.Commander:
            commander.Commander(game_moves, self.command_queue, self.ns,
                                self.commander_music)
            self.tracked_moves = {}
        elif self.game_mode == common.Games.Ninja:
            speed_bomb.Bomb(game_moves, self.command_queue, self.ns,
                            self.commander_music)
            self.tracked_moves = {}
        elif self.game_mode == common.Games.Swapper:
            swapper.Swapper(game_moves, self.command_queue, self.ns,
                            self.joust_music)
            self.tracked_moves = {}
        elif self.game_mode == common.Games.FightClub:
            if random.randint(0, 1) == 1:
                fight_music = self.commander_music
            else:
                fight_music = self.joust_music
            fight_club.Fight_club(game_moves, self.command_queue, self.ns,
                                  fight_music)
            self.tracked_moves = {}
        elif self.game_mode == common.Games.Tournament:
            tournament.Tournament(game_moves, self.command_queue, self.ns,
                                  self.joust_music)
            self.tracked_moves = {}
        else:
            if self.game_mode == common.Games.JoustFFA and self.experimental:
                print("Playing EXPERIMENTAL FFA Mode.")
                moves = [
                    common.get_move(serial, num)
                    for num, serial in enumerate(game_moves)
                ]
                game = ffa.FreeForAll(moves, self.joust_music)
                game.run_loop()
            else:
                #may need to put in moves that have selected to not be in the game
                joust.Joust(game_moves, self.command_queue, self.ns,
                            self.joust_music, self.teams, self.game_mode)
            self.tracked_moves = {}
        if random_mode:
            self.game_mode = common.Games.Random
            if self.ns.settings['play_instructions']:
                if self.ns.settings['play_audio']:
                    Audio('audio/Menu/tradeoff2.wav').start_effect_and_wait()
        self.play_menu_music = True
        #reset music
        self.choose_new_music()
        #turn off admin mode so someone can't accidentally press a button
        self.admin_move = None
        self.random_added = []
Exemplo n.º 4
0
    def start_game(self, random_mode=False):
        self.enable_bt_scanning(False)
        self.exclude_out_moves()
        time.sleep(1)
        self.teams = {
            serial: self.move_opts[serial][Opts.team.value]
            for serial in self.tracked_moves.keys()
            if self.out_moves[serial] == Alive.on.value
        }
        game_moves = [
            move.get_serial() for move in self.moves
            if self.out_moves[move.get_serial()] == Alive.on.value
        ]
        try:
            self.menu_music.stop_audio()
        except:
            pass

        if len(game_moves
               ) < self.game_mode.minimum_players and self.ns.settings[
                   'enforce_minimum']:
            Audio('audio/Menu/vox/' + self.ns.settings['menu_voice'] +
                  '/notenoughplayers.wav').start_effect()
            self.reset_controller_game_state()
            return
        self.menu.value = 0
        self.restart.value = 1
        self.update_status('starting')

        self.sensitivity = self.ns.settings['sensitivity']
        self.controller_sensitivity[0] = common.SLOW_MAX[self.sensitivity]
        self.controller_sensitivity[1] = common.SLOW_WARNING[self.sensitivity]
        self.controller_sensitivity[2] = common.FAST_MAX[self.sensitivity]
        self.controller_sensitivity[3] = common.FAST_WARNING[self.sensitivity]

        self.controller_sensitivity[4] = common.WERE_SLOW_MAX[self.sensitivity]
        self.controller_sensitivity[5] = common.WERE_SLOW_WARNING[
            self.sensitivity]
        self.controller_sensitivity[6] = common.WERE_FAST_MAX[self.sensitivity]
        self.controller_sensitivity[7] = common.WERE_FAST_WARNING[
            self.sensitivity]

        self.controller_sensitivity[8] = common.ZOMBIE_MAX[self.sensitivity]
        self.controller_sensitivity[9] = common.ZOMBIE_WARNING[
            self.sensitivity]

        if random_mode:
            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)
                ]
            if len(good_random_modes) == 0:
                selected_game = common.Games.JoustFFA  #force Joust FFA
            elif len(good_random_modes) == 1:
                selected_game = good_random_modes[0]
            else:
                if len(self.rand_game_list) >= len(good_random_modes):
                    #empty rand game list, append old game, to not play it twice
                    self.rand_game_list = [self.old_game_mode]

                selected_game = random.choice(good_random_modes)
                while selected_game in self.rand_game_list:
                    selected_game = random.choice(good_random_modes)

                self.old_game_mode = selected_game
                self.rand_game_list.append(selected_game)

            self.game_mode = selected_game
        self.controller_game_mode.value = self.game_mode.value

        if self.ns.settings['play_instructions'] and self.ns.settings[
                'play_audio']:
            self.play_random_instructions()

        if self.game_mode == common.Games.Zombies:
            zombie.Zombie(game_moves, self.command_queue, self.ns,
                          self.zombie_music, self.restart, self.zombie_opts)
        elif self.game_mode == common.Games.Commander:
            commander.Commander(game_moves, self.command_queue, self.ns, self.commander_music, self.dead_moves,  self.commander_intro, self.commander_move_opts, \
                                self.commander_powers, self.commander_overdrive, self.music_speed, self.force_color, self.restart, self.controller_teams)
        elif self.game_mode == common.Games.Ninja:
            speed_bomb.Bomb(game_moves, self.command_queue, self.ns,
                            self.commander_music, self.bomb_color,
                            self.game_start, self.five_controller_opts,
                            self.dead_moves, self.force_color,
                            self.false_colors, self.was_faked, self.rumble,
                            self.music_speed, self.restart)
        elif self.game_mode == common.Games.Swapper:
            swapper.Swapper(game_moves, self.command_queue, self.ns, self.joust_music, \
                            self.swapper_team_colors, self.dead_moves, self.music_speed, self.force_color, self.five_controller_opts, self.controller_teams, self.restart)
        elif self.game_mode == common.Games.FightClub:
            if random.randint(0, 1) == 1:
                fight_music = self.commander_music
            else:
                fight_music = self.joust_music
            fight_club.Fight_club(game_moves, self.command_queue, self.ns,
                                  fight_music, self.show_team_colors,
                                  self.music_speed, self.dead_moves,
                                  self.force_color, self.invincible_moves,
                                  self.fight_club_colors, self.restart)
        elif self.game_mode == common.Games.Tournament:
            tournament.Tournament(game_moves, self.command_queue, self.ns,
                                  self.joust_music, self.show_team_colors,
                                  self.music_speed, self.controller_teams,
                                  self.dead_moves, self.force_color,
                                  self.invincible_moves, self.num_teams,
                                  self.restart)
        else:
            if self.game_mode == common.Games.JoustFFA and self.experimental:
                print("Playing EXPERIMENTAL FFA Mode.")
                moves = [
                    common.get_move(serial, num)
                    for num, serial in enumerate(game_moves)
                ]
                game = ffa.FreeForAll(moves, self.joust_music)
                game.run_loop()
            else:
                #may need to put in moves that have selected to not be in the game
                joust.Joust(game_moves, self.command_queue, self.ns,
                            self.joust_music, self.teams, self.game_mode,
                            self.controller_teams, self.controller_colors,
                            self.dead_moves, self.force_color,
                            self.music_speed, self.werewolf_reveal,
                            self.show_team_colors, self.red_on_kill,
                            self.restart)
        if random_mode:
            self.game_mode = common.Games.Random
            if self.ns.settings['play_instructions']:
                if self.ns.settings['play_audio']:
                    Audio('audio/Menu/vox/' + self.ns.settings['menu_voice'] +
                          '/tradeoff2.wav').start_effect_and_wait()
        self.play_menu_music = True
        #reset music
        self.choose_new_music()
        #turn off admin mode so someone can't accidentally press a button
        self.admin_move = None
        self.random_added = []
        self.reset_controller_game_state()
        self.menu.value = 1
        self.restart.value = 0
        self.reset_controller_game_state()
Exemplo n.º 5
0
    def start_game(self, random_mode=False):
        self.enable_bt_scanning(False)
        self.exclude_out_moves()
        self.stop_tracking_moves()
        time.sleep(0.2)
        self.teams = {
            serial: self.move_opts[serial][Opts.team.value]
            for serial in self.tracked_moves.keys()
            if self.out_moves[serial] == Alive.on.value
        }
        game_moves = [
            move.get_serial() for move in self.moves
            if self.out_moves[move.get_serial()] == Alive.on.value
        ]

        if len(game_moves) < common.minimum_players[
                self.game_mode] and self.enforce_minimum:
            Audio('audio/Menu/notenoughplayers.wav').start_effect()
            self.tracked_moves = {}
            return
        self.update_status('starting')

        if random_mode:
            if self.enforce_minimum:
                good_con_games = [
                    i for i in self.con_games
                    if common.minimum_players[i] <= len(game_moves)
                ]
            else:
                good_con_games = self.con_games
            if len(good_con_games) == 0:
                selected_game = 0  #force Joust FFA
            elif len(good_con_games) == 1:
                selected_game = good_con_games[0]
            else:
                if len(self.rand_game_list) >= len(good_con_games):
                    #empty rand game list, append old game, to not play it twice
                    self.rand_game_list = [self.old_game_mode]

                selected_game = random.choice(good_con_games)
                while selected_game in self.rand_game_list:
                    selected_game = random.choice(good_con_games)

                self.old_game_mode = selected_game
                self.rand_game_list.append(selected_game)

            self.game_mode = selected_game

        if self.instructions and self.audio_toggle:
            self.play_random_instructions()

        if self.game_mode == common.Games.Zombies.value:
            zombie.Zombie(game_moves, self.sensitivity, self.command_queue,
                          self.status_ns, self.audio_toggle, self.zombie_music)
            self.tracked_moves = {}
        elif self.game_mode == common.Games.Commander.value:
            commander.Commander(game_moves, self.sensitivity,
                                self.command_queue, self.status_ns,
                                self.commander_music)
            self.tracked_moves = {}
        elif self.game_mode == common.Games.Ninja.value:
            speed_bomb.Bomb(game_moves, self.command_queue, self.status_ns,
                            self.audio_toggle, self.commander_music)
            self.tracked_moves = {}
        elif self.game_mode == common.Games.Swapper.value:
            swapper.Swapper(game_moves, self.sensitivity, self.command_queue,
                            self.status_ns, self.audio_toggle,
                            self.joust_music)
            self.tracked_moves = {}
        elif self.game_mode == common.Games.Tournament.value:
            tournament.Tournament(game_moves, self.sensitivity,
                                  self.command_queue, self.status_ns,
                                  self.audio_toggle, self.joust_music)
            self.tracked_moves = {}
        else:
            #may need to put in moves that have selected to not be in the game
            joust.Joust(self.game_mode, game_moves, self.teams,
                        self.sensitivity, self.command_queue, self.status_ns,
                        self.audio_toggle, self.joust_music)
            self.tracked_moves = {}
        if random_mode:
            self.game_mode = common.Games.Random.value
            if self.instructions:
                if self.audio_toggle:
                    Audio('audio/Menu/tradeoff2.wav').start_effect()
                    time.sleep(8)
        #reset music
        self.choose_new_music()
        #turn off admin mode so someone can't accidentally press a button
        self.admin_move = None
        self.random_added = []