@junaidtomlin_francis/

TextAdventureTemplate

Python

No description

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
class Room(object):
  def __init__(self, description, items, exits):
    self.description = description
    self.items = items
    self.exits = exits
     
  def __repr__(self):
    listExits = ""
    if len(self.exits) == 1:
      listExits = "There is an exit to the " + self.exits[0]
    else:
      listExits = "There are exits to the " + self.exits[0] + " and " + self.exits[1]
    if len(self.items) > 0:  
      listItems = "There is "
      for i in range(len(self.items)):
        first = self.items[i][0]
        if first == "a" or first == "e" or first == "i" or first == "o" or first == "u":
          listItems += "an " + self.items[i]
        else:
          listItems += "a " + self.items[i]
        if i < len(self.items)-2:
          listItems += ", "
        elif i < len(self.items)-1:
          listItems += " and "
        else:
          listItems += " here."
      return self.description + "\n" + listItems + "\n" + listExits
    else:
      return self.description + "\n" + listExits
 
# Your code goes below this line
# Remember to indent you
hotelroom = Room("i will find you and i will kill you .",["stone","knife "],["South"])
space= Room("i will find you and i will kill you .",["stone","knife "],["North","East"])
hospital = Room("i will find you and i will kill you .",["stone","knife "],["West"]) 
space= Room("i will find you and i will kill you .",["stone","knife "],["North","East"])
hotelroom = Room("i found you and now you're dead .") End game