# I keep forgetting to branch at the start import textwrap from room import Room from item import Item from lightsource import LightSource from player import Player wrapper = textwrap.TextWrapper(width=50) play = True # Declare all the rooms amulet = Item("Amulet", "Revives the wearer's beloved") trident = Item("Trident", "King Triton's prized posession") torch = LightSource("Torch", "a wooden torch", True) room = { 'outside': Room("Outside Cave Entrance", "North of you, the cave mount beckons"), 'foyer': Room( "Foyer", """Dim light filters in from the south. Dusty passages run north and east.""", [torch]), 'overlook': Room( "Grand Overlook", """A steep cliff appears before you, falling into the darkness. Ahead to the north, a light flickers in the distance, but there is no way across the chasm."""), 'narrow': Room( "Narrow Passage", """The narrow passage bends here from west
room["foyer"].n_to = room["overlook"] room["foyer"].e_to = room["narrow"] room["overlook"].s_to = room["foyer"] room["narrow"].w_to = room["foyer"] room["narrow"].n_to = room["treasure"] room["treasure"].s_to = room["narrow"] room["streets"].s_to = room["city"] room["streets"].n_to = room["outside"] room["city"].n_to = room["streets"] room["outside"].items.append(Item("sword", "Long Sword")) room["outside"].items.append(Item("coins", "Gold Coins")) # Gets random room and puts the torch there key, random_room = random.choice(list(room.items())) random_room.items.append(LightSource("torch", "Torch")) # # Main # # Make a new player object that is currently in the 'outside' room. player = Player("Rodrigo", room["outside"]) # Write a loop that: # # * Prints the current room name # * Prints the current description (the textwrap module might be useful here). # * Waits for user input and decides what to do. #
import printing import commandparser as parser # Declare the items items = { 'jewel': Treasure(100, "jewel", ["glittering"], "It is a deep red hue and seems to pulse to an unheard rhythm."), 'locket': Item("locket", ["battered", "silver"], "Opening it reveals a faded photograph of two lovers."), 'dagger': Weapon(10, "dagger", ["thin"], "It looks like it could be used to stab somebody."), 'lantern': LightSource("lantern", ["spooky"], "It flickers gently as if spurred by an unfelt breeze.") } monsters = { 'demon': Monster( "demon", "Its festering skin appears to be falling off with every movement", 10, 5), 'dragon': Monster( "dragon", "It fills the room with its presence, and the air with the choking fumes of its breath", 100, 20) }