コード例 #1
0
 def intro() -> DecisionScene:
     return DecisionScene(
         'Choose scene arc.', {
             '1': DecisionOption('Swamp', start_scene),
             '2': DecisionOption('Space trip',
                                 space_arc.SpaceArc().intro)
         })
コード例 #2
0
ファイル: space_arc.py プロジェクト: mick-warehime/sixth_corp
    def cryo_chambers(self) -> DecisionScene:
        prompt = ('You enter the cryo-chambers, where all human personnel are '
                  'stored. As there are only {} hours left until landing, they '
                  'are in the process of being reanimated. Status monitors '
                  'indicate that some malfunction may be in progress, and that '
                  'the humans may expire due to lack of oxygen. A medical robot'
                  ' administrators look to be frantically administering some '
                  'fixes.').format(self._time_until_landing)

        check_failure = transition_to(
            self.medical_bot_combat,
            'You fail, causing the medical bots to attack.')

        # choices
        hack = DecisionOption('Hack the systems so that only the rival factions'
                              ' expire, and make it look like the medical robot'
                              'was at fault.', check_failure,
                              self._decrement_time_left)

        help = DecisionOption('Provide technical support to the medical robot.'
                              ' All human life is precious.', check_failure,
                              self._decrement_time_left)
        disable = DecisionOption('Attempt to disable the medical robot to '
                                 'access its encryption key.',
                                 check_failure, self._decrement_time_left)

        return DecisionScene(prompt, {'1': hack, '2': help, '3': disable})
コード例 #3
0
def start_scene() -> DecisionScene:
    options = {
        '1': DecisionOption('Go in the swamp.', swamp_scene),
        '2': DecisionOption('COMBAT!', example_combat_scene)
    }

    main_text = (
        'You are walking down the path to the city. You pass by a decaying sign'
        ' pointing in the direction of an overgrown path. The sign says '
        '"DANGER: Rogue drones in swamp".')
    return DecisionScene(main_text, options)
コード例 #4
0
def second_scene() -> DecisionScene:
    player = get_player()
    main_text = ('Player HP: {}. Player Max HP: {}.'.format(
        player.status.get_attribute(Attributes.HEALTH),
        player.status.get_attribute(Attributes.MAX_HEALTH)))

    options = {
        '1':
        DecisionOption('Gain 1 HP', second_scene,
                       partial(increment_attribute, Attributes.HEALTH, 1)),
        '2':
        DecisionOption('Lose 1 HP', second_scene,
                       partial(increment_attribute, Attributes.HEALTH, -1))
    }
    return DecisionScene(main_text, options)
コード例 #5
0
    def success(loot_scene: bool = True) -> Scene:
        load_loot_scene = partial(InventoryScene, partial(success, False),
                                  _mini_laser)
        gain_3 = partial(increment_attribute, Attributes.CREDITS, 3)

        if loot_scene:
            return DecisionScene(
                'After deactivating the drone, you pick up 3 credits and '
                'dismantle it.', {
                    '1': DecisionOption('Loot the body.', load_loot_scene),
                    '2': DecisionOption('Back to start.', start_scene, gain_3)
                })
        return DecisionScene(
            'After deactivating the drone, you pick up 3 credits and '
            'dismantle it.',
            {'1': DecisionOption('Back to start.', start_scene, gain_3)})
コード例 #6
0
ファイル: space_arc.py プロジェクト: mick-warehime/sixth_corp
    def staging_area(self) -> DecisionScene:
        """The main scene where player chooses different random scenes.

        Game history and randomness is used to provide choices.
        """

        prompt = ('You enter the staging area. The wall monitor indicates that '
                  'there are {} hours until the ship lands on Mars.')

        cryo = DecisionOption('The cryo-chambers look promising.',
                              self.cryo_chambers)
        scene_2 = DecisionOption('Filler for scene 2',
                                 self.scene_2)

        return DecisionScene(prompt.format(self._time_until_landing), {
            '1': cryo, '2': scene_2})
コード例 #7
0
def test_making_choices_removes_listener():
    game = Game()  # noqa: F841

    # scene_0 (Decision) -> combat scene

    options_0 = {
        's': DecisionOption('load next scene', combat_scene.CombatScene)
    }
    scene_0 = DecisionScene('first scene', options_0)

    event_utils.post_scene_change(scene_0)
    ctl = _get_active_controller()
    assert isinstance(ctl, DecisionSceneController)
    # we must remove references otherwise EventManager will keep this listener
    del ctl
    del scene_0
    event_utils.simulate_key_press('s')

    # The scene machine only changes scenes on a tick
    EventManager.post(BasicEvents.TICK)

    assert not any(
        isinstance(l, DecisionScene) for l in EventManager.listeners)
    assert not any(
        isinstance(l, DecisionSceneController) for l in EventManager.listeners)

    ctl = _get_active_controller()
    assert isinstance(ctl, CombatSceneController)
    assert any(
        isinstance(l, combat_scene.CombatScene)
        for l in EventManager.listeners)
