refrigerator.key = knife kitchen.add_items(refrigerator, cheese, pizza) book = Item("book") dining_hall.add_items(book) # define characters and enemies mike = Character("Mike", "a computer programmer") mike.conversation = ["You never know when you could use some cheese.", "And you can't use cheese after you've eaten it."] mike.QA = ({"what", "favorite", "language"}, "Python, of course!") kitchen.inhabitants.add(mike) dave = Enemy("Dave", "a smelly zombie") dave.conversation = ["What's up, dude! I'm hungry.", "What do you call cheese that isn't yours?", "Nacho cheese!"] dave.weakness = cheese dining_hall.inhabitants.add(dave) eddie = Enemy("Eddie", "another smelly zombie") eddie.conversation = ["I'm not really hungry.", "Ok, I'm a zombie. I'm always hungry.", "But for what?!"] eddie.weakness = pizza dining_hall.inhabitants.add(eddie) tabitha = Enemy("Tabitha", "an enormous spider with countless eyes and furry legs.") tabitha.conversation = ["Sssss....I'm so bored...", "Read any good books lately?"] tabitha.weakness = book ballroom.inhabitants.add(tabitha) current_place = kitchen
# link the kitchen to the ballrom and dining hall kitchen.link_room(ballroom, 'southwest') kitchen.link_room(dining_hall, 'south') # link the dining to the ballrom and kitchen dining_hall.link_room(kitchen, 'north') dining_hall.link_room(ballroom, 'east') # link the ballroom to the kitchen and dining hall ballroom.link_room(kitchen, 'northeast') ballroom.link_room(dining_hall, 'west') # creating the first enemy and putting him in the dining hall enemy = Enemy('Drake', 'A sweetie zumbie') enemy.conversation = 'braaain, I want braaaain' enemy.weakness = 'cheese' dining_hall.character = enemy # creating the second enemy and putting him in the ballroom enemy_two = Enemy('David', 'A dangerous demon') enemy_two.conversation = 'I want to take your soul' enemy_two.weakness = 'silver' ballroom.character = enemy_two # creating a friendly person and putting in the kitchen friend = Friend('jacob', 'A very friendly guy') friend.conversation = 'I\'m just passing a time here' kitchen.character = friend knife = Item('knife', 'to kill people')
kitchen = Room("Kitchen") kitchen.description = "A dank and dirty room buzzing with flies." dining_hall = Room("Dining Hall") dining_hall.description = "A large room with ornate golden decorations on each wall." ballroom = Room("Ballroom") ballroom.description = "A vast room with a shiny wooden floor. Huge candlesticks guard the entrance." print("There are " + str(Room.number_of_rooms) + " rooms to explore.") kitchen.link_room(dining_hall, "south") dining_hall.link_room(kitchen, "north") dining_hall.link_room(ballroom, "west") ballroom.link_room(dining_hall, "east") dave = Enemy("Dave", "A smelly zombie") dave.conversation = "Brrlgrh... rgrhl... brains..." dave.weakness = "cheese" catrina = Character("Catrina", "A friendly skeleton.") catrina.conversation = "I got your back, my friend" dining_hall.character = dave kitchen.character = catrina cheese = Item("cheese") cheese.description = "The ideal weapon to fight 'Dave' with." cheese.room = kitchen kitchen.item = cheese key = Item("key") key.description = "Use this key to unlock the ballroom's door with." cheese.character = dave dave.char_item = key
# main.py from world import Spot from character import Player, Enemy alkirasc = Spot('Alkira Secondary College', 'A lot of kids spend their lives here.') daveshome = Spot("Dave's Home", "It is a dark house and a bad smell comes out from it.") alkirasc.connect(daveshome, 'south') daveshome.connect(alkirasc, 'north') #player_name = input('Name of the Great Adventure please: ') player_name = 'Jeremy' player = Player(player_name, alkirasc) dave = Enemy('Dave', 'A smelly zombie.', 'garlic') dave.conversation = 'I like to eat humans.' steve = Enemy('Steve', 'A shifty ghost.', 'cake') steve.conversation = "This doesn't look good, dude." daveshome.add_characters(dave) daveshome.add_characters(steve) def who(command): commands = command.split() if len(commands) == 1: return player.current_spot.characters[0] elif len(commands) == 2: for character in player.current_spot.characters: if character.name.lower() == commands[1].lower(): return character
from character import Enemy dave = Enemy('Dave', 'A smelly zombie.', 'garlic') dave.conversation = 'I like to eat humans.' print(dave.bio) print(dave.chat) weapon = input('Fight with: ') dave.fight(weapon)