Exemple #1
0
    def step_begin(self):
        self.ask_for_app_launch(message_id='LAUNCH')

        highest_level = self._app.get_js_property('highestAchievedLevel')

        # @fixme: This is a workaround to https://phabricator.endlessm.com/T29180
        # Sometimes Sidetrack app takes lot of time to start and get_js_property times out.
        if highest_level is None:
            logger.debug('Quest %s: Cannot get \'highestAchievedLevel\' for %s. Trying again...',
                         self.get_id(), self.app.dbus_name)
            return self.step_begin

        # This is a workaround to wait until the sidetrack app reads the
        # information from the game state service. In the future we should add
        # a signal or a property to the toyapps and move this wait to a new
        # method in Quest
        current_level = int(self._app.get_js_property('currentLevel'))
        while current_level == 0:
            logger.debug('Current level is 0, waiting for sidetrack to load data')
            self.pause(1)
            current_level = self._app.get_js_property('currentLevel')

        if highest_level > 36:
            self._app.set_js_property('highestAchievedLevel', ('u', 28))
        self._app.set_js_property('availableLevels', ('u', 36))
        self._reset_confirmed_messages()
        return self.step_play_level, False
Exemple #2
0
        def _props_changed_cb(_proxy, _owner, signal_name, params, props,
                              js_property_changed_cb, *args):
            if signal_name != 'ObjectNotify':
                return

            _notify_obj, notify_prop, value = params.unpack()

            if notify_prop in props and value != values[notify_prop]:
                logger.debug('Property %s changed from %s to %s', notify_prop,
                             values[notify_prop], value)
                values[notify_prop] = value
                js_property_changed_cb(*args)
Exemple #3
0
    def play(self, name):
        if self._loading:
            self._animation_after_load = name
            return

        new_animation = self._animations.get(name)
        current_animation = self.get_current_animation()

        if new_animation is None:
            logger.debug(
                'Animation \'%s\' not found. Current animation will be cleared.',
                name)
            AnimationSystem.remove_animation(id(self))
            self._target_image.clear()
            return

        if current_animation is not None and new_animation != current_animation:
            current_animation.reset()

        AnimationSystem.animate(id(self), new_animation)
Exemple #4
0
    def step_begin(self):
        if not self.app.is_installed():
            self.wait_confirm('NOTINSTALLED', confirm_label='Got it!')
            return self.step_abort

        self.ask_for_app_launch(message_id='LAUNCH_ADA')

        highest_achieved_level = self.app.get_js_property(
            'highestAchievedLevel')

        # @fixme: This is a workaround to https://phabricator.endlessm.com/T29180
        # Sometimes Sidetrack app takes lot of time to start and get_js_property times out.
        if highest_achieved_level is None:
            logger.debug(
                'Quest %s: Cannot get \'highestAchievedLevel\' for %s. Trying again...',
                self.get_id(), self.app.dbus_name)
            return self.step_begin

        self.app.set_js_property('availableLevels', ('u', self.MAX_LEVEL))
        self._reset_confirmed_messages()
        return self.step_play_level, False
Exemple #5
0
    def step_play_level(self, level_changed, level_succeed=None):
        current_level = self.app.get_js_property('currentLevel')

        # @fixme: This is a workaround to https://phabricator.endlessm.com/T29180
        # Sometimes Sidetrack app takes lot of time to start and get_js_property times out.
        if current_level is None:
            logger.debug(
                'Quest %s: Cannot get \'current_level\' for %s. Trying again...',
                self.get_id(), self.app.dbus_name)
            return self.step_play_level, level_changed, level_succeed

        message_id = None
        # messages_to_confirm = []
        # hint_message = None
        if current_level == 1:
            if level_succeed is False:
                message_id = self._get_unconfirmed_message(['DIED_RESTART'])
            else:
                message_id = self._get_unconfirmed_message([
                    'ASSIGNMENT_ADA', 'ASSIGNMENT_RILEY', 'ASSIGNMENT_FABER',
                    'ASSIGNMENT_STUDENT', 'ASSIGNMENT_ESTELLE',
                    'ASSIGNMENT_SANIEL', 'MANUAL1_INTRO'
                ])
                if message_id is None:
                    self.show_hints_message('MANUAL1')
        elif current_level == 2:
            message_id = self._get_unconfirmed_message(['MANUAL2'])
        elif current_level == 3:
            message_id = self._get_unconfirmed_message(['MANUAL3'])
        elif current_level == 4:
            message_id = self._get_unconfirmed_message(['MANUAL4', 'MANUAL5'])
        elif current_level == 6:
            message_id = self._get_unconfirmed_message(['MANUAL6', 'MANUAL7'])
        elif current_level == 7:
            message_id = self._get_unconfirmed_message(['ROBOTS1', 'ROBOTS2'])
            if message_id is None:
                self.show_hints_message('ROBOTS3')
        elif current_level == 10:
            message_id = self._get_unconfirmed_message(['MOREROBOTS'])
        elif current_level == 13:
            message_id = self._get_unconfirmed_message(['AUTO1'])
        elif current_level == 14:
            if not self.cutscene_played:
                # felix destroys the controls here
                self.app.set_js_property('controlsCutscene', ('b', True))
                self.pause(1)
                self.wait_for_app_js_props_changed(self.app,
                                                   ['controlsCutscene'],
                                                   timeout=20)
                self.cutscene_played = True
            message_id = self._get_unconfirmed_message([
                'AUTO1_FELIX',
                'AUTO1_FABER',
                'AUTO1_ADA',
                'AUTO1_PLOT',
                'AUTO1_ESTELLE_REACTION',
            ])
            if message_id is None:
                self.show_hints_message('AUTO1_RILEY')
        elif current_level == 15:
            message_id = self._get_unconfirmed_message(['AUTO2_INTRO'])
            if message_id is None:
                self.show_hints_message('AUTO2')
        elif current_level == 16:
            if level_changed:
                self.show_hints_message('AUTO3')
            elif level_succeed is False:
                message_id = self._get_unconfirmed_message(['AUTO3_FAILURE'])
        elif current_level == 17:
            message_id = self._get_unconfirmed_message(
                ['AUTO3_SUCCESS', 'AUTO4_SANIEL', 'AUTO4_RILEY'])
        elif current_level == 18:
            message_id = self._get_unconfirmed_message(
                ['ONEJUMP_PRE', 'ONEJUMP'])
            if message_id is None:
                self.show_hints_message('ONEJUMP_ADA')
        elif current_level == 19:
            message_id = self._get_unconfirmed_message(['ONEFORWARD'])
            if message_id is None:
                self.show_hints_message('ONEFORWARD_ADA')
        elif current_level == 20:
            message_id = self._get_unconfirmed_message(['SLIDING'])
        elif current_level == 21:
            message_id = self._get_unconfirmed_message(['WASTEJUMPS'])
        elif current_level == 22:
            message_id = self._get_unconfirmed_message(
                ['DRAMA_ADA', 'DRAMA_FABER'])
        elif current_level == self.MAX_LEVEL:
            return self.last_level
        else:
            self.dismiss_message()

        actions = [
            self.connect_app_js_props_changes(self.app,
                                              ['currentLevel', 'success'])
        ]
        if message_id is not None:
            actions.append(self.show_confirm_message(message_id))

        self.wait_for_one(actions)

        level_changed = False
        level_succeed = None
        if self.confirmed_step():
            self.confirmed_messages.append(message_id)
        elif current_level != self.app.get_js_property('currentLevel', 1):
            level_changed = True
            self._reset_confirmed_messages()
        else:
            # Current level hasn't changed, so either the player
            # completed the level or died:
            level_succeed = self.app.get_js_property('success', False)

        return self.step_play_level, level_changed, level_succeed