def battle_random(char1): # name = choice(char_list) char_list = ['Hero', 'Medic', 'Shadow', 'Wizard', 'Tank', 'Drunkard', 'Zombie', 'Goblin'] job_index = randint(0,7) # char2 = Character(name,name,randint(30,50), randint(5,7)) job = char_list[job_index] random_health = randint(30, 50) random_power = randint(5, 7) job_selection_dict = { "0":Hero(job, random_health, random_power), "1":Medic(job, random_health, random_power), "2":Shadow(job, 1, random_power), "3":Wizard(job, random_health, random_power), "4":Tank(job, random_health, random_power), "5":Drunkard(job, random_health, random_power), "6":Zombie(job, random_health, randint(1,2)), "7":Goblin(job, random_health, randint(3,5)) } char2 = job_selection_dict[str(job_index)] print("%s encountered a %s!" % (char1.name, char2.name)) battle(char1, char2)
def create_hero(): print("Time to create your character!") name = input("What is your character's name?: ") print() job_selection = input("What is %s's class?\n1. Hero\n2. Medic\n3. Shadow\n4. Wizard\n5. Tank\n6. Drunkard\n: " % name) print() health = randint(100,150) power = randint(5,10) job_selection_dict = { "1":Hero(name, health, power), "2":Medic(name, health, power), "3":Shadow(name, health, power), "4":Wizard(name, health, power), "5":Tank(name, health, power), "6":Drunkard(name, health, power) } # char = Character(name, job_selection_dict[job_selection], health, power) char = job_selection_dict[job_selection] print("Your character has been created! %s the %s, with starting stats of %d health and %d power" % (name, char.job, char.health, char.power)) return char
def main(): player = Hero("King", "The brave king of nowhere!") player.Talk = "Who is here?" enemy = Enemy("Wizard", "The evil wizard!") enemy.Talk = "Your worst enemy!!!!" castle = [] layout(castle) current_room = castle[0] castle[random.randint(1, len(castle) - 1)].Character = enemy print(player) print("I'm in:") print(current_room) print() while True: direction = input("Where to ? ").upper() if direction == "EXIT": break print() if direction in DIRECTIONS: current_room = current_room.move_to_direction(direction) print(current_room) if current_room.Character: print(player.Talk) print(enemy.Talk) if player.fight(current_room.Character): print("\nWell done you have defeated your enemy!\n") break print(player.Back) player.change_weapon() print()
jon = Character("Jon Stark", "jon.png") print(arya.name, arya.avatar) print(jon.name, jon.avatar) # After adding stuff two inventory # length of inventory should == 2 arya.inventory.append('Needle') arya.inventory.append('Mask') print(len(arya.inventory)) # aray should have a `greet` method # and when called should return # "hello, I am arya start?" #when i call it with `arya.greet_charactor(jon) # should return # 'hello jon snow, i'm arya starK?` print(arya.greet()) print(arya.greet_character(jon)) print(arya.greet_character()) #I should be able to create a `Hero` instance bronn = Hero("Broon of the Blackwater", "bron.png") the_night_king = Monster("The Night King", "night.png") #Hero should be able to greet Character print(bronn.greet_character(arya)) print(jon.greet_character(bronn)) print(the_night_king.greet_character(bronn))
# Arya should have a `greet` method and return # "Hello, I am Arya Stark. I am awesome" when called print(arya.greet()) # Arya should have a `greet` method that accepts another Character # Return "Hello, Jon Snow, I am Arya Stark. I am awesome." print(arya.greet(jon)) # Testing adding, viewing, and removing items to inventory arya.add_inventory("food") print(arya.view_inventory()) arya.remove_inventory("sword") print(arya.view_inventory()) # Hero class bronn = Hero("Bronn of the Blackwater", "bron.png") print(bronn.name) # Hero should be able to greet Character print(bronn.greet(arya)) print(jon.greet(bronn)) # Monster class walker = Monster("White Walker") print(walker.name) # Hero greets Monster jon = Hero("Jon Snow", "jon.png") print(jon.greet(walker)) # Should print "uuuggghhhh"
def setUp(self): self.hero = Hero("Anna", 20, Race.GREMLIN, Hero_class.PALADIN) self.enemy = Hero("Clay", 20, Race.HUMAN, Hero_class.MAGE)
# characters can be instantiated with name and avatar arya = Character("Arya Stark", "arya.png") jon = Character("Jon Snow", "jon.pgn") print(arya.name, arya.avatar) print(jon.name, jon.avatar) # after adding 2 items to inventory, inventory length should = 2 arya.inventory.append('sword') arya.inventory.append('mask') print(len(arya.inventory)) # arya should have a 'greet' method # when i call with arya.greet(jon) it should return "hello, jon snow, i am arya stark, i will destroy you." print(arya.greet(jon)) # arya should have a 'greet' method # when i call with arya.greet() it should return "hello, i am arya stark. i will destroy you" print(arya.greet()) # should be able to create a hero instance. bronn = Hero("Bronn of the Blackwater", "bron.pgn") # hero should be able to greet character. print(bronn.greet(arya)) print(jon.greet(bronn)) # creates monster instance Dragon = Monster("Scary Dragon", "dragon.img") print(Dragon.greet(bronn)) print(Dragon.greet(jon))
# these arent real tests from character import Character from character import Hero # Characters can be instantiated with name and avatar ayra = Character("Ayra Stark", "PHOTO.png") jon = Character("Jon Snow", "SUPERPHOTO.png") print(jon.name, jon.avatar, ayra.name, ayra.avatar) print(jon.inventory) jon.inventory.append("CAT") jon.inventory.append("Valayrian steel") # should print ... print(jon.inventory) # it should print ... print(ayra.greet(jon)) # should print without "hello i am.." print(ayra.greet()) # i should be able to create a hero instance Giant_Cat = Hero("Giant Cat from beyond the wall", "cat.png")
def __init__(self, scene_map): """Initialize the engine with the map and the hero.""" self.scene_map = scene_map self.hero = Hero('Lancelot', 14)
arya.inventory.append("sword") arya.inventory.append("mask") jon.inventory.append("dragon glass") print(len(arya.inventory)) print(len(jon.inventory)) # arya should hava a `greet` method # and when I call it with `arya.greet()`, it should return # "Hello,I am Arya Stark. You killed my father. Prepare to die." print(arya.greet()) # arya should hava a `greet` method # and when I call it with `arya.greet(jon)`, it should return # "Hello, Jon Snow, I am Arya Stark. You killed my father. Prepare to die." print(arya.greet(jon)) # I should be able to create a Hero instance bronn = Hero("Bronn of the Blackwater", "bron.gif") mittens = Monster("Mittens the Kitten", "mitten.jpeg") # Hero should be able to `.greet` Character print(bronn.greet(arya)) print(jon.greet(bronn)) # Monster should be able to `.groan` a Character or Hero print(mittens.groan(arya)) print(mittens.groan(bronn)) print(bronn.attack(mittens))
def main_character_creation(): """ Create a Character""" char_name = input("Please enter the name of your character: ") character = Hero(char_name) return character
from room import Room from item import Item from character import Character, Enemy, Hero from rpginfo import RPGInfo hero = Hero("Hero") enemy = Enemy("enemy", "Example enemy") item = Item("Sword", 25) print(hero.health) print(enemy.health) hero.fight(enemy, item.damage) hero.fight(enemy, item.damage) enemy.fight(hero, 5) print(hero.health) print(enemy.health)
# Characters can be instantiated with name and avatar arya = Character("Arya Stark", "arya.png") jon = Character("Jon Snow", "jon.png") print(arya.name, arya.avatar) print(jon.name, jon.avatar) # after adding 2 items to inventory # length of inventory should == 2 arya.inventory.append('sword') arya.inventory.append('mask') print("there are %d items in %s's inventory" % (len(arya.inventory), arya.name)) # arya should have a `greet` method # and when I call it with arya.greet(jon), it should return # "Hello, Jon Snow, I am Arya Stark. I am awesome" # arya should have a `greet` method # and when I call it with arya.greet(), it should return # "Hello, I am Arya Stark. I am awesome" print(arya.greet(jon)) print(arya.greet()) # I should be able to create a Hero instance bronn = Hero("Bronn of Blackwater", "bron.jng")