コード例 #8
0
def loading_scene() -> DecisionScene:
    # intro scene
    def intro() -> DecisionScene:
        return DecisionScene(
            'Choose scene arc.', {
                '1': DecisionOption('Swamp', start_scene),
                '2': DecisionOption('Space trip',
                                    space_arc.SpaceArc().intro)
            })

    options = {
        's': DecisionOption('Start Game', intro),
        'x': DecisionOption('Settings', intro)
    }
    return DecisionScene('6TH Corp',
                         options,
                         background_image=BackgroundImages.LOADING.path,
                         inventory_available=False,
                         centered_prompt=True,
                         centered_choices=True)
コード例 #9
0
def swamp_scene() -> DecisionScene:
    main_text = (
        'You walk into the swamp. The foliage overhead blocks most of'
        ' the sunlight. Flies and mosquitoes buzz near your ears. Your'
        ' olfactory sensors detect the smell of sulfur. Ahead you see '
        'the curving form of a rogue drone. It is currently in '
        'hibernation mode.')

    def success(loot_scene: bool = True) -> Scene:
        load_loot_scene = partial(InventoryScene, partial(success, False),
                                  _mini_laser)
        gain_3 = partial(increment_attribute, Attributes.CREDITS, 3)

        if loot_scene:
            return DecisionScene(
                'After deactivating the drone, you pick up 3 credits and '
                'dismantle it.', {
                    '1': DecisionOption('Loot the body.', load_loot_scene),
                    '2': DecisionOption('Back to start.', start_scene, gain_3)
                })
        return DecisionScene(
            'After deactivating the drone, you pick up 3 credits and '
            'dismantle it.',
            {'1': DecisionOption('Back to start.', start_scene, gain_3)})

    if Difficulty.EASY.sample_success(Skills.STEALTH):
        deactivate_outcome: SceneConstructor = success
    else:
        deactivate_outcome = transition_to(
            example_combat_scene, 'The drone awakens. Prepare to fight!')

    options = {
        '1': DecisionOption('Continue walking.', second_scene),
        '2': DecisionOption('Attempt to deactivate the drone.',
                            deactivate_outcome),
        '3': DecisionOption('Attack the drone', example_combat_scene)
    }
    return DecisionScene(main_text, options)
コード例 #10
0
ファイル: space_arc.py プロジェクト: mick-warehime/sixth_corp
 def intro(self) -> DecisionScene:
     chars = string.ascii_uppercase + string.digits
     serial_number = ''.join(random.choices(chars, k=10))
     serial_number = serial_number[:4] + '-' + serial_number[4:]
     serial_number = serial_number[:8] + '-' + serial_number[8:]
     prompt = (
         'The overhead speaker emits: "Utility Robot Mk II, serial number '
         '{}, exit hibernation mode and report to the staging area at '
         'maximum speed." You slide out of your charging pod. Your '
         'gryoscopes indicate that the "Mars or Bust" colony ship is still'
         ' in low gravity mode, so it has not yet initiated its landing '
         'sequence. You look up the content of your current mission in '
         'your long-term memory bank - help your current employer, the XXX'
         ' faction, dominate the new colony at all costs!').format(
         serial_number)
     return DecisionScene(prompt,
                          {'1': DecisionOption('Continue to staging area.',
                                               self.staging_area)})
コード例 #11
0
def game_over_scene() -> DecisionScene:
    prompt = 'Game over. You loose.'
    options = {'1': DecisionOption('Play again.', loading_scene, restart_game)}
    return DecisionScene(prompt, options)
コード例 #12
0
ファイル: space_arc.py プロジェクト: mick-warehime/sixth_corp
 def scene_2(self) -> DecisionScene:
     return DecisionScene('Something with space unicorns',
                          {'1': DecisionOption('Back to staging area',
                                               self.staging_area,
                                               self._decrement_time_left)})
コード例 #13
0
 def start_scene() -> DecisionScene:
     loot_scene = partial(InventoryScene, start_scene, lambda: ground_mods)
     return DecisionScene('dummy scene for testing purposes',
                          {'1': DecisionOption('Loot', loot_scene)})