Advertisement
Guest User

Untitled

a guest
Aug 28th, 2016
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. def get_input():
  2. command = input(": ").split()
  3. verb_word = command[0]
  4. if verb_word in verb_dict:
  5. verb = verb_dict [verb_word]
  6. else:
  7. print("Unknown verb {}".format(verb_word))
  8. return
  9.  
  10. if len(command) >= 2:
  11. noun_word = command[1]
  12. print(verb(noun_word))
  13. else:
  14. print(verb())
  15.  
  16. def say(noun):
  17. return 'You said "{}"'.format(noun)
  18.  
  19. verb_dict = {
  20. "say": say,
  21. "examine": examine,
  22. }
  23.  
  24. while True:
  25. get_input()
  26.  
  27. class GameObject:
  28. class_name = ""
  29. desc = ""
  30. objects = {}
  31.  
  32. def __init__(self, name):
  33. self.name = name
  34. GameObject.objects[self.class_name] = self
  35.  
  36. def get_desc(self):
  37. return self.class_name + "\n" + self.desc
  38.  
  39. class Goblin(GameObject):
  40. class_name = "goblin"
  41. desc = "A foul creature"
  42. goblin = Goblin("Gobbly")
  43.  
  44. def examine(noun):
  45. if noun in GameObject.objects:
  46. return
  47. GameObject.objects[noun].get_desc()
  48. else:
  49. return "Thete is no {} he.".format(noun)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement