def run_room(player_inventory, rooms_visited): # Let the user know what the room looks like print(Fore.BLUE + Style.BRIGHT + room8_description + Style.RESET_ALL) # valid commands for this room commands = ["go", "take", "drop", "use", "examine", "status", "help"] no_args = ["examine", "status", "help"] # nonsense room number, # In the loop below the user should eventually ask to "go" somewhere. # If they give you a valid direction then set next_room to that value next_room = -1 done_with_room = False while not done_with_room: # Examine the response and decide what to do response = utils.ask_command("Which direction do you want to go?", commands, no_args) the_command = response[0] # now deal with the command if the_command == 'go': go_where = response[1].lower() if go_where == 'north': next_room = 5 done_with_room = True if go_where == 'east': if utils.has_a(player_inventory, 'key') == True: next_room = 9 done_with_room = True else: print('The door is locked') else: print(go_where, 'is not a valid direction') # END of WHILE LOOP else: print('the command', the_command, 'has not been implemented') return next_room
def run_room(player_inventory): # Let the user know what the room looks like print(room7_description) # valid commands for this room commands = ["go", "take", "drop", "use", "examine", "status", "help"] no_args = ["examine", "status", "help"] # nonsense room number, # In the loop below the user should eventually ask to "go" somewhere. # If they give you a valid direction then set next_room to that value next_room = -1 done_with_room = False while not done_with_room: # Examine the response and decide what to do response = utils.ask_command("What do you want to do?", commands, no_args) the_command = response[0] # now deal with the command if the_command == 'go': go_where = response[1].lower() if go_where == 'east': next_room = 8 done_with_room = True elif go_where == 'north': if utils.has_a(player_inventory, 'golden goblet') == True: print("The door is slammed shut") else: next_room = 2 done_with_room = True else: print('You cannot go:', go_where) elif the_command == 'take': response = utils.scrub_response(response) take_what = response[1] utils.take_item(player_inventory, r7_inventory, take_what) if take_what == 'golden goblet': print("The door suddenly slams to the north!") elif the_command == 'drop': response = utils.scrub_response(response) drop_what = response[1] utils.drop_item(player_inventory, r7_inventory, drop_what) if drop_what == 'golden goblet': print("The door to the north swings back open!") elif the_command == 'status': utils.player_status(player_inventory) utils.room_status(r7_inventory) elif the_command == 'examine': print(room7_description) elif the_command == 'help': utils.player_help() else: print("The command:", the_command, "has not been implemented in Room 7") # END of WHILE LOOP return next_room
def run_room(player_inventory, rooms_visited): description = ''' . . . You are in a brightly lit room. The room appears to be an office. There is a desk. There is a door to the SOUTH ''' # # # if room_inventory['key'] > 0: # description = description + '\nYou notice a key on the desk' # else: # description = description + '\nThe desk surface is empty' # print(Fore.BLUE + Style.BRIGHT + description + Style.RESET_ALL) # valid commands for this room commands = ["go", "take", "drop", "use", "examine", "status", "help"] no_args = ["examine", "status", "help"] # nonsense room number, we need to figure out which room they want in the loop next_room = -1 done_with_room = False while not done_with_room: # Examine the response and decide what to do response = utils.ask_command("What do you want to do?", commands, no_args) the_command = response[0] if the_command == 'go': direction = response[1] # Use your hand drawn map to help you think about what is valid if direction == 'north': next_room = 1 done_with_room = True if direction == 'south': next_room = 4 done_with_room = True else: # In this room, there is nowhere else to go. print(" There is no way to go,", direction) elif the_command == 'take': take_what = response[1] # What are they trying to take? if take_what == "gun": if utils.has_a(room_inventory, 'gun'): utils.take_item(player_inventory, room_inventory, 'gun') gun_prompt = " In the desk is a gun. You feel powerful" print(Fore.BLUE + Style.BRIGHT + gun_prompt + Style.RESET_ALL) else: gun_taken = ' You already took the gun' print(Fore.BLUE + Style.BRIGHT + gun_taken + Style.RESET_ALL) else: print("You can not take,", take_what) # end of main while loop return next_room
def run_room(player_inventory, rooms_visited): # Let the user know what the room looks like print(Fore.BLUE + Style.BRIGHT + room4_description + Style.RESET_ALL) # valid commands for this room commands = ["go", "confront", "help"] no_args = ["help"] # nonsense room number, # In the loop below the user should eventually ask to "go" somewhere. # If they give you a valid direction then set next_room to that value next_room = -1 done_with_room = False while not done_with_room: # Examine the response and decide what to do response = utils.ask_command("What do you want to do?", commands, no_args) the_command = response[0] # now deal with the command if the_command == 'go': go_where = response[1].lower() if go_where == 'east': next_room = 5 done_with_room = True else: print(go_where, 'is not a valid direction') # END of WHILE LOOP elif the_command == 'confront': if utils.has_a(player_inventory, 'gun') == True: chance = random.randint(1, 10) if chance < 7: print( "You shoot and kill the bear. In the bear's nest is a suit of armor. You feel even more powerful" ) utils.take_item(player_inventory, room_inventory, 'armor') print("You head east") time.sleep(2) next_room = 5 done_with_room = True else: print( 'You shoot at the bear, but miss. The bear rips your body into ribbons of flesh' ) next_room = 0 done_with_room = True else: print( "The bear is angry, it rips your body into ribbons of flesh" ) next_room = 0 done_with_room = True else: print('the command', the_command, 'has not been implemented') return next_room
def run_room(player_inventory): # Let the user know what the room looks like print(room8_description) # valid commands for this room commands = ["go", "take", "drop", "use", "examine", "status", "unlock"] no_args = ["examine", "status"] # nonsense room number, # In the loop below the user should eventually ask to "go" somewhere. # If they give you a valid direction then set next_room to that value next_room = -1 done_with_room = False while not done_with_room: # Examine the response and decide what to do response = utils.ask_command("What do you want to do?", commands, no_args) the_command = response[0].lower() response = utils.scrub_response(response) # now deal with the command if the_command == 'go': go_where = response[1].lower() if go_where == "north": next_room = 4 done_with_room = True elif go_where == "south": next_room = 10 done_with_room = True else: print("That direction is not an option") elif the_command == 'take': utils.take(player_inventory, room8_inventory, response) elif the_command == 'drop': utils.drop(player_inventory, room8_inventory, response) elif the_command == "status": utils.player_status(player_inventory) elif the_command == "examine": utils.examine(room8_inventory) elif the_command == "unlock": utils.unlock(player_inventory, room8_inventory, room8_locked, response) else: print("The command:", the_command, "has not been implemented in room 8") if not utils.has_a(player_inventory, "antidote"): utils.player_health["health"] = utils.player_health["health"] - 2 print("your throat is burning and your eyes water, you lose two hp") if utils.player_health["health"] <= 0: next_room = 666 done_with_room = True return next_room
def run_room(player_inventory): # Let the user know what the room looks like print(room9_description) # valid commands for this room commands = ["go", "take", "drop", "use", "examine", "status", "help"] no_args = ["examine", "status", "help"] # nonsense room number, # In the loop below the user should eventually ask to "go" somewhere. # If they give you a valid direction then set next_room to that value next_room = -1 done_with_room = False while not done_with_room: # Examine the response and decide what to do response = utils.ask_command("What do you want to do?", commands, no_args) the_command = response[0] # now deal with the command if the_command == 'go': go_where = response[1].lower() if go_where == 'west': next_room = 8 done_with_room = True else: print("Can't go", go_where) elif the_command == 'take': response = utils.scrub_response(response) take_what = response[1] utils.take_item(player_inventory, room9_inventory, take_what) elif the_command == 'status': utils.player_status(player_inventory) utils.room_status(room9_inventory, room9_interacts) elif the_command == 'use': response = utils.scrub_response(response) use_what = response[1] if utils.has_a(player_inventory, use_what): if use_what == 'key': print( "You approach the box with the key out to unlock it.") utils.use_item(player_inventory, use_what) utils.open_box(box_inventory, player_inventory) else: print("You can't use that here.") else: print("You can't use that here.") elif the_command == 'drop': response = utils.scrub_response(response) drop_what = response[1] utils.drop_item(player_inventory, room9_inventory, drop_what) elif the_command == 'help': print( "The valid commands are", commands, no_args, ) else: print("that command is not supported yet") # END of WHILE LOOP return next_room
def run_room(player_inventory, player_equipped, combat_off_inventory, combat_spell_inventory, mobs, player_health): description = ''' A puddle of blood covers the dungeon floor, coming from a body the wolf was feasting on. The body was the commanding officer who had given you a walk through the prison. There are passages going north, east, south, and west. ''' next_room = 6 done_with_room = False if room_state['encounter']: print("Before you are able to get a good look around, a wolf pounces at you!") utils.combat(player_equipped, player_inventory, combat_off_inventory, combat_spell_inventory, mobs, mob, player_health, wolf_attack) room_state['encounter'] = False if player_health['pl_hp'] <= 0: next_room = 15 done_with_room = True print(description) # valid commands for this room commands = ["go", "take", "drop", "use", "status", "loot", "equip"] no_args = ["loot", "equip"] # nonsense room number, we need to figure out which room they want in the loop while not done_with_room: # Examine the response and decide what to do response = utils.ask_command("What do you want to do?", commands, no_args) the_command = response[0] if the_command == 'go': direction = response[1] if direction == 'north': next_room = 11 done_with_room = True elif direction == 'east': next_room = 7 done_with_room = True elif direction == 'south': next_room = 2 done_with_room = True elif direction == 'west': next_room = 5 done_with_room = True else: print("\n\tYou may not go in that direction.\n\t") elif the_command == 'take': take_what = response[1] utils.take_item(player_inventory, room6_inventory, take_what) elif the_command == 'drop': drop_what = response[1] utils.drop_item(player_inventory, room6_inventory, drop_what) elif the_command == 'status': status = response[1] if status == 'player': utils.player_status(player_inventory, player_equipped, player_health) elif status == 'room': utils.room_status(room6_inventory, room6_map, room6_loot_sources) else: print("That is not a valid option.") elif the_command == 'equip': utils.equip_item(player_equipped, player_inventory) elif the_command == 'loot': while True: print("The available loot sources are:\n") for key in room6_loot_sources.keys(): print("\t\t", key) chosen = input("\nWhich would you like to loot? Type 'Q' if you wish to stop looting.\n\t") chosen = chosen.title() if chosen == 'Q': break elif chosen in room6_loot_sources: utils.loot(chosen, room6_loot_sources, player_inventory) break else: print("That is not an available loot source.\n") elif the_command == 'use': interaction = response[1] if interaction == 'heal': if room_state['heal']: if utils.has_a(player_inventory, 'Bolster'): utils.heal(player_health, player_inventory, combat_spell_inventory) room_state['heal'] = False elif utils.has_a(player_inventory, 'Heal'): utils.heal(player_health, player_inventory, combat_spell_inventory) room_state['heal'] = False else: print("You do not have the heal spell!") else: print("You have already used your heal in this room!\n") else: print("\n\tThat is not an available command in this room.\n\t") if player_health['pl_hp'] <= 0: print("A light consumes you...") else: print("\n\tYou press on the door and it slowly creaks ajar.") print("********************************************************\n") # end of main while loop return next_room
def run_room(player_inventory, player_equipped, combat_off_inventory, combat_spell_inventory, mobs, player_health): description = ''' The northern wall has a bookcase covering it. The bookcase is filled with cobwebs and only contains one book. There are passages going east, south, and west. ''' print(description) # valid commands for this room commands = ["go", "take", "drop", "use", "status", "loot", "equip"] no_args = ["loot", "equip"] # nonsense room number, we need to figure out which room they want in the loop next_room = 7 done_with_room = False while not done_with_room: # Examine the response and decide what to do response = utils.ask_command("What do you want to do?", commands, no_args) the_command = response[0] if the_command == 'go': direction = response[1] if direction == 'east': next_room = 9 done_with_room = True elif direction == 'south': next_room = 4 done_with_room = True elif direction == 'west': next_room = 6 done_with_room = True else: print("\n\tYou may not go in that direction.\n\t") elif the_command == 'take': take_what = response[1] utils.take_item(player_inventory, room7_inventory, take_what) elif the_command == 'drop': drop_what = response[1] utils.drop_item(player_inventory, room7_inventory, drop_what) elif the_command == 'status': status = response[1] if status == 'player': utils.player_status(player_inventory, player_equipped, player_health) elif status == 'room': utils.room_status(room7_inventory, room7_map, room7_loot_sources) else: print("That is not a valid option.") elif the_command == 'equip': utils.equip_item(player_equipped, player_inventory) elif the_command == 'loot': while True: print("The available loot sources are:\n") for key in room7_loot_sources.keys(): print("\t\t", key) chosen = input("\nWhich would you like to loot? Type 'Q' if you wish to stop looting.\n\t") chosen = chosen.title() if chosen == 'Q': break elif chosen in room7_loot_sources: utils.loot(chosen, room7_loot_sources, player_inventory) break else: print("That is not an available loot source.\n") elif the_command == 'use': interaction = response[1] if interaction == 'heal': if room_state['heal']: if utils.has_a(player_inventory, 'Bolster'): utils.heal(player_health, player_inventory, combat_spell_inventory) room_state['heal'] = False elif utils.has_a(player_inventory, 'Heal'): utils.heal(player_health, player_inventory, combat_spell_inventory) room_state['heal'] = False else: print("You do not have the heal spell!") else: print("You have already used your heal in this room!\n") else: print("\n\tThat is not an available command in this room.\n\t") if player_health['pl_hp'] <= 0: print("A light consumes you...") else: print("\n\tYou press on the door and it slowly creaks ajar.") print("********************************************************\n") # end of main while loop return next_room
def run_room(player_inventory, player_equipped, combat_off_inventory, combat_spell_inventory, mobs, player_health): description = ''' There are skeletons of small animals covering the ground. On the northern wall is gate with a massive bloody paw print covering what seems to be a keyhole. There are passages to the north and to the south. ''' next_room = 11 done_with_room = False print(description) if room_state['encounter']: print("Amongst the bones in the room stands a massive wolf with many scars covering it's face. It's beaming eyes" "match the same tint of red as the blood on it's claws. Around it's neck is a rope with a key on it.") utils.combat(player_equipped, player_inventory, combat_off_inventory, combat_spell_inventory, mobs, mob, player_health, wolf_attack) room_state['encounter'] = False if player_health['pl_hp'] <= 0: next_room = 15 done_with_room = True else: utils.take_item(player_inventory, room11_inventory, 'Key') # valid commands for this room commands = ["go", "take", "drop", "use", "status", "loot", "equip"] no_args = ["loot", "equip"] # nonsense room number, we need to figure out which room they want in the loop while not done_with_room: # Examine the response and decide what to do response = utils.ask_command("What do you want to do?", commands, no_args) the_command = response[0] if the_command == 'go': direction = response[1] if direction == 'north': if room_state['is_locked']: print("The door is locked.") else: print("You enter the room.") next_room = 13 done_with_room = True elif direction == 'south': next_room = 6 done_with_room = True else: print("\n\tYou may not go in that direction.\n\t") elif the_command == 'take': take_what = response[1] utils.take_item(player_inventory, room11_inventory, take_what) elif the_command == 'drop': drop_what = response[1] utils.drop_item(player_inventory, room11_inventory, drop_what) elif the_command == 'status': status = response[1] if status == 'player': utils.player_status(player_inventory, player_equipped, player_health) elif status == 'room': utils.room_status(room11_inventory, room11_map, room11_loot_sources) else: print("That is not a valid option.") elif the_command == 'equip': utils.equip_item(player_equipped, player_inventory) elif the_command == 'loot': print("There is nothing to loot in this room.") elif the_command == 'use': interaction = response[1] if interaction == 'heal': if room_state['heal']: if utils.has_a(player_inventory, 'Bolster'): utils.heal(player_health, player_inventory, combat_spell_inventory) room_state['heal'] = False elif utils.has_a(player_inventory, 'Heal'): utils.heal(player_health, player_inventory, combat_spell_inventory) room_state['heal'] = False else: print("You do not have the heal spell!") else: print("You have already used your heal in this room!\n") if interaction == 'key': if utils.has_a(player_inventory, 'Key'): if room_state['is_locked']: print("You place the key into the keyhole and turn it until it clicks.\n") room_state['is_locked'] = False while True: answer = input("Would you like to enter?") answer = answer.title() if answer == 'Yes': next_room = 13 done_with_room = True break elif answer == 'No': print("You back away from the room with the door still unlocked.") break else: print("That is not a valid response.\n") else: print("\n\tThat is not an available command in this room.\n\t") if player_health['pl_hp'] <= 0: print("A light consumes you...") else: print("\n\tYou press on the door and it slowly creaks ajar.") print("********************************************************\n") # end of main while loop return next_room
def run_room(player_inventory): if room11_status["dragon alive"] == 0 and room11_inventory["ruby"] == 0: print(room11_description_no_dragon_no_ruby) elif room11_status["dragon alive"] == 0 and room11_inventory["ruby"] == 1: print(room11_description_no_dragon) else: print(room11_description) commands = ["go", "take", "drop", "use", "status", "examine"] no_args = ["status", "examine"] next_room = -1 done_with_room = False while not done_with_room: response = utils.ask_command("What do you want to do?", commands, no_args) the_command = response[0] if the_command == "go": go_where = response[1] if go_where == "south": next_room = 10 done_with_room = True else: print("You cannot go", go_where) elif the_command == "status": utils.player_status(player_inventory) utils.room_status(room11_inventory) elif the_command == "examine": if room11_status["dragon alive"] == 0 and room11_inventory[ "ruby"] == 0: print(room11_description_no_dragon_no_ruby) elif room11_status["dragon alive"] == 0 and room11_inventory[ "ruby"] == 1: print(room11_description_no_dragon) else: print(room11_description) elif the_command == "drop": drop_what = response[1] utils.drop_item(player_inventory, room11_inventory, drop_what) elif the_command == "take": take_what = response[1] if take_what == "ruby": if room11_status["dragon alive"] == 0: utils.take_item(player_inventory, room11_inventory, "ruby") else: print( "Maybe try doing something about that dragon before\n" "taking the *ruby*") else: utils.take_item(player_inventory, room11_inventory, take_what) elif the_command == "use": use_what = response[1] if use_what == "sword": if utils.has_a(player_inventory, "sword"): room11_status["dragon alive"] = 0 print( "You walk up yo the sleeping dragon very stealthily, as\n" "you approach it you can feel its hot breath as it snores\n" "peacefully. You take your sword and stab straight down\n" "into a crack between its scales near its torso. The\n" "dragon makes a terrible roar and lets loose a jet of\n" "flame straight up into the air through its nostrils. The\n" "dragon then falls lifeless to the ground and you feel it\n" "is much safer now to take the *ruby*.") else: print("You cannot use what you do not possess.") elif use_what == "torch": utils.use_torch1(use_what, player_inventory) else: print("There is no reason to use", use_what, "here") else: print("I do not understand", the_command) return next_room
def run_room(player_inventory, rooms_visited): # Let the user know what the room looks like if utils.has_a(player_inventory, 'gun') and utils.has_a(player_inventory, 'armor'): print(Fore.BLUE + Style.BRIGHT + room_description_intimidated + Style.RESET_ALL) else: print(Fore.BLUE + Style.BRIGHT + room7_description + Style.RESET_ALL) # valid commands for this room commands = ["go", "confront", "help"] no_args = ["help"] # nonsense room number, # In the loop below the user should eventually ask to "go" somewhere. # If they give you a valid direction then set next_room to that value next_room = -1 done_with_room = False while not done_with_room: # Examine the response and decide what to do computer_wins = 0 user_wins = 0 games = 0 r_done = False while r_done == False: comp_choice = r.comp() print(Fore.BLUE + Style.BRIGHT + "The master has made his choice. Now it is your turn!" + Style.RESET_ALL) user_choice = r.user_dungeon() if comp_choice == user_choice: print(Fore.RED + Style.BRIGHT + '\tMaster chose', comp_choice, ', Draw! Go again!' + Style.RESET_ALL) if comp_choice == 'rock' and user_choice == 'scissors': print(Fore.RED + Style.BRIGHT + '\tMaster chose', comp_choice, ', Bow to your superior overlord, LOSER!' + Style.RESET_ALL) computer_wins = computer_wins + 1 games += 1 if comp_choice == 'rock' and user_choice == 'paper': print(Fore.RED + Style.BRIGHT + '\tMaster chose', comp_choice, ', You win!' + Style.RESET_ALL) user_wins = user_wins + 1 games += 1 if comp_choice == 'paper' and user_choice == 'rock': print(Fore.RED + Style.BRIGHT + '\tMaster chose', comp_choice, ', Bow to your superior overlord, LOSER!' + Style.RESET_ALL) computer_wins = computer_wins + 1 games += 1 if comp_choice == 'paper' and user_choice == 'scissors': print(Fore.RED + Style.BRIGHT + '\tMaster chose', comp_choice, ', You win!' + Style.RESET_ALL) user_wins = user_wins + 1 games += 1 if comp_choice == 'scissors' and user_choice == 'paper': print(Fore.RED + Style.BRIGHT + '\tMaster chose', comp_choice, ', Bow to your superior overlord, LOSER!' + Style.RESET_ALL) computer_wins = computer_wins + 1 games += 1 if comp_choice == 'scissors' and user_choice == 'rock': print(Fore.RED + Style.BRIGHT + '\tMaster chose', comp_choice, ', You win!' + Style.RESET_ALL) user_wins = user_wins + 1 games += 1 if games == 5: r_done = True if user_wins == 3: print(Fore.BLUE + Style.BRIGHT + 'You defeated the master, he gives you a key' + Style.RESET_ALL) utils.take_item(player_inventory, room_inventory, 'key') print(Fore.BLUE + Style.BRIGHT + 'You head back to the last room' + Style.RESET_ALL) time.sleep(2) next_room = 6 done_with_room = True if user_wins < 3: print(Fore.BLUE + Style.BRIGHT + 'The master defeated you, you are now his slave forever' + Style.RESET_ALL) next_room = 0 done_with_room = True return next_room
def run_room(player_inventory): # Let the user know what the room looks like print(room11_description) # valid commands for this room commands = ["go", "take", "drop", "use", "examine", "status", "help"] no_args = ["examine", "status", "help"] # nonsense room number, # In the loop below the user should eventually ask to "go" somewhere. # If they give you a valid direction then set next_room to that value next_room = -1 done_with_room = False while not done_with_room: # Examine the response and decide what to do response = utils.ask_command("What do you want to do?", commands, no_args) the_command = response[0] # now deal with the command if the_command == 'go': go_where = response[1].lower() if go_where == 'west': next_room = 9 done_with_room = True elif go_where == 'north': next_room = 12 done_with_room = True else: print('You cannot go:', go_where) elif the_command == 'take': response = utils.scrub_response(response) take_what = response[1] utils.take_item(player_inventory, r11_inventory, take_what) elif the_command == 'drop': drop_what = response[1] utils.drop_item(player_inventory, r11_inventory, drop_what) elif the_command == 'use': use_what = response[1] if use_what == 'flask': if utils.has_a(player_inventory, 'flask'): print( "You scoop the milk up into the flask and put it into your inventory" ) player_inventory['flask'] = player_inventory['flask'] - 1 player_inventory['milk'] = player_inventory['milk'] + 1 else: print("You cannot use imaginary objects") else: print("Not useful in this room") elif the_command == 'status': utils.player_status(player_inventory) utils.room_status(r11_inventory) elif the_command == 'examine': print(room11_description) elif the_command == 'help': utils.player_help() else: print("The command:", the_command, "has not been implemented in Room 11") # END of WHILE LOOP return next_room
def run_room(player_inventory): # Let the user know what the room looks like if room_state['empty'] == False: print(room10_initial_description) else: print(room10_finished_description) # valid commands for this room commands = ["go", "take", "drop", "use", "examine", "status", "help"] no_args = ["examine", "status", "help"] # nonsense room number, # In the loop below the user should eventually ask to "go" somewhere. # If they give you a valid direction then set next_room to that value next_room = -1 done_with_room = False while not done_with_room: # Examine the response and decide what to do response = utils.ask_command("What do you want to do?", commands, no_args) the_command = response[0] # now deal with the command if the_command == 'go': go_where = response[1].lower() if go_where == 'north': if utils.has_a(r10_inventory, 'cake'): if utils.has_a(r10_inventory, 'milk'): print( '"Wait adventurer" says the old man in a panicked fashion "Do not forgot your reward."' '\nHe reaches into this robes and pulls out a key, but soon drops it to finish his tasty' '\ntreat. "It is yours" He proceeds "I have no need for it anymore"' ) r10_inventory['key'] = r10_inventory['key'] + 1 r10_inventory['cake'] = r10_inventory['cake'] - 1 r10_inventory['milk'] = r10_inventory['milk'] - 1 empty = room_state['empty'] if empty == False: room_state['empty'] = True else: next_room = 9 done_with_room = True else: next_room = 9 done_with_room = True else: print('You cannot go:', go_where) elif the_command == 'take': response = utils.scrub_response(response) take_what = response[1] utils.take_item(player_inventory, r10_inventory, take_what) elif the_command == 'drop': response = utils.scrub_response(response) drop_what = response[1] utils.drop_item(player_inventory, r10_inventory, drop_what) if drop_what == 'cake': print('"Thank you kind person" the old man says') if drop_what == 'milk': print('"Thank you kind person" the old man says') elif the_command == 'status': utils.player_status(player_inventory) utils.room_status(r10_inventory) elif the_command == 'examine': print(room10_initial_description) elif the_command == 'help': utils.player_help() else: print("The command:", the_command, "has not been implemented in Room 10") # END of WHILE LOOP return next_room
def run_room(player_inventory): # Let the user know what the room looks like print(room11_description) global kobolds_alive # valid commands for this room commands = ["go", "take", "drop", "use", "examine", "status", "unlock", "attack"] no_args = ["examine", "status"] # nonsense room number, # In the loop below the user should eventually ask to "go" somewhere. # If they give you a valid direction then set next_room to that value next_room = -1 kobolds_health = 15 kobolds_atk = 6 done_with_room = False while not done_with_room: # Examine the response and decide what to do response = utils.ask_command("What do you want to do?", commands, no_args) the_command = response[0].lower() response = utils.scrub_response(response) # now deal with the command if the_command == 'go': go_where = response[1].lower() if go_where == "west": next_room = 9 done_with_room = True elif go_where == "north": is_locked = room11_locked["north"] if not is_locked: next_room = 13 done_with_room = True if is_locked: print("door is locked") else: print("That direction is not an option") elif the_command == 'take': utils.take(player_inventory, room11_inventory, response) elif the_command == 'drop': utils.drop(player_inventory, room11_inventory, response) elif the_command == "status": utils.player_status(player_inventory) elif the_command == "examine": utils.examine(room11_inventory) elif the_command == "unlock": utils.unlock(player_inventory, room11_inventory, room11_locked, response) elif the_command == "attack": x = utils.attack(player_inventory, "kobolds", kobolds_health, kobolds_alive, response) kobolds_health = x if x <= 0: print("the kobolds are dead") kobolds_alive = False else: print("The command:", the_command, "has not been implemented in room 11") x = utils.creature_action(kobolds_alive, player_inventory, kobolds_atk, "kobolds") if x: next_room = 666 done_with_room = True if utils.has_a(player_inventory, "healing rune"): for i in range(3): if utils.player_health["health"] < 20: utils.player_health["health"] = utils.player_health["health"] + 1 print("you've been healed extra for having the healing rune and by the magical pool") else: for i in range(2): if utils.player_health["health"] < 20: utils.player_health["health"] = utils.player_health["health"] + 1 print("you've been healed for being by the magical pool") return next_room
def run_room(player_inventory): # Let the user know what the room looks like if room_state['pitch_black']: print(room12_dim_description) else: print(room12_lit_description) # valid commands for this room commands = ["go", "take", "drop", "use", "examine", "status", "help"] no_args = ["examine", "status", "help"] # nonsense room number, # In the loop below the user should eventually ask to "go" somewhere. # If they give you a valid direction then set next_room to that value next_room = -1 done_with_room = False while not done_with_room: # Examine the response and decide what to do response = utils.ask_command("What do you want to do?", commands, no_args) the_command = response[0] # now deal with the command if room_state['pitch_black'] == False: if the_command == 'go': go_where = response[1].lower() if go_where == 'south': next_room = 11 done_with_room = True elif go_where == 'east': is_locked = room_state['door_locked'] if not is_locked: next_room = 13 done_with_room = True else: print("Key required to open locked door.") else: print('You cannot go:', go_where) elif the_command == 'take': response = utils.scrub_response(response) take_what = response[1] utils.take_item(player_inventory, r12_inventory, take_what) elif the_command == 'drop': drop_what = response[1] utils.drop_item(player_inventory, r12_inventory, drop_what) elif the_command == 'use': use_what = response[1] if use_what == 'torch': if utils.has_a(player_inventory, 'torch') == True: pitch_black = room_state['pitch_black'] if pitch_black: room_state['pitch_black'] = False print("The room is filled with bright light!") else: print("The room is already lit!") elif use_what == 'key': if utils.has_a(player_inventory, 'key') == True: door_locked = room_state['door_locked'] if door_locked: room_state['door_locked'] = False print("The door to the EAST is unlocked!") player_inventory[ 'key'] = player_inventory['key'] - 1 else: print("The door was already unlocked!") else: print("You need a key to open this door") else: print("You need a torch to operate in this room") elif the_command == 'status': utils.player_status(player_inventory) utils.room_status(r12_inventory) elif the_command == 'examine': print(room12_lit_description) elif the_command == 'help': utils.player_help() else: print("The command:", the_command, "has not been implemented in Room 4") else: if the_command == 'use': use_what = response[1] if use_what == 'torch': if utils.has_a(player_inventory, 'torch') == True: pitch_black = room_state['pitch_black'] if pitch_black: room_state['pitch_black'] = False print("The room is filled with bright light!") player_inventory[ 'torch'] = player_inventory['torch'] - 1 print(room12_lit_description) else: print("The room is already lit!") else: print("You need a torch to operate in this room") else: print("You cannot use that") elif the_command == 'examine': print(room12_dim_description) elif the_command == 'status': utils.player_status(player_inventory) elif the_command == 'go': go_where = response[1].lower() if go_where == 'south': next_room = 11 done_with_room = True elif the_command == 'help': utils.player_help() else: print("The command:", the_command, "has not been implemented in Room 12") # END of WHILE LOOP return next_room
def run_room(player_inventory): # Let the user know what the room looks like if room_state['pitch_black'] == True: print(room4_dim_description) else: print(room4_lit_description) # valid commands for this room commands = ["go", "take", "drop", "use", "examine", "status", "help"] no_args = ["examine", "status", "help"] # nonsense room number, # In the loop below the user should eventually ask to "go" somewhere. # If they give you a valid direction then set next_room to that value next_room = -1 done_with_room = False while not done_with_room: # Examine the response and decide what to do response = utils.ask_command("What do you want to do?", commands, no_args) the_command = response[0] # now deal with the command if room_state['pitch_black'] == False: if the_command == 'go': go_where = response[1].lower() if go_where == 'south': next_room = 3 done_with_room = True elif go_where == 'north': next_room = 5 done_with_room = True else: print('You cannot go:', go_where) elif the_command == 'take': response = utils.scrub_response(response) take_what = response[1] utils.take_item(player_inventory, r4_inventory, take_what) elif the_command == 'drop': drop_what = response[1] utils.drop_item(player_inventory, r4_inventory, drop_what) elif the_command == 'use': use_what = response[1] if use_what == 'torch': if utils.has_a(player_inventory, 'torch') == True: pitch_black = room_state['pitch_black'] if pitch_black: room_state['pitch_black'] = False print("The room is filled with bright light!") else: print("The room is already lit!") elif use_what == 'sword': if utils.has_a(player_inventory, 'short sword'): print( "You put your short sword into the sheath and it fits perfectly. The chest next to it " "opens and inside you can see a key.") player_inventory['short sword'] = player_inventory[ 'short sword'] - 1 r4_inventory['key'] = r4_inventory['key'] + 1 else: print("You don't possess the correct item") else: print("You need a torch to operate in this room") elif the_command == 'status': utils.player_status(player_inventory) utils.room_status(r4_inventory) elif the_command == 'examine': print(room4_lit_description) elif the_command == 'help': utils.player_help() else: print("The command:", the_command, "has not been implemented in Room 4") else: if the_command == 'use': use_what = response[1] if use_what == 'torch': if utils.has_a(player_inventory, 'torch') == True: pitch_black = room_state['pitch_black'] if pitch_black: room_state['pitch_black'] = False print("The room is filled with bright light!") player_inventory[ 'torch'] = player_inventory['torch'] - 1 print(room4_lit_description) else: print("The room is already lit!") else: print("You need a torch to operate in this room") else: print("You cannot use that") elif the_command == 'examine': print(room4_dim_description) elif the_command == 'status': utils.player_status(player_inventory) elif the_command == 'go': go_where = response[1].lower() if go_where == 'south': next_room = 3 done_with_room = True elif the_command == 'help': utils.player_help() else: print("The command:", the_command, "has not been implemented in Room 4") # END of WHILE LOOP return next_room
def run_room(player_inventory, player_equipped, combat_off_inventory, combat_spell_inventory, mobs, player_health): description = ''' On the western wall there is a painting of a man neatly dressed, giving the impression of a baron or a bishop. Upon closer inspection you see the man has the paws of a wolf and his eyes are a dark red. On the northern wall is an empty torch sconce. There is a passage going west. ''' next_room = 9 done_with_room = False if room_state['encounter']: print( "You walk into the room and see a grimacing wolf with beaming red eyes staring you down. The wolf has jet black" "fur and massive talons.") utils.combat(player_equipped, player_inventory, combat_off_inventory, combat_spell_inventory, mobs, mob, player_health, alpha_attack) room_state['encounter'] = False if player_health['pl_hp'] <= 0: next_room = 15 done_with_room = True else: print(description) else: print(description) # valid commands for this room commands = ["go", "take", "drop", "use", "status", "loot", "equip"] no_args = ["loot", "equip"] # nonsense room number, we need to figure out which room they want in the loop while not done_with_room: # Examine the response and decide what to do response = utils.ask_command("What do you want to do?", commands, no_args) the_command = response[0] if the_command == 'go': direction = response[1] if direction == 'west': next_room = 7 done_with_room = True else: print("\n\tYou may not go in that direction.\n\t") elif the_command == 'take': take_what = response[1] utils.take_item(player_inventory, room9_inventory, take_what) elif the_command == 'drop': drop_what = response[1] utils.drop_item(player_inventory, room9_inventory, drop_what) elif the_command == 'status': status = response[1] if status == 'player': utils.player_status(player_inventory, player_equipped, player_health) elif status == 'room': utils.room_status(room9_inventory, room9_map, room9_loot_sources) else: print("That is not a valid option.") elif the_command == 'equip': utils.equip_item(player_equipped, player_inventory) elif the_command == 'loot': print("There is nothing to loot in this room.") elif the_command == 'use': interaction = response[1] if interaction == 'heal': if room_state['heal']: if utils.has_a(player_inventory, 'Bolster'): utils.heal(player_health, player_inventory, combat_spell_inventory) room_state['heal'] = False elif utils.has_a(player_inventory, 'Heal'): utils.heal(player_health, player_inventory, combat_spell_inventory) room_state['heal'] = False else: print("You do not have the heal spell!") else: print("You have already used your heal in this room!\n") if interaction == 'torch': if room_state['is_locked']: if utils.has_a(player_inventory, 'Torch'): print( "You place the torch inside the sconce and the wall behind it shakes. A blinding light consumes you" "and carries you into a new passage.") player_inventory[ 'Torch'] = player_inventory['Torch'] - 1 next_room = 12 done_with_room = True else: print("You do not possess a torch!.\n") else: print("You are once again consumed by the light.") else: print("\n\tThat is not an available command in this room.\n\t") if player_health['pl_hp'] <= 0: print("A light consumes you...") else: print("\n\tYou press on the door and it slowly creaks ajar.") print("********************************************************\n") # end of main while loop return next_room
def run_room(player_inventory): # Let the user know what the room looks like print(room12_description) global tree_container # valid commands for this room commands = [ "go", "take", "drop", "use", "examine", "status", "unlock", "attack" ] no_args = ["examine", "status"] # nonsense room number, # In the loop below the user should eventually ask to "go" somewhere. # If they give you a valid direction then set next_room to that value next_room = -1 done_with_room = False while not done_with_room: # Examine the response and decide what to do response = utils.ask_command("What do you want to do?", commands, no_args) the_command = response[0].lower() response = utils.scrub_response(response) # now deal with the command if the_command == 'go': go_where = response[1].lower() if go_where == "east": next_room = 10 done_with_room = True else: print("That direction is not an option") elif the_command == 'take': utils.take(player_inventory, room12_inventory, response) elif the_command == 'drop': utils.drop(player_inventory, room12_inventory, response) elif the_command == "status": utils.player_status(player_inventory) elif the_command == "examine": utils.examine(room12_inventory) elif the_command == "unlock": utils.unlock(player_inventory, room12_inventory, room12_locked, response) elif the_command == "attack": if tree_container: if response[1] == "tree" or "roots": if utils.has_a(player_inventory, "axe"): print( "you chop away the roots revealing the key and helm" ) room12_inventory["helm"] = 1 room12_inventory["key"] = 1 tree_container = False else: print("this action requires an axe") else: print("your option for attacking is roots") else: print("you alredy chopped away the roots") else: print("The command:", the_command, "has not been implemented in room 12") return next_room
def run_room(player_inventory): # Let the user know what the room looks like print(room6_description) # valid commands for this room commands = ["go", "take", "drop", "use", "examine", "status", "help"] no_args = ["examine", "status", "help"] # nonsense room number, # In the loop below the user should eventually ask to "go" somewhere. # If they give you a valid direction then set next_room to that value next_room = -1 if utils.has_a(player_inventory, 'special_item'): if utils.has_a(player_inventory, 'special_item2'): if utils.has_a(player_inventory, 'special_item3'): print( "\tA hole has opened up in the western wall and you can see the light of day." "\n\tIt is apparent the end is near.") done_with_room = False while not done_with_room: # Examine the response and decide what to do response = utils.ask_command("What do you want to do?", commands, no_args) the_command = response[0] # now deal with the command if the_command == 'go': go_where = response[1].lower() if go_where == 'east': next_room = 5 done_with_room = True elif go_where == 'west': if utils.has_a(player_inventory, 'special_item'): if utils.has_a(player_inventory, 'special_item2'): if utils.has_a(player_inventory, 'special_item3'): room_state['ending_closed'] = False is_closed = room_state['ending_closed'] if not is_closed: next_room = 14 done_with_room = True else: print( "You cannot fit through this small of an opening." ) else: print( "You cannot fit through this small of an opening." ) else: print( "You cannot fit through this small of an opening.") else: print("You cannot fit through this small of an opening.") else: print('You cannot go:', go_where) elif the_command == 'take': response = utils.scrub_response(response) take_what = response[1] utils.take_item(player_inventory, r6_inventory, take_what) elif the_command == 'drop': drop_what = response[1] utils.drop_item(player_inventory, r6_inventory, drop_what) elif the_command == 'status': utils.player_status(player_inventory) utils.room_status(r6_inventory) elif the_command == 'examine': print(room6_description) elif the_command == 'help': utils.player_help() else: print("Command not implemented in ROOM 6,", the_command) # END of WHILE LOOP return next_room
def run_room(player_inventory, player_equipped, player_health, combat_spell_inventory): description = ''' A red light persists throughout the room and shines down on an blood trail going north. There is a faint drip of water coming from the ceiling. There are passages going north, east, south, and west. ''' player_hp = utils.get_player_hp(player_health) print(description) # valid commands for this room commands = ["go", "take", "drop", "use", "status", "loot", "equip"] no_args = ["loot", "equip"] # nonsense room number, we need to figure out which room they want in the loop next_room = 2 done_with_room = False if player_hp == 0: next_room = 15 done_with_room = True while not done_with_room: # Examine the response and decide what to do response = utils.ask_command("What do you want to do?", commands, no_args) the_command = response[0] if the_command == 'go': direction = response[1] if direction == 'east': next_room = 4 done_with_room = True elif direction == 'west': next_room = 3 done_with_room = True elif direction == 'north': next_room = 6 done_with_room = True elif direction == 'south': next_room = 1 done_with_room = True else: print("\n\tYou may not go in that direction.\n\t") elif the_command == 'take': take_what = response[1] utils.take_item(player_inventory, room2_inventory, take_what) elif the_command == 'drop': drop_what = response[1] utils.drop_item(player_inventory, room2_inventory, drop_what) elif the_command == 'status': status = response[1] if status == 'player': utils.player_status(player_inventory, player_equipped, player_health) elif status == 'room': utils.room_status(room2_inventory, room2_map, room2_loot_sources) else: print("That is not a valid option.") elif the_command == 'equip': utils.equip_item(player_equipped, player_inventory) elif the_command == 'loot': print("There are no loot sources in this room.") elif the_command == 'use': interaction = response[1] if interaction == 'heal': if room_state['heal']: if utils.has_a(player_inventory, 'Bolster'): utils.heal(player_health, player_inventory, combat_spell_inventory) room_state['heal'] = False elif utils.has_a(player_inventory, 'Heal'): utils.heal(player_health, player_inventory, combat_spell_inventory) room_state['heal'] = False else: print("You do not have the heal spell!") else: print("You have already used your heal in this room!\n") else: print("\n\tThat is not an available command in this room.\n\t") if player_health['pl_hp'] <= 0: print("A light consumes you...") else: print("\n\tYou press on the door and it slowly creaks ajar.") print("********************************************************\n") # end of main while loop return next_room
def run_room(player_inventory): room1_description = ''' . . . Main Room . . . You open your eyes. The room you see is musty and dank. You look around and see a brightly lit doorway to the SOUTH as well as a closed door with a small keyhole To the EAST. Inside this room is nothing to pick up, but you scan and see a rather large button is protruding in the northern wall. ''' print(room1_description) # valid commands for this room commands = ["go", "take", "drop", "use", "examine", "status", "help"] no_args = ["examine", "status", "help"] # nonsense room number, we need to figure out which room they want in the loop next_room = -1 done_with_room = False while not done_with_room: # Examine the response and decide what to do response = utils.ask_command("What do you want to do?", commands, no_args) the_command = response[0] if the_command == 'go': direction = response[1] # Use your hand drawn map to help you think about what is valid if direction == 'south': next_room = 2 done_with_room = True elif direction == 'east': is_locked = room_state['door_locked'] if not is_locked: next_room = 3 done_with_room = True else: print("Key required to open locked door.") else: # In this room, there is nowhere else to go. print("There is no way to go,", direction) elif the_command == 'take': take_what = response[1] utils.take_item(player_inventory, r1_inventory, take_what) elif the_command == 'drop': drop_what = response[1] utils.drop_item(player_inventory, r1_inventory, drop_what) elif the_command == 'use': use_what = response[1] if use_what == 'key': if utils.has_a(player_inventory, 'key') == True: door_locked = room_state['door_locked'] if door_locked: room_state['door_locked'] = False print("The door to the EAST is unlocked!") player_inventory['key'] = player_inventory['key'] - 1 else: print("The door was already unlocked!") else: print("You need a key to open this door") if use_what == 'button': player_inventory['special_item'] = 7 print("The button is pressed") elif the_command == 'examine': print(room1_description) elif the_command == 'status': utils.player_status(player_inventory) utils.room_status(r1_inventory) elif the_command == 'help': utils.player_help() else: print("Command not implemented in ROOM 1,", the_command) # end of while loop return next_room
def run_room(player_inventory): room11_description = ''' . . . 11th Room ... There it is! The ELEVATOR!!! However it is blocked by fire. You must use something to ''' print(room11_description) # valid commands for this room commands = ["go", "take", "drop", "use", "examine", "status", "help"] no_args = ["examine", "status", "help"] # nonsense room number, we need to figure out which room they want in the loop next_room = -1 done_with_room = False while not done_with_room: # Examine the response and decide what to do response = utils.ask_command("What do you want to do?", commands, no_args) the_command = response[0] if the_command == 'go': direction = response[1] # Use your hand drawn map to help you think about what is valid if direction == 'north': next_room = 10 done_with_room = True if direction == 'east': if room11_interacts['fire']: print("You can't walk through fire.") else: next_room = 12 done_with_room = True else: # In this room, there is nowhere else to go. print("There is no way to go,", direction) elif the_command == 'take': response = utils.scrub_response(response) take_what = response[1] utils.take_item(player_inventory, room11_inventory, take_what) elif the_command == 'status': utils.player_status(player_inventory) utils.room_status(room11_inventory, room11_interacts) elif the_command == 'drop': response = utils.scrub_response(response) drop_what = response[1] utils.drop_item(player_inventory, room11_inventory, drop_what) elif the_command == 'help': print( "The valid commands are", commands, no_args, ) elif the_command == 'use': response = utils.scrub_response(response) use_what = response[1] if utils.has_a(player_inventory, use_what): if use_what == 'filled mug': room11_interacts['fire'] = False print( "You throw the water and extinguish the flame. Now you can leave through the elevator." ) else: print("You can't use that here.") else: print("You can't use that here.") else: print("Command not implemented in ROOM 2,", the_command) # end of main while loop return next_room
def run_room(player_inventory, player_equipped, combat_off_inventory, combat_spell_inventory, mobs, player_health): description = ''' In the middle of the room is an ancient statue depicting a man with a sword fending off three wolves. The sword the warrior is holding is not cement like the statue, instead it looks like it's made of metal and has a realistic sheen. The warrior has an insignia on his arm saying 'Protector of the Flame'. There are passages going north and east. ''' next_room = 3 done_with_room = False print(description) # valid commands for this room commands = ["go", "take", "drop", "use", "status", "loot", "equip"] no_args = ["loot", "equip"] while not done_with_room: # Examine the response and decide what to do response = utils.ask_command("What do you want to do?", commands, no_args) the_command = response[0] if the_command == 'go': direction = response[1] if direction == 'north': next_room = 5 done_with_room = True elif direction == 'east': next_room = 2 done_with_room = True else: print("\n\tYou may not go in that direction.\n\t") elif the_command == 'take': take_what = response[1] utils.take_item(player_inventory, room3_inventory, take_what) elif the_command == 'drop': drop_what = response[1] utils.drop_item(player_inventory, room3_inventory, drop_what) elif the_command == 'status': status = response[1] if status == 'player': utils.player_status(player_inventory, player_equipped, player_health) elif status == 'room': utils.room_status(room3_inventory, room3_map, room3_loot_sources) else: print("That is not a valid option.") elif the_command == 'equip': utils.equip_item(player_equipped, player_inventory) elif the_command == 'loot': while True: print("The available loot sources are:\n") for key in room3_loot_sources.keys(): print("\t\t", key) chosen = input( "\nWhich would you like to loot? Type 'Q' if you wish to stop looting.\n\t" ) chosen = chosen.title() if chosen == 'Q': break elif chosen in room3_loot_sources: utils.loot(chosen, room3_loot_sources, player_inventory) break else: print("That is not an available loot source.\n") elif the_command == 'use': interaction = response[1] if interaction == 'heal': if room_state['heal']: if utils.has_a(player_inventory, 'Bolster'): utils.heal(player_health, player_inventory, combat_spell_inventory) room_state['heal'] = False elif utils.has_a(player_inventory, 'Heal'): utils.heal(player_health, player_inventory, combat_spell_inventory) room_state['heal'] = False else: print("You do not have the heal spell!") else: print("You have already used your heal in this room!\n") else: print("\n\tThat is not an available command in this room.\n\t") if player_health['pl_hp'] <= 0: print("A light consumes you...") else: print("\n\tYou press on the door and it slowly creaks ajar.") print("********************************************************\n") # end of main while loop return next_room
def run_room(player_inventory, player_equipped, combat_off_inventory, combat_spell_inventory, mobs, player_health): description = ''' In the middle of the room is a giant hearth. Next to the hearth is an empty set of armor holding a sword in the fire, as if it were poking the flames. The sword shines bright red and is on fire, yet not bent or melting in the slightest. There is a passage to the south. ''' print(description) # valid commands for this room commands = ["go", "take", "drop", "use", "status", "loot", "equip"] no_args = ["loot", "equip"] # nonsense room number, we need to figure out which room they want in the loop next_room = 10 done_with_room = False while not done_with_room: # Examine the response and decide what to do response = utils.ask_command("What do you want to do?", commands, no_args) the_command = response[0] if the_command == 'go': direction = response[1] if direction == 'south': next_room = 8 done_with_room = True else: print("\n\tYou may not go in that direction.\n\t") elif the_command == 'take': take_what = response[1] utils.take_item(player_inventory, room10_inventory, take_what) elif the_command == 'drop': drop_what = response[1] utils.drop_item(player_inventory, room10_inventory, drop_what) elif the_command == 'status': status = response[1] if status == 'player': utils.player_status(player_inventory, player_equipped, player_health) elif status == 'room': utils.room_status(room10_inventory, room10_map, room10_loot_sources) else: print("That is not a valid option.") elif the_command == 'equip': utils.equip_item(player_equipped, player_inventory) elif the_command == 'loot': while True: print("The available loot sources are:\n") for key in room10_loot_sources.keys(): print("\t\t", key) chosen = input( "\nWhich would you like to loot? Type 'Q' if you wish to stop looting.\n\t" ) chosen = chosen.title() if chosen == 'Q': break elif chosen in room10_loot_sources: utils.loot(chosen, room10_loot_sources, player_inventory) break else: print("That is not an available loot source.\n") elif the_command == 'use': interaction = response[1] if interaction == 'heal': if room_state['heal']: if utils.has_a(player_inventory, 'Bolster'): utils.heal(player_health, player_inventory, combat_spell_inventory) room_state['heal'] = False elif utils.has_a(player_inventory, 'Heal'): utils.heal(player_health, player_inventory, combat_spell_inventory) room_state['heal'] = False else: print("You do not have the heal spell!") else: print("You have already used your heal in this room!\n") else: print("\n\tThat is not an available command in this room.\n\t") if player_health['pl_hp'] <= 0: print("A light consumes you...") else: print("\n\tYou press on the door and it slowly creaks ajar.") print("********************************************************\n") # end of main while loop return next_room
def run_room(player_inventory): # Let the user know what the room looks like if room_state['dark']: print(room13_dark_description) else: print(room13_bright_description) # valid commands for this room commands = ["go", "take", "drop", "use", "examine", "status", "help"] no_args = ["examine", "status", "help"] # nonsense room number, # In the loop below the user should eventually ask to "go" somewhere. # If they give you a valid direction then set next_room to that value next_room = -1 done_with_room = False while not done_with_room: # Examine the response and decide what to do response = utils.ask_command("What do you want to do?", commands, no_args) the_command = response[0] if room_state['dark']: if the_command == 'use': response = utils.scrub_response(response) use_what = response[1] if utils.has_a(player_inventory, use_what): if use_what == 'flashlight': room_state['dark'] = False print( "You turn on your flashlight and the room fills with bright white light." ) print(room13_bright_description) else: print("You can't use that in this room") else: print("You can't use what you don't have!") elif the_command == "status": print(room13_dark_description) elif the_command == 'go': response = utils.scrub_response(response) direction = response[1] if direction == 'west': next_room = 5 done_with_room = True else: print("There is nowhere to go besides west") elif the_command == 'help': print( "The valid commands are go, help, status, and use, at least until the room is lit." ) else: print( "There is nothing else to do in this room until it is lit") # now deal with the command else: if the_command == 'go': go_where = response[1].lower() if go_where == 'west': next_room = 5 done_with_room = True else: print("Can't go", go_where) elif the_command == 'take': response = utils.scrub_response(response) take_what = response[1] utils.take_item(player_inventory, room13_inventory, take_what) elif the_command == 'status': utils.player_status(player_inventory) utils.room_status(room13_inventory, room13_interacts) elif the_command == 'drop': response = utils.scrub_response(response) drop_what = response[1] utils.drop_item(player_inventory, room13_inventory, drop_what) elif the_command == 'help': print( "The valid commands are", commands, no_args, ) else: print("that command is not supported yet") # END of WHILE LOOP return next_room
def run_room(player_inventory, player_equipped, combat_off_inventory, combat_spell_inventory, mobs, player_health): description = ''' In the middle of the room is a fountain of blood. The fountain is elegantly designed with etchings of ancient battles between man and wolf. The dark red light of the room fades into a ruby shade towards the middle of the room. There are passages going north and west. ''' print(description) # valid commands for this room commands = ["go", "take", "drop", "use", "status", "loot", "equip"] no_args = ["loot", "equip"] # nonsense room number, we need to figure out which room they want in the loop next_room = 4 done_with_room = False while not done_with_room: # Examine the response and decide what to do response = utils.ask_command("What do you want to do?", commands, no_args) the_command = response[0] if the_command == 'go': direction = response[1] if direction == 'north': next_room = 7 done_with_room = True elif direction == 'west': next_room = 2 done_with_room = True else: print("\n\tYou may not go in that direction.\n\t") elif the_command == 'take': take_what = response[1] utils.take_item(player_inventory, room4_inventory, take_what) elif the_command == 'drop': drop_what = response[1] utils.drop_item(player_inventory, room4_inventory, drop_what) elif the_command == 'status': status = response[1] if status == 'player': utils.player_status(player_inventory, player_equipped, player_health) elif status == 'room': utils.room_status(room4_inventory, room4_map, room4_loot_sources) else: print("That is not a valid option.") elif the_command == 'equip': utils.equip_item(player_equipped, player_inventory) elif the_command == 'loot': print("There is nothing to loot in this room.") elif the_command == 'use': interaction = response[1] if interaction == 'heal': if room_state['heal']: if utils.has_a(player_inventory, 'Bolster'): utils.heal(player_health, player_inventory, combat_spell_inventory) room_state['heal'] = False elif utils.has_a(player_inventory, 'Heal'): utils.heal(player_health, player_inventory, combat_spell_inventory) room_state['heal'] = False else: print("You do not have the heal spell!") else: print("You have already used your heal in this room!\n") else: print("\n\tThat is not an available command in this room.\n\t") if player_health['pl_hp'] <= 0: print("A light consumes you...") else: print("\n\tYou press on the door and it slowly creaks ajar.") print("********************************************************\n") # end of main while loop return next_room
def run_room(player_inventory, player_equipped, combat_off_inventory, combat_spell_inventory, mobs, player_health): description = ( "\nThe red light still shines in the dimly light room, exposing the gruesome scene of what used to" "\nguards. To the west is a mossy wall stained with blood. To the east is a wall with guard's corpse" "\npropped up against it. In the center are the torn shackles and another corpse. There's a passage going" "\nnorth.\n") print(description) # valid commands for this room commands = ["go", "take", "drop", "use", "status", "loot", "equip"] no_args = ["loot", "equip"] # nonsense room number, we need to figure out which room they want in the loop next_room = -1 done_with_room = False while not done_with_room: # Examine the response and decide what to do response = utils.ask_command("What do you want to do?", commands, no_args) response = utils.scrub_response(response) the_command = response[0] if the_command == 'go': direction = response[1] # Use your hand drawn map to help you think about what is valid if direction == 'north': if room_state['encounter']: print( "As you go to enter the next room, a Young Wolf attacks you!" ) utils.combat(player_equipped, player_inventory, combat_off_inventory, combat_spell_inventory, mobs, mob, player_health, rat_attack) room_state['encounter'] = False if player_health['pl_hp'] <= 0: next_room = 15 done_with_room = True else: next_room = 2 done_with_room = True else: next_room = 2 done_with_room = True else: print("\n\tYou may not go in that direction.\n\t") elif the_command == 'take': response = utils.scrub_response(response) take_what = response[1] utils.take_item(player_inventory, room1_inventory, take_what) elif the_command == 'drop': drop_what = response[1] utils.drop_item(player_inventory, room1_inventory, drop_what) elif the_command == 'status': status = response[1] if status == 'player': utils.player_status(player_inventory, player_equipped, player_health) elif status == 'room': utils.room_status(room1_inventory, room1_map, room1_loot_sources) else: print("That is not a valid option.") elif the_command == 'equip': utils.equip_item(player_equipped, player_inventory) elif the_command == 'loot': while True: print("The available loot sources are:\n") for key in room1_loot_sources.keys(): print("\t\t", key) chosen = input( "\nWhich would you like to loot? Type 'Q' if you wish to stop looting.\n\t" ) chosen = chosen.title() if chosen == 'Q': break elif chosen in room1_loot_sources: utils.loot(chosen, room1_loot_sources, player_inventory) break else: print("That is not an available loot source.\n") elif the_command == 'use': interaction = response[1] if interaction == 'heal': if room_state['heal']: if utils.has_a(player_inventory, 'Bolster'): utils.heal(player_health, player_inventory, combat_spell_inventory) room_state['heal'] = False elif utils.has_a(player_inventory, 'Heal'): utils.heal(player_health, player_inventory, combat_spell_inventory) room_state['heal'] = False else: print("You do not have the heal spell!") else: print("You have already used your heal in this room!\n") else: print("That is not an option in this room.") else: print("\n\tThat is not an available command in this room.\n\t") if player_health['pl_hp'] <= 0: print("A light consumes you...") else: print("\n\tYou press on the door and it slowly creaks ajar.") print("********************************************************") # end of while loop return next_room
def run_room(player_inventory, player_equipped, combat_off_inventory, combat_spell_inventory, mobs, player_health): description = ''' The room seems to look like an abandoned living space. There is an empty table in the center and a dusty study on the southern wall. There is a door to the north and a passage to the east. ''' print(description) # valid commands for this room commands = ["go", "take", "drop", "use", "status", "loot", "equip"] no_args = ["loot", "equip"] # nonsense room number, we need to figure out which room they want in the loop next_room = 8 done_with_room = False while not done_with_room: # Examine the response and decide what to do response = utils.ask_command("What do you want to do?", commands, no_args) the_command = response[0] if the_command == 'go': direction = response[1] if direction == 'north': if room_state['is_locked']: print(''' You suddenly hear a faint voice whisper, 'You may not go further into my residence if you do not identify my being. I have no legs, yet I can dance. I have no lungs, yet I breathe. I have no life to lose, yet I am capable of dying.' ''') while True: print("Type 'Q' if you wish to stop guessing.") answer = input("What am I?\n") answer = answer.title() if answer == 'Q': print("You are done guessing.\n") break elif answer == 'Fire': print( "The voice catches your ear, saying 'You may enter'." ) next_room = 10 room_state["is_locked"] = False done_with_room = True break else: print("The door does not move.\n") else: print("The voice says, 'You may enter.'") elif direction == 'east': next_room = 5 done_with_room = True else: print("\n\tYou may not go in that direction.\n\t") elif the_command == 'take': take_what = response[1] utils.take_item(player_inventory, room8_inventory, take_what) elif the_command == 'drop': drop_what = response[1] utils.drop_item(player_inventory, room8_inventory, drop_what) elif the_command == 'status': status = response[1] if status == 'player': utils.player_status(player_inventory, player_equipped, player_health) elif status == 'room': utils.room_status(room8_inventory, room8_map, room8_loot_sources) else: print("That is not a valid option.") elif the_command == 'equip': utils.equip_item(player_equipped, player_inventory) elif the_command == 'loot': print("There is nothing to loot in this room.") elif the_command == 'use': interaction = response[1] if interaction == 'heal': if room_state['heal']: if utils.has_a(player_inventory, 'Bolster'): utils.heal(player_health, player_inventory, combat_spell_inventory) room_state['heal'] = False elif utils.has_a(player_inventory, 'Heal'): utils.heal(player_health, player_inventory, combat_spell_inventory) room_state['heal'] = False else: print("You do not have the heal spell!") else: print("You have already used your heal in this room!\n") else: print("\n\tThat is not an available command in this room.\n\t") if player_health['pl_hp'] <= 0: print("A light consumes you...") else: print("\n\tYou press on the door and it slowly creaks ajar.") print("********************************************************\n") # end of main while loop return next_room
def run_room(player_inventory, player_equipped, combat_off_inventory, combat_spell_inventory, mobs, player_health): description = ''' The ground is damp from the drool of the wolf and the walls contain scratches. The red light still persists throughout the room. There are passages going east, south, and west. ''' next_room = 5 done_with_room = False if room_state['encounter']: print( "In the middle of the stands a snarling wolf with deep red eyes and brown fur. You get a chance to look around the room." ) print(description) utils.combat(player_equipped, player_inventory, combat_off_inventory, combat_spell_inventory, mobs, mob, player_health, wolf_attack) room_state['encounter'] = False if player_health['pl_hp'] <= 0: next_room = 15 done_with_room = True else: print(description) # valid commands for this room commands = ["go", "take", "drop", "use", "status", "loot", "equip"] no_args = ["loot", "equip"] # nonsense room number, we need to figure out which room they want in the loop while not done_with_room: # Examine the response and decide what to do response = utils.ask_command("What do you want to do?", commands, no_args) the_command = response[0] if the_command == 'go': direction = response[1] if direction == 'west': next_room = 8 done_with_room = True elif direction == 'east': next_room = 6 done_with_room = True elif direction == 'south': next_room = 3 done_with_room = True else: print("\n\tYou may not go in that direction.\n\t") elif the_command == 'take': take_what = response[1] utils.take_item(player_inventory, room5_inventory, take_what) elif the_command == 'drop': drop_what = response[1] utils.drop_item(player_inventory, room5_inventory, drop_what) elif the_command == 'status': status = response[1] if status == 'player': utils.player_status(player_inventory, player_equipped, player_health) elif status == 'room': utils.room_status(room5_inventory, room5_map, room5_loot_sources) else: print("That is not a valid option.") elif the_command == 'equip': utils.equip_item(player_equipped, player_inventory) elif the_command == 'loot': print("There is nothing to loot in this room.") elif the_command == 'use': interaction = response[1] if interaction == 'heal': if room_state['heal']: if utils.has_a(player_inventory, 'Bolster'): utils.heal(player_health, player_inventory, combat_spell_inventory) room_state['heal'] = False elif utils.has_a(player_inventory, 'Heal'): utils.heal(player_health, player_inventory, combat_spell_inventory) room_state['heal'] = False else: print("You do not have the heal spell!") else: print("You have already used your heal in this room!\n") else: print("\n\tThat is not an available command in this room.\n\t") if player_health['pl_hp'] <= 0: print("A light consumes you...") else: print("\n\tYou press on the door and it slowly creaks ajar.") print("********************************************************\n") # end of main while loop return next_room