Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from room import Room
- from item import Item
- from character import Enemy, Friend
- kitchen = Room("Kitchen")
- kitchen.set_description("A dank and dirty room buzzing with flies.")
- dining_hall = Room("Dining Hall")
- dining_hall.set_description("A large room with ornate golden decorations on every wall.")
- ballroom = Room("Ballroom")
- ballroom.set_description("A vast room with shiny wooden floor. Huge candlesticks guard the entrance.")
- kitchen.link_room(dining_hall, "south")
- dining_hall.link_room(kitchen, "north")
- dining_hall.link_room(ballroom, "west")
- ballroom.link_room(dining_hall, "east")
- # Create an enemy
- dave = Enemy("Dave", "A smelly zombie")
- dave.set_conversation("Ready to fight")
- dave.set_weakness("cheese")
- dining_hall.set_character(dave)
- arthur = Enemy("Arthur", "A clown with golden juggling balls")
- arthur.set_conversation("I like to juggle with my golden juggling balls")
- arthur.set_weakness("duster")
- arthur.set_possession("golden juggling balls")
- kitchen.set_character(arthur)
- #Create a friend
- catrina=Friend("Catrina","A friendly skeleton")
- catrina.set_conversation("Hi there, I am here to help")
- ballroom.set_character(catrina)
- meat_cleaver=Item("Meat Cleaver")
- meat_cleaver.set_description("A large and heavy commercial meat cleaver")
- current_room = kitchen
- #current_item=meat_cleaver
- dead=False
- while dead==False:
- print("\n")
- current_room.get_details()
- #current_item.get_details()
- inhabitant = current_room.get_character()
- if inhabitant is not None:
- inhabitant.describe()
- command = input("> ")
- # Check whether a direction was typed
- if command in ["north", "south", "east", "west"]:
- current_room = current_room.move(command)
- elif command == "talk":
- if inhabitant is not None:
- inhabitant.talk()
- else:
- print("Nobody to talk to")
- elif command=="fight":
- if inhabitant is not None:
- if isinstance(inhabitant,Enemy)==True:
- print("What will you fight with?")
- fight_with = input()
- if inhabitant.fight(fight_with)==True:
- dead=False
- current_room.set_character(None)
- else:
- dead=True
- print("GAME OVER")
- else:
- inhabitant.fight()
- else:
- print("There is no-one to fight")
- elif command=="hug":
- if isinstance(inhabitant,Friend)==True:
- inhabitant.hug()
- else:
- print("get off")
- elif command=="steal":
- if isinstance(inhabitant,Enemy)==True:
- if inhabitant.get_possession is not None:
- inhabitant.steal()
- else:
- print("Nothing to steal")
- else:
- print("You don't steal from friends")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement