def test_room(player): """ To create a room, initialize an inventory either with generate_room_inv(), or insert items manually, or write None. Set can_sell to True or False based off of the vendor status. player.location should always be set to the current room function. Exits is a dictionary of available directions, with the string direction as a key and the function it corresponds to as a value. """ # intialize room inventory and variables test_room_inv = [ classes.Weapon("dagger", "A simple blade, dull and rusted.", 5, 3), classes.Armor( "rags", "Gross and worn old rags, provides a tiny amount of protection.", 2, 1), Item( "note", "'If you're reading this, you have been chosen. Escape from this place and find me where the sun meets the stars'", 0) ] can_sell = False player.location = test_room exits = {"north": test_room2} # introduction print( "You're standing in a small room with dank stone walls. Beside you lie a dagger stabbed into a piece of parchment. There is a tight passageway to the north.\n(type help for commands)" ) # persistently get input, passing the player, the room inventory, and whether or not you can sell items in this space. while True: action = functions.get_action(player, test_room_inv, True, exits)
def test_room2(player): # intialize room inventory and variables test_room2_inv = [ classes.Weapon("dagger", "A simple blade, dull and rusted.", 5, 3), classes.Armor( "old rags", "Gross and worn old rags, provides a tiny amount of protection.", 2, 1) ] can_sell = False player.location = test_room2 exits = {"south": test_room} # introduction print( "You enter into an empty chamber, devoid of any furnishings. There is a rusty dagger and some rags on the floor." ) # persistently get input, passing the player, the room inventory, and whether or not you can sell items in this space. while True: action = functions.get_action(player, test_room2_inv, True, exits)
def generate_weapon(): """ Returns class item Weapon. Works the exact same as generate_item(), but with a seperated list of weapon names and an extra damage value. """ name_list = ["axe", "sword", "club"] weapon_name = choice(name_list) # choose from the name list at random # check what item is generated and assign a description and random damage value from a range if weapon_name == "axe": weapon_description = "a hefty axe" weapon_value = choice(range(50, 90)) weapon_damage = choice(range(10, 25)) elif weapon_name == "sword": weapon_description = "a small shortsword" weapon_value = choice(range(70, 125)) weapon_damage = choice(range(15, 30)) elif weapon_name == "club": weapon_description = "a sturdy club" weapon_value = choice(range(20, 50)) weapon_damage = choice(range(5, 15)) return classes.Weapon(weapon_name, weapon_description, weapon_value, weapon_damage)