Beispiel #1
0
    def setup(self):
        """docstring for setup"""
        #setup score display
        self.score_display = AlphaScoreDisplay(self, 0)
        
        self.load_config(self.yamlpath)
        #self.load_settings(settings_path, user_settings_path)
        self.load_settings(settings_template_path, settings_path)
        
        self.setup_ball_search()
        self.load_game_data(game_data_template_path, game_data_path)
        
        # Instantiate basic game features
        self.effects = Effects(self)
        self.modes.add(self.effects)
        self.attract_mode = Attract(self)
        self.base_game_mode = BaseGameMode(self)

        # Note - Game specific item:
        # The last parameter should be the name of the game's ball save lamp
        self.ball_save = procgame.modes.BallSave(self, self.lamps.shootAgain, 'shooterLane')
        
        trough_switchnames = []
        # Note - Game specific item:
        # This range should include the number of trough switches for
        # the specific game being run.  In range(1,x), x = last number + 1.
        for i in range(1,4):
            trough_switchnames.append('ballTrough' + str(i))
        early_save_switchnames = ['rightOutlane', 'leftOutlane']
        
        # Note - Game specific item:
        # Here, trough6 is used for the 'eject_switchname'.  This must
        # be the switch of the next ball to be ejected.  Some games
        # number the trough switches in the opposite order; so trough1
        # might be the proper switchname to user here.
        self.trough = procgame.modes.Trough(self,trough_switchnames,'ballTrough1','ballFeed', early_save_switchnames, 'shooterLane', self.drain_callback)
        
        # Link ball_save to trough
        self.trough.ball_save_callback = self.ball_save.launch_callback
        self.trough.num_balls_to_save = self.ball_save.get_num_balls_to_save
        self.ball_save.trough_enable_ball_save = self.trough.enable_ball_save
        
        # Setup and instantiate service mode
        
        self.sound.register_sound('service_enter', sound_path+"menu_in.wav")
        self.sound.register_sound('service_exit', sound_path+"menu_out.wav")
        self.sound.register_sound('service_next', sound_path+"next_item.wav")
        self.sound.register_sound('service_previous', sound_path+"previous_item.wav")
        self.sound.register_sound('service_switch_edge', sound_path+"switch_edge.wav")
        self.sound.register_sound('service_save', sound_path+"save.wav")
        self.sound.register_sound('service_cancel', sound_path+"cancel.wav")
        self.sound.register_sound('bonus', sound_path+"bonus.wav")
        self.sound.register_sound('3boink', sound_path+"3bonks.wav")
        #self.service_mode = procgame.service.ServiceMode(self,100,font_tiny7,[])
        
        # Setup fonts
        #self.fonts = {}
        #self.fonts['tiny7'] = font_tiny7
        #self.fonts['jazz18'] = font_jazz18
        
        self.lampshow_keys = []
        key_ctr = 0
        for file in lampshow_files:
            key = 'attract' + str(key_ctr)
            self.lampshow_keys.append(key)
            self.lampctrl.register_show(key, file)
            key_ctr += 1
    
        # Instead of resetting everything here as well as when a user
        # initiated reset occurs, do everything in self.reset() and call it
        # now and during a user initiated reset.
        self.reset()
    def reset(self):
        #super(EarthshakerAftershock, self).reset()

        self.ball = 0
        self.old_players = []
        self.old_players = self.players[:]
        self.players = []
        self.current_player_index = 0
        self.modes.modes = []
        self.shooter_lane_status = 0
        self.tiltStatus = 0

        #setup high scores
        self.highscore_categories = []

        #### Classic High Score Data ####
        cat = highscore.HighScoreCategory()
        cat.game_data_key = 'ClassicHighScoreData'
        self.highscore_categories.append(cat)

        #### Mileage Champ ####
        cat = highscore.HighScoreCategory()
        cat.game_data_key = 'MilesChampion'
        self.highscore_categories.append(cat)

        for category in self.highscore_categories:
            category.load_from_game(self)

        #### Setup Alphanumeric Display Controller ####
        self.alpha_score_display = AlphaScoreDisplay(self, 0)
        self.modes.add(self.alpha_score_display)

        #### Setup Sound Controller ####
        self.sound = procgame.sound.SoundController(self)
        self.RegisterSound()

        #### Setup Lamp Controller ####
        self.lampctrl = procgame.lamps.LampController(self)
        self.lampctrlflash = procgame.lamps.LampController(self)
        self.RegisterLampshows()

        #### software version number ####
        self.revision = "1.0.0"

        #### Mode Definitions ####
        self.utilities = UtilitiesMode(self, 0)
        #self.healthcheck_mode = HealthCheckMode(self,0)

        self.base_mode = BaseGameMode(self, 2)
        self.attract_mode = AttractMode(self, 5)
        self.centerramp_mode = CenterRampMode(self, 7)
        self.rightramp_mode = RightRampMode(self, 8)
        self.drops_mode = DropTargets(self, 9)
        self.collect_mode = CollectZones(self, 10)
        self.spinner_mode = Spinner(self, 11)
        self.jackpot_mode = Jackpot(self, 12)
        self.million_mode = Million(self, 14)
        self.bonusmultiplier_mode = BonusMultiplier(self, 98)
        self.shelter_mode = Shelter(self, 99)
        self.skillshot_mode = SkillshotMode(self, 100)
        self.multiball_mode = Multiball(self, 101)
        self.combo_mode = Combo(self, 102)
        self.ballsaver_mode = BallSaver(self, 199)
        self.tilt = Tilt(self, 200)
        self.bonus_mode = Bonus(self, 1000)
        self.highscore_mode = HighScore(self, 1001)
        self.switch_tracker_mode = SwitchTrackerMode(self, 1999)
        self.trough = Trough(self, 2000)

        #### Mini Mode Definitions ####
        self.mode_1 = Mode1(self, 30)
        self.mode_2 = Mode2(self, 31)
        self.mode_3 = Mode3(self, 32)
        self.mode_4 = Mode4(self, 33)
        self.mode_5 = Mode5(self, 34)
        self.mode_6 = Mode6(self, 35)
        self.mode_7 = Mode7(self, 36)
        self.mode_8 = Mode8(self, 37)
        self.mode_9 = Mode9(self, 38)

        #### Initial Mode Queue ####
        self.modes.add(self.utilities)
        self.modes.add(self.trough)
        self.modes.add(self.base_mode)
Beispiel #3
0
class Game(game.BasicGame):
    """docstring for Game"""
    def __init__(self, machine_type):
        super(Game, self).__init__(machine_type)
        self.sound = procgame.sound.SoundController(self)
        self.lampctrl = procgame.lamps.LampController(self)
        self.settings = {}
    
    def save_settings(self):
        #self.write_settings(settings_path)
        super(Game, self).save_settings(settings_path)
        #pass

    def save_game_data(self):
        super(Game, self).save_game_data(game_data_path)

    def create_player(self, name):
        return mpcPlayer(name)
    
    def setup(self):
        """docstring for setup"""
        #setup score display
        self.score_display = AlphaScoreDisplay(self, 0)
        
        self.load_config(self.yamlpath)
        #self.load_settings(settings_path, user_settings_path)
        self.load_settings(settings_template_path, settings_path)
        
        self.setup_ball_search()
        self.load_game_data(game_data_template_path, game_data_path)
        
        # Instantiate basic game features
        self.effects = Effects(self)
        self.modes.add(self.effects)
        self.attract_mode = Attract(self)
        self.base_game_mode = BaseGameMode(self)

        # Note - Game specific item:
        # The last parameter should be the name of the game's ball save lamp
        self.ball_save = procgame.modes.BallSave(self, self.lamps.shootAgain, 'shooterLane')
        
        trough_switchnames = []
        # Note - Game specific item:
        # This range should include the number of trough switches for
        # the specific game being run.  In range(1,x), x = last number + 1.
        for i in range(1,4):
            trough_switchnames.append('ballTrough' + str(i))
        early_save_switchnames = ['rightOutlane', 'leftOutlane']
        
        # Note - Game specific item:
        # Here, trough6 is used for the 'eject_switchname'.  This must
        # be the switch of the next ball to be ejected.  Some games
        # number the trough switches in the opposite order; so trough1
        # might be the proper switchname to user here.
        self.trough = procgame.modes.Trough(self,trough_switchnames,'ballTrough1','ballFeed', early_save_switchnames, 'shooterLane', self.drain_callback)
        
        # Link ball_save to trough
        self.trough.ball_save_callback = self.ball_save.launch_callback
        self.trough.num_balls_to_save = self.ball_save.get_num_balls_to_save
        self.ball_save.trough_enable_ball_save = self.trough.enable_ball_save
        
        # Setup and instantiate service mode
        
        self.sound.register_sound('service_enter', sound_path+"menu_in.wav")
        self.sound.register_sound('service_exit', sound_path+"menu_out.wav")
        self.sound.register_sound('service_next', sound_path+"next_item.wav")
        self.sound.register_sound('service_previous', sound_path+"previous_item.wav")
        self.sound.register_sound('service_switch_edge', sound_path+"switch_edge.wav")
        self.sound.register_sound('service_save', sound_path+"save.wav")
        self.sound.register_sound('service_cancel', sound_path+"cancel.wav")
        self.sound.register_sound('bonus', sound_path+"bonus.wav")
        self.sound.register_sound('3boink', sound_path+"3bonks.wav")
        #self.service_mode = procgame.service.ServiceMode(self,100,font_tiny7,[])
        
        # Setup fonts
        #self.fonts = {}
        #self.fonts['tiny7'] = font_tiny7
        #self.fonts['jazz18'] = font_jazz18
        
        self.lampshow_keys = []
        key_ctr = 0
        for file in lampshow_files:
            key = 'attract' + str(key_ctr)
            self.lampshow_keys.append(key)
            self.lampctrl.register_show(key, file)
            key_ctr += 1
    
        # Instead of resetting everything here as well as when a user
        # initiated reset occurs, do everything in self.reset() and call it
        # now and during a user initiated reset.
        self.reset()

    def reset(self):
        # Reset the entire game framework
        super(Game, self).reset()
        
        # Add the basic modes to the mode queue
        self.modes.add(self.attract_mode)
        self.modes.add(self.ball_search)
        self.modes.add(self.ball_save)
        self.modes.add(self.trough)
        
        # Make sure flippers are off, especially for user initiated resets.
        #self.enable_flippers(enable=False)
        super(Game, self).coils.flipperEnable.disable()
    #self.game.coils.flipperEnable.disable();
    
    # Empty callback just incase a ball drains into the trough before another
    # drain_callback can be installed by a gameplay mode.
    def drain_callback(self):
        self.game.coils.outhole.pulse(40)
    
    def ball_saved_callback(self):
        self.game.set_status("*Ball Saved*")
    
    def ball_starting(self):
        super(Game, self).ball_starting()
        self.modes.add(self.base_game_mode)
    
    def ball_ended(self):
        self.modes.remove(self.base_game_mode)
        super(Game, self).ball_ended()
    
    def game_ended(self):
        super(Game, self).game_ended()
        self.modes.remove(self.base_game_mode)
        self.set_status("Game    Over")
        self.modes.add(self.attract_mode)
    
    def set_status(self, text, row=0, align='center'):
        #self.dmd.set_message(text, 3)
        if row==0:
            self.score_display.set_text(text,0,justify=align,opaque=True,blink_rate=0,seconds=2)
        else:
            self.score_display.set_text(text,1,justify=align,opaque=True,blink_rate=0,seconds=2)
        print(text)
    
    def run_modecall(self, mode_name, call_name):
        self[mode_name][call_name]()
        
    def set_player_stats(self,id,value):
            p = self.current_player()
            p.player_stats[id]=value

    def get_player_stats(self,id):
            p = self.current_player()
            return p.player_stats[id]
    
    def extra_ball(self):
        p = self.current_player()
        p.extra_balls += 1
    
    def setup_ball_search(self):
        # No special handlers in starter game.
        special_handler_modes = []
        self.ball_search = procgame.modes.BallSearch(self, priority=100, \
                                                     countdown_time=10, coils=self.ballsearch_coils, \
                                                     reset_switches=self.ballsearch_resetSwitches, \
                                                     stop_switches=self.ballsearch_stopSwitches, \
                                                     special_handler_modes=special_handler_modes)