def run_room(player_inventory, player_equipped, combat_off_inventory, combat_spell_inventory, mobs, player_health): description = ''' A glowing aura of blinding light floats in the center of the room. The aura hums and swirls, cascading light throughout the seemingly infinite room. ''' 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 = 3 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 = 9 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, room12_inventory, take_what) elif the_command == 'drop': drop_what = response[1] utils.drop_item(player_inventory, room12_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(room12_inventory, room12_map, room12_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 room12_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 room12_loot_sources: utils.loot(chosen, room12_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': print( "A strange wind blows through the room and snuffs out the magic you are trying to use." ) 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 close you eyes and the light fades.\n\t") print("The torch you had placed has been burned up.") # 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, 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 = ( "\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 = ''' 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