Exemplo n.º 1
0
def play():

    world.load_tiles()
    Player = player()
    room = world.tile_exists(Player.location_x, Player.location_y)
    print(room.intro_text())

    while Player.is_alive() and not Player.victory:
        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:
            print("\nChoose an action:\n")
            available_actions = room.available_actions()

            # if isinstance(room, tiles.trader_room):
            #     available_actions.append(actions.Trade())

            for action in available_actions:
                print(action)
            action_input = input(
                '===================================\nAction: ')

            for action in available_actions:
                if action_input == action.hotkey:
                    Player.do_action(action, **action.kwargs)
                    break
Exemplo n.º 2
0
def play():
    world.load_tiles()
    player = Player()

    room = world.tile_exists(player.location_x, player.location_y)
    print(room.intro_text())

    while player.is_alive() and not player.victory:
        room = world.tile_exists(player.location_x, player.location_y)
        room.modify_player(player)

        if room.id == CONST.EXIT_TILE_ID:
            player.victory = True

        if player.is_alive() and not player.victory:
            print("Choose an action:\n")
            available_actions = room.available_actions()
            for action in available_actions:
                print(action)

            action_input = input('Action: ')
            for action in available_actions:
                if action_input == action.hotkey:
                    player.do_action(action, **action.kwargs)
                    break
Exemplo n.º 3
0
def play():
    os.system('cls')
    os.system('color 0f')

    world.load_tiles()
    player = Player()
    messages.output('prelude')

    while player.is_alive() and not player.victory:
        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:
            ends_turn = False
            while ends_turn == False:
                print("\nChoose an action:")
                available_actions = room.available_actions()
                for action in available_actions:
                    print(action)
                action_input = input('Action: ')
                player.update_map()
                invalid_input = True
                for action in available_actions:
                    if action_input == action.hotkey:
                        invalid_input = False
                        player.do_action(action, **action.kwargs)
                        ends_turn = action.ends_turn
                if invalid_input:
                    print("\n***********Action Not Allowed***********\n")

    if player.dead:
        print("You have died! care to try again?")
        print("")
        input('''
		Press enter to quit''')
Exemplo n.º 4
0
def play():
    world.load_tiles()
    #    pcs = npcs()
    global player
    global room

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

    #    print vars(room)
    print room.room_name()
    print room.intro_text()
    if room.inventory is not None:
        for item in room.inventory:
            print "\t{} is here.".format(item.name)
    room.exits_text()
    while player.is_alive() and not player.victory:
        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:
            #            print("Choose an action:\n")
            global available_actions
            available_actions = room.available_actions()
            Prompt().cmdloop()
def play():
    world.load_tiles()
    player = Player()
    while player.is_alive() and not player.victory:
        #sets room variable to the tile where the player is
        room = world.tile_exists(player.location_x, player.location_y)
        if player.in_battle == False and player.in_shop == False:
            print(room.intro_text(), "\n")
        room.modify_player(player)
        #Check again as room can change the player's state
        if player.is_alive() and not player.victory:
            print("Choose an action:\n")
            available_actions = room.available_actions(player)
            for action in available_actions:
                print(action)
            player_action = input("What do you do?\n")
            for action in available_actions:
                if player_action == action.name:
                    player.do_action(action, **action.kwargs)
                    break
            if player_action != action.name:
                print("That is not a valid action.")
    if not player.is_alive():
        print("You have been slain!\nYour remains will rot for eternity...")
    if player.victory:
        print(
            "Congratulations! You have completed the Interactive Text Adventure by Jovin Bains.\n\
Version 2.0 is in the works and will be finished in the near future. Contact Jovin Bains for further details."
        )
Exemplo n.º 6
0
def game_loop():
	
	world.load_tiles()
	player = Player()
	room = world.tile_exists(player.location_x, player.location_y)
	
	while player.is_alive() and not player.victory:
		for event in pygame.event.get():
			if event.type == pygame.QUIT:
				quitgame()
	
		#get starting tile for intro text
		#These lines load the starting room and display the text
		room = world.tile_exists(player.location_x, player.location_y)
		print(room)
		room.modify_player(player)
		text = room.intro_text()
		blit_text(screen,text,(40,40),font)
		
		if player.is_alive() and not player.victory:
			
			#put player actions in button format at bottom of the screen
			available_actions = room.available_actions()
			action_list = []
			for action in available_actions:
				action_list.append(action)
			action_text_tile(action_list,player)
			
		update()
Exemplo n.º 7
0
def play():
    world.load_tiles()
    
    player = Player()
    room = world.tile_exists(player.location_x, player.location_y)
#    print(room.tile_name())
#    print vars(room)
    print room.room_name()
    print room.intro_text()
    
    while player.is_alive() and not player.victory:
        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:
