bugblatter = rpg.Enemy("the Bugblatter Beast of Trall", "the fiercest monster you have ever seen") bugblatter.set_conversation( "I can't see you because you have a towel covering your eyes") bugblatter.set_weakness("sword") tinkerbell = rpg.Fairy("Tinkerbell", "a twinkling light floating in the corner", "a glowing fairy figure") tinkerbell.set_conversation("if you find the bell and ring it I can appear") #------------------------------------------------------------- #set up items sword = rpg.Item("sword", "a sharp, long, shiny metal object", "use") stick = rpg.Item("stick", "a long, stout stick", "beat") bell = rpg.Item("bell", "a small brass bell", "ring") panda = rpg.Item("panda", "a large stuffed panda", "carry") #------------------------------------------------------------- #set initial parameters dining_hall.set_character(eric_the_zombie) conservatory.set_character(elding) porch.set_character(sue) ballroom.set_character(bugblatter) kitchen.set_character(tinkerbell) kitchen.set_item(sword, True) dining_hall.set_item(bell, True)
kitchen = rpg.Room("Kitchen") kitchen.set_description("A dank and dirty room buzzing with flies.") dining_hall = rpg.Room("Dining Hall") dining_hall.set_description( "A large room with ornate golden decorations on each wall.") ball_room = rpg.Room("Ball Room") ball_room.set_description("A vast room with a shiney wooden floor.") """set up room interlinks""" kitchen.link_room(dining_hall, "south") ball_room.link_room(dining_hall, "east") dining_hall.link_room(kitchen, "north") dining_hall.link_room(ball_room, "west") """set up items""" club = rpg.Item("club") club.set_description("a heavy wooden club") dining_hall.set_item(club) bread = rpg.Item("bread") bread.set_description("a loaf of rough milled bread.") kitchen.set_item(bread) cheese = rpg.Item("cheese") cheese.set_description("a large wedge of tasty looking cheese.") ball_room.set_item(cheese) """set up characters""" dave = rpg.Enemy("Dave", "A smelly zombie") dave.set_conversation("Errrrgh, Brains!") dave.set_weakness("cheese") dining_hall.set_character(dave)
dinning_room.link_to_room(kitchen, "north") dinning_room.link_to_room(living_room, "east") kitchen.link_to_room(dinning_room, "south") living_room.link_to_room(dinning_room, "west") dave = rpg.Enemy("Dave", "A smelly zombie") dave.set_conversation("Me want brainnnnnsss >:(") dave.set_weakness("dog") dave.set_stolen_item("nothing") catrina = rpg.Friend("Catrina", "A friendly skeleton") catrina.set_conversation("Why hello there!") catrina.set_greetings("Hi, my name is Catrina, it's nice to meet you!") cheese = rpg.Item("cheese") cheese.set_desc_item("a large and smelly block of cheese") dog = rpg.Item("dog") dog.set_desc_item("a protective dog, cute with you," "\nmercilessly against your enemies") dinning_room.set_character(dave) living_room.set_character(catrina) kitchen.set_item(cheese) living_room.set_item(dog) current_room = kitchen backpack = [] ready_to_fight = None fight_mode = not None
"A large room with ornate golden decorations on each wall.") ball = rpg.Room("Ballroom") ball.set_description( "A vast room with a shiny wooden floor. Huge candlesticks guard the entrance.") # setup characters john = rpg.Friend("John", "A nice fellow guarding the door.") john.set_conversation("Hi there. You may not pass through this door.") dave = rpg.Enemy("Dave", "A smelly zombie") dave.set_conversation("Brrlgrh... rgrhl... brains...") dave.set_weakness("knife") # setup items knife = rpg.Item("Knife", "A sharp knife is lying on the table") bag = rpg.Item( "bag", "A small bag, like the ones used to hold coins. Seems to have something inside.") # link rooms, characters and items kitchen.link(dining, "south") dining.link(kitchen, "north") dining.link(ball, "west") ball.link(dining, "east") dining.set_character(dave) ball.set_character(john) dining.set_item(knife) ball.set_item(bag) # the main game loop
dining_hall = rpg.Room("Dining Hall") dining_hall.set_description( "A large room with a long central wooden table layed out with moldy food on cracked plates" ) ballroom = rpg.Room("Ballroom") ballroom.set_description( "A large hall with a marbel floor, this hasn't been danced in for a millenia" ) kitchen.link_room(dining_hall, 'south') dining_hall.link_room(kitchen, 'north') dining_hall.link_room(ballroom, 'west') ballroom.link_room(dining_hall, 'east') starter_weapon = rpg.Item("Wooden Sword", "A basic sword made out of cheap wood", "Sword") greg = rpg.Enemy("Greg", 'Just a normal dude') greg.set_conversation( "Hi, My name is greg, i'm just a normal dude trying to make his way in the text adventure" ) greg.set_weakness("Nintendo Switch") greg.set_item(starter_weapon) greg_corpse = rpg.Character( "Greg's Body", "The corpse of a perfectly innocent man that you just murdered") greg_corpse.set_conversation("Nothing, because he's dead") switch = rpg.Item( "Nintendo Switch",
import rpg # Items (location is set in the Room object) broom = rpg.Item("broom", "A long, bristly broom.") broom.set_smell("The broom smells of pine and rosemary.") cheese = rpg.Item("cheese", "A nice bit of crumbly cheese.") cheese.set_smell("The cheese smells sharp and fresh.") diamond = rpg.Item("diamond", "A tiny, sparkling diamond.") hyacinth = rpg.Item("hyacinth", "A common hyacinth.") hyacinth.set_smell("A strong, sweet scent.") orchid = rpg.Item("orchid", "A rare, indigo-blue orchid - very pretty.") orchid.set_smell("A strong, sweet scent. " + "\n" + "Ohhhhhhhh... my mistake, it's a hyacinth.") orchid.set_alternative(hyacinth) torch = rpg.Item("torch", "An ultra-bright electric torch.") # Characters davos = rpg.Enemy("Davos", "An ancient and crumbling butler.") davos.set_conversation("Brrlgrh... rgrhl... brains..." + "\n" + "(Oh dear, Davos doesn't sound too well. Best " + "keep your distance.)") davos.set_attack_moves(["lurches forward, arms outstretched.", "thrashes around the room, punching everything in his path.", "wobbles mightily, before trying to kill you again.",
dining_hall.link_room(kitchen, "north") dining_hall.link_room(ballroom, "west") ballroom.link_room(dining_hall, "east") dave = rpg.Enemy("Dave", "A smelly zombie") dave.set_conversation("What's up, dude! I'm hungry.") dave.set_weakness("cheese") dining_hall.set_character(dave) tabitha = rpg.Enemy("Tabitha", "An enormous spider with countless eyes and furry legs.") tabitha.set_conversation("Sssss....I'm so bored...") tabitha.set_weakness("book") ballroom.set_character(tabitha) cheese = rpg.Item("cheese") cheese.set_description("A large and smelly block of cheese") ballroom.set_item(cheese) book = rpg.Item("book") book.set_description("A really good book entitled 'Knitting for dummies'") dining_hall.set_item(book) current_room = kitchen backpack = [] dead = False while dead == False: print("\n")
import rpg #Our weapons -- you will need to get these from the friendly characters cheese = rpg.Item("Cheese", "A lovely smelly Gorgonzola!") magic_bean = rpg.Item("Magic bean", "Maybe Jack left this behind...") garlic = rpg.Item("Garlic", "Great for sorting out vampires") #The baddies, and their weaknesses dave = rpg.Enemy("Dave", "A smelly zombie") dave.conversation = "Brrlgrh... rgrhl... brains..." dave.weakness = cheese.name tilda = rpg.Enemy("Tilda", "A poisonous toad") tilda.conversation = "Ribbit..... ribbit....." tilda.weakness = magic_bean.name madge = rpg.Enemy("Madge", "A fearsome witch, Mildred's evil twin!") madge.conversation = "Hubble bubble, toil and trouble!" madge.weakness = garlic.name #Some friendlier folk... they might be able to help you fred = rpg.Friend("Fred", "A helpful giant") fred.set_item_carried(cheese) mildred = rpg.Friend("Mildred", "A wise witch, Madge's helpful twin.") mildred.set_item_carried(garlic) bascule = rpg.Friend("Bascule", "A curious fellow, with a kindly twinkle in his eyes.") bascule.set_item_carried(magic_bean)
import rpg #To take itens backpack = [] #All objects declations billy = rpg.Enemy("Billy", "A f*****g weirdo with a baseball bat") jesse = rpg.Character("Jesse", "A sweet little stranger, an eminent danger") kitchen = rpg.Room("Kitchen") dinning_hall = rpg.Room("Dinning Hall") ballroom = rpg.Room("Ballroom") sword = rpg.Item("sword", "Galandor") #The descriptions of some objects kitchen.set_description("A dank and dirty room buzzing with flies.") dinning_hall.set_description( "A large room with ornate golden decorations on each wall.") ballroom.set_description("I don\'t know what this was supposed to be.") sword.set_description("Pure simpathy") #Linking the rooms kitchen.link_room(dinning_hall, "south") dinning_hall.link_room(kitchen, "north") dinning_hall.link_room(ballroom, "east") ballroom.link_room(dinning_hall, "west") #Setting an item in the ballroom ballroom.set_item(sword) # Some actions with a friendly character
dining_hall = rpg.Room('Dining Hall') dining_hall.set_description('A large room with ornate golden decorations on each wall.') # Set up Ballroom ballroom = rpg.Room('Ballroom') ballroom.set_description('A vast room with a shiny wooden floor. Huge candlesticks guard the entrance.') # Set up bedroom bedroom = rpg.Room('Bedroom') bedroom.set_description('The master bedroom - huge 4 poster bed!') # Link the 3 rooms together as per diagram in 2.6 # Add in a link to the bedroom in the top quadrant kitchen.link_room(dining_hall, 'south') dining_hall.link_room(ballroom, 'west') bedroom.link_room(kitchen, 'east') bedroom.link_room(ballroom,'south') # create and place items item1 = rpg.Item('banana', 'A large yellow piece of fruit', 'small', 'light') item2 = rpg.Item('sword', 'A massive steel sword', 'large', 'heavy') item3 = rpg.Item('pineapple', 'A juicy piece of fruit', 'large', 'light') dining_hall.set_item(item1) kitchen.set_item(item2) bedroom.set_item(item3) # Set up and place enemies #Dave dave = rpg.Enemy('Dave', 'A smelly zombie') dave.set_conversation("I'm simply to die for!") dave.set_weakness(item3.get_name()) dining_hall.set_character(dave) #Lucretia lucretia = rpg.Enemy('Lucretia', 'A wicked and cunning witch') lucretia.set_conversation("Look at my lovely blond hair.") lucretia.set_weakness(item2.get_name())
who = input(("With whom did you wish to converse, Sire?")) else: who = words[1] interlocutor = find_item(who) if interlocutor == {}: print((who + " is not here.")) return if len(words) < 3: what = input("And what message did you wish to convey to this " + interlocutor.getDescription() + "?") else: what = words[2] interlocutor.respondTo(what) revolver = rpg.Item("revolver", "A shiny, metal object", "loaded") dishWasher = rpg.Item("dishwasher", "A large kitchen appliance", "closed") pill = rpg.Item( "pill", "Something that cures headaches, perhaps even gonorrhea and cancer", "glowing") dishWasher.placeItem(pill, "inside") towel = rpg.Item("towel", "Something fluffy, full of magic dust and cobwebs", "dry and ready") troll = rpg.Character("Busey", "A big, hairy troll", "angry") troll.addResponse( "up", lambda x: troll.speak("I wish I could, but I'm too fat, mate")) alex = rpg.Enemy("Alex", "A very, very bad radio host", "baleful") alex.addResponse(
"Vlad", "A dark sinister figure, pale skinned and with pointed teeth, occupies a dark corner of the ballroom.\n" ) vampire.set_conversation("I vant to suck your blood, blaaa!") vampire.set_weakness("stake") ballroom.set_character(vampire) # --Friends-- # Casper casper = rpg.Friend("Casper", "A friendly ghost") casper.set_conversation("I would really like a hug.") kitchen.set_character(casper) # --Items-- # Salad salad = rpg.Item("salad") salad.set_description("A nice caesar salad lays here") kitchen.set_item(salad) # Stake stake = rpg.Item("stake") stake.set_description("A sharp wodden stake sits quietly on the floor") dining_hall.set_item(stake) # --Game Loop-- while dead == False: # Room details print("\n") current_room.get_details() inhabitant = current_room.get_character()