Beispiel #1
0
def scenario2(player):
    print_text.print_text("""
A thick fog presses from the tip of your wand, filling the Training Field, so much so that you can no longer see the dementors.
One dementor claws at your back, cutting deep into your skin and causing you to fall to the ground.
Another dementor flies in to start sucking your life away. Darkness clouds around you, but you have enough strength for one last spell.

What spell will you cast to dispel of the dementors?
Enter "A" for Glacius to freeze the target with icy-cold air.
"B" for Expecto Patronum to cast a Patronus Charm filled with positive emotions.
"C" for Draconifors to transform your target into a dragon.
"D" for Wingardium Leviosa to make the dementors levitate.
            """)
    # Remove 10 points for scratch
    player.health -= 10

    answer = input(">").strip().upper()

    if answer == 'B':
        expecto_patronum()
    else:
        print_text.print_text("""
Your spell falls short, having no affect on the dementors.
One dementor knocks you to the ground, causing you to fall on top of your wand, snapping it in half.
        """)
        loser()
Beispiel #2
0
def handle_monster():
    global monster_won
    inventory = player.inventory
    monster = rooms[currentRoom]["monster"]

    if monster != 'dementors':
        print_text.print_text(f"You have come face to face with a {monster}!")

    if monster == 'dragon':
        # Will return true or false if monster was defeated. If not, the game was lost
        if dragon.dragon_encountered(inventory, player):
            monster_defeated('dragon')
            rooms[currentRoom]['narrow-path'] = 'Charms Class'
        else:
            monster_won = True
    elif monster == 'basilisk':
        # Will return true or false if monster was defeated. If not, the game was lost
        if basilisk.basilisk_encountered(inventory, player):
            monster_defeated('basilisk')
            rooms[currentRoom]['west'] = 'Slytherin CR'
        else:
            monster_won = True
    elif monster == 'dementors':
        # Will return true or false if monster was defeated. If not, the game was lost
        if dementors.dementors_encountered(inventory, player):
            monster_defeated('dementors')
            rooms[currentRoom]['west'] = 'Herbology Grounds'
        else:
            monster_won = True
Beispiel #3
0
def scenario1(player, inventory):
    # Continue to take damage until sword or wand is chosen
    while True:

        print_text.print_text("""
The basilisk turns towards you, ready to strike.
Will you grab your sword or wand?
Enter "A" for sword.
"B" for wand.
        """)

        answer = input(">").strip().upper()

        if answer == 'A':
            scenario3(player, inventory)
            break
        elif answer == 'B':
            scenario2(player, inventory)
            break
        else:
            print_text.print_text("""
You fail to grab your sword or wand.
The basilisk barrels into you, hurling you across the room and crashing into a sculpture.
            """)
            player.health -= 25
Beispiel #4
0
def loser():
    print_text.print_text("""
With no defenses, you trimmer in fear! Dementors sweep in to suck the life away from you.

GAME OVER
    """)
    return
Beispiel #5
0
def print_winner(name):
    print_text.print_text(f"""
Professor Albus Dumbledore rushes to your side with a special thank you!

"Congratulations, {name}! You saved Hogwarts, and all of your classmates! It's time to celebrate with your graduation.
With your skills of taking down dragons, basilisks and dementors, you are bound to have a bright future in the wizarding world!"
    """)
Beispiel #6
0
def fail_no_sword():
    print_text.print_text("""
You raise your wand, but as you are about to cast your first spell, the dragon knocks you to the ground.
Your wand snaps as you fall to the hard ground.
The dragon takes a deep breath, letting out one last burst of flames.

GAME OVER
    """)
    return
Beispiel #7
0
def fail_no_wand():
    print_text.print_text("""
You jump to action, brandishing your sword. 
The dragon flaps its wings in intimidation, shaking the ground beneath you as it lands.
You take a swing at the dragons stomach, but you are too close and too slow.
The dragon opens its mouth, swiftly wrapping it around your head.

GAME OVER
    """)
    return
Beispiel #8
0
def showInstructions():
    # print a main menu and the commands
    print_text.print_text(f'''
How to play:
============
Commands:
  go [direction]
  get [item]
  q <quit game>
  i <show instructions>
    ''')
Beispiel #9
0
def restricted_access():
    global currentRoom
    if 'key' in inventory:
        currentRoom = rooms[currentRoom][move[1]]
        player.inventory.remove('key')
        print_text.print_text(
            'You reach for the key as you enter, but the key has vanished.')
    else:
        print_text.print_text(
            'Access to the Restricted Section is reserved to those with permission from the Headmaster.'
        )
Beispiel #10
0
def sword_winning(player):
    print_text.print_text("""
The basilisk enters the room, and is ready to kill.
From a hidden corner, you jump on the neck of the lowered basilisk and sink your sword into the back of its head.
In agony, the beast throws you off it's back and into a wall, flailing about the room.
With a tremendous amount of blood loss, the basilisk weakens until it cannot stand anymore.
You suffer 20 points of damage, but you have defeated the basilisk.
                    """)
    player.health -= 20
    basilisk_defeated()
    return
Beispiel #11
0
def print_story():
    print_text.print_text(f"""
You are a senior at the mysterious and mystical Hogwarts School of Witchcraft and Wizardry!
With graduation around the corner and scoring at the top of your class, you cannot wait to share your abilities with the world.
There seems to be something wrong with the school you have come to know over the past seven years.
Students from your class have gone missing, teachers have no explanations for strange occurrences in class, and abnormal sounds come from the walls at night.

You have heard legends of monsters within the depths of your school. A dragon, a basilisk, and a pack of dementors are among the worst to have haunted your school.
With your expert knowledge of the very creatures in the legends you have learned of, it is up to you to save your school!
Become the hero of this story, explore Hogwarts with the utmost haste, but don't be too eager to explore hidden paths, for being unprepared could lead to another student taking your place at the top during graduation.
    """)
Beispiel #12
0
def dementors_encountered(inventory, player):
    print_text.print_text("""
As you enter the Training Grounds, the light around you begins to slip away.
Happiness drains from you as fear shivers down the length of your spine.

From above, a group of dementors swirl around you, preventing a hasty escape.
You must be cleaver against these dark creatures, for only magic will force them to retreat.
    """)

    if 'wand' in inventory:
        scenario1(player)
    else:
        loser()
        return

    return defeated
def headmasters_office():
    print_text.print_text("""
            What's the password?
            Enter "A" for Quidditch
            "B" for Sherbet Lemon
            "C" for Hocus Pocus
            "D" for Gillyweed
        """)

    answer = input(">").strip().upper()

    if answer == "B":
        return True
    else:
        print_text.print_text("\nThat is incorrect.")
        return False
def slytherin_dorm():
    dorm_warning()
    print_text.print_text('''
                According to a Malfoy, what is more important than anything else?

                Enter "A" for magic. 
                "B" for pure-blood. 
                "C" for Tom Riddle. 
                "D" for Hogwarts.
        ''')

    if dorm_answer() == 'B':
        return True
    else:
        dorm_caught("Severus Snape")
        return False
def ravenclaw_dorm():
    dorm_warning()
    print_text.print_text('''
                Which came first, the phoenix or the flame?

                Enter "A" for phoenix. 
                "B" for flame. 
                "C" for weird question. 
                "D" for a circle has no beginning.
        ''')

    if dorm_answer() == 'D':
        return True
    else:
        dorm_caught("Filius Flitwick")
        return False
def hufflepuff_dorm():
    dorm_warning()
    print_text.print_text('''
                There once was a kind woman that was known by all as Helga Hufflepuff.
                
                Here resides students inside her house.
                Tap the barrels, ounce by ounce.

                Enter "A" for [8, 5, 12, 7, 1, 8, 21, 6, 6, 12, 5, 16 21, 6, 6]
                "B" for [1, 12. 2. 21. 19. 4. 21. 13. 2. 12. 4. 15.18. 5]
                "C" for [23, 18, 15, 14, 7, 1, 14, 19, 23, 5, 18] 
                "D" for [8, 5, 1, 4, 13, 1, 19, 20, 5, 18, 19, 15, 6, 6, 9, 3, 5]
        ''')

    if dorm_answer() == 'A':
        return True
    else:
        dorm_caught("Pomonoa Sprout")
        return False
def gryffindor_dorm():
    dorm_warning()
    print_text.print_text('''
                I'm often very stern,
                I wear my hair up in a bun,
                I'm really very fair,
                I find Quidditch very fun.
                Who am I?

                Enter "A" for Albus Dumbledore - 
                "B" for Harry Potter - 
                "C" for Hermione Granger - 
                "D" for Minerva McGonagall
        ''')

    if dorm_answer() == 'D':
        return True
    else:
        dorm_caught("Minerva McGonagall")
        return False
