Ejemplo n.º 1
0
def checkpoint_save(checkpoint_name=''):
    if player1.health <= 0:
        print_red('You have reached a checkpoint and currently have no more health! You have lost the game!\n', 1)
        restart()
    merchant()
    print_green('A checkpoint has been reached...\n', .5)
    player1.check_point = checkpoint_name
    game_data.save_game(player1)  # Sends player1 info to save file
    print_green(f'Current Health: {player1.health}\n', 1)
    print_green(f'Current Balance: {player1.balance}\n', 1)
    print_health(player1.difficulty, f'Current Difficulty: {player1.difficulty.name}\n', 1)
Ejemplo n.º 2
0
def merchant():
    """
    Handles the merchant who randomly shows up in-game. This function allows the player to purchase weapons.
    """

    if player1.health <= 0:  # Basic check to make sure the game is not continuing if the player has no more health left
        print_red('You currently have no health left...\n', 1)
        bad_ending()

    if randint(1, 7) != 3:  # random chance for player to interact with merchant
        return

    sounds.good_luck()
    print_green('Whoosh! The lucky merchant has appeared in-front of you...\n', 1)
    if player1.balance <= 0:
        print_yellow('Uh-Oh! You do not have enough money to buy anything... keep playing to acquire more money!\n', 1)
        return

    choices = ['b', 'buy', 'y', 'yes', 's', 'skip', 'n', 'no']
    choice_options = ['Would you like to buy from the merchant or skip past the merchant (buy / skip): ']
    choice = _player_choice(choices, choice_options)

    if choice in ['b', 'buy', 'y', 'yes']:
        buy_item = ''
        weapon_choices = [f"({k}) {v[0]} ({v[1]} Dollars)" for k,v in player1.weapon_dict.items() if k != '0']
        while buy_item != EXIT_MERCHANT_MENU:
            print_green(f'Balance: {player1.balance}\n', 1)
            choice_options = ['--- Merchants inventory ---']
            choice_options.extend(weapon_choices)
            choice_options.extend([f'({EXIT_MERCHANT_MENU}) Exit The Merchant Shop\n',
                                   'What would you like to buy: ',
                                  ])
            buy_item = _player_choice([str(x) for x in range(1, 8)], choice_options)
            
            if user_item_buy == EXIT_MERCHANT_MENU:
                print_s('The merchant bids you a farewell and good luck!\n', 1)
                break
            elif player1.weapon_dict[buy_item][2]:
                sounds.bad_luck()
                print_yellow(f'{player1.weapon_dict[buy_item][0]} has already been purchased!\n', 1)
            elif player1.balance >= player1.weapon_dict[buy_item][1]:
                sounds.merchant_purchase_sound()
                player1.balance -= player1.weapon_dict[buy_item][1]
                player1.weapon_dict[buy_item][2] = True
                print_green(f'{player1.weapon_dict[buy_item][1]} has been purchased!\n', 1)
                if buy_item == '6':
                    print_green(
                    'As the Merchant hands you his own crafted spell, he tells you that you now wield true pain to foes whilst providing restoration to thine self.\n',
                    2.5)
    elif choice in ['s', 'skip', 'n', 'no']:
        print_s('The merchant has been skipped but can be brought back later...\n', 1)
Ejemplo n.º 3
0
def game():
    if game_data.file_exists:
        sounds.difficulty_select_sound()
        print_green('Difficulty screen skipped due to saved data already existing...\n', 1)
        choice_options = ['Would you like to start a new game or continue with your saved data (new / continue): ']
        choice = _player_choice(['n', 'new', 'c', 'continue'], choice_options)

        if choice in ['n', 'new']:
            difficulty()
            player1.balance = 0
            for k,v in player1.weapon_dict.items():
                v[2] = False
            player1.check_point = ''
            checkpoint_save()
        elif choice in ['c', 'continue']:
            print_green('Continuing game...\n', 1)
            go_to_checkpoint()
    else:
        difficulty()

    if player1.health <= 0:
        print_red('You currently have no health left...\n', 1)
        bad_ending()

    print('You have ended up in a small local town called Hinesville. This old town contains a population of about\n'
          'only 6000 people and holds only a Gas Station, Diner, and a Park. The current year is 1999 and you\n'
          'cannot wait to finally get on with your life and move somewhere more alive\n')
    sleep(2)
    choices = [str(x) for x in range(1, 4)]
    choices.append('unlock_all_cheat')
    choice_options = [
        'While sitting down in the living room of your house, you can either (1) Look around (2) Walk outside (3) Travel down the hidden door in the floor: ']
    choice = _player_choice(choices, choice_options)

    if choice == '1':
        print('You have decided to look around your apartment and decide to grab a concealed knife that you legally\n'
              'are allowed to carry in public areas just in case anything happens...\n')
        sleep(1)
        player1.weapon_dict['0'][2] = True
        outside_area()
    elif choice == '2':
        sleep(1)
        outside_area()
    elif choice == '3':
        sleep(1)
        basement_area()
    elif choice == 'unlock_all_cheat':
        unlock_all_cheat()
        outside_area()
Ejemplo n.º 4
0
def user_attack():
    """
This function is called whenever the players gets into a fight with zombies or humans. The logic is ordered in a way
so that the stronger weapon is used first instead of weaker weapons when attacking enemies.
    """
    choice_names = [v[0] for k,v in player1.weapon_dict.items() if v[2]]
    if len(choice_names) == 0:  # no choice for them to make
        player1.health = 0
        print_red(
            'Due to not having any available weapons on you... You try to defend yourself...\nThe zombie overpowers you! Game Over!\n',
            3)
        bad_ending()
        return

    choices = [str(c + 1) for c,_ in enumerate(choice_names)]
    choice_options = [f'({c + 1}) {v}' for c,v in enumerate(choice_names)]
    choice_options.extend(['\nWhich item would you like to use: '])
    choice = _player_choice(choices, choice_options)

    choice_idx = str(deep_index(list(player1.weapon_dict.values()), choice_names[int(choice)]) - 1)

    if choice_idx == '6':
        print_green(
            f'You have used the Merchants Strange Spell and defeated the zombies without losing any health! Through the power of the Strange Spell, you gain {player1.get_health(10, 30)} health through its restoration casting!\n',
            3.5)
    elif choice_idx == '5':
        print_green('You have used the Rocket Missile Launcher and defeated the zombies without losing any health!\n',
                    2)
    elif choice_idx == '4':
        print_green(
            f'You have used the Barrett Sniper Rifle and defeated the zombies with only losing {player1.lose_health(3, 10)} health!\n',
            2)
    elif choice_idx == '3':
        print_green(
            f'You have used the AK-47 Rifle and defeated the zombies with only losing {player1.lose_health(10, 20)} health!\n',
            2)
    elif choice_idx == '2':
        print_green(
            f'You have used the Beretta Pistol and defeated the zombies with only losing {player1.lose_health(20, 30)} health!\n',
            2)
    elif choice_idx == '1':
        print_yellow(
            f'You have used the Spiked Baseball Bat and defeated the zombies with losing {player1.lose_health(30, 40)} health!\n',
            2)
    elif choice_idx == '0':
        print_red(
            f'You have used the Starting Knife and defeated the zombies with losing {player1.lose_health(40, 45)} health!\n',
            2)
