Пример #1
0
def render_room_3():
    session.dungeon = "01"
    session.room = "03"
    screen.clear_screen()
    screen.print_general_screen()
    screen.print_room_description(
        "You enter a messy and dry room, there are an interesting desk in the\n"
        "corner, covered with papers and a shiny drawer")
    screen.print_room_options(["Check the drawer", "Leave the room"])

    option = ""
    while option != "q":
        option = raw_input("Choose an option (q to quit): ")
        if option == "1":
            screen.clear_screen()
            if session.player_found_gp_in_room_2:
                screen.print_room_notice("The drawer is empty")
            else:
                session.player_gp = session.player_gp + 2
                session.player_found_gp_in_room_2 = True
                screen.print_room_notice("You found 2GP")
            render_room_3()
        elif option == "2":
            render_room_2()
        elif option == "q":
            screen.print_game_over()
        else:
            screen.print_error("Choose a valid option")
Пример #2
0
def render_room_3():
    session.dungeon = "01"
    session.room = "03"
    screen.clear_screen()
    screen.print_general_screen()
    screen.print_room_description(
        "You enter a messy and dry room, there are an interesting desk in the\n"
        "corner, covered with papers and a shiny drawer"
    )
    screen.print_room_options([
        "Check the drawer",
        "Leave the room"
    ])

    option = ""
    while option != "q":
        option = raw_input("Choose an option (q to quit): ")
        if option == "1":
            screen.clear_screen()
            if session.player_found_gp_in_room_2:
                screen.print_room_notice("The drawer is empty")
            else:
                session.player_gp = session.player_gp + 2
                session.player_found_gp_in_room_2 = True
                screen.print_room_notice("You found 2GP")
            render_room_3()
        elif option == "2":
            render_room_2()
        elif option == "q":
            screen.print_game_over()
        else:
            screen.print_error("Choose a valid option")
Пример #3
0
def render_room_2():
    session.dungeon = "01"
    session.room = "02"
    screen.clear_screen()
    screen.print_general_screen()
    screen.print_room_description(
        "This look like a corridor full of cells. There is an open door on\n"
        "the right and a long corridor on the left"
    )
    screen.print_room_options([
        "Enter the open door on the right",
        "Run through the corridor on the left"
    ])

    option = ""
    while option != "q":
        option = raw_input("Choose an option (q to quit): ")
        if option == "1":
            render_room_3()
        elif option == "2":
            render_room_4()
        elif option == "q":
            screen.print_game_over()
        else:
            screen.print_error("Choose a valid option")
Пример #4
0
def render_room_4():
    session.dungeon = "01"
    session.room = "04"
    screen.clear_screen()
    screen.print_general_screen()
    screen.print_room_description(
        "You enter the main hall. You fell a huge shade coming from nowhere\n"
        "weaving a big axe at you... TIME TO BATTLE!")
    raw_input("Press any key to continue...")
    battles.render_battle_1()
Пример #5
0
def render_room_4():
    session.dungeon = "01"
    session.room = "04"
    screen.clear_screen()
    screen.print_general_screen()
    screen.print_room_description(
        "You enter the main hall. You fell a huge shade coming from nowhere\n"
        "weaving a big axe at you... TIME TO BATTLE!"
    )
    raw_input("Press any key to continue...")
    battles.render_battle_1()
def main():
    """
    Starting point for the whole game. Called automatically when script is run.
    """
    interaction.do_load_default_game()
    while True:
        screen.clear_screen()
        screen.draw_screen(interaction.last_message)
        interaction.last_message = ""

        user_input = interaction.get_user_command()
        should_continue = interaction.do_command(user_input)
        if should_continue == False:  # LT
            break
    screen.write_new_line()
    screen.write('Thank you for playing. Goodbye.')
Пример #7
0
def do_show_help():
    """
    Displays the list of keyboard commands on the screen. Updates last_message.
    """
    global last_message  # DO NOT REMOVE
    screen.clear_screen()
    screen.write('KEYBOARD COMMANDS\n')
    screen.write(f'   {KEYBOARD_UP}  Move up.\n')
    screen.write(f'   {KEYBOARD_DOWN}  Move down.\n')
    screen.write(f'   {KEYBOARD_LEFT}  Move left.\n')
    screen.write(f'   {KEYBOARD_RIGHT}  Move right.\n')
    screen.write(f'   {KEYBOARD_LOOK}  Look at the square immediately in front of you.\n')
    screen.write(f'   {KEYBOARD_TAKE}  Take object immediately in front of you.\n')
    screen.write(f'   {KEYBOARD_USE}  Use an item from your inventory.\n')
    screen.write(f'   {KEYBOARD_QUIT}  Quit the game.\n')
    screen.write(f'   {KEYBOARD_LOAD_GAME}  Load game from file.\n')
    screen.write(f'   {KEYBOARD_SAVE_GAME}  Save game to file.\n')
    screen.write(f'   {KEYBOARD_SHOW_HELP}  Show this help screen.\n')
    last_message = 'Scroll up to see a list of keyboard commands.'
Пример #8
0
def render_room_1():
    session.dungeon = "01"
    session.room = "01"
    screen.clear_screen()
    screen.print_general_screen()
    screen.print_room_description(
        "You wake up in a dark and dry room. You look around and it's looks\n"
        "like a cell. Right in front of you, close to the cell bars, there is\n"
        "a guard, drop dead"
    )
    screen.print_room_options([
        "Scream for help",
        "Check the guard's body"
    ])

    option = ""
    while option != "q":
        option = raw_input("Choose an option (q to quit): ")
        if option == "1":
            screen.clear_screen()
            screen.print_room_notice("No one listens to you, you are on your own")
            render_room_1()
        elif option == "2":
            screen.clear_screen()
            screen.print_room_notice(
                "You find the cell key in his pocket. You leave the cell"
            )
            render_room_2()
        elif option == "q":
            screen.print_game_over()
        else:
            screen.print_error("Choose a valid option")
Пример #9
0
def render_room_5():
    session.dungeon = "01"
    session.room = "05"
    screen.clear_screen()
    screen.print_general_screen()
    screen.print_room_description(
        "After a heat battle, you still have energy to run. At the end of the\n"
        "hall, there is a dark corridor. When you enter it, you notice that\n"
        "part of the floor looks different"
    )
    screen.print_room_options([
        "Check for traps",
        "Run like there is no tomorrow"
    ])

    option = ""
    while option != "q":
        option = raw_input("Choose an option (q to quit): ")
        if option == "1":
            screen.clear_screen()
            screen.print_room_notice(
                "You find a trap, a clumsy deep hole full of pythons. You jump "
                "over it"
            )
            screen.print_game_over()
        elif option == "2":
            screen.clear_screen()
            screen.print_room_notice(
                "You fall in a deep hole and get bitten by the pythons"
            )
            screen.print_game_over()
        elif option == "q":
            screen.print_game_over()
        else:
            screen.print_error("Choose a valid option")
Пример #10
0
def render_room_1():
    session.dungeon = "01"
    session.room = "01"
    screen.clear_screen()
    screen.print_general_screen()
    screen.print_room_description(
        "You wake up in a dark and dry room. You look around and it's looks\n"
        "like a cell. Right in front of you, close to the cell bars, there is\n"
        "a guard, drop dead")
    screen.print_room_options(["Scream for help", "Check the guard's body"])

    option = ""
    while option != "q":
        option = raw_input("Choose an option (q to quit): ")
        if option == "1":
            screen.clear_screen()
            screen.print_room_notice(
                "No one listens to you, you are on your own")
            render_room_1()
        elif option == "2":
            screen.clear_screen()
            screen.print_room_notice(
                "You find the cell key in his pocket. You leave the cell")
            render_room_2()
        elif option == "q":
            screen.print_game_over()
        else:
            screen.print_error("Choose a valid option")
