#Text Adventure
import shlex
def map():
print ' ______________________________'
print '| | | |'
print '| | | |'
print '| Room B = Room D = Room E |'
print '| Jack | Sword | Bear |'
print '| | | |'
print '|----||---|----||---|----------|'
print '| | |'
print '| | |'
print '| Steve | Jesse |'
print '| Room A = Room C |'
print '|_________|_________|'
class Room(object):
def __init__(self, location, description):
self.location = location
self.description = description
def display_Room(self):
return self.description
class People(object):
def __init__(self,location,name,text,description,state):
self.location = location
self.name = name
self.text = text
self.description = description
self.state = state
def printText(self):
print self.text
def go(self,location,Decision):
newlocation = list(self.location)
if Decision == 'go north' or Decision == 'go n' or Decision == 'n':
newlocation[1] += 1
test = world.get(tuple(newlocation))
if test == None:
print 'You cannot go there'
else:
Ply.location = tuple(newlocation)
elif Decision == 'go south' or Decision == 'go s' or Decision == 's':
newlocation[1] -= 1
test = world.get(tuple(newlocation))
if test == None:
print 'You cannot go there'
else:
Ply.location = tuple(newlocation)
elif Decision == 'go east' or Decision == 'go e' or Decision == 'e':
newlocation[0] += 1
test = world.get(tuple(newlocation))
if test == None:
print 'You cannot go there'
else:
Ply.location = tuple(newlocation)
elif Decision == 'go west' or Decision == 'go w' or Decision == 'w':
newlocation[0] -= 1
test = world.get(tuple(newlocation))
if test == None:
print 'You cannot go there'
else:
Ply.location = tuple(newlocation)
class Player(People):
def __init__(self,location,name,text,state):
self.location = location
self.name = name
self.text = text
self.state = state
def printlocation(self,location):
return world.get(self.location).display_Room()
def take(self,location,Decision):
if Decision == 'take sword':
if self.location == sword.location:
Inventory.append(sword.name)
print 'Taken'
RoomC.description = 'You are in Room C.'
elif Decision == 'take meth' or 'take drugs':
if 'Meth' in Inventory:
print 'YOU ARE HIGH'
Inventory.remove('Meth')
else:
print "You don't have that"
def talk(self,location,Decision):
if Decision == 'talk steve' or Decision == 'talk to steve':
if self.location == Steve.location:
if Jack.state == 'dead':
print 'You killed Jack! Take this is a reward.'
print 'Gold added to Inventory'
Inventory.append(gold.name)
elif Steve.state == 'dead':
print 'This person is dead.'\
else:
Steve.printText()
else:
print "This person is not here."
elif Decision == 'talk jack' or Decision == 'talk to jack':
if self.location == Jack.location:
if Jack.state == 'dead':
print 'This person is dead.'
else:
Jack.printText()
else:
print 'This person is not here'
elif Decision == 'talk jesse' or Decision == 'talk to jesse':
if self.location == Jesse.location:
if Jesse.state == 'dead':
print 'this person is dead'
elif 'Gold' in Inventory:
Drug = raw_input('You wanna buy some drugs?')
if Drug == 'no':
print 'THEN FUCK OFF'
elif Drug == 'yes':
Inventory.remove('Gold')
Inventory.append(meth.name)
print 'Gold removed from Inventory'
print 'Meth added to Inventory'
else:
Jesse.printText()
else:
print 'This person is not here'
elif Decision == 'talk bear' or Decision == 'talk to bear':
if self.location == Bear.location:
if Bear.state == 'dead':
print 'this monster is dead'
else:
Bear.printText()
print 'The bear killed you'
print 'Game over'
Ply.state = 'dead'
else:
print 'This thing is not here'
class Item(object):
def __init__(self,name,text,location):
self.name = name
self.text = text
self.location = location
def kill(Decision):
if Decision == 'kill steve':
if Ply.location == Steve.location:
killhelp('Steve')
else:
print "You don't see this person"
elif Decision == 'kill jack':
if Ply.location == Jack.location:
killhelp('Jack')
else:
print "You don't see this person"
elif Decision == 'kill jesse':
if Ply.location == Jesse.location:
killhelp('Jesse')
else:
print "You don't see this person"
elif Decision == "kill myself":
killhelp('myself')
elif Decision == "kill bear":
print "YOU CAN'T KILL A FRICKIN BEAR."
elif Decision == 'kill steve with sword':
if Ply.location == Steve.location:
killhelpwithitem('Sword','Steve')
else:
print "You don't see this person"
elif Decision == 'kill jack with sword':
if Ply.location == Jack.location:
killhelpwithitem('Sword','Jack')
else:
print "You don't see this person"
elif Decision == 'kill jesse with sword':
if Ply.location == Jesse.location:
killhelpwithitem('Sword','Jesse')
else:
print "You don't see this person"
elif Decision == "kill myself with sword":
killhelpwithitem('Sword','myself')
elif Decision == "kill bear with sword":
print "YOU CAN'T KILL A FRICKIN BEAR WITH A SWORD."
def killhelp(victim):
Dec = raw_input('With what?')
Dec2 = Dec.lower()
if Dec2 == 'sword':
if 'Sword' in Inventory:
killcons(victim)
else:
print "You can't do that"
else:
print "You can't do that"
def killhelpwithitem(Item,victim):
if Item in Inventory:
if Item in Inventory:
killcons(victim)
else:
print "You can't do that"
else:
print "You can't do that"
def killcons(victim):
if victim == 'Steve':
Steve.state = 'dead'
print 'Steve died'
RoomA.description = "You are in Room A. You see Steve's dead body"
if victim == 'Jack':
Jack.state = 'dead'
print 'Jack died'
RoomB.description = "You are in Room B. You see Jack's dead body"
if victim == 'Jesse':
Jesse.state = 'dead'
print 'Jesse died'
RoomD.description = "You are in Room D. You see Jesse's dead body"
if victim == 'myself':
print 'You killed yourself. Good job, Really. Congratulations.'
print 'Game over'
Ply.state = 'dead'
def inv():
print Inventory
def exam(Decision):
if Decision == "examine sword":
print sword.text
elif Decision == "examine gold":
print gold.text
elif Decision == "examine meth":
print meth.text
def help():
print "You can use the following commands:"
print "go (north,south,west,east)"
print "talk (person)"
print "kill (person) with (item)"
print "take (item)"
print "inventory"
print "examine (item)"
print "quit"
Inventory = []
sword = Item('Sword','This is a sword',(2,2))
gold = Item('Gold','This is gold',(1,1))
meth = Item('Meth','THIS IS SOME REALLY NICE BLUE METH',(1,2))
Ply = Player((1,1),'Player','','alive')
Steve = People((1,1),'Steve',"Hi, I'm Steve. Dude, can you do me favor? Kill Jack.",'This is Steve','alive')
Jack = People((1,2),'Jack',"Hi, I'm Jack.",'This is Jack','alive')
Jesse = People((2,1),'Steve','Piss off, bitch.','This is Jesse','alive')
Bear = People((3,2),'Bear','RAWWWRRR','THIS IS A FUCKING BEAR','alive')
RoomA = Room((1,1),'You are in Room A. You see Steve.')
RoomB = Room((1,2),'You are in Room B. You see Jack.')
RoomC = Room((2,2),'You are in Room C. You see a sword.')
RoomD = Room((2,1),'You are in Room D. You see Jesse.')
RoomE = Room((3,2),'You are in Room E. You see a bear.')
world = {
(1,1):RoomA,
(1,2):RoomB,
(2,2):RoomC,
(2,1):RoomD,
(3,2):RoomE
}
def parser():
while Ply.state == 'alive':
print Ply.printlocation(Ply.location)
Decisionst = raw_input('>')
Decisionstr = Decisionst.lower()
lst = shlex.split(Decisionstr)
if lst[0] == 'go' or lst[0] in 'nwse':
Ply.go(Ply.location,Decisionstr)
elif lst[0] == 'take':
Ply.take(Ply.location, Decisionstr)
elif lst[0] == 'quit':
break
elif lst[0] == 'talk':
Ply.talk(Ply.location, Decisionstr)
elif lst[0] == 'kill':
kill(Decisionstr)
elif lst[0] == 'inventory':
inv()
elif lst[0] == 'help':
help()
elif lst[0] == 'win':
print 'nice try'
elif lst[0] == 'shout':
print 'AAARGGGGGGHHHHH'
elif lst[0] == 'look':
Ply.printlocation(Ply.location)
elif lst[0] == 'examine' or 'exam':
exam(Decisionstr)
else:
print 'This doesnt work'
map()
parser()