Beispiel #18
0
def expecto_patronum():
    print_text.print_text("""
    A burst of light shoots from your wand, holding off the dementors for a moment, but not sending them away.
    You struggle to hold the force of your wand as the dark creatures push against the light.
    Trying to remember your training and how to properly cast a Patronus Charm, you think about Harry Potter.

    Who saved Harry Potter from the dementors by the lake in Prisoner of Azkaban?
    Enter "A" for Albus Dumbledore
    "B" for Harry Potter's Father
    "C" for Sirius Black
    "D" for Harry Potter 
            """)

    answer = input(">").strip().upper()

    if answer == 'D':
        print_text.print_text("""
    Love and happiness builds within you, and you steady your hand and wand.
    You shout out 'Expecto Patronum' once more, casting out your patronus.
    Scouring away from the bouncing patronus, dementors disappear one-by-one.
    Light clears the dark sky, revealing an empty Training Field, and your patronus dances away, disappearing in the distance.
                """)
        dementors_defeated()
    else:
        print_text.print_text("""
    The light shooting from your want weakens more and more as dementors close in.
    Each time one of the dark creatures pass you, a piece of your life is sucked away.
    With strength dwindling, you drop your wand to the ground and fall to the ground.
    Dementors close in closer and closer until all of the light has dissipated.

    GAME OVER 
                """)
Beispiel #19
0
def scenario3(player):
    print_text.print_text("""
You cast a spell at the dragon, but it cannot penetrate the dragon's skin and fails to work.
Aggravated, the dragon swings its tail and knocks you to the ground. Your wand flies through the air.
You take 10 points of damage.
    """)
    player.health -= 10

    print_text.print_text("""
With no way to cast spells, you are left with your sword to defend yourself.
What will you do?
Enter "A" to make a run for your wand.
"B" to attack with your sword.
    """)

    answer = input('>').strip().upper()

    if answer == 'A':
        print_text.print_text("""
You dive and roll in the direction of your wand, narrowly avoiding a grab from the dragon.
You land inches from your wand and pick it up just in time.        
        """)
        scenario2(player)
    else:
        fail_no_wand()
Beispiel #20
0
def scenario2(player):
    print_text.print_text("""
Three spells come to your mind:
Enter "A" for Defodio to dig and carve through the dragon.
"B" for Moblicorpus to levitate and move the dragon.
"C" for Wingardium Leviosa to levitate a large rock onto the dragon.
    """)

    answer = input('>').strip().upper()

    # winning spell
    if answer == 'C':
        print_text.print_text("""
You cast Wingardium Leviosa to the largest rock you can see, causing the rock smash into the dragon.
The dragon falls to the ground, shaking its head from the blunt of the rock.
With spared time, you brandish your sword, jabbing it into the side of the dragon.
It swats you away, causing you to take on 25 points of damage when you hit a wall.
Luckily for you, the sword was enough to cause the dragon to bleed out, giving you access to an exit.
        """)
        player.health -= 25
        dragon_defeated()
    # Other spells fail and the player loses
    else:
        print_text.print_text("""
When it is too late, you remember that your spell cannot penetrate the skin of the dragon.
The dragon breathes fire onto your hand, knocking your wand away.
You reach for your sword, but the dragon is too quick, moving its flames to your other hand.
You become overwhelmed in the fire with no other options.
\nGAME OVER
        """)
        return
Beispiel #21
0
def scenario1(inventory, player):
    print_text.print_text("""
With your wand at the ready, you must come up with a spell to distract the dragon!
Enter "A" for Aqua Eructo to shoot a stream of water at the dragon.
"B" for Langlock to stick the dragon's tongue to the tip of its mouth.
"C" fo Flipendo to knock the dragon backwards
    """)
    answer = input('>').strip().upper()

    # If they select the correct spell, they are taken on a winning path against the dragon
    if answer == "A":
        print_text.print_text("""
Like a firehose, water bursts from the tip of your wand, forcing the dragon towards the corner of the room.
You know that charms and jinx won't penetrate the dragon's thick skin, so you must be clever.
        """)
        if 'broom' in inventory:
            print_text.print_text("""
You swiftly use the Accio summoning charm to call your broom, mounting it.
Flying around the dragon, you confuse it with your speed, giving you time to brandish your sword.
You fly below the belly of the dragon, thrusting your sword into the stomach of the creature.
Just as you clear the dragon above you, it stumbles to the ground, its body shaking the ground and walls.
Beyond the tail of the dragon, you can now see the exit. 
            """)
            dragon_defeated()
        else:
            scenario2(player)
    # Any other spell will fail, causing more effort to win against the dragon
    # This scenario is not yet completed
    else:
        scenario3(player)
Beispiel #22
0
def dragon_encountered(inventory, player):
    print_text.print_text("""
The magnificent dragon flaps its wings and blows fire in your direction.
You narrowly jump out of the way of the burning flames.
You must act quickly if you wish to survive!
                """)
    # Player can only win with both sword and wand
    if 'wand' in inventory and 'sword' in inventory:
        scenario1(inventory, player)
    # without a sword, the wizard has no means to win
    elif 'wand' in inventory:
        fail_no_sword()
    # without a wand, the wizard cannot get close enough to the dragon to use the sword
    elif 'sword' in inventory:
        fail_no_wand()
    # would you fight a dragon with nothing but your hands?
    else:
        print_text.print_text("""
With no defenses, you trimmer in fear, only to be engulfed by the flames of the dragon.
\nGAME OVER
        """)
    return defeated
Beispiel #23
0
def scenario1(player):
    print_text.print_text("""
You pull out your wand and hold it at the ready.
What spell will you cast to dispel of the dementors?
Enter "A" for Locomotor Wibbly to cause the dementors legs to collapse beneath them.
"B" for Nebulus to create a fog from the tip of your wand.
"C" for Expecto Patronum to cast a Patronus Charm filled with positive emotions.
"D" for Diffindo to send a cutting charm at the dementors.
    """)

    answer = input(">").strip().upper()

    if answer == 'A':
        print_text.print_text("""
Your spell shoots through the dementors as if nothing had happened.
A dementor comes from behind, knocking your wand from your hand and into a far away bush.
        """)
        loser()
    elif answer == 'B':
        scenario2(player)
    elif answer == 'C':
        expecto_patronum()
    elif answer == 'D':
        print_text.print_text("""
Your wand shoots a burst of light at one of the dementors, temporarily slowing it in its path to you.
A small piece of it's cloak cuts away and falls to the ground, but the dementor regains speed, sucking life away from you.
More dementors fly in to take away everything that you are, forcing you to slowly crumble.

GAME OVER
        """)
        return
    else:
        print_text.print_text("""
You miss your chance to cast a spell and a dementor knocks your wand away.
        """)
        loser()
Beispiel #24
0
def basilisk_encountered(inventory, player):
    print_text.print_text("""
You quickly reach for the door behind you, but the door has vanished, leaving no exit.
The gigantic basilisk slithers across the room and opens its mouth with a hiss.
You slide under a desk, barely avoiding the deadly bite of the serpent.
You must act quickly if you wish to survive!
    """)

    if 'wand' in inventory and 'sword' in inventory:
        scenario1(player, inventory)
    elif 'wand' in inventory:
        scenario2(player, inventory)
    elif 'sword' in inventory:
        scenario3(player, inventory)
    else:
        print_text.print_text("""
        With no defenses, you trimmer in fear, only to be eaten whole by the basilisk.
        
        GAME OVER
                """)
    if defeated:
        print_text.print_text("The door you came in through has returned.")
    return defeated
Beispiel #25
0
def scenario2(player, inventory):
    print_text.print_text("""
With your wand pointed at the speeding basilisk, you cast a spell.
Enter "A" for Melofors to encase the basilisk head in a pumpkin.
"B" for Colovaria to change the color of the serpent.
"C" for Condundo to confuse and befuddle the basilisk.
"D" for Crucio to inflict intense paine on the basilisk.
        """)

    answer = input(">").strip().upper()

    if answer == 'A':
        print_text.print_text("""
A pumpkin covers the basilisk's head, causing it to change course and crash into a wall.
The tail of the creature swings and knocks the wind out of you. You suffer 10 points of damage.
        """)
        player.health -= 10
        if 'sword' in inventory:
            print_text.print_text("""
Will you cast another spell, or will you brandish your sword?
Enter "A" for spell.
"B" for sword.
            """)

            answer = input(">").strip().upper()

            if answer == 'A':
                scenario2(player, inventory)
            elif answer == 'B':
                scenario3(player, inventory)

    elif answer == 'B':
        print_text.print_text("""
Your spell performs all too well, causing the basilisk's color to blend more with the surrounding.
Almost impossible to see, the serpent crashes into you, forcing you against a wall and crushing your insides.

GAME OVER
        """)
        return
    elif answer == 'C':
        print_text.print_text(
            "Your spell works, confusing the basilisk and causes it to move in a different direction."
        )
        if 'sword' in inventory:
            print_text.print_text("""
Will you cast another spell, or will you brandish your sword?
Enter "A" for spell.
"B" for sword.
            """)

            answer = input(">").strip().upper()

            if answer == 'A':
                scenario2(player, inventory)
            elif answer == 'B':
                scenario3(player, inventory)
    elif answer == 'D':
        print_text.print_text("""
Choosing the dark-side to perform an unforgivable curse, you direct your wand directly at the basilisk.
The creature screams in pain, swinging its head uncontrollably in an attempt to remove the pain.
Crashing into walls and the ceiling, it is clear that the basilisk has gone mad.
You witness the destruction of the room until it all comes to a stop when the basilisk throws its head into a sharp, stone point on the ceiling.
The basilisk falls to the ground, motionless and defeated.      
        """)
        basilisk_defeated()
        return
Beispiel #26
0
def scenario3(player, inventory):
    print_text.print_text("""
You swing your sword as the basilisk approaches, causing it to hesitate in strategy on how to attack.
What is your next move?
Enter "A" to run away from basilisk.
"B" to attack the basilisk head on.
"C" to hide back under desk.
    """)

    answer = input(">").strip().upper()

    if answer == 'A':
        print_text.print_text("""
You make a run for it, but the basilisk is quicker than you, taking a chunk from your arm as it snips. You suffer 25 points in damage.
Ahead, there is a ceiling too low for the basilisk at its current speed.
        """)
        player.health -= 25
        if 'wand' in inventory:
            print_text.print_text("""
What will you do next?
Enter "A" to continue with sword.
"B" to switch to your wand.
            """)

            answer = input(">").strip().upper()

            if answer == 'B':
                scenario2(player, inventory)
            else:
                sword_winning(player)
        else:
            sword_winning(player)

    elif answer == 'B':
        print_text.print_text("""
Your bravery carries to head on to the basilisk. You slide across the floor to avoid a strike, cutting into the side of the creature.
The basilisk is swift at turning around to face you again. You are now trapped in a corner.
        """)

        if 'wand' in inventory:
            print_text.print_text("""
What will you do next?
Enter "A" to stand strong with your sword.
"B" to pull out your wand for some magic.
            """)

            answer = input(">").strip().upper()

            if answer == 'B':
                scenario2(player, inventory)
            else:
                print_text.print_text("""
You see a small opening to a room with a ceiling that is too low for the basilisk at a swift speed.
You make a run for it, barely clearing the next room before the basilisk hits the wall.
                """)
                sword_winning(player)
        else:
            print_text.print_text("""
You see a small opening to a room with a ceiling that is too low for the basilisk at a swift speed.
What will you do?
Enter "A" to make a run for the room.
"B" to face the basilisk head on.
            """)

            answer = input(">").strip().upper()

            if answer == 'A':
                print_text.print_text(
                    "You make a run for it, barely clearing the next room before the basilisk hits the wall."
                )
                sword_winning(player)
            else:
                print_text.print_text("""
You make a grave mistake in trying to face the basilisk head on, as you have nowhere to jump away from attacks.
Your bravery is strong as you run at the creature, but the basilisk is too quick for you to attack.
The basilisk knocks the sword from your hand, leaving you defenseless in a corner.

GAME OVER
                """)
                return

    elif answer == 'C':
        print_text.print_text("""
You quickly hide under the desk, but the basilisk saw your every move.
The dark creature barrels towards you, destroying everything in its path.
In a last moment of bravery, you attempt to come out with the sword, but it slips from your hand.
The basilisk is swift in its strike.

GAME OVER
        """)
        return
Beispiel #27
0
        # Otherwise they are taken to Headmaster's Office
        else:
            currentRoom = "Headmaster\'s Office"


# Kick of game, followed by while loop
# showInstructions()
game_kickoff()

# loop forever
while True:

    if player.health <= 0:
        print_text.print_text(f"""
Your health has declined to {player.health}, which means your heart is no longer beating.

GAME OVER
        """)
        break
    elif monster_won:
        break

    if len(monsters) == 0:
        story.print_winner(player.name)
        break

    showStatus()

    # get the player's next 'move'
    # .split() breaks it up into an list array
    # eg typing 'go east' would give the list:
def dorm_warning():
    print_text.print_text("""
In order to enter the house dorm, you must first answer this riddle. 
Answer correctly and you may enter. 
Answer incorrectly and face the consequences.
        """)
def dorm_caught(professor):
    print_text.print_text(f"""
You have been caught by Professor {professor} for trying to sneak into another houses dorm!
They take you directly to the Headmaster's Office!
            """)