Пример #11
0
def render_room_5():
    session.dungeon = "01"
    session.room = "05"
    screen.clear_screen()
    screen.print_general_screen()
    screen.print_room_description(
        "After a heat battle, you still have energy to run. At the end of the\n"
        "hall, there is a dark corridor. When you enter it, you notice that\n"
        "part of the floor looks different")
    screen.print_room_options(
        ["Check for traps", "Run like there is no tomorrow"])

    option = ""
    while option != "q":
        option = raw_input("Choose an option (q to quit): ")
        if option == "1":
            screen.clear_screen()
            screen.print_room_notice(
                "You find a trap, a clumsy deep hole full of pythons. You jump "
                "over it")
            screen.print_game_over()
        elif option == "2":
            screen.clear_screen()
            screen.print_room_notice(
                "You fall in a deep hole and get bitten by the pythons")
            screen.print_game_over()
        elif option == "q":
            screen.print_game_over()
        else:
            screen.print_error("Choose a valid option")
Пример #12
0
def render_room_2():
    session.dungeon = "01"
    session.room = "02"
    screen.clear_screen()
    screen.print_general_screen()
    screen.print_room_description(
        "This look like a corridor full of cells. There is an open door on\n"
        "the right and a long corridor on the left")
    screen.print_room_options([
        "Enter the open door on the right",
        "Run through the corridor on the left"
    ])

    option = ""
    while option != "q":
        option = raw_input("Choose an option (q to quit): ")
        if option == "1":
            render_room_3()
        elif option == "2":
            render_room_4()
        elif option == "q":
            screen.print_game_over()
        else:
            screen.print_error("Choose a valid option")
Пример #13
0
def start():
    screen.clear_screen()
    print "Welcome to Dungeons and Pythons\n"
    session.player_name = raw_input("What's your name? ")
    rooms.render_room_1()
Пример #14
0
def render_battle_1():
    session.monster_name = "Ugly Orc"
    turn = "player"
    player_defense = 0
    monster_defense = 0
    time_to_battle = session.monster_hp > 0 and session.player_hp > 0
    while time_to_battle:
        screen.clear_screen()
        screen.print_general_screen()
        screen.print_battle_screen()
        if turn == "player":
            dice = utils.rolls_dice()
            option = ""
            while option != "q":
                screen.print_battle_options(["Attack", "Defend"])
                option = raw_input("Choose an option (q to quit): ")
                if option == "1":
                    if monster_defense > 0:
                        damage = (dice + session.player_ap) - (
                            session.monster_dp + monster_defense)
                    else:
                        damage = (dice +
                                  session.player_ap) - session.monster_dp
                    if damage < 0:
                        damage = 0
                    screen.clear_screen()
                    screen.print_general_screen()
                    screen.print_battle_screen()
                    screen.print_battle_info(
                        "Player attacks, rolls %s, dealing %s of damage" %
                        (dice, damage))
                    raw_input("Press any key to continue...")
                    session.monster_hp = session.monster_hp - damage
                    player_defense = 0
                    turn = "monster"
                    break
                elif option == "2":
                    player_defense = dice + session.player_dp
                    screen.clear_screen()
                    screen.print_general_screen()
                    screen.print_battle_screen()
                    screen.print_battle_info(
                        "Player defends, rolls %s, getting %s of defense" %
                        (dice, player_defense))
                    raw_input("Press any key to continue...")
                    turn = "monster"
                    break
                else:
                    screen.print_error("Choose a valid option")
        elif turn == "monster":
            dice = utils.rolls_dice()
            option = utils.choose_one(["1", "2"])
            if option == "1":
                if player_defense > 0:
                    damage = (dice + session.monster_ap) - (session.player_dp +
                                                            player_defense)
                else:
                    damage = (dice + session.monster_ap) - session.player_dp
                if damage < 0:
                    damage = 0
                screen.clear_screen()
                screen.print_general_screen()
                screen.print_battle_screen()
                screen.print_battle_info(
                    "Monster attacks, rolls %s, dealing %s of damage" %
                    (dice, damage))
                raw_input("Press any key to continue...")
                session.player_hp = session.player_hp - damage
                monster_defense = 0
                turn = "player"
            elif option == "2":
                monster_defense = dice + session.monster_dp
                screen.clear_screen()
                screen.print_general_screen()
                screen.print_battle_screen()
                screen.print_battle_info(
                    "Monster defends, rolls %s, getting %s of defense" %
                    (dice, monster_defense))
                raw_input("Press any key to continue...")
                turn = "player"
            else:
                screen.print_error("Unknown monster action")
        else:
            screen.print_error("Unknown turn")

        if session.monster_hp <= 0:
            screen.print_room_notice("You won!")
            screen.print_room_notice("You found %sGP" % session.monster_gp)
            session.player_gp = session.player_gp + session.monster_gp
            rooms.render_room_5()
        elif session.player_hp <= 0:
            screen.print_room_notice("You died!")
            screen.print_game_over()
        else:
            continue
Пример #15
0
def start():
    screen.clear_screen()
    print "Welcome to Dungeons and Pythons\n"
    session.player_name = raw_input("What's your name? ")
    rooms.render_room_1()
Пример #16
0
def render_battle_1():
    session.monster_name = "Ugly Orc"
    turn = "player"
    player_defense = 0
    monster_defense = 0
    time_to_battle = session.monster_hp > 0 and session.player_hp > 0
    while time_to_battle:
        screen.clear_screen()
        screen.print_general_screen()
        screen.print_battle_screen()
        if turn == "player":
            dice = utils.rolls_dice()
            option = ""
            while option != "q":
                screen.print_battle_options([
                    "Attack",
                    "Defend"
                ])
                option = raw_input("Choose an option (q to quit): ")
                if option == "1":
                    if monster_defense > 0:
                        damage = (dice + session.player_ap) - (session.monster_dp + monster_defense)
                    else:
                        damage = (dice + session.player_ap) - session.monster_dp
                    if damage < 0:
                        damage = 0
                    screen.clear_screen()
                    screen.print_general_screen()
                    screen.print_battle_screen()
                    screen.print_battle_info(
                        "Player attacks, rolls %s, dealing %s of damage" % (dice, damage)
                    )
                    raw_input("Press any key to continue...")
                    session.monster_hp = session.monster_hp - damage
                    player_defense = 0
                    turn = "monster"
                    break
                elif option == "2":
                    player_defense = dice + session.player_dp
                    screen.clear_screen()
                    screen.print_general_screen()
                    screen.print_battle_screen()
                    screen.print_battle_info(
                        "Player defends, rolls %s, getting %s of defense" % (dice, player_defense)
                    )
                    raw_input("Press any key to continue...")
                    turn = "monster"
                    break
                else:
                    screen.print_error("Choose a valid option")
        elif turn == "monster":
            dice = utils.rolls_dice()
            option = utils.choose_one(["1", "2"])
            if option == "1":
                if player_defense > 0:
                    damage = (dice + session.monster_ap) - (session.player_dp + player_defense)
                else:
                    damage = (dice + session.monster_ap) - session.player_dp
                if damage < 0:
                    damage = 0
                screen.clear_screen()
                screen.print_general_screen()
                screen.print_battle_screen()
                screen.print_battle_info(
                    "Monster attacks, rolls %s, dealing %s of damage" % (dice, damage)
                )
                raw_input("Press any key to continue...")
                session.player_hp = session.player_hp - damage
                monster_defense = 0
                turn = "player"
            elif option == "2":
                monster_defense = dice + session.monster_dp
                screen.clear_screen()
                screen.print_general_screen()
                screen.print_battle_screen()
                screen.print_battle_info(
                    "Monster defends, rolls %s, getting %s of defense" % (dice, monster_defense)
                )
                raw_input("Press any key to continue...")
                turn = "player"
            else:
                screen.print_error("Unknown monster action")
        else:
            screen.print_error("Unknown turn")

        if session.monster_hp <= 0:
            screen.print_room_notice("You won!")
            screen.print_room_notice("You found %sGP" % session.monster_gp)
            session.player_gp = session.player_gp + session.monster_gp
            rooms.render_room_5()
        elif session.player_hp <= 0:
            screen.print_room_notice("You died!")
            screen.print_game_over()
        else:
            continue