def level(player, inv, board_name, file_name, inv_X, inv_Y, ret_X, ret_Y):
    life = 100
    char = ""
    x_pos = 1
    y_pos = 1
    board = create_board(board_name)
    functions.delay_print(file_name)
    time.sleep(15)
    os.system('clear')
    functions.delay_print("click_to_start.txt")
    while char != "p":
        if board[ret_X][ret_Y] == player:
            os.system('clear')
            return

        if life <= 0:
            os.system('clear')
            functions.delay_print("koniec_gry.txt")
            exit()

        char = functions.getch()
        board, x_pos, y_pos = wsad(board, char, x_pos, y_pos)
        life, inv = functions.interaction_with_items(life, inv, board, x_pos,
                                                     y_pos)

        board_with_player = insert_player(board, x_pos, y_pos, player)
        board = functions.print_inventory(board, inv, life, inv_X, inv_Y)
        os.system('clear')
        print_board(board_with_player)
Esempio n. 2
0
def combat(monster):
    """
    Function manages whole combat system, reads player and enemy statisctics and calls
    other functions to return combat rewards (such as experiece, items and gold)
    """

    win = True
    monster_stats, graphic, monster_name, exp, gold = monster

    player_stats = character.get_battle_stats()
    player_stats = convert_stats(player_stats)
    player_damage = player_stats["Attack"] - monster_stats["Defence"]
    monster_damage = monster_stats["Attack"] - player_stats["Defence"]

    while monster_stats["HP"] > 0 and player_stats["HP"] > 0:

        handle_graphics(graphic, monster_name, monster_stats, player_stats)
        combat_action = functions.getch()

        if combat_action == "1":

            if player_damage > 0:
                monster_stats["HP"] -= player_damage

            if monster_damage > 0 and monster_stats["HP"] > 0:
                player_stats["HP"] -= monster_damage

        elif combat_action == "2":
            player_stats["HP"] += inventory.use_item()

        elif combat_action == "3":
            character.change_hp(-10)
            return not win

    return resolve_encounter(player_stats["HP"], exp, gold, monster_name)
Esempio n. 3
0
def main():
    os.system("clear")
    choice = ""
    while choice != "3":
        os.system("clear")
        plot.main_menu()
        choice = functions.getch()
        if choice == "1":
            rogue.game()
        elif choice == "2":
            highscore.print_highscore()
        elif choice == "0":
            plot.about()
Esempio n. 4
0
def level_up(stats):
    """
    Function used to manage stats. Player has to spend 3 points to finish level-up process

    Args:
        stats: Dict. containing current players stats
    """

    done = False
    skill_points = 3
    stats_copy = copy.copy(stats)

    while not done:
        os.system("clear")
        print("LEVEL UP!")
        handle_stat_management()
        current_stats(stats_copy)
        print("Skill points:", skill_points)

        choice = functions.getch().lower()

        if choice == "s" and skill_points > 0:
            skill_points -= 1
            stats_copy["Strength"] += 1

        elif choice == "a" and skill_points > 0:
            skill_points -= 1
            stats_copy["Agility"] += 1

        elif choice == "e" and skill_points > 0:
            skill_points -= 1
            stats_copy["Endurance"] += 1

        elif choice == "f" and skill_points == 0:
            done = True

        elif choice == "t":
            stat_tutorial()
            input("Press Enter to continue...")

        elif choice == "x":
            skill_points = 3
            stats_copy = copy.copy(stats)

    save_stats(stats_copy)
Esempio n. 5
0
def create_character():
    """
    Function used to create new character
    """

    skill_points = 10
    stats = {
        "Strength": 5,
        "Agility": 5,
        "Endurance": 5,
        "Experience": 0,
        "Gold": 0
    }
    created = False

    while not created:
        os.system("clear")
        handle_stat_management()
        current_stats(stats)
        print("Skill points:", skill_points)

        choice = functions.getch().lower()

        if choice == "s" and skill_points > 0:
            skill_points -= 1
            stats["Strength"] += 1

        elif choice == "a" and skill_points > 0:
            skill_points -= 1
            stats["Agility"] += 1

        elif choice == "e" and skill_points > 0:
            skill_points -= 1
            stats["Endurance"] += 1

        elif choice == "f" and skill_points == 0:
            print("Great! Last thing. What's your name?")
            name = input()
            stats["Name"] = name
            stats["Weapon"] = "Stick"
            stats["HP"] = stats["Endurance"] * 15

            if name == "OnePunchMan":
                stats = god_mode_on()

            save_stats(stats)

            eq = {"Apple": ("POTION", 3)}
            inventory.save_inventory(eq)
            created = True

        elif choice == "t":
            stat_tutorial()
            input("Press Enter to continue...")

        elif choice == "x":
            skill_points = 10
            stats = {
                "Strength": 5,
                "Agility": 5,
                "Endurance": 5,
                "Experience": 0,
                "Gold": 0
            }