Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Text Adventure
- import shlex
- class Room(object):
- def __init__(self, location, description):
- self.location = location
- self.description = description
- def display_Room(self):
- print 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(Player.location)
- if Decision == 'go north':
- newlocation[1] += 1
- test = world.get(tuple(newlocation))
- if test == None:
- print 'You cannot go there'
- else:
- self.location = tuple(newlocation)
- elif Decision == 'go south':
- newlocation[1] -= 1
- test = world.get(tuple(newlocation))
- if test == None:
- print 'You cannot go there'
- else:
- self.location = tuple(newlocation)
- elif Decision == 'go east':
- newlocation[0] += 1
- test = world.get(tuple(newlocation))
- if test == None:
- print 'You cannot go there'
- else:
- self.location = tuple(newlocation)
- elif Decision == 'go west':
- newlocation[0] -= 1
- test = world.get(tuple(newlocation))
- if test == None:
- print 'You cannot go there'
- else:
- self.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 pos(self,location):
- return self.location
- 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'
- if 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'
- class Item(object):
- def __init__(self,name,text,location):
- self.name = name
- self.text = text
- self.location = location
- def exam(self):
- print self.text
- def kill(Decision):
- if Decision == 'kill steve':
- killhelp('Steve')
- elif Decision == 'kill jack':
- killhelp('Jack')
- elif Decision == 'kill jesse':
- killhelp('Jesse')
- elif Decision == 'kill steve with sword':
- killhelpwithitem('Sword','Steve')
- elif Decision == 'kill jack with sword':
- killhelpwithitem('Sword','Jack')
- elif Decision == 'kill jesse with sword':
- killhelpwithitem('Sword','Jesse')
- 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"
- def inv():
- print Inventory
- 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))
- Player = 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')
- 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')
- world = {
- (1,1):RoomA,
- (1,2):RoomB,
- (2,2):RoomC,
- (2,1):RoomD,
- }
- def parser():
- while Player.state == 'alive':
- print Player.printlocation(Player.location)
- Decisionst = raw_input('>')
- Decisionstr = Decisionst.lower()
- lst = shlex.split(Decisionstr)
- if lst[0] == 'go':
- Player.go(Player.location,Decisionstr)
- elif lst[0] == 'take':
- Player.take(Player.location, Decisionstr)
- elif lst[0] == 'quit':
- break
- elif lst[0] == 'talk':
- Player.talk(Player.location, Decisionstr)
- elif lst[0] == 'kill':
- kill(Decisionstr)
- elif lst[0] == 'inventory':
- inv()
- elif lst[0] == 'win':
- print 'nice try'
- else:
- print 'This doesnt work'
- parser()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement