コード例 #1
0
def main():
    util.clear_screen()
    player = create_player()
    player_inv = create_player_inventory()
    sword = create_sword()
    monster = create_monster()

    engine.get_player_stats(player)
    util.clear_screen()

    is_running = True
    while is_running:
        board1 = engine.create_board(gate1=(16, 29), gate2=(16, 0))
        everyone_in_room1 = [sword, monster,
                             player]  # player should be the last one(!)
        coordinates_who_is_alive = collect_coordinates_who_is_alive(
            everyone_in_room1)
        # print(coordinates_who_is_alive) # This line is for test phase(!)
        engine.put_everyone_on_board(board1, coordinates_who_is_alive)
        ui.display_player_info_and_control_info(player)
        ui.display_board(board1)
        key = util.key_pressed()
        if key == 'q':
            is_running = False
        elif key == 'I':
            x = ""
            while x == "":
                ui.display_inv(player_inv)
                x = util.key_pressed()
        else:
            engine.refresh_player_coord(key, player, player_inv, board1,
                                        everyone_in_room1)
        util.clear_screen()
コード例 #2
0
ファイル: ui.py プロジェクト: mcjczapiewski/roguelike_game
def display_fight(fight_text, enemy, quit_possible=False):
    """
    displayes fight screen with fight text
    fight_text: string
    enemy: dictionary
    quit_possible: True or False
    """
    util.clear_screen()
    print("\n\n\tKONFRONTACJA\n")
    display_stats_fight(interaction.characters["hero"])
    display_stats_fight(enemy)
    print(f"\t~ {fight_text}")
    if quit_possible:
        print(
            "\n\tOpcje"
            + "\n\t[1] Wciśnij Q aby przerwac konfrontacje"
            + "\n\t[2] Wciśnij I aby użyć posiadanych przedmiotów"
            + "\n\t[3] Wciśnij dowolny klawisz aby kontynuować walkę"
        )
        key = util.key_pressed().lower()
        if key == "q":
            return False
        else:
            return True
    else:
        print(
            "\n\tOpcje"
            + "\n\t[1] Wciśnij I aby użyć posiadanych przedmiotów"
            + "\n\t[2] Wciśnij dowolny klawisz aby kontynuować walkę"
        )
        key = util.key_pressed().lower()
        return True
コード例 #3
0
def main():
    util.clear_screen()
    ui.UI.display_by_line(ui.IMAGES_DIRECTORY + ui.OPENING_FILE)
    engine = game.Game()
    sounds.Music.play_music()

    board_created = False

    while not board_created:
        try:
            engine.create_new_board()
        except TypeError:
            engine.UI.display_error_info("expected number")
        else:
            board_created = True

    engine.is_running = True

    character_name = engine.player_character.ui.get_user_value(
        ui.UI.PROVIDE_NAME, "Keanu")
    engine.add_character_name(character_name)
    engine.initialize_player_class_and_race()

    util.key_pressed()
    engine.UI.display_help()

    while engine.is_running:
        engine.handle_action()

    engine.UI.display_goodbye()
コード例 #4
0
def win():
    util.clear_screen()
    help.logo("win")
    print(
        "You beat the boss of the duongeon and are able to go back to your old life"
    )
    print("Thank you for playing.")
    util.key_pressed()
コード例 #5
0
ファイル: main.py プロジェクト: hubbabubb/ThunderCry
def tutorial(board, player):
    print_method = 1
    engine.put_player_on_board(board, player)

    snake = LevelItem('🐍', 'snake', True, 13, 14)
    bag = LevelItem('💰', 'bag', True, 3, 7)
    letter = LevelItem('📜', 'letter', True, 8, 5)

    level = True
    top = "TUTORIAL"
    message = "Info"
    while level:
        util.clear_screen()
        print_level(board, message, player, print_method, top)
        key = util.key_pressed()

        # MAIN CONTROL
        if key == 'q':
            levels.quit_game()
        elif key == "d":
            player.move_right(board)
        elif key == "s":
            player.move_down(board)
        elif key == "w":
            player.move_up(board)
        elif key == "a":
            player.move_left(board)
        elif key == "f":
            if letter.is_close(board, player):
                print_message(('W, A, S, D = move', 'F = Use item/FIGHT', 'T = Open Tools Bar/Talk', '', 'Good luck on your way!'))
            elif snake.is_close(board, player) and snake.on:
                top = "You can battle later"
                snake.turn_off(board)
            elif bag.is_close(board, player) and bag.on:
                message = 'You got the key!'
                bag.turn_off(board)
                board[3][14] = '  '
                board[3][16] = '  '
        elif key == 't':
            top = 'Your tools will be here!'
            util.clear_screen()
            print_level(board, message, player, print_method, top)
            util.key_pressed()

        if letter.is_close(board, player):
            message = "Letters sometimes are useful. Press F to read!"
        elif snake.is_close(board, player) and snake.on:
            message = "This is an enemy. Press F to fight!"
        elif bag.is_close(board, player) and bag.on:
            message = "This, and similar bags will help you on your way! Press F to loot!"
        elif player.pos_x == 3 and player.pos_y == 14:
            message = "This is the exit"
        elif player.pos_x == 3 and player.pos_y == 15:
            player.level = 'Gender'
            return
        else:
            message = "Info"
            top = "TUTORIAL"
コード例 #6
0
ファイル: shop.py プロジェクト: Zsoltsrosi/Rougelike-RPG
def welcome(level):
    print(
        "welcome traveler in my shop. I am Akashi you can find my shops at every 5th level of the duongeon"
    )
    print("I see you come a long way and somehow got to the ", level,
          "th level with you outdated gear")
    print("But don't worry as I sell the best gear in the whole duongeon")
    print("Do you want to buy something?")
    util.key_pressed()
