import rpg marc = rpg.Character("Marc", "A wizard with awesome powers") marc.describe()
ballroom.link_room(conservatory, "south") dining_hall.link_room(ballroom, "west") dining_hall.link_room(kitchen, "north") porch.link_room(kitchen, "west") conservatory.link_room(ballroom, "north") #------------------------------------------------------------- #set up characters eric_the_zombie = rpg.Enemy( "Eric the Zombie", "a bloodstained, ragged youth with a far off expression") eric_the_zombie.set_conversation("growl.... growl...") eric_the_zombie.set_weakness("stick") elding = rpg.Character("Elding", "a friendly elf") elding.set_conversation("hi, pleased to meet you. Can I help?") sue = rpg.Character("Sue", "a smiling woman with a colourful jacket") sue.set_conversation("I'm very happy to see you here") 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")
while True: character_1.atk_basic(character_2) character_2.atk_basic(character_1) if character_1.hp_current <= 0: print(character_2.name.title(), "wins the brawl!") break if character_2.hp_current <= 0: print(character_1.name.title(), "wins the brawl!") break ''' ######################################################################## import rpg as r christian = r.Character("christian", atk=16) zachery = r.Character("zachery", hp=100) print(zachery.hp_current) christian.atk_basic(zachery) christian.atk_basic(zachery) christian.atk_basic(zachery) christian.atk_basic(zachery) print(zachery.hp_current) zachery.heal_self() zachery.heal_self() zachery.heal_self() print(zachery.hp_current)
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", "An amazing portable video game console brought to you by Nintendo", "Utility") blob = rpg.Friend("Blob", "Just a blob of slime, kind of cute though") blob.set_feeling(15) dining_hall.set_character(greg) ballroom.set_character(blob) ballroom.set_item(switch)
import rpg marc = rpg.Character("Marc", "A mystical wizard with magic powers") marc.describe()
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.", "throws himself forward once more.", "is still flat on his back from last time, but seizes" + "\n" + "his chance to grab you by the ankle and try to eat your foot."]) davos.set_post_attack(4, "Davos trips on the broom and flies head over heels.") davos.set_post_attack(5, "Davos fixes you with a look of withering contempt, before" + "\n" + "hauling himself off to the terrace for a nice rest.") davos.set_weakness(broom) davos.set_wants(cheese) davos.set_owns(diamond) davos_neutral = rpg.Character("Davos", "A peaceful butler, having a rest.") cora_friend = rpg.Friend("Cora", "A blithe spirit.") cora_friend.set_conversation("I've opened the secret vault - have a look!") cora = rpg.Enemy("Cora", "The restless, ghostly presence of a young lady.") cora.set_conversation("Thief! Give me back my diamond!") cora.set_alter_ego(cora_friend) cora.set_weakness(torch) cora.set_wants(diamond) cora.set_post_attack(1, "The torch flies from your hand and shatters on the floor." + "\n" + "Cora swirls away to the other side of the room.") teddy = rpg.Friend("Teddy", "A small, friendly bear cub, with soft brown fur.") teddy.says["cora"] = ( "This house is haunted... " + "\n" + "Watch out for Lady Cora's ghost! She's angry!" + "\n" +
def check_death(characters): # return true if every character in the list is dead for char in characters: if char.hp != 0: return False return True # print python version & welcome message print(sys.version) print("-" * 20 + "\n\n\n") print("Welcome to Endless Battles!") # Game setup player = rpg.Character("Link",[6, 3, 4, 2, 5, 6], 100) foes = [rpg.Character("Undead Knight",[2, 2, 1, 1, 2, 0], 50), rpg.Character("Medusa", [1, 1, 2, -2, 1, 0], 35)] # Game main loop print("\n\n Battle has started!") while not check_death(foes): index = 0 while index < len(foes): print("{0}. {1} \t [{2} HP]".format(index+1, foes[index].name, foes[index].hp)) index = index + 1 choice = int(input("Attack enemy: ")) foes[choice-1].get_hit(23) print("\n\n") print("\n Victory Fare ~~~~")
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
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( "silence", lambda x: alex.speak( "OOOPS!!\n *Unfortunately, Alex uses epithets unsuitable for print*")) alex.addFightResponse("revolver", lambda x: alex.killWith("guhn")) def daveHelpPill(word): if word == "dishwasher": dave.speak(word + "? Let me take a look. Yes, there's a pill in here") if word == "headache": dave.speak(
import rpg gonad = rpg.Character("Gonad", "A wizard with big magic powers!") gonad.describe()