Ejemplo n.º 5
0
def parkview_area():
    sounds.horror_sound_effects()
    print_s('You have entered the parkview area...\n', 1)
    checkpoint_save('4')
    sounds.parkview_entrance()
    sleep(2.5)
    print_s('Upon arriving to the parkview area, you are still incapable of seeing very much ahead of yourself...\n',
            1.5)
    choice_options = ['You have the choice to either (1) Explore the Parkview Area (2) Explore onto the Broken Roads: ']
    user_choice = _player_choice([str(x) for x in range(1, 3)], choice_options)

    if user_choice == '1':
        print('Upon searching the Parkview Area... You come across a deranged man who is killing zombies left and '
              'right...\n')
        sleep(2)
        choice_options = ['You have the choice to either (1) Help the man (2) Kill the man: ']
        user_choice = _player_choice([str(x) for x in range(1, 3)], choice_options)

        if user_choice == '1':
            sounds.horror_sound_effects()
            print('In attempts of helping the man, he screams get the hell away from me, I will blow your head off! '
                  'You now prepare to fight him off!\n')
            sleep(2.5)
        elif user_choice == '2':
            sounds.bad_luck()
        # attack ensues - same for both options - only difference is the lead up to it
        user_attack()
        if player1.health > 0:
            print_green(
                f'You have successfully killed the man! Upon searching his body, you find a total of ${player1.get_money()}!\n',
                1)
            checkpoint_save('5')
            sounds.horror_sound_effects()
            print_s('You now decide to leave the Parkview Area...\n', 1.5)
            broken_roads_area()
        else:
            sounds.bad_luck()
            print_red('The man has killed you and zombies start to feast on your dead decaying flesh...\n', 2)
            bad_ending()
    elif user_choice == '2':
        broken_roads_area()
Ejemplo n.º 6
0
def diner_area():
    sounds.horror_sound_effects()
    print_s('You have entered the local Diner...\n', 1)
    checkpoint_save('2')
    choice_options = [
        'You have the choice to either (1) Search inside the Diner Restaurant Area (2) head towards the Parkview Area: ']
    user_choice = _player_choice([str(x) for x in range(1, 3)], choice_options)

    if user_choice == '1':
        sounds.good_luck()
        print(
            f'After finishing up your entire search of the diner, you find a total of {player1.get_money()} dollars and ',
            f'you refresh up on some food and gain a total of {player1.get_health(5, 15)} health!\n')
        sleep(3)
        print('You also manage to find a bloody photograph on the ground and upon looking at the image, you see a '
              'familiar face...')
        print('You see the face of the man you met earlier at the local Gas Station taking a group '
              'familiar face... \nYou see the face of the man you met earlier at the local Gas Station taking a group '
              'family picture!\n')
        sleep(3)
        sounds.horror_sound_effects()
        print('Since you are finished exploring and searching the diner area, you proceed on your path to the '
              'parkview area...\n')
        sleep(3.5)
        parkview_area()
    elif user_choice == '2':
        sounds.zombie_attack_outside()
        print_red(
            'Upon leaving the diner area, you come across a group of about 5 zombies heading directly towards you!\n',
            1.5)
        user_attack()

        if player1.health > 0:
            print_green(
                'You have successfully defended off the zombies outside the local Diner... You will now head over to the Parkview Area\n',
                2)
            parkview_area()

        else:
            bad_ending()
Ejemplo n.º 7
0
def difficulty():
    print_green('(1) Easy\n')
    print_yellow('(2) Medium\n')
    print_red('(3) Hardcore\n')
    choices = [str(x) for x in range(1, 4)]
    choices.append('unlock_all_cheat')
    choice_options = ['Select a difficulty: ']
    try:
        player1.difficulty = Difficulty(int(_player_choice(choices, choice_options)))
    except:
        player1.difficulty = Difficulty(0)  # unlock_all_cheat 

    sounds.difficulty_select_sound()
    if player1.difficulty == Difficulty(1):
        player1.health = 200
    elif player1.difficulty == Difficulty(2):
        player1.health = 100
    elif player1.difficulty == Difficulty(3):
        player1.health = 50
    elif player1.difficulty == Difficulty(0):
        unlock_all_cheat()
    print_health(player1.difficulty,
                 f'{player1.difficulty.name} mode has been selected, you will begin with only {player1.health} health.\n',
                 1)
Ejemplo n.º 8
0
def bad_ending():
    sounds.bad_ending()
    print_red('You have died and not reached the end of the horrors...\n', 1)
    checkpoint_save('8')
    restart()