Exemple #1
0
def intro():
    display.slow_print("""
                            ---------------------
                         |    End of the Tunnel    |
                         |  A Text Adventure Game  |
                            ---------------------


        In an alternate 1830’s industrial revolution, our world was 
        hit a brutal ice age. In order for people to survive, they had to 
        relocate to the underground tunnels and catacombs. Although, 
        people banded together for their survival, a caste system forms 
        between those that could afford to bring machinery and resources 
        and those who could not. The upper class citizen had access to 
        basic necessities and lived lavishly while the lower class were 
        farmers that lived in disease filled conditions.

        Our story begins with a man named Jack Hill, a lower class citizen 
        and mechanic of the power generator providing heat for his 
        underground colony. Jack recently lost his wife, Hilda, a servant 
        for an upper class noble a month ago due to poor working conditions. 
        Devastated and without any friends, Jack begins talking to himself 
        as if Hilda, never left him. One day, Jack wakes up to his town in disarray. 
        As Jack makes his way to the Town Hall, he learns that someone has sabotaged 
        the generator and three pieces are missing. Now Jack has to recover the 
        pieces before he and the town die without a heat source.  
        """)
Exemple #2
0
 def modify_player(self, player):
     if player.blackouts < 1:
         display.slow_print("""
     Two guards tell Jack that no one has entered or exited the generator
     pieces went missing. No one is allowed past this point.
         """)
     else:
         display.slow_print("""
     Two guards lay on the floor lifeless. The exit out of town is blocked off by
     dirt and rubble from an explosion.
         """)
Exemple #3
0
 def modify_player(self, player):
     if (self.itemAvailable):
         display.slow_print("""
     Jack finds a missing piece of the generator.
         """)
         player.inventory.append(items.GeneratorPart3(0))
         self.itemAvailable = False
     if player.blackouts == 2:
         if self.finalCheck == False:
             player.nonUppClassAreaRoomsVisited += 1
             self.finalCheck = True
Exemple #4
0
 def modify_player(self, player):
     if player.blackouts == 1:
         if self.resetItemAvailable:
             display.slow_print("""
     Jack recovers the missing generator piece.
             """)
             player.inventory.append(items.GeneratorPart3(0))
             self.resetItemAvailable = False
     if player.blackouts == 2:
         if self.finalCheck == False:
             player.nonUppClassAreaRoomsVisited += 1
             self.finalCheck = True
Exemple #5
0
    def adjacent_moves(self):
        """Returns all move actions for adjacent tiles."""
        moves = []
        if world.tile_exists(self.x + 1, self.y):
            moves.append(actions.MoveEast())
        if world.tile_exists(self.x - 1, self.y):
            moves.append(actions.MoveWest())
        if world.tile_exists(self.x, self.y + 1):
            moves.append(actions.MoveSouth())

        # Modify room to allow player to enter Upper Class Area
        if self.blackouts == 2:
            display.slow_print("""
        Jack tells the guards he needs to go through to continue his
        search, but the they tell him to search around town first.
            """)
            if self.nonUpperClassRooms == self.playerVisits:
                if world.tile_exists(self.x, self.y - 1):
                    moves.append(actions.MoveNorth())
                display.slow_print("""
        After telling the guards that the missing piece is not in town,
        the guards exclaim, "You may pass".
                """)
            else:
                display.slow_print("""
        You must leave.
                """)

        return moves
Exemple #6
0
    def modify_player(self, player):
        player.hp -= 5

        if player.generatorPiecesObtained == 3:
            if player.blackouts < 2:
                # Discard generator part 3
                for item in player.inventory:
                    if item.name == items.GeneratorPart3(0).name:
                        player.inventory.remove(item)
                        player.generatorPiecesObtained -= 1
                if player.blackouts == 0:
                    display.slow_print("""
        Hilda, I'm feeling really tired. My mind is starting to 
        go blank. I--
                """)
                    time.sleep(3)
                    os.system('cls')
                    time.sleep(3)

                    for x in range(0, 1000):
                        print("HEHEHE", end="")

                    sys.stdout.flush()
                    time.sleep(2)
                    os.system('cls')
                    time.sleep(3)
                    # Spawn player
                    player.location_x = 5
                    player.location_y = 4
                    player.blackouts += 1

                elif player.blackouts == 1:
                    display.slow_print("""
        Hilda, it's happening again. I feel weak. Make it sto--
                """)
                    time.sleep(3)
                    os.system('cls')
                    time.sleep(3)

                    for x in range(0, 1000):
                        print("DIEDIE", end="")

                    sys.stdout.flush()
                    time.sleep(2)
                    os.system('cls')
                    time.sleep(3)
                    # Spawn player
                    player.location_x = 5
                    player.location_y = 5
                    player.blackouts += 1

                display.slow_print("""
       Location: ???
       Jack slowly opens his eyes. He notices that one of
       the generator pieces is missing.

       Hilda, what happened to me?
                """)
