Room Code
Room Code
@property
def name(self):
return self._name
@name.setter
def name(self,name):
self._name = name
@property
def items(self):
return self._items
@items.setter
def items(self,items):
self._items = items
@property
def exits(self):
return self._exits
@exits.setter
def exits(self,exits):
self._exits = exits
@property
def grabbables(self):
return self._grabbables
@grabbables.setter
def grabbables(self, grabbable):
self._grabbables = grabbable
@property
def exitLocation(self):
return self._exitLocation
@exitLocation.setter
def exitLocation(self, exitLocation):
self._exitLocation = exitLocation
@property
def itemDescriptions(self):
return self._itemDescriptions
@itemDescriptions.setter
def itemDescriptions(self, description):
self._itemDescriptions = description
s += "Exits: \n"
for exit in self.exits:
s += exit + " "
s += "\n"
return s
def createRooms():
r1 = Room("Dining Room")
r2 = Room("Living Room")
r3 = Room("Office")
r4 = Room("Brewery")
r5 = Room("Taylor Swift Room") # new room
r6 = Room("Resting Room") # new room
r7 = Room("Bathroom") # new room
r8 = Room("Vault Room") # new room
r9 = Room("Basement") # new room (a basement)
r1.addExit("east", r2)
r1.addExit("south",r3)
r1.addExit("stairs",r5) # exit to stairs to a second floor
r2.addExit("west",r1)
r2.addExit("south",r4)
r2.addExit("downstairs",r9) # exit down to the basment
r3.addExit("north",r1)
r3.addExit("east",r4)
r4.addExit("north",r2)
r4.addExit("west",r3)
r4.addExit("south",None)
r5.addExit("stairs",r1)
r5.addExit("east",r6)
r5.addExit("south",r7)
r6.addExit("west",r5)
r6.addExit("south",r8)
r7.addExit("north",r5)
r7.addExit("east",r8)
r8.addExit("west",r7)
r8.addExit("north",r6)
r9.addExit("upstairs",r2) # exit up from the basement
r1.addGrabbable("key")
r3.addGrabbable("book")
r4.addGrabbable("6-pack")
r5.addGrabbable("taylor_swift_action_figure")
# new grabbable
r6.addGrabbable("coins")
# new grabbable
r7.addGrabbable("soap")
# new grabbable
currentRoom = r1
return currentRoom
def death():
print(" " * 17 + "u" * 7)
print(" " * 13 + "u" * 2 + "$" * 11 + "u" * 2)
print(" " * 10 + "u" * 2 + "$" * 17 + "u" * 2)
print(" " * 9 + "u" + "$" * 21 + "u")
print(" " * 8 + "u" + "$" * 23 + "u")
print(" " * 7 + "u" + "$" * 25 + "u")
print(" " * 7 + "u" + "$" * 25 + "u")
print(" " * 7 + "u" + "$" * 6 + "\"" + " " * 3 + "\"" + "$" * 3 + "\"" + " " *
3 + "\"" + "$" * 6 + "u")
print(" " * 7 + "\"" + "$" * 4 + "\"" + " " * 6 + "u$u" + " " * 7 + "$" * 4 +
"\"")
print(" " * 8 + "$" * 3 + "u" + " " * 7 + "u$u" + " " * 7 + "u" + "$" * 3)
print(" " * 8 + "$" * 3 + "u" + " " * 6 + "u" + "$" * 3 + "u" + " " * 6 + "u" +
"$" * 3)
print(" " * 9 + "\"" + "$" * 4 + "u" * 2 + "$" * 3 + " " * 3 + "$" * 3 + "u" *
2 + "$" * 4 + "\"")
print(" " * 10 + "\"" + "$" * 7 + "\"" + " " * 3 + "\"" + "$" * 7 + "\"")
print(" " * 12 + "u" + "$" * 7 + "u" + "$" * 7 + "u")
print(" " * 13 + "u$\"$\"$\"$\"$\"$\"$u")
print(" " * 2 + "u" * 3 + " " * 8 + "$" * 2 + "u$ $ $ $ $u" + "$" * 2 + " " * 7
+ "u" * 3)
print(" u" + "$" * 4 + " " * 8 + "$" * 5 + "u$u$u" + "$" * 3 + " " * 7 + "u" +
"$" * 4)
print(" " * 2 + "$" * 5 + "u" * 2 + " " * 6 + "\"" + "$" * 9 + "\"" + " " * 5 +
"u" * 2 + "$" * 6)
print("u" + "$" * 11 + "u" * 2 + " " * 4 + "\"" * 5 + " " * 4 + "u" * 4 + "$" *
10)
print("$" * 4 + "\"" * 3 + "$" * 10 + "u" * 3 + " " * 3 + "u" * 2 + "$" * 9 +
"\"" * 3 + "$" * 3 + "\"")
print(" " + "\"" * 3 + " " * 6 + "\"" * 2 + "$" * 11 + "u" * 2 + " " + "\"" * 2
+ "$" + "\"" * 3)
print(" " * 11 + "u" * 4 + " \"\"" + "$" * 10 + "u" * 3)
print(" " * 2 + "u" + "$" * 3 + "u" * 3 + "$" * 9 + "u" * 2 + " \"\"" + "$" *
11 + "u" * 3 + "$" * 3)
print(" " * 2 + "$" * 10 + "\"" * 4 + " " * 11 + "\"\"" + "$" * 11 + "\"")
print(" " * 3 + "\"" + "$" * 5 + "\"" + " " * 22 + "\"\"" + "$" * 4 + "\"\"")
print(" " * 5 + "$" * 3 + "\"" + " " * 25 + "$" * 4 + "\"")
currentRoom = createRooms()
inventory = []
while(True):
status = "{}\nYou are carrying: {}\n".format(currentRoom, inventory)
if (currentRoom == None):
death()
break
print("="*60)
print(status)
response = "I don't understand. Try verb noun. Valid verbs are go, look, and
take"
words = action.split()
if (len(words) == 2):
verb = words[0]
noun = words[1]
if (verb == "go"):
response = "Invalid exit."
for i in range(len(currentRoom.exits)):
if (noun == currentRoom.exits[i]):
currentRoom = currentRoom.exitLocation[i]
response = "Room changed."
break
#
if (currentRoom.items[i] == 'brew_rig' and grababbleSearch('6-
pack', currentRoom.grabbables) == False): # These if
statements
currentRoom.itemDescriptions[i] = "Gourd is brewing some sort
of oatmeal stout on the brew rig. A 6-pack is gone." # check to see if
#
if (currentRoom.items[i] == 'couch' and grababbleSearch('coins',
currentRoom.grabbables) == False): #
currentRoom.itemDescriptions[i] = "Made with the best fabric.
Somebody found the coins." #
#
if (currentRoom.items[i] == 'sink' and grababbleSearch('soap',
currentRoom.grabbables) == False): #
currentRoom.itemDescriptions[i] = "Made of granite. The soap
has been picked up." # end of new
addition
if (noun == currentRoom.items[i]):
response = currentRoom.itemDescriptions[i]
break
print("\n{}".format(response))