コード例 #7
0
def W_A_S_D(board, player):
    key = util.key_pressed()

    if key == "w" and board[player['position_x'] -
                            1][player['position_y']] != '🤑':
        player['position_x'] -= 1
        if verify_if_it_is_on_border(board, player) is False:
            board[player['position_x'] + 1][player['position_y']] = '  '
            put_player_on_board(board, player)
            util.clear_screen()
            print_board(board)
        elif verify_if_it_is_on_border(board, player) is True:
            player['position_x'] += 1
            key = util.key_pressed()

    elif key == "s" and board[player['position_x'] +
                              1][player['position_y']] != '🤑':
        player['position_x'] += 1

        if verify_if_it_is_on_border(board, player) is False:
            board[player['position_x'] - 1][player['position_y']] = '  '
            put_player_on_board(board, player)
            util.clear_screen()
            print_board(board)
        elif verify_if_it_is_on_border(board, player) is True:
            player['position_x'] -= 1
            key = util.key_pressed()

    elif key == "a" and board[player['position_x']][player['position_y'] -
                                                    1] != '🤑':
        player['position_y'] -= 1

        if verify_if_it_is_on_border(board, player) is False:
            board[player['position_x']][player['position_y'] + 1] = '  '
            put_player_on_board(board, player)
            util.clear_screen()
            print_board(board)
        elif verify_if_it_is_on_border(board, player) is True:
            player['position_y'] += 1
            key = util.key_pressed()

    elif key == "d" and board[player['position_x']][player['position_y'] +
                                                    1] != '🤑':
        player['position_y'] += 1

        if verify_if_it_is_on_border(board, player) is False:
            board[player['position_x']][player['position_y'] - 1] = '  '
            put_player_on_board(board, player)
            util.clear_screen()
            print_board(board)
        elif verify_if_it_is_on_border(board, player) is True:
            player['position_y'] -= 1
            key = util.key_pressed()
    # key = util.key_pressed()
    return board
コード例 #8
0
def open_text(txt, s=6, countdown_screen=False):
    if countdown_screen is False:
        print(txt)
        # wciśnięcie klawisza zamiast sleep,
        # żeby można było przejść szybciej dalej
        print("\n\n\nWciśnij dowolny klawisz, aby kontynuować...")
        util.key_pressed()
        util.clear_screen()
    if countdown_screen is True:
        for second in reversed(range(1, 6)):
            print(f"{first_line}Uważaj, grę zaczniesz za: \
\033[91m{second}\033[0m")
            sleep(1)
            util.clear_screen()
コード例 #9
0
    def handle_action(self):
        player_move = util.key_pressed()

        if player_move in Game.SUPPORTED_KEYS['Player movement']:
            self.handle_movement_effects(player_move)
        elif player_move == Game.SUPPORTED_KEYS['Character details']:
            self.UI.display_char_details()
        elif player_move == Game.SUPPORTED_KEYS['Help']:
            self.get_help(**Game.SUPPORTED_KEYS)
        elif player_move == Game.SUPPORTED_KEYS['Inventory']:
            self.get_inventory()
        elif player_move == Game.SUPPORTED_KEYS['Pick up sth']:
            self.pick_up_something()
        elif player_move == Game.SUPPORTED_KEYS['Equip sth']:
            self.equip()
        elif player_move == Game.SUPPORTED_KEYS['Use sth']:
            self.use_item()
        elif player_move == Game.SUPPORTED_KEYS["Distribute exp points"]:
            self.player_character.distribute_points()
            self.UI.display_board_after_key_press()
        elif player_move == Game.SUPPORTED_KEYS["Examine the item"]:
            self.examine_item()
        elif player_move == Game.PLAYER_STATS:
            self.player_character.ui.display_dict_details(
                "\n Player stats:\n", **self.player_character.__dict__)
        elif player_move == Game.SUPPORTED_KEYS["Quit"]:
            self.is_running = False
        elif player_move == "f":
            self.say()
コード例 #10
0
def main():
    """
    Main function of the game, transforms user's input into player's movement and plot changes.

    Returns: Nothing
    """

    message, message_type, name = "", "no_type", ""
    show_inventory = False
    show_legend = True
    is_running = True
    global boards

    game_introduction()
    player = create_player()

    while is_running:
        util.clear_screen()
        board = engine.create_board(boards[player["current_board"]], player)
        ui.display_board(board, boards[player["current_board"]]["name"],
                         player, quests, show_inventory, show_legend, legend,
                         message)
        engine.validate_answer(name, player, boards, message_type)
        key = util.key_pressed()
        board = engine.remove_player_from_board(board, player)
        player, show_inventory, show_legend, is_running, boards = react_to_pressed_key(
            key, board, boards, player, show_inventory, show_legend,
            is_running)
        message, message_type, name = engine.plot_development(
            player, boards, board)
        is_running = engine.check_health_is_zero_or_below(player, is_running)
コード例 #11
0
ファイル: main.py プロジェクト: hubbabubb/ThunderCry
def outro(board, player):
    engine.put_player_on_board(board, player)
    engine.put_enemy_on_board(board, Enemies.king)

    play_outro(board, Enemies.king)

    display_mode = 13
    level = True
    while level:
        display_mode += 1
        if display_mode == 15:
            display_mode = 10
        util.clear_screen()
        print('\n\n')
        ui.display_board(board, display_mode, Enemies.king)
        print('\n\n\n')

        key = util.key_pressed()

        # MAIN CONTROL
        if key == 'q':
            levels.quit_game()
        elif key == "d":
            player.move_right(board)
        elif key == "s":
            player.move_down(board)
        elif key == "w":
            player.move_up(board)
        elif key == "a":
            player.move_left(board)
        elif key == "t" and player.pos_x == 8 and player.pos_y == 16:
            print_message(['YOU', 'DID', 'IT!!! :)'])
        elif key == "i":
            print_character(player, " character")
コード例 #12
0
def process_game(level, player):
    enemies = create_enemies(level)
    items = create_items(level)

    is_running = True
    while is_running:
        board = engine.create_board(BOARD_WIDTH, BOARD_HEIGHT)
        engine.put_player_on_board(board, player)
        engine.put_objects_on_board(board, items)
        engine.put_enemies_on_board(board, enemies)
        ui.display_board(board)
        ui.display_attributes(player, level)
        key = util.key_pressed()
        if key == 'q':
            is_running = False
        elif key == 's' or key == "w" or key == 'a' or key == 'd':
            handle_exit(player, level, key)
            move_if_valid(key, player, board)
            handle_meets(enemies, player)
            if not is_player_alive(player):
                print("Sorry, you died.")
                is_running = False
            handle_meets_with_items(items, player)
            move_enemies(enemies, player)
        elif key == 'c':
            player["health"] += 10000
        else:
            continue
コード例 #13
0
    def handle_fight_round(self):
        self.monster_initiative += self.monster.speed
        self.character_initiative += self.player_character.speed

        if self.monster_initiative > self.character_initiative:
            dodge_difficulty = random.randint(0, 100)

            if dodge_difficulty > self.player_character.dodge_chance:
                monster_damage = self.calculate_damage(
                    self.monster.attack, self.player_character.armor)
                self.player_character.current_hp -= monster_damage
                print("{} inflicted {} damage. {} has {} HP left".format(
                    self.monster.name,
                    colors.ENEMY + str(monster_damage) + colors.RESET,
                    self.player_character.name, colors.PLAYER +
                    str(self.player_character.current_hp) + colors.RESET))
            else:
                print("{} dodged the attack!".format(
                    colors.PLAYER + str(self.player_character.name) +
                    colors.RESET))
            self.character_initiative += self.player_character.speed
            player_alive = self.check_if_player_alive()
            return player_alive

        elif self.monster_initiative <= self.character_initiative:
            print("Your turn! You want to run " + colors.ACTION + "(r)" +
                  colors.RESET + " or attack " + colors.ACTION + "(a)" +
                  colors.RESET + "?")
            player_choice = ""

            while player_choice not in ["r", "a"]:
                player_choice = util.key_pressed()

                if player_choice == "r":
                    print("{} escaped safely from {}".format(
                        colors.PLAYER + str(self.player_character.name) +
                        colors.RESET, self.monster.name))
                    return False

                else:
                    dodge_difficulty = random.randint(0, 100)
                    if dodge_difficulty > self.monster.dodge_chance:
                        player_damage = self.calculate_damage(
                            self.player_character.attack, self.monster.armor)
                        self.monster_hp -= player_damage
                        print(
                            "{} inflicted {} damage. {} has {} HP left".format(
                                self.player_character.name, colors.PLAYER +
                                str(player_damage) + colors.RESET,
                                self.monster.name, colors.ENEMY +
                                str(self.monster_hp) + colors.RESET))
                    else:
                        print("{} dodged the attack".format(
                            colors.ENEMY + str(self.monster.name) +
                            colors.RESET))

                    self.monster_initiative += self.monster.speed
                    monster_alive = self.check_if_monster_alive()
                    return monster_alive
コード例 #14
0
def put_player_on_board(board, player, monsters_alive, monster_dict,
                        valid_place, player_dict):
    place_player(board, player)
    previous_spot = ' '
    while True:
        time.sleep(0.05)
        util.clear_screen()
        print_board(board)
        key = util.key_pressed()

        player_position = [
            np.where(board == player)[0][0],
            np.where(board == player)[1][0]
        ]
        original_position = player_position[:]
        height = player_position[0]
        width = player_position[1]

        if key == 'd':
            move_right(board, previous_spot, height, width, player_position)
            enemy.monster_movement(board, monsters_alive, valid_place)
        elif key == 'a':
            move_left(board, previous_spot, height, width, player_position)
            enemy.monster_movement(board, monsters_alive, valid_place)
        elif key == 'w':
            move_up(board, previous_spot, height, width, player_position)
            enemy.monster_movement(board, monsters_alive, valid_place)
        elif key == 's':
            move_down(board, previous_spot, height, width, player_position)
            enemy.monster_movement(board, monsters_alive, valid_place)
        elif key == 'q':
            break

        try:
            if next_map(board, player):
                break
        except:
            break

        height = player_position[0]
        width = player_position[1]
        board[height][width] = player

        monster_coords = [[mob['X'], mob['Y'] - 2] for mob in monsters_alive]
        for coords in monster_coords:
            if [original_position[0] + 1, original_position[1]] == coords or [
                    original_position[0], original_position[1] - 1
            ] == coords:
                fight.fight(
                    player_dict, {
                        'Name': 'Orc',
                        'Hp': 20,
                        'Attack': 6,
                        'Defense': 5,
                        'Agility': 5,
                        'Level': 1
                    })

    return player_position
コード例 #15
0
ファイル: help.py プロジェクト: Zsoltsrosi/Rougelike-RPG
def help():
    util.clear_screen()
    print("Your main objective is to get to the 21st dungeon to escape",
          "You can move with W A S D keys.")
    print(
        "If you feel like you are not strong enough you can switch weapons and, skills via the inventory key (I)"
    )
    print("In the inventory you have to navigate with the default controls.")
    print(
        "If you see what weapon you want to use navigate to it and press e to equip. (You can only use 1 weapon and or, armor at once and, 3 of booth skill types)"
    )
    print(
        "You can loot and level up by killing enemys, the more you go on the harder the enemy will be but the reward will be plenty."
    )
    print(
        "You only have one life if you die you have to start it again. Unlike in reality you can retry whenever you want."
    )
    util.key_pressed()
コード例 #16
0
def get_input(board, level):
    move = util.key_pressed()
    row = playerindex_row(board)
    col = playerindex_col(board)
    if move == "d":
        if board[row][col + 1] == "O":
            return 1
        elif board[row][col + 1] == "E":
            fight.fight_sys(level)
            board[row][col] = " "
            board[row][col + 1] = "X"
        elif board[row][col + 1] == " ":
            board[row][col] = " "
            board[row][col + 1] = "X"
        elif board[row][col + 1] == "S":
            shop.shop(level)
    elif move == "a":
        if board[row][col - 1] == " ":
            board[row][col] = " "
            board[row][col - 1] = "X"
        elif board[row][col - 1] == "E":
            fight.fight_sys(level)
            board[row][col] = " "
            board[row][col - 1] = "X"
        elif board[row][col - 1] == "S":
            shop.shop(level)
    elif move == "s":
        if board[row + 1][col] == " ":
            board[row][col] = " "
            board[row + 1][col] = "X"
        elif board[row + 1][col] == "E":
            fight.fight_sys(level)
            board[row][col] = " "
            board[row + 1][col] = "X"
        elif board[row + 1][col] == "S":
            shop.shop(level)
    elif move == "w":
        if board[row - 1][col] == " ":
            board[row][col] = " "
            board[row - 1][col] = "X"
        elif board[row - 1][col] == "E":
            fight.fight_sys(level)
            board[row][col] = " "
            board[row - 1][col] = "X"
        elif board[row - 1][col] == "S":
            shop.shop(level)
    elif move == "h":
        help.help()
    elif move == "i":
        inventory_sys.inventory()
    elif move == "q":
        util.clear_screen()
        sys.exit()
    return 0
コード例 #17
0
def fight_sys(level):
    skills.return_stats('0', 'fight', '0')
    enemy_stats(level)
    og_health = YOUR_STAT['health']
    og_mana = YOUR_STAT['mana']
    if YOUR_STAT['health'] > 0 and ENEMY_STAT['health'] > 0:
        lose = fight(level)
        if lose == 2:
            util.clear_screen()
            inventory_sys.looting_phase(level)
            YOUR_STAT['health'] = og_health
            YOUR_STAT['mana'] = og_mana
            time.sleep(3)
        else:
            util.clear_screen()
            help.logo("lose")
            print(
                "you lost the game for now but don't worry you can try again anytime. Good luck next time"
            )
            print("Press any key to quit")
            util.key_pressed()
            sys.exit()
コード例 #18
0
ファイル: ui.py プロジェクト: mcjczapiewski/roguelike_game
def display_meets(txt, quit_possible=False):
    """
    displayes meets screen with text
    fight_text: string
    enemy: dictionary
    quit_possible: True or False
    """
    util.clear_screen()
    print("\n\n\tSPOTYKASZ PRACOWNIKA BIEDRY\n")
    print(f"\t~ {txt}")

    if quit_possible:
        print("\n\tOpcje" + "\n\tWciśnij Q aby przerwac konfrontacje")
        key = util.key_pressed().lower()
        if key == "q":
            return False
        else:
            return True
    else:
        print("")
        key = util.key_pressed().lower()
        return True
コード例 #19
0
 def distribute_points(self):
     util.clear_screen()
     print(
         "\nYou have {} points to distribute\nYour strengh is {} next point costs {}\nYour dexterity is {} next point costs {}\nYour intelligence is {} next point costs {}\n Your max HP is {} next point costs {}"
         .format(self.points, self.strength, self.strength * 2,
                 self.dexterity, self.dexterity * 2, self.intelligence,
                 self.intelligence * 2, self.max_hp, (self.max_hp - 9) * 2))
     print(
         "Push q to quit, push s, d, i, h to upgrade strenght, dexterity, intelligence or HP. Push p to show your points"
     )
     is_distributing = True
     while is_distributing:
         player_choice = util.key_pressed()
         if player_choice == "s":
             if self.points >= self.strength * 2:
                 self.points -= self.strength * 2
                 self.strength += 1
                 print("You upgraded strenght")
             else:
                 print("You don't have enough points to upgrade!")
         elif player_choice == "d":
             if self.points >= self.dexterity * 2:
                 self.points -= self.dexterity * 2
                 self.dexterity += 1
                 print("You upgraded dexterity")
             else:
                 print("You don't have enough points to upgrade!")
         elif player_choice == "i":
             if self.points >= self.intelligence * 2:
                 self.points -= self.intelligence * 2
                 self.intelligence += 1
                 print("You upgraded intelligence")
             else:
                 print("You don't have enough points to upgrade!")
         elif player_choice == "h":
             if self.points >= (self.max_hp - 9) * 2:
                 self.points -= (self.max_hp - 9) * 2
                 self.max_hp += 1
                 self.current_hp += 1
                 print("You upgraded HP")
             else:
                 print("You don't have enough points to upgrade!")
         elif player_choice == "p":
             print("You have {} points left".format(self.points))
         elif player_choice == "q":
             is_distributing = False
         else:
             print("Incorrect key")
コード例 #20
0
ファイル: menu.py プロジェクト: Zsoltsrosi/Rougelike-RPG
def menu_inputs(menu):
    key = util.key_pressed()
    if key == "w":
        menu[0] = ["│", "Play", "│"]
        menu[1] = [" ", "Quit", " "]
        return 0
    elif key == "s":
        menu[1] = ["│", "Quit", "│"]
        menu[0] = [" ", "Play", " "]
        return 0
    elif key == "e":
        if menu[0][0] == "│":
            return 1
        elif menu[1][0] == "│":
            return 2
    else:
        return 0
コード例 #21
0
ファイル: main.py プロジェクト: hubbabubb/ThunderCry
def gender(board, player):
    print_method = 2
    player.icon = "@"
    engine.put_player_on_board(board, player)
    level = True
    top = "CHOOSE YOUR GENDER"
    message = "Press F to be a female"
    while level:
        util.clear_screen()
        print_level(board, message, player, print_method, top)
        key = util.key_pressed()

        # MAIN CONTROL
        if key == 'q':
            levels.quit_game()
        elif key == "d":
            player.move_right(board, '▒')
            player.move_right(board, '░')
            player.move_right(board, ' ')
        elif key == "s":
            player.move_down(board, '▒')
            player.move_down(board, '░')
        elif key == "w":
            player.move_up(board, '▒')
            player.move_up(board, '░')
        elif key == "a":
            player.move_left(board, '▒')
            player.move_left(board, '░')
        elif key == "f":
            if board[player.pos_x - 1][player.pos_y] == '▒':
                top = "You choose female"
                board[3][30] = ' '
                player.level = 1
            if board[player.pos_x - 1][player.pos_y] == '░':
                top = "You choose male"
                board[3][30] = ' '
                player.level = 2

        if board[player.pos_x - 1][player.pos_y] == '▒':
            message = "Press F to be a female"
        elif board[player.pos_x - 1][player.pos_y] == '░':
            message = "Press F to be a male"

        if player.pos_x == 3 and player.pos_y == 30:
            return
コード例 #22
0
ファイル: shop.py プロジェクト: Zsoltsrosi/Rougelike-RPG
def skill_input(skill_fill, price, item_stat):
    key_input = util.key_pressed()
    row = get_XY("X", skill_fill)
    last = skill_fill[row]
    if key_input == "w":
        if row == 0:
            pass
        else:
            word = [skill_fill[row]]
            word[0][0] = " "
            word[0][-1] = " "
            word = [skill_fill[row - 1]]
            word[0][0] = "│"
            word[0][-1] = "│"
    elif key_input == "s":
        if last == skill_fill[-1]:
            pass
        else:
            word = [skill_fill[row]]
            word[0][0] = " "
            word[0][-1] = " "
            word = [skill_fill[row + 1]]
            word[0][0] = "│"
            word[0][-1] = "│"
    elif key_input == "e":
        if price < inventory_sys.YOUR_GOLD['gold']:
            if skill_fill[row][1] != " ":
                skill_fill[row][0] = " "
                skill_fill[row][2] = " "
                inventory_sys.inventory_fill.append(skill_fill[row])
                inventory_sys.inventory_stat.append(item_stat[row])
                skill_fill[row] = [" ", " ", " "]
                skill_fill[0][0] = "│"
                skill_fill[0][2] = "│"
                inventory_sys.YOUR_GOLD['gold'] -= price
        else:
            pass
    elif key_input == "q":
        return 1
コード例 #23
0
def main():
    player = create_player()
    board = engine.create_board(BOARD_WIDTH, BOARD_HEIGHT)
    ui.display_board(board, player)
    util.clear_screen()
    is_running = True
    while is_running:
        engine.put_player_on_board(board, player)
        ui.display_board(board, player)

        key = util.key_pressed().lower()
        engine.clear_player_previous_position(board, player[ROW], player[COL])
        row = player[ROW]
        col = player[COL]
        if key == 'q':
            is_running = False
        elif key == 'd':
            #move right
            if engine.can_player_move(player, board, row, col + 1):
                player[COL] += 1
        elif key == 'a':
            #move left
            if engine.can_player_move(player, board, row, col - 1):
                player[COL] -= 1
        elif key == 'w':
            #move up
            if engine.can_player_move(player, board, row - 1, col):
                player[ROW] -= 1
        elif key == 's':
            #move down
            if engine.can_player_move(player, board, row + 1, col):
                player[ROW] += 1
        else:
            pass

        player, board = engine.check_if_change_board(player, board)
        util.clear_screen()
コード例 #24
0
ファイル: menu.py プロジェクト: Zsoltsrosi/Rougelike-RPG
def char_input(menu):
    x = get_x(menu)
    chooice = util.key_pressed()
    if chooice == "w":
        if menu[x] != menu[0] and menu[x] != menu[1]:
            menu[x][0] = " "
            menu[x][2] = " "
            menu[x - 2][0] = "│"
            menu[x - 2][2] = "│"
        return 0
    elif chooice == "s":
        if menu[x] != menu[2] and menu[x] != menu[3]:
            menu[x][0] = " "
            menu[x][2] = " "
            menu[x + 2][0] = "│"
            menu[x + 2][2] = "│"
        return 0
    elif chooice == "d":
        if menu[x] != menu[1] and menu[x] != menu[3]:
            menu[x][0] = " "
            menu[x][2] = " "
            menu[x + 1][0] = "│"
            menu[x + 1][2] = "│"
        return 0
    elif chooice == "a":
        if menu[x] != menu[2] and menu[x] != menu[0]:
            menu[x][0] = " "
            menu[x][2] = " "
            menu[x - 1][0] = "│"
            menu[x - 1][2] = "│"
        return 0
    elif chooice == "e":
        update_stats(menu)
        return 1
    else:
        return 0
コード例 #25
0
def inv_input():
    key_input = util.key_pressed()
    row = get_XY("X")
    last = inventory_fill[row]
    if key_input == "w":
        if row == 0:
            pass
        else:
            word = [inventory_fill[row]]
            word[0][0] = " "
            word[0][-1] = " "
            word = [inventory_fill[row - 1]]
            word[0][0] = "│"
            word[0][-1] = "│"
    elif key_input == "s":
        if last == inventory_fill[-1]:
            pass
        else:
            word = [inventory_fill[row]]
            word[0][0] = " "
            word[0][-1] = " "
            word = [inventory_fill[row + 1]]
            word[0][0] = "│"
            word[0][-1] = "│"
    elif key_input == "d":
        skills.skill()
        return 1
    elif key_input == "e":
        if inventory_stat[row][2] == 0:
            equiped[0] = inventory_fill[row][1]
            stat_differ(row, 'armor')
        else:
            equiped[1] = inventory_fill[row][1]
            stat_differ(row, 'attack')
    elif key_input == "q":
        return 1
コード例 #26
0
def player_is_going_throug_map(maps_names, world, player_initial_position,
                               user_name, player_dict, player_inventory):

    player_current_position = [
        player_initial_position[0], player_initial_position[1]
    ]

    enemy_dict_1 = {'name': 'Elf', 'stats': {'att': 10, 'HP': 100}}
    enemy_dict_2 = {'name': 'Knight', 'stats': {'att': 45, 'HP': 130}}
    enemy_dict_3 = {'name': 'Orc', 'stats': {'att': 80, 'HP': 160}}
    enemy_dict_4 = {'boss': {'att': 110, 'HP': 200}}
    if world == 1:
        enemy_dict = enemy_dict_1
    if world == 2:
        enemy_dict = enemy_dict_2
    if world == 3:
        enemy_dict = enemy_dict_3

    final_board = create_board(maps_names[world - 1])
    put_player_on_board(final_board, player_dict, player_initial_position)
    items_list = create_item_list()
    while True:
        util.clear_screen()
        ui.display_board(final_board)
        ui.display_stats(player_dict)
        ui.display_inventory(player_inventory)
        key_pressed = util.key_pressed()
        effect_of_key_pressed = effect_of_key(final_board,
                                              player_current_position,
                                              key_pressed)
        if effect_of_key_pressed == 'move':
            lower_HP(player_dict)
            move_player_on_board(key_pressed, final_board, player_dict,
                                 player_current_position)
            update_curr_player_posit(player_current_position, key_pressed)
        elif effect_of_key_pressed == 'blocked':
            continue
        elif effect_of_key_pressed == 'food':
            higher_HP(player_dict)
            move_player_on_board(key_pressed, final_board, player_dict,
                                 player_current_position)
            update_curr_player_posit(player_current_position, key_pressed)
        elif effect_of_key_pressed == 'item':
            #pick random item from item list
            ###dopisane Roman
            picked_item = draw_item(items_list)
            add_to_inventory(player_inventory, items_list, picked_item)
            update_player_stats(player_dict, items_list, picked_item)
            #add to inventory
            #update stats ```ROMAN DZIAŁA NAD TYM```
            move_player_on_board(key_pressed, final_board, player_dict,
                                 player_current_position)
            update_curr_player_posit(player_current_position, key_pressed)
        elif effect_of_key_pressed == 'enemy':
            # go to fight ``` ADAM TO ZROBI ```
            move_player_on_board(key_pressed, final_board, player_dict,
                                 player_current_position)
            update_curr_player_posit(player_current_position, key_pressed)
            enemy_encounter(player_dict, player_inventory, enemy_dict)
            os.system('pause')
            os.system('color 07')
            enemy_dict_1 = {'name': 'Elf', 'stats': {'att': 10, 'HP': 100}}
            enemy_dict_2 = {'name': 'Knight', 'stats': {'att': 45, 'HP': 130}}
            enemy_dict_3 = {'name': 'Orc', 'stats': {'att': 80, 'HP': 160}}
            enemy_dict_4 = {'boss': {'att': 110, 'HP': 200}}
            if world == 1:
                enemy_dict = enemy_dict_1
            if world == 2:
                enemy_dict = enemy_dict_2
            if world == 3:
                enemy_dict = enemy_dict_3
            #return True or False#w zależności czy wygrasz czy przegrasz walkę
        elif effect_of_key_pressed == 'gate':
            return True
        elif effect_of_key_pressed == 'boss_encounter':
            enemy_dict = enemy_dict_4
            enemy_encounter(player_dict, player_inventory, enemy_dict)
            return False
コード例 #27
0
def main():
    util.clear_screen()

    player = database_player.create_player()

    board_list = database_boards.create_boards()
    current_board = board_list['1']
    npc_dictionary = {}

    is_running = True
    npc = None
    while is_running:

        x, y = player['position']
        future_x = x
        future_y = y

        print('Current Howling Forest Region: ',
              extras.board_level_info(board_list, current_board))
        extras.how_is_the_hp(player)
        extras.print_player_stats(player)
        if npc:
            extras.how_is_the_npc_hp(npc)
            if engine.fight_is_over:
                npc = None
        database_player.put_player_on_board(current_board, player)
        ui.display_board(current_board)

        key = util.key_pressed()

        if key == 'q':
            is_running = False
        elif key == 'w':
            future_x = x - 1
        elif key == 's':
            future_x = x + 1
        elif key == 'a':
            future_y = y - 1
        elif key == 'd':
            future_y = y + 1
        elif key == 'i':
            print(player['inventory'])
            util.press_any_key()
        elif key == 'h':
            extras.help()
            util.press_any_key()
        elif key == 'k':
            item = database_items.small_hp_potion
            engine.use_item_from_inventory(player, item)
        elif key == 'l':
            item = database_items.small_hp_potion
            engine.use_item_from_inventory(player, item)
        else:
            pass
        engine.remove_player_from_board(current_board, player)
        database_player
        # moves the player to the next/previous board(s) if has the teleportation orb // put items to inv
        if engine.can_move_player_to(current_board, player, future_x,
                                     future_y):
            engine.idle_hp_regeneration(player, future_x, future_y)
            if database_boards.is_cell_exit(current_board, future_x, future_y):
                if engine.player_has_item(player,
                                          database_items.teleportation_orb):
                    for key in board_list:
                        if current_board[future_x][future_y] == key:
                            current_board = board_list[key]
                            break
                    if future_y == 0:
                        player[
                            'position'] = future_x, future_y + database_boards.BOARD_WIDTH - 2
                    else:
                        player[
                            'position'] = future_x, future_y - database_boards.BOARD_WIDTH + 2
                    database_player.put_player_on_board(current_board, player)
                else:
                    print(
                        'You need to find the teleportation orb first... (#)')
                    util.press_any_key()
            else:
                engine.move_player_to(player, future_x, future_y)
                if current_board[future_x][
                        future_y] in database_items.item_database:
                    item = database_items.item_database[current_board[future_x]
                                                        [future_y]]
                    if item['type'] == 'sword':
                        engine.choose_weapon_to_use(player, item)
                    elif item['type'] == 'shield':
                        engine.choose_shield_to_use(player, item)
                    elif item['type'] == 'upgrade':
                        engine.add_upgrade_to_stats(player, item)
                    else:
                        engine.put_item_into_the_inv(player, item)

        elif engine.is_occupied_by_npc(current_board, future_x, future_y):
            npc_key = extras.encode_location(board_list, current_board,
                                             future_x, future_y)
            if npc_key in npc_dictionary:
                npc = npc_dictionary[npc_key]
            else:
                npc = database_npc.npc_database[current_board[future_x]
                                                [future_y]].copy()
                npc_dictionary[npc_key] = npc
            extras.how_is_the_npc_hp(npc)
            engine.player_vs_npc(player, npc, future_x, future_y)
            if player['hp'] == 0:
                is_running = False
        util.clear_screen()
コード例 #28
0
def main():
    # initial level
    level = 'BOARD_1'

    # initial key
    key = ''

    menu_start.run()

    ui.print_message('\n\n\n LEVEL %s \n\n\n' % (level[-1]))
    time.sleep(1.0)
    util.clear_screen()

    pass_key_input = False

    while level != 'WIN' and level != 'QUIT' and level != 'LOSE':

        util.clear_screen()
        pass_key_input = False

        view.print_table(players.data_to_print(dictionaries.player))

        # Set up board
        global BOARD_1
        global BOARD_2
        global BOARD_3
        # global items_u_will_use
        # global coordonate_of_items_that_u_will_use
        # player = create_player()
        BOARD_1 = engine.create_board()
        BOARD_2 = engine.create_board()
        BOARD_3 = engine.create_board()
        BOARD_1, items_u_will_use_1, coordonate_of_items_that_u_will_use_1 = engine.create_final_board(BOARD_1, little_boss_1)
        BOARD_2, items_u_will_use_2, coordonate_of_items_that_u_will_use_2 = engine.create_final_board(BOARD_2, little_boss_2)
        BOARD_3, items_u_will_use_3, coordonate_of_items_that_u_will_use_3 = engine.create_final_board(BOARD_3, boss)
        BOARD_1 = engine.create_board()
        BOARD_2 = engine.create_board()
        BOARD_3 = engine.create_board()
        util.clear_screen()
        is_running = True
        while is_running:
            print()
            print("U entered first level")
            print()
            items_u_will_use_1, coordonate_of_items_that_u_will_use_1 = engine.items_and_coordonates_that_u_can_use(BOARD_1)
            (BOARD_1, items_u_will_use, coordonate_of_items_that_u_will_use_1) = engine.create_final_board(BOARD_1, little_boss_1)
            (BOARD_1, items_u_will_use_1, coordonate_of_items_that_u_will_use_1) = engine.put_player_on_board(BOARD_1, little_boss_1)
            engine.move_something_and_gate(BOARD_1, player, little_boss_1, gate_1)

            if player['player_life'] > 0:
                print()
                print("U entered second level")
                print()
            items_u_will_use_2, coordonate_of_items_that_u_will_use_2 = engine.items_and_coordonates_that_u_can_use(BOARD_2)
            (BOARD_2, items_u_will_use_2, coordonate_of_items_that_u_will_use_2) = engine.create_final_board(BOARD_2, little_boss_2)
            engine.move_something_and_gate(BOARD_2, player, little_boss_2, gate_2)

            if player['player_life'] > 0:
                print()
                print("U entered the third level")
                print()
            items_u_will_use_3, coordonate_of_items_that_u_will_use_3 = engine.items_and_coordonates_that_u_can_use(BOARD_3)
            (BOARD_3, items_u_will_use_3, coordonate_of_items_that_u_will_use_3) = engine.create_final_board(BOARD_3, boss)
            engine.move_something_and_gate(BOARD_3, player, boss, gate_3)
            # ui.display_board(board)

        key = util.key_pressed()
        if key == 'q':
            is_running = False
        # elif key == 'i':
        #     print(inventory)
        is_running = False
        # util.clear_screen()
        print(key)
        # break
            # ui.display_board(board)

        key = util.key_pressed()
        # if key == 'q':
        #     is_running = False
        # elif key == 'i':
        #     print(inventory)

        # util.clear_screen()
        print(key)

        # Display essential info
        ui.print_player_essential_atributes(dictionaries.player)

        # Display board
        ui.display_board(board)

        # Message panel intoduction (always displayed)
        ui.print_message('  MESSAGE PANEL \n' + 17 * '-' + '\n')

        # Interaction whit items

        # Display inventory
        if key == 'i':
            ui.print_message('This is your inventory content: ')
            ui.print_table(dictionaries.inventory)

        # Interaction with other characters

        # Insert secret code
        if key == "c":
            engine.use_secret_code(dictionaries.player, dictionaries.others, level, dictionaries.codes)

        # Gate and level change handling
        # if engine.player_enters_gate() != level:
            # util.clear_screen()
            # level = engine.player_enters_gate()

            if level == 'BOARD_2' or level == 'BOARD_3':
                dictionaries.player['position_y'] = 15
                dictionaries.player['position_x'] = 3

            if level == 'WIN':
                pass_key_input = True
                pass
            else:
                ui.print_message('\n\n\n LEVEL %s \n\n\n' % (level[-1]))
                time.sleep(1.0)
                util.clear_screen()
                pass_key_input = True

        # Player input
        if pass_key_input is False:
            key = util.key_pressed()

        # Movement
        if pass_key_input is False:
            pass
        # engine.movement()

        # Check if quit
        if key == 'q':
            quit_assertion = ''
            while quit_assertion != 'y' and quit_assertion != 'n':
                util.clear_screen()
                print('Are you sure you want to quit? ( Y / N )')
                quit_assertion = util.key_pressed()
                if quit_assertion == 'y':
                    level = 'QUIT'
                elif quit_assertion == 'n':
                    pass
                else:
                    pass

        if dictionaries.player['player_life'] == 0:
            level = 'LOSE'

    if level == 'WIN':
        util.clear_screen()
        ui.display_board(board)
        print(text2art("VICTORY!", font='block', chr_ignore=True))

    elif level == 'LOSE':
        util.clear_screen()
        ui.display_board(board)
        print(text2art("GAME OVER!", font='block', chr_ignore=True))
        time.sleep(10.7)

    print('\n\n\n Goodbye, see you soon!')
    time.sleep(1.0)
コード例 #29
0
def main():
    player = create_player()
    board = engine.create_board(BOARD_WIDTH, BOARD_HEIGHT)
    util.clear_screen()
    level = 1

    inventory = {
        "Pierogi": 5,
        "Bigos": 5,
        "Złom": 5,
        "Sliptape": 5,
        "Ropa": 5,
        "Działko": 5
    }

    if level == 1:
        # import text from ASCII file
        title = ui.get_ascii("./ascii_files/poland_can_into_space.txt")
        # displays ASCII file with color defined by number
        ui.display_ascii(title, font_colors=[34], spacing=5)
        input(" ")
        os.system('cls')
        print("\n\n")
        txt = "Rok 2030. Trwa wyścig światowych mocarstw o każdy kawłek lądu. Pewnej nocy na niebie pojawia się tajemnicza anomalia... "
        ui.print_text(txt, font_color=33)

        # import text from ASCII file
        anomaly = ui.get_ascii("./ascii_files/saturn.txt")
        # displays ASCII file with color defined by number
        ui.display_ascii(anomaly, font_colors=[35], spacing=5)
        input(" ")
        os.system('cls')
        # import text from ASCII file
        im = ui.get_ascii("./ascii_files/roz1.txt")
        # displays ASCII file with color defined by number
        ui.display_ascii(im, font_colors=[31], spacing=1)
        input(" ")
        os.system('cls')
        txt = ('''
        
        Po Twojej głowie wędruje wyłącznie jedna myśl. To jest mój czas. Muszę polecieć i zbadać tajemniczą anomalię. 
        Postanawiasz przerobić swojego Golfa 1.9 TDI pieszczotliwie nazywanego Gulfem na statek kosmiczny i niezwłocznie wyruszyć w drogę.'''
               )
        ui.print_text(txt, font_color=33)
        input(" ")
        os.system('cls')

        mum_house = engine.generate_game_board_1(board)

        is_running = True
        while is_running:
            x = player['player_x_position']
            y = player['player_y_position']
            engine.add_to_inventory(player, mum_house, inventory)
            temporary_board = deepcopy(mum_house)
            engine.put_player_on_board(temporary_board, player)
            ui.display_board(temporary_board)
            engine.display_players_card(inventory)
            # print(f"Player position: ({x},{y})")
            key = util.key_pressed()
            if key == 'q':
                is_running = False
            else:
                engine.player_moves(key, mum_house, player)
            util.clear_screen()
            pass_condition = engine.chceck_inventory(inventory, level)
            if engine.exit_board(level, player) == True:
                if pass_condition == True:
                    is_running = False
                    level = 2

            else:
                is_running = True

    if level == 2:
        txt = (
            '''Wyszedłeś na miasto. Uzupełnij zasoby, zdobądź paliwo, osłony i działa do statku.'''
        )
        ui.print_text(txt, font_color=33)
        input(" ")
        os.system('cls')
        city = engine.generate_game_board_2(board)
        is_running = True
        while is_running:
            x = player['player_x_position']
            y = player['player_y_position']
            engine.add_to_inventory(player, city, inventory)
            temporary_board = deepcopy(city)
            engine.put_player_on_board(temporary_board, player)
            ui.display_board(temporary_board)
            engine.display_players_card(inventory)
            # print(f"Player position: ({x},{y})")
            key = util.key_pressed()
            if key == 'q':
                is_running = False
            else:
                engine.player_moves(key, city, player)
            util.clear_screen()
            inventory = engine.exchange_of_goods(player, inventory)
            engine.ferdek(player)
            inventory = engine.get_blasters(player, inventory)
            pass_condition = engine.chceck_inventory(inventory, level)
            if engine.exit_board(level, player) == True:
                if pass_condition == True:
                    engine.going_to_the_moon()
                    level = 3
                    is_running = False
            elif engine.exit_board(level, player) == False:
                is_running = True

    if level == 3:
        player['player_x_position'] = PLAYER_START_X
        player['player_y_position'] = PLAYER_START_Y
        board = engine.create_board(21, 15)
        util.clear_screen()
        board_level_2 = engine.maze_generator(board)
        engine.put_quizzes(board_level_2)
        engine.put_memes(board_level_2)
        is_running = True
        level_2 = True
        while is_running:
            engine.level_2_start()
            while level_2:
                engine.quiz_function(board_level_2, player)
                engine.meme_function(board_level_2, player)
                temporary_board = deepcopy(board_level_2)
                engine.put_player_on_board(temporary_board, player)
                engine.display_maze_status(player)
                ui.display_maze(temporary_board, player)

                key = util.key_pressed()

                if key == 'q':
                    is_running = False
                else:
                    engine.player_moves(key, temporary_board, player)
                util.clear_screen()
                level_4 = player['player_*']
                if level_4 > 7:
                    level = 4
                    is_running = False
                    level_2 = False
    if level == 4:
        txt = (
            "Po latach podrózy i licznych przeszkodach na horyzoncie ukazuje się anomalia. Aby do niej dotrzeć musisz zmierzyć się z obcymi..."
        )
        ui.print_text(txt, font_color=33)
        input()
        os.system("cls||clear")
        level_3 = True
        player['player_x_position'] = PLAYER_START_X
        player['player_y_position'] = PLAYER_START_Y

        board_level_3 = engine.create_board(BOARD_WIDTH_lvl3,
                                            BOARD_HEIGHT_lvl3)
        im = ui.get_ascii(
            "./ascii_files/battle.txt")  #import text from ASCII file
        ui.display_ascii(
            im, font_colors=[31],
            spacing=1)  #displays ASCII file with color defined by number
        input()
        os.system('cls')
        counter = 0
        engine.intro_lvl3()
        while level_3:
            counter += 1

            temporary_board = deepcopy(board_level_3)
            engine.put_player_on_board(temporary_board, player)
            level_3 = engine.play_level3(temporary_board, player, counter)
            if level_3:
                ui.display_board(temporary_board)

        is_running = False
        util.clear_screen()
        level = 5

    if level == 5:
        engine.end_game()
コード例 #30
0
 def display_board_after_key_press(self):
     print("Press any key to continue")
     util.key_pressed()
     self.display_board()