Exemple #7
0
    def attack(self, enemy):
        best_weapon = None
        max_dmg = 0
        for i in self.inventory:
            if isinstance(i, items.Weapon):
                if i.damage > max_dmg:
                    max_dmg = i.damage
                    best_weapon = i

        display.slow_print("Jack uses {} against {}!".format(
            best_weapon.name, enemy.name))
        enemy.hp -= best_weapon.damage
        if not enemy.is_alive():
            display.slow_print("Jack defeated {}!".format(enemy.name))
        else:
            display.slow_print("{} HP is {}.".format(enemy.name, enemy.hp))
        print("")
Exemple #8
0
 def modify_player(self, the_player):
     if self.enemy.is_alive():
         the_player.hp = the_player.hp - self.enemy.damage
         display.slow_print("Enemy does {} damage.".format(
             self.enemy.damage))
         print("")
Exemple #9
0
    def modify_player(self, player):
        player.inventory.append(items.GeneratorPart3(0))
        time.sleep(3)
        os.system('cls')
        time.sleep(3)

        for x in range(0, 1000):
            print("HAHAHA", end="")

        sys.stdout.flush()
        time.sleep(2)
        os.system('cls')
        time.sleep(3)

        display.slow_print("Jack's HP:".format(player.hp))
        display.slow_print("Generator Parts Obtained: {}".format(
            player.generatorPiecesObtained))
        display.slow_print("\nHilda, what should I do?")
        display.slow_print("...")
        time.sleep(1)
        display.slow_print("...")
        time.sleep(1)
        display.slow_print("...")
        time.sleep(1)
        display.slow_print("But your name isn't Hilda, is it {}?".format(
            os.getlogin()))
        display.slow_print(
            "You've only just got here, but you don't know how twisted this world is."
        )
        display.slow_print(
            "They took everything from me and now they'll pay. They all will.")
        print("")
        display.slow_print("""
        Jack takes a piece of the generator and smashes it onto the ground repeatedly as the nobles 
        look on in horror. As word gets around that the generator can no longer be repaired, people
        begin trying to leave the town. However, they find the exit to their city has been blocked off
        by a cave in. With nowhere left to turn, despair begins to creep in to people's minds. The coldness 
        begins to settle in. Within a week, everyone dies from sickness and the cold.
        """)
        display.slow_print("""
                                               ----------- 
                                              |  The End  |
                                               -----------
        """)
        player.victory = True
Exemple #10
0
def play():
    world.load_tiles()
    player = Player()
    # Display introduction to game
    intro()
    # These lines load the starting room and display the text
    room = world.tile_exists(player.location_x, player.location_y)
    display.slow_print(room.intro_text())
    while player.is_alive() and not player.victory:
        # Check if player has all generator pieces
        generatorPiecesObtained = 0
        for item in player.inventory:
            if item.name == items.GeneratorPart1(0).name:
                generatorPiecesObtained += 1
            elif item.name == items.GeneratorPart2(0).name:
                generatorPiecesObtained += 1
            elif item.name == items.GeneratorPart3(0).name:
                generatorPiecesObtained += 1
        player.generatorPiecesObtained = generatorPiecesObtained

        room = world.tile_exists(player.location_x, player.location_y)
        room.modify_player(player)

        # Check again since the room could have changed the player's state
        if player.is_alive() and not player.victory:
            display.slow_print("Jack's HP: {}".format(player.hp))
            display.slow_print("Generator Parts Obtained: {}".format(
                player.generatorPiecesObtained))
            display.slow_print("\nHilda, what should I do?\n")
            available_actions = room.available_actions()
            for action in available_actions:
                print(action)
            action_input = input('\nAction: ')
            for action in available_actions:
                if action_input.upper() == action.hotkey:
                    player.do_action(action, **action.kwargs)
                    break
        elif player.hp == 0:
            display.slow_print("""
        Jack feels numb and can no longer move his body. His vision blurs as he falls.
        """)

            display.slow_print("""
        Game Over
            """)
            return
Exemple #11
0
 def move(self, dx, dy):
     self.location_x += dx
     self.location_y += dy
     display.slow_print(
         world.tile_exists(self.location_x, self.location_y).intro_text())
Exemple #12
0
 def print_inventory(self):
     display.slow_print("\n\nInventory:")
     for item in self.inventory:
         print(item, '\n')