#            print("Choose an action:\n")
            available_actions = room.available_actions()
            room.exits_text()
#            print exits
            for action in available_actions:
                 print(action)
#            print " "
            action_input = raw_input('\tWhat would you like to do? :')
            for action in available_actions:
                if action_input == action.hotkey:
                    player.do_action(action, **action.kwargs)
                    break
Exemplo n.º 8
0
def play():
    world.load_tiles()
    player = Player()
    room = world.tile_exists(player.location_x, player.location_y)
    print(room.intro_text())
    while player.is_alive() and not player.victory:
        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:
            if player.hp < player.maxhp:
                player.hp += 1

            print("Choose an action:\n")
            available_actions = room.available_actions()
            for action in available_actions:
                print(action)

            action_input = input('Action: ')
            print()
            for action in available_actions:
                if action_input == action.hotkey:
                    player.do_action(action, **action.kwargs)
                    break

        if not player.is_alive():
            print('You are dead.')
Exemplo n.º 9
0
def play():
    world.load_tiles()
    player = Player()
    # Load starting room and display text
    room = world.tile_exists(player.location_x, player.location_y)
    print(room.intro_text())

    while player.is_alive() and not player.victory:
        room = world.tile_exists(player.location_x, player.location_y)
        room.modify_player(player)
        # check if room has changed player state
        if player.is_alive() and not player.victory:
            print("Choose an action:\n")
            available_actions = room.available_actions()
            for action in available_actions:
                print(action)
            action_input = input("Action: ")
            print("")
            for action in available_actions:
                if action_input == action.hotkey:
                    player.do_action(action, **action.kwargs)
                    break
        elif not player.is_alive() and not player.victory:
            print("""
            You have been slain!
            The life force pours out from your body
            and you are left to wonder what you did wrong.     
                  """)
Exemplo n.º 10
0
def play():
    world.load_tiles()

    player = Player()
    room = world.tile_exists(player.location_x, player.location_y)
    #    print(room.tile_name())
    #    print vars(room)
    print room.room_name()
    print room.intro_text()

    while player.is_alive() and not player.victory:
        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:
            #            print("Choose an action:\n")
            available_actions = room.available_actions()
            room.exits_text()
            #            print exits
            for action in available_actions:
                print (action)
            #            print " "
            action_input = raw_input("\tWhat would you like to do? :")
            for action in available_actions:
                if action_input == action.hotkey:
                    player.do_action(action, **action.kwargs)
                    break
Exemplo n.º 11
0
def play():
    world.load_tiles()
    player = Player()
    while player.is_alive() and not player.victory:
        # loop begins here
        def play():
            world.load_tiles()
            player = Player()
            # These lines load the starting room and display the text
            room = world.tile_exists(player.location_x, player.location_y)
            print(room.intro_text())
            while player.is_alive() and not player.victory:
                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:
                    print("Choose an action:\n")
                    available_actions = room.available_actions()
                    for action in available_actions:
                        print(action)
                        action_input = input('Action: ')
                        for action in available_actions:
                            if action_input == action.hotkey:
                                player.do_action(action, **action.kwargs)
                                break
Exemplo n.º 12
0
def play():
    world.load_tiles()
    player = Player()  #creates player as an object of the Player class
    room = world.tile_exists(player.location_x, player.location_y)
    print(room.intro_text())
    player.isquit = False
    while player.is_alive() and not player.victory and not player.isquit:
        room = world.tile_exists(player.location_x, player.location_y)
        room.modify_player(player)  #modifies the player based on the room
        if player.is_alive(
        ) and not player.victory:  #checks to see that player is not dead to room actions
            print("Choose an action:")  #edit to change message
            available_actions = room.available_actions(player)
            if player.aa and not player.dr:  #st: aa turns off listing all actions
                for action in available_actions:
                    print(action)  #lists possible actions to player
            if player.dr:  #st: dr lists only directional actions
                partial_actions = room.adjacent_moves()
                for action in partial_actions:
                    print(action)

            action_input = input('Action: ')  #takes action input from player
            for action in available_actions:
                if action_input == action.hotkey:
                    player.do_action(action, **action.kwargs)
                    break
Exemplo n.º 13
0
def play():
    world.load_tiles()
    player = Player()
    #These lines load the starting room and display the textg
    room = world.tile_exists(player.location_x, player.location_y)
    util.printGameText(
        room.intro_text(player))  #Added player to check inventory before text
    print("")
    while player.is_alive() and not player.victory:
        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:
            print("Choose an action:\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 == action.hotkey:
                    player.do_action(action, **action.kwargs)
                    break
    if player.is_alive() == False:
        sounds.die()
        print("You died.")
Exemplo n.º 14
0
    def __init__(self, fenetre, **kwargs):
        Frame.__init__(self,
                       fenetre,
                       width=800,
                       height=600,
                       borderwidth=1,
                       **kwargs)

        # configuration de la fenêtre principale
        self.master.title("L'incroyable aventure")
        self.master.geometry("800x600+50+50")
        self.pack(fill=BOTH)

        # initiation des parametres du jeu
        world.load_tiles()
        self.player = Player()
        self.room = world.tile_exists(self.player.location_x,
                                      self.player.location_y)

        # design de l'interface
        self.titre = Label(
            self,
            text=
            "Un jeu d'aventure basique mais incroyablement trépidant peut être même épileptogène"
        )
        self.message = Label(self,
                             width=40,
                             relief='sunken',
                             wraplength=250,
                             justify='left',
                             text=self.room.intro_text())
        self.info = Label(self, text="Options possibles :")
        self.question = Label(self, text="Qu'allez vous faire maintenant ?")
        self.entr1 = Entry(self)

        self.bouton_quitter = Button(self, text="Quitter", command=self.quit)
        self.bouton_avancer = Button(self,
                                     text="Avancer",
                                     fg="red",
                                     command=self.cliquer)
        # création d'un widget 'Canvas' contenant une image bitmap :
        self.can1 = Canvas(self, width=320, height=200, bg='white')
        self.photo = PhotoImage(file='resources/torche.gif')
        self.can1.create_image(160, 100, image=self.photo)
        # Mise en page à l'aide de la méthode 'grid' :
        #       rappel : ne pas utiliser pack() et grid() dans une mm fonction !
        self.titre.grid(row=1, column=1, columnspan=3)
        self.message.grid(row=2, column=1, columnspan=2)
        self.info.grid(row=3, column=1, columnspan=2)
        self.question.grid(row=4, column=1)
        self.entr1.grid(row=4, column=2)
        self.bouton_quitter.grid(row=5, column=3, sticky=E)
        self.bouton_avancer.grid(row=5, column=1, sticky=W)
        self.can1.grid(row=2,
                       column=3,
                       columnspan=1,
                       rowspan=3,
                       sticky=W + N,
                       padx=5,
                       pady=5)
Exemplo n.º 15
0
def play():
	world.load_tiles()
	player = Player()
	room = world.tile_exists(player.location_x, player.location_y)
	print(room.intro_text())
	while player.is_alive() and not player.victory:
		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:
			if player.hp < player.maxhp:
				player.hp += 1

			print("Choose an action:\n")
			available_actions = room.available_actions()
			for action in available_actions:
				print(action)

			action_input = input('Action: ')
			print()
			for action in available_actions:
				if action_input == action.hotkey:
					player.do_action(action, **action.kwargs)
					break

		if not player.is_alive():
			print('You are dead.')
Exemplo n.º 16
0
def play():
    world.load_tiles()
#    pcs = npcs()
    global player
    global room

    player = Player()
    room = world.tile_exists(player.location_x, player.location_y)
    
#    print vars(room)
    print room.room_name()
    print room.intro_text()
    if room.inventory is not None:
        for item in room.inventory:
            print "\t{} is here.".format(item.name)
    room.exits_text()         
    while player.is_alive() and not player.victory:
        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:
#            print("Choose an action:\n")
            global available_actions
            available_actions = room.available_actions()
            Prompt().cmdloop()
Exemplo n.º 17
0
def play():
    world.load_tiles()
#    pcs = npcs()
    player = Player()
    room = world.tile_exists(player.location_x, player.location_y)
#    print(room.tile_name())
#    print vars(room)
    print room.room_name()
    print room.intro_text()
    
    while player.is_alive() and not player.victory:
        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:
#            print("Choose an action:\n")
            available_actions = room.available_actions()
            room.exits_text()
#            print exits
            # for action in available_actions:
            #      print(action)
#            print " "
            action_input = raw_input('\tWhat would you like to do? :')
            action_input = parse_translate(action_input)
#            print action_input
            action_parser(action_input, available_actions, player, room)
Exemplo n.º 18
0
def engine():
    intro = title.choose_title()
    raw_input(intro)
    world.load_tiles()
    player = Player()
    # room_old to make sure a new room intro is given
    room_old = None
    while player.is_alive() and not player.victory:
        room = world.tile_exists(player.loc_x, player.loc_y)
        if room is not room_old:
            print room.intro_text()
            room_old = room
        room.alter_player(player)
        if player.is_alive() and not player.victory:
            available_actions = room.available_actions()
            # print '\tChoose from the following actions:'
            # for action in available_actions:
            #     print '\t\t', action.name[0]
            action_in = raw_input('\n\t> ').lower()
            # if action_in == help or other special actions?
            if action_in == 'exit' or action_in == 'quit':
                sys.exit("\n\tSEE YOU SPACE COWBOY...\n")

            for action in available_actions:
                # problem with user just hitting enter?
                if action_in in action.name:
                    player.do_action(action)
                    done = True
                    break
                else:
                    done = False
                    continue

            if not done:
                print "\n\tSorry, I don't know what that means..."
Exemplo n.º 19
0
def play():
    world.load_tiles()
    player = Player()
    #These lines load the starting room and display the text
    room = world.tile_exists(player.location_x, player.location_y)
    if room is None:
        room = world.tile_exists(2, 0)
    print(room.intro_text())
    while player.is_alive() and not player.victory:
        #loop that shit
        room = world.tile_exists(player.location_x, player.location_y)
        room.modify_player(player)
        #check again since the room could've changed the player's state
        if player.is_alive() and not player.victory:
            #commented this shit out, prints the actions, we want them to guess
            #print("Choose an action:\n")
            available_actions = room.available_actions()
            #for action in available_actions:
            #	print(action)
            action_input = input('Action: ')
            action_found = False
            for action in available_actions:
                #print(action_input, action.hotkey)
                if action_input == action.hotkey:
                    action_found = True
                    player.do_action(action, **action.kwargs)
                    break

            if not action_found:
                print("\nYOU CAN'T DO THAT\n")
Exemplo n.º 20
0
def engine():
    intro = title.choose_title()
    raw_input(intro)
    world.load_tiles()
    player = Player()
    # room_old to make sure a new room intro is given
    room_old = None
    while player.is_alive() and not player.victory:
        room = world.tile_exists(player.loc_x, player.loc_y)
        if room is not room_old:
            print room.intro_text()
            room_old = room
        room.alter_player(player)
        if player.is_alive() and not player.victory:
            available_actions = room.available_actions()
            # print '\tChoose from the following actions:'
            # for action in available_actions:
            #     print '\t\t', action.name[0]
            action_in = raw_input('\n\t> ').lower()
            # if action_in == help or other special actions?
            if action_in == 'exit' or action_in == 'quit':
                sys.exit("\n\tSEE YOU SPACE COWBOY...\n")

            for action in available_actions:
                # problem with user just hitting enter?
                if action_in in action.name:
                    player.do_action(action)
                    done = True
                    break
                else:
                    done = False
                    continue

            if not done:
                print "\n\tSorry, I don't know what that means..."
Exemplo n.º 21
0
def play(saved_world=None, saved_player=None):
    if saved_world and saved_player:
        world._world = saved_world
        player = saved_player
    else:
        world.load_tiles()
        player = Player()
    game_loop(player)
Exemplo n.º 22
0
def play(level, p):
  world.load_tiles(level)
  p.location_x, p.location_y = world.starting_position
  prev_turn = (-1,-1)
  while p.is_alive() and not p.victory and not p.quit:
    if prev_turn != (p.location_x,p.location_y):
      room = world.tile_at(p.location_x, p.location_y)
      room.enter_room(p)
    prev_turn = (p.location_x, p.location_y)
    choose_action(room, p)
Exemplo n.º 23
0
def play():
	world.load_tiles()
	player = Player()
	#These lines load the starting room and display the text
	room = world.tile_exists(player.location_x, player.location_y)
	while player.is_alive() and not player.victory:
		room = world.tile_exists(player.location_x, player.location_y)
		room.modify_player(player)
		if player.is_alive() and not player.victory:
			available_actions = room.available_actions()
			action_input = input('Action: ')
			for action in available_actions:
				if action_input == action.hotkey:
					player.do_action(action)
					break
Exemplo n.º 24
0
def play():
    colorama.init()
    scale = world.load_tiles()
    player = Player()
    # initialize an empty world map to the scale returned from loading
    # the world tiles
    player.worldMap = [[' X ' for x in range(scale[0])]
                       for y in range(scale[1])]
    room = world.tile_exists(player.location_x, player.location_y)
    player.updateMap(room)
    print(Fore.WHITE, end='\r')
    print(room.intro_text())
    while player.is_alive() and not player.victory:
        room = world.tile_exists(player.location_x, player.location_y)
        player.updateMap(room)
        room.modify_player(player)
        # Check again since the room could have changed the player's state
        if player.is_alive() and not player.victory:
            print(Fore.RED + Back.WHITE + "Choose an action")
            available_actions = room.available_actions()
            print(Fore.GREEN + Back.BLACK, end='\r')
            for action in available_actions:
                print(action)
            print(Fore.RED, end='\r')
            action_input = input('Action: ')
            print(Fore.WHITE, end='\r')
            os.system("cls")
            for action in available_actions:
                if action_input == action.hotkey:
                    player.do_action(action, **action.kwargs)
                    break
    if not player.is_alive():
        print("You have died!")
Exemplo n.º 25
0
def play():
    world.load_tiles()
    player = Player()
    while player.is_alive() and not player.victory:
        room = world.tile_exists(player.location_x, player.location_y)
        room.modify_player(player)
        if player.is_alive() and not player.victory:
            print("Choose an action:\n")
            available_actions = room.available_actions()
            for action in available_actions:
                print(action)
            action_input = input("Action: ")
            for action in available_actions:
                if action_input == action.hotkey:
                    player.do_action(action, **action.kwargs)
                    break
Exemplo n.º 26
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
Exemplo n.º 27
0
def play():
    world.load_tiles()
    player = Player()
    while player.is_alive() and not player.victory:
        room = world.tile_exists(player.location_x, player.location_y)
        room.modify_player(player)
#Check again since the room could have change
        if player.is_alive() and not player.victory:
            print("Choose an action: \n")
            available_actions = room.available_actions()
            for action in available_actions = room.available_actions():
                print(action)
            action_input = input('Action: ').lower()
            for action in available_actions:
                if action_input == action.hotkey:
                    player.do_action(action, **action.kwargs)
                    break
Exemplo n.º 28
0
def play():

    world.load_tiles()
    player = Player()
    tile_name = world.tile_exists(player.location_x, player.location_y)

    os.system('cls' if os.name == 'nt' else 'clear')

    map_url = 'https://drive.google.com/file/d/1Cf2d9SXhKff3Lf30xqqnwsrIPWQNUYrQ/view?usp=sharing'
    webbrowser.open(map_url, new=2, autoraise=True)

    print(tile_name.welcome_text())
    leaderboard.show_leaderboard('intro', 0)
    action_input = str(
        raw_input("Please type 'go' to start your treasure hunt: "))

    if action_input == "go":
        os.system('cls' if os.name == 'nt' else 'clear')
        player.move(0, 0)
    else:
        print("\nGoodbye!\n")
        player.hunt_over = True

    while player.hunt_over == False:

        tile_name = world.tile_exists(player.location_x, player.location_y)

        print("        Choose an action:")
        print("        ----------------- ")
        available_actions = tile_name.available_actions(tile_name.id)

        for action in available_actions:
            print("        " + action.__str__())

        action_input = str(raw_input("\n        ACTION: "))

        action_match = False
        for action in available_actions:
            if action_input.lower() == action.hotkey:
                player.do_action(action, **action.kwargs)
                action_match = True

        if action_match == False:
            print("\n        ERROR: '" + action_input +
                  "' is not a valid action in " + tile_name.id + "...\n\n")
Exemplo n.º 29
0
def play():
    world.load_tiles()
    player = Player()
    #This line loads the player into the starting room location and displys the room text
    player.move(2,5) # starting location
    while player.is_alive() and not player.victory:
        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:
            print "Choose an action:\n"
            available_actions = room.available_actions()
            for action in available_actions:
                print action
            action_input = str(raw_input("Action: "))
            for action in available_actions:
                if action_input == action.hotkey:
                    player.do_action(action, **action.kwargs)
                    break
Exemplo n.º 30
0
def play():
    loadingscreen()
    ReadyPlayerOne()
    time.sleep(1)
    os.system('cls' if os.name == 'nt' else 'clear')
    Sound()
    time.sleep(0.75)
    print(
        " __          __  _                            _     s      _____      _           _  \n \ \        / / | |                          | |         / ____|    (_)         | | \n  \ \  /\  / /__| | ___ ___  _ __ ___   ___  | |_ ___   | |     _ __ _ _ __ ___ | | \n   \ \/  \/ / _ \ |/ __/ _ \| '_ ` _ \ / _ \ | __/ _ \  | |    | '__| | '_ ` _ \| | \n    \  /\  /  __/ | (_| (_) | | | | | |  __/ | || (_) | | |____| |  | | | | | | |_| \n     \/  \/ \___|_|\___\___/|_| |_| |_|\___|  \__\___/   \_____|_|  |_|_| |_| |_(_) \n\n"
    )
    print('CRIM v1.5')
    print("Created by Brady Kruse\n\n")
    global room
    world.load_tiles()
    player = Player()
    room = world.tile_exists(player.location_x, player.location_y)
    print(room.intro_text(player))
    while not player.victory:
        room = world.tile_exists(player.location_x, player.location_y)
        room.modify_player(player)
        if not player.victory:
            print("\nChoose an action:\n")
            available_actions = room.available_actions(player)
            for action in available_actions:
                print(action)
            action_input = input('\nAction: ')
            print()
            fail = 0
            for action in available_actions:
                if action_input.lower() == action.hotkey:
                    print(
                        "============================================================================================="
                    )
                    player.do_action(action, **action.kwargs)
                    break
                else:
                    fail += 1
            if fail == len(available_actions):
                print("Invalid input!\n")

    credits()
    time.sleep(20)
Exemplo n.º 31
0
def play():
    world.load_tiles()
    player = Player()
    # These lines load the starting room and display the text
    room = world.tile_exists(player.location_x, player.location_y)
    print(room.intro_text(player))
    while player.is_alive() and not player.victory:
        room = world.tile_exists(player.location_x, player.location_y)
        # Check to see if player moved before modding player
        if player.last_position(player.location_x, player.location_y):
            room.modify_player(player)
        if player.is_alive() and not player.victory:
            print("Choose an action:")
            available_actions = room.available_actions(player)
            for action in available_actions:
                print(action)
            action_input = input('Action: ')
            for action in available_actions:
                if action_input == action.hotkey:
                    player.do_action(action, **action.kwargs)
                    break
    if player.victory:
        time.sleep(1)
        mod_slow_text.super_slow(
            '                ************************************\n'
            '                *            GAME   OVER           *\n'
            '                ************************************\n')
        mod_sound_effects.undead_mob()
        time.sleep(7)
    if not player.victory:
        mod_slow_text.super_slow(
            'The agony of defeat. You have not been able to survive. Your body lays there\n'
            'cold and dead forever......\n')
        mod_sound_effects.zombie()
        time.sleep(1)
        mod_slow_text.super_slow(
            'Or maybe not.......\n'
            '                ************************************\n'
            '                *            GAME   OVER           *\n'
            '                ************************************\n')
        mod_sound_effects.undead_mob()
        time.sleep(7)
Exemplo n.º 32
0
def play():
    world.load_tiles()
    player = Player()
    room = world.tile_exists(player.location_x, player.location_y)
    print(room.intro_text())
    while player.is_alive() and not player.victory:
        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:
            print("Choose an action:\n")
            available_actions = room.available_actions(
            )  # Printing out the actions that the player can do
            for action in available_actions:
                print(action)
            action_input = input('Action: ')
            for action in available_actions:  # Letting the player type in what they would like to do
                if action_input == action.hotkey:
                    player.do_action(action, **action.kwargs)
                    break
Exemplo n.º 33
0
def play():
    world.load_tiles()
    player = Player()
    # These lines load the starting room and display the text.
    room = world.tile_exists(player.location_x, player.location_y)
    print room.intro_text()
    while player.is_alive() and not player.victory:
        room = world.tile_exists(player.location_x, player.location_y)
        room.modify_player(player)
        # Check again as room could have changed the player state
        if player.is_alive() and not player.victory:
            print "Choose an action: \n"
            available_actions = room.available_actions()
            for action in available_actions:
                print action
            action_input = raw_input("Action: ")
            for action in available_actions:
                if action_input == action.hotkey:
                    player.do_action(action, **action.kwargs)
                    break
Exemplo n.º 34
0
def play():
    world.load_tiles()
    my_character = Character()
    my_character.name = input("Initializing...\n\n\n\n\nAh! Hello\n" +\
        "What is your name, stranger?\n\nCall me ")
    while my_character.is_alive() and not (my_character.victory):
        room = world.tile_exists(my_character.location_x, my_character.location_y)
        room.modify_character(my_character)
        # Check again since the room could have changed the player's state
        if my_character.is_alive() and not my_character.victory:
            print("--------------\n--\n--------------\nChoose an action: " +"\n")
            available_actions = room.available_actions()
            print("room avail actions: %s"%room.name)
            for action in available_actions:
                print(action)
            action_input = input('Action: ')
            for action in available_actions:
                if action_input == action.hotkey:  #see world.tile_exists(x,y).room.available_actions()
                    my_character.do_action(action, **action.kwargs)
                    break
Exemplo n.º 35
0
def play():
    world.load_tiles()
    player = Player()
    # These lines load the starting room and display the text.
    room = world.tile_exists(player.location_x, player.location_y)
    print room.intro_text()
    while player.is_alive() and not player.victory:
        room = world.tile_exists(player.location_x, player.location_y)
        room.modify_player(player)
        # Check again as room could have changed the player state
        if player.is_alive() and not player.victory:
            print "Choose an action: \n"
            available_actions = room.available_actions()
            for action in available_actions:
                print action
            action_input = raw_input("Action: ")
            for action in available_actions:
                if action_input == action.hotkey:
                    player.do_action(action, **action.kwargs)
                    break
Exemplo n.º 36
0
def play():
    world.load_tiles()
    player = Player()
    room = world.tile_exists(player.location_x, player.location_y)
    print(room.intro_text())
    while player.is_alive() and not player.victory:
        #loop starts here
        room = world.tile_exists(player.location_x, player.location_y)
        room.modify_player(player)
        #check again bc room could change player state
        if player.is_alive() and not player.victory:
            print("Choose an action:\n")
            available_actions = room.available_actions()
            for action in available_actions:
                print(action)
            action_input = input('Action: ')
            for action in available_actions:
                if action_input == action.hotkey:
                    player.do_action(action, **action.kwargs)
                    break
Exemplo n.º 37
0
def play():
    world.load_tiles()
    player = Player()
    # Load the starting room and display the text
    room = world.tile_exists(player.location_x, player.location_y)
    print(colored(room.intro_text(), color="green"))
    while player.is_alive() and not player.victory:
        room = world.tile_exists(player.location_x, player.location_y)
        room.modify_player(player)
        # Check the player's state after each room
        if player.is_alive() and not player.victory:
            print("Choose an action:\n")
            available_actions = room.available_actions()
            for action in available_actions:
                print(colored(action, color="blue"))
            action_input = input('\nAction: ')
            for action in available_actions:
                if action_input == action.hotkey:
                    player.do_action(action, **action.kwargs)
                    break
Exemplo n.º 38
0
def play():
	print ("Welcome to Josh's Dungeon Crawler! Currently this is a little game, but it is being worked on as time allows! The game begins below!")
	world.load_tiles()
	player = Player()
	#These lines load the starting room and display the text
	room = world.tile_exists(player.location_x, player.location_y)
	print(room.intro_text())
	while player.is_alive() and not player.victory:
		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:
			print("Choose an action:\n")
			available_actions = room.available_actions()
			for action in available_actions:
				print(action)
			action_input = input('Action: ')
			for action in available_actions:
				if action_input == action.hotkey:
					player.do_action(action, **action.kwargs)
					break
Exemplo n.º 39
0
def play():
	world.load_tiles()
	player = Player()
	#These lines load the starting room and display the text
	room = world.tile_exists(player.location_x, player.location_y)
	if room is None:
		room = world.tile_exists(2,0)
	print(room.intro_text())
	while player.is_alive() and not player.victory:
		#loop that shit
		room = world.tile_exists(player.location_x, player.location_y)
		room.modify_player(player)
		#check again since the room could've changed the player's state
		if player.is_alive() and not player.victory:
			#commented this shit out, prints the actions, we want them to guess
			#print("Choose an action:\n")
			available_actions = room.available_actions()
			#for action in available_actions:
			#	print(action)
			action_input = input('Action: ')
			action_found = False
			#print(available_actions)
			for action in available_actions:
				#print('hey', action)
				for hotkey in action.hotkeys:
					#print(action_input, action.hotkey)
					if action_input == hotkey:
						action_found = True
						player.do_action(action, **action.kwargs)
						break

			if not action_found:
				no_action_found_messages = ["\nYOU CAN'T DO THAT\n", "ARGGHH The ocean be a dark place, if ye go that we ye'll fall to yer death\n", "\nOUCH bumped into a wall, ye should stop drinkin so much rum!\n","\nYOU CAN'T DO THAT\n", "ARGGHH The ocean be a dark place, if ye go that we ye'll fall to yer death\n", "\nOUCH bumped into a wall, ye should stop drinkin so much rum!\n", "\nOH NO YE FELL OFF THE PLANK! CHOWDER HEAD!\n"]
				no_action_found_message = random.choice(no_action_found_messages)

				if no_action_found_message == "\nOH NO YE FELL OFF THE PLANK! CHOWDER HEAD!\n":
					player.hp = 0

				print(no_action_found_message)
Exemplo n.º 40
0
def play():
    world.load_tiles()
    player = Player()
    room = world.tile_exists(player.location_x, player.location_y)
    print(room.intro_text())
    while player.is_alive() and not player.victory:
        room = world.tile_exists(player.location_x, player.location_y)
        room.modify_player(
            player
        )  # CHANGE THIS SO THE USER DOESN'T LOSE HP FOR BEING IN THE ROOM
        # Check again since the room could have changed the player's state
        if player.is_alive() and not player.victory:
            print("Choose an action:\n")
            available_actions = room.available_actions()
            for action in available_actions:
                print(action)
            print()
            action_input = input('ACTION: ')
            for action in available_actions:
                if action_input.lower() == action.hotkey:
                    player.do_action(action, **action.kwargs)
                    break
Exemplo n.º 41
0
def play():
    # Calls the load_tiles() method from the world module, creating the game grid.
    world.load_tiles()
    # Creates a variable named "player" that's an instance of the Player() class in the player module.
    player_one = player.Player()
    # Finds the name of the room at the player's starting location and assigns it to the variable "room".
    room = world.tile_exists(player_one.location_x, player_one.location_y)
    # Prints the intro text for the player's starting room.
    # os.system('cls')
    player_one.print_map(player_one.location_x, player_one.location_y)
    print(room.intro_text())
    # Repeats the game loop as long as the player is alive and hasn't won.
    while player_one.is_alive() and not player_one.victory:
        # Updates the "room" variable based on the player's current location.
        room = world.tile_exists(player_one.location_x, player_one.location_y)
        # Calls the modify_player() method from the room the player is currently in.
        # This applies whatever room effect will hit the player, if any.
        room.modify_player(player_one)
        # Check the While conditions again in case the modify_player() method killed the player
        # or caused them to win.
        if player_one.is_alive() and not player_one.victory:
            # Print out the UI for choosing an action.
            print("Choose an action:")
            print("=================")
            # Finds a list of the available actions in the room the player is currently in.
            available_actions = room.available_actions()
            # Prints all the available actions individually in a list.
            for action in available_actions:
                print(action)
                # Asks for the player's input and assigns it to the "action_input" variable.
            action_input = raw_input("\nAction: ")
            # Loops through all the available actions and compares the player's input
            # to the action's hotkey. If they match, the do_action() method is called to execute the action.
            for action in available_actions:
                if action_input == action.hotkey:
                    player_one.do_action(action, **action.kwargs)
                    break
Exemplo n.º 42
0
def play():
    world.load_tiles()
    global player
    player = Player()
    global room
    room = world.tile_exists(player.location_x, player.location_y)
    mapref = world.mapref()
    for k in mapref:
        print k
        print mapref[k]
    print type(mapref)

    describe_room(room)

    while player.is_alive() and not player.victory:
        room = world.tile_exists(player.location_x, player.location_y)
        loc = [player.location_x, player.location_y]
#        room.modify_player(player)
        if player.is_alive() and not player.victory:
            global available_actions
            available_actions = room.available_actions()
        
            if player.moves > 0:
#                print "Running all rooms NPC default"
                room.default(player)
                temp = world.allrooms()
                npclist =[]
                for x, y in temp:
                    
                    tmproom= world.tile_exists(x, y)
                    if tmproom and tmproom.npcs:
                        for npc in tmproom.npcs:
                            if npc.name not in npclist: #we haven't called default on npc yet for this move
                                npc.default(player, world)
                                npclist.append(npc.name)
                                #print "called default on {}".format(npc.name)
        Prompt().cmdloop()
Exemplo n.º 43
0
def play():
    world.load_tiles()
    player = Player()
    room = world.tile_exists(player.location_x, player.location_y)
    print(room.intro_text())
    while player.is_alive() and not player.victory:
        room = world.tile_exists(player.location_x, player.location_y)
        if (room in visited) and ('LootRoom' in str(room.__class__.__bases__)):
            pass
        else:
            visited.append(room)
            room.modify_player(player)
        #  check again since the room could have changed the player's state
        if player.is_alive() and not player.victory:
            print('Choose an action:\n')
            available_actions = room.available_actions()
            for action in available_actions:
                print(action)
            action_input = input('Action: ')
            print('\n')
            for action in available_actions:
                if action_input == action.hotkey:
                    player.do_action(action, **action.kwargs)
                    break
Exemplo n.º 44
0
def play():

    world.load_tiles()
    player = Player()

    print("While walking through an uncharted forest you are set upon by bandits...")
    time.sleep(4)
    print("They catch you off-guard, and knock you out cold!")
    time.sleep(4)
    print("After taking most of your gold, they toss your rag-doll body into a crevice in the ground.")
    time.sleep(5)
    print("You regain consciousness, and find yourself in a cave.")
    time.sleep(4)
    print("You can see the crack far above through which they threw you.")
    time.sleep(4)
    print("You look around, and see there are four directions you can take...")
    time.sleep(4)
    print("...each equally as dark and foreboding as the rest.")
    time.sleep(4)
    print("You hear muffled grows and screaches echo through the cave..")
    time.sleep(4)
    print("Realising that you are in mortal danger, you pick a rock up from the floor for protection.")
    time.sleep(5)
    print("After gathering yourself, you decide to get moving. You need to escape.")
    time.sleep(4)

    while player.is_alive() and not player.victory:

        # Game loop starts here
        room = world.tile_exists(player.location_x, player.location_y)

        # Some rooms modify the player e.g. HP, inventory etc.
        room.modify_player(player)

        # Check again since the room could have changed the player's state.
        if player.is_alive() and not player.victory:

            print("Choose an action:\n")

            # Actions available to the player depend on which room they are current in.
            available_actions = room.available_actions()

            action_hotkeys = []

            for action in available_actions:
                print(action)
                action_hotkeys.append(action.hotkey)

            while True:
                try:
                    action_input = input('Action: ')
                    assert action_input in action_hotkeys
                    break
                except AssertionError:
                    print("Invalid choice. Please try again:\n")

            for action in available_actions:

                if action_input == action.hotkey:

                    player.do_action(action, **action.kwargs)
                    break