Advertisement
Guest User

Untitled

a guest
Feb 18th, 2020
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.86 KB | None | 0 0
  1. from room import Room
  2. from item import Item
  3. from character import Enemy, Friend
  4.  
  5.  
  6. kitchen = Room("Kitchen")
  7. kitchen.set_description("A dank and dirty room buzzing with flies.")
  8.  
  9. dining_hall = Room("Dining Hall")
  10. dining_hall.set_description("A large room with ornate golden decorations on every wall.")
  11.  
  12. ballroom = Room("Ballroom")
  13. ballroom.set_description("A vast room with shiny wooden floor. Huge candlesticks guard the entrance.")
  14.  
  15. kitchen.link_room(dining_hall, "south")
  16. dining_hall.link_room(kitchen, "north")
  17. dining_hall.link_room(ballroom, "west")
  18. ballroom.link_room(dining_hall, "east")
  19.  
  20. # Create an enemy
  21. dave = Enemy("Dave", "A smelly zombie")
  22. dave.set_conversation("Ready to fight")
  23. dave.set_weakness("cheese")
  24. dining_hall.set_character(dave)
  25.  
  26. arthur = Enemy("Arthur", "A clown with golden juggling balls")
  27. arthur.set_conversation("I like to juggle with my golden juggling balls")
  28. arthur.set_weakness("duster")
  29. arthur.set_possession("golden juggling balls")
  30. kitchen.set_character(arthur)
  31.  
  32. #Create a friend
  33. catrina=Friend("Catrina","A friendly skeleton")
  34. catrina.set_conversation("Hi there, I am here to help")
  35. ballroom.set_character(catrina)
  36.  
  37. meat_cleaver=Item("Meat Cleaver")
  38. meat_cleaver.set_description("A large and heavy commercial meat cleaver")
  39.  
  40. current_room = kitchen
  41. #current_item=meat_cleaver
  42.  
  43. dead=False
  44. while dead==False:
  45. print("\n")
  46. current_room.get_details()
  47. #current_item.get_details()
  48. inhabitant = current_room.get_character()
  49.  
  50. if inhabitant is not None:
  51. inhabitant.describe()
  52.  
  53.  
  54. command = input("> ")
  55. # Check whether a direction was typed
  56. if command in ["north", "south", "east", "west"]:
  57. current_room = current_room.move(command)
  58.  
  59. elif command == "talk":
  60. if inhabitant is not None:
  61. inhabitant.talk()
  62. else:
  63. print("Nobody to talk to")
  64.  
  65. elif command=="fight":
  66. if inhabitant is not None:
  67. if isinstance(inhabitant,Enemy)==True:
  68. print("What will you fight with?")
  69. fight_with = input()
  70. if inhabitant.fight(fight_with)==True:
  71. dead=False
  72. current_room.set_character(None)
  73. else:
  74. dead=True
  75. print("GAME OVER")
  76.  
  77. else:
  78. inhabitant.fight()
  79. else:
  80. print("There is no-one to fight")
  81.  
  82. elif command=="hug":
  83. if isinstance(inhabitant,Friend)==True:
  84. inhabitant.hug()
  85. else:
  86. print("get off")
  87.  
  88. elif command=="steal":
  89. if isinstance(inhabitant,Enemy)==True:
  90. if inhabitant.get_possession is not None:
  91. inhabitant.steal()
  92. else:
  93. print("Nothing to steal")
  94.  
  95. else:
  96. print("You don't steal from friends")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement