Exemplo n.º 1
0
 def get_winner(self):
     winner = None
     for player in self.player_list:
         if player.is_alive() and winner == None:
             winner = player
         elif player.is_alive() and winner:
             return None
     return winner
    def get_living_players(self):
        living = list()

        for player in self.players:
            if player.is_alive():
                living.append(player)

        return living
Exemplo n.º 3
0
def play():
    print("Escape from Cave Terror!")
    print("version 1.1.1")
    world.parse_world_dsl()
    player = Player()
    while player.is_alive() and not player.victory:
        room = world.tile_at(player.x, player.y)
        print(room.intro_text())
        room.modify_player(player)
        if player.is_alive() and not player.victory:
            choose_action(room, player)
        elif not player.is_alive():
            print("You have died! R.I.P")

    actions = OrderedDict()
    if player.inventory:
        actions['i'] = player.print_inventory
        actions['I'] = player.print_inventory
        print("i: View inventory")
Exemplo n.º 4
0
def play():
    world.load_tiles()
    player = Player()
    #These lines load the starting room and display the text
    room = world.tile_exists(player.location_x, player.location_y)
    print(room.intro_text())
    while player.is_alive() and not player.victory:
        room = world.tile_exists(player.location_x, player.location_y)
        room.modify_player(player)
        # Check again since the room could have changed the player's state
        if player.is_alive() and not player.victory:
            print("Choose an action:\n")
            available_actions = room.available_actions()
            for action in available_actions:
                print(action)
            action_input = input('Action: ')
            for action in available_actions:
                if action_input == action.hotkey:
                    player.do_action(action, **action.kwargs)
                    break
Exemplo n.º 5
0
def do_command(command):
    """
    Performs the command.
    :param command: str, single character representing a user's command
    :return: bool, True if game should keep going, False if user wants to quit
    """
    global last_message  # DO NOT REMOVE
    if player.is_alive():
        # These commands can only be done if the player is alive:
        if command == KEYBOARD_UP:
            player.set_symbol(player.LOOKING_UP)
            if player.is_open_space(player.x, player.y - 1):
                player.y -= 1
        elif command == KEYBOARD_DOWN:
            player.set_symbol(player.LOOKING_DOWN)
            if player.is_open_space(player.x, player.y + 1):
                player.y += 1
        elif command == KEYBOARD_LEFT:
            player.set_symbol(player.LOOKING_LEFT)
            if player.is_open_space(player.x - 1, player.y):
                player.x -= 1
        elif command == KEYBOARD_RIGHT:
            player.set_symbol(player.LOOKING_RIGHT)
            if player.is_open_space(player.x + 1, player.y):
                player.x += 1
        elif command == KEYBOARD_LOOK:
            do_look(player.x, player.y, player.get_symbol())
        elif command == KEYBOARD_TAKE:
            do_take(player.x, player.y, player.get_symbol())
        elif command == KEYBOARD_USE:
            do_use(player.x, player.y, player.get_symbol())

    # Okay to do alive or dead:
    if command == KEYBOARD_QUIT:
        return False
    elif command == KEYBOARD_LOAD_GAME:
        # TODO: Mark the werewolf's turn to be skipped.
        do_load_game()
    elif command == KEYBOARD_SAVE_GAME:
        # TODO: Mark the werewolf's turn to be skipped.
        do_save_game()
    elif command == KEYBOARD_SHOW_HELP:
        # TODO: Mark the werewolf's turn to be skipped.
        do_show_help()

    # Handle the werewolf after doing user command.
    werewolf.do_next_move(player.x, player.y)
    do_check_for_player_damage()
    return True
def lobby():
    set_font("Courier New", 20, 20)
    r = random.randint(1, 2)
    if r == 1:
        play_sound("Sounds\Dalarna.mp3")
    else:
        play_sound("Sounds\Halland.mp3")
    world.world_map = []
    world.world_dsl = world.lobby_dsl
    pyautogui.press('f11')
    time.sleep(0.1)
    pyautogui.press('f11')
    os.system("cls")
    print("Location: Camp")
    world.parse_world_dsl()
    player = Player()
    player.victory = False
    while player.is_alive() and not player.victory:
        room = world.tile_at(player.x, player.y)
        print(room.intro_text())
        print("")
        room.modify_player(player)
        if player.is_alive() and not player.victory:
            choose_action(room, player)
Exemplo n.º 7
0
                  location.description)

            # Initiate attack cycle if enemy is present and alive.
            if isinstance(location.enemy,
                          enemy.Enemy) and location.enemy.is_alive():
                input("\nYou see something out of the corner of your eye...")
                os.system("cls")
                player.attack_cycle(location.enemy)

# Check for victory.
            if location == room17:
                if player.victory(location) == True:
                    game_choice = "2"
                    break
# Check for defeat.
            if not player.is_alive():
                player.game_over()
                game_choice = "2"
                break

# Loot and inventory menu.
            player.inv_loc_menu(location)
            # Next destination choice.
            print("\nCurrent location: ", location.name)
            print("\nCurrent HP:", player.hp)
            print("\nThe areas you can go from here: \n")
            choice = -1
            lim = len(worldmap[location])
            while choice not in range(1, lim + 1):
                for (i, place) in enumerate(worldmap[location]):
                    print("\n", i + 1, place.name)
def play():
    tic = time.perf_counter()
    set_font("Courier New", 20, 20)
    play_sound("Sounds\SquidCoast.mp3")
    world.world_map = []
    world.world_dsl = world.squidcoast_dsl
    os.system("cls")
    print("Objective: Escape from The Dungeons!")
    world.parse_world_dsl()
    player = Player()
    while player.is_alive() and not player.victory:
        room = world.tile_at(player.x, player.y)
        print(room.intro_text())
        print("")
        room.modify_player(player)
        if player.is_alive() and not player.victory:
            choose_action(room, player)
        elif not player.is_alive():
            toc = time.perf_counter()
            intro_title = open('Art\\lose.txt', 'r').read() + str(
                "\n\nGame won in {} seconds".format(math.ceil(toc - tic)))
            original_color_r = 0
            original_color_g = 0
            original_color_b = 0
            print('\033[38;2;%d;%d;%dm' %
                  (original_color_r, original_color_g, original_color_b) +
                  intro_title)
            for i in range(30, 51):
                print('\033[38;2;%d;%d;%dm' %
                      (original_color_r, original_color_g, original_color_b) +
                      intro_title)
                time.sleep(.02)
                os.system('cls')
                original_color_r = original_color_r + 10
                original_color_g = original_color_g + 5
                original_color_b = original_color_b
            os.system('cls')
            original_color_r = 255
            original_color_g = 119
            original_color_b = 0
            print('\033[38;2;%d;%d;%dm' %
                  (original_color_r, original_color_g, original_color_b) +
                  intro_title)
            time.sleep(9)
            os.system('cls')
            for i in range(30, 51):
                print('\033[38;2;%d;%d;%dm' %
                      (original_color_r, original_color_g, original_color_b) +
                      intro_title)
                time.sleep(.02)
                os.system('cls')
                original_color_r = original_color_r - 10
                original_color_g = original_color_g - 5
                original_color_b = original_color_b
            time.sleep(.5)
            travel_lobby()
        elif player.victory:
            play_sound("Sounds\Finally.mp3")
            toc = time.perf_counter()
            intro_title = open('Art\\win.txt', 'r').read() + str(
                "\n\nGame won in {} seconds".format(math.ceil(toc - tic)))
            original_color_r = 0
            original_color_g = 0
            original_color_b = 0
            print('\033[38;2;%d;%d;%dm' %
                  (original_color_r, original_color_g, original_color_b) +
                  intro_title)
            for i in range(30, 51):
                print('\033[38;2;%d;%d;%dm' %
                      (original_color_r, original_color_g, original_color_b) +
                      intro_title)
                time.sleep(.02)
                os.system('cls')
                original_color_r = original_color_r + 10
                original_color_g = original_color_g + 5
                original_color_b = original_color_b
            os.system('cls')
            original_color_r = 255
            original_color_g = 119
            original_color_b = 0
            print('\033[38;2;%d;%d;%dm' %
                  (original_color_r, original_color_g, original_color_b) +
                  intro_title)
            time.sleep(9)
            os.system('cls')
            for i in range(30, 51):
                print('\033[38;2;%d;%d;%dm' %
                      (original_color_r, original_color_g, original_color_b) +
                      intro_title)
                time.sleep(.02)
                os.system('cls')
                original_color_r = original_color_r - 10
                original_color_g = original_color_g - 5
                original_color_b = original_color_b
            time.sleep(.5)
            travel_lobby()