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 description(): print("Is your character a wizard, archer, or warrior?") character = input("> ") if "wizard" in character: Wizard(10, 20, 30, 30) elif "archer" in character: Archer(50, 50, 50, 50) elif "warrior" in character: Warrior(50, 50, 50, 60) else: print("Please try again.") random
if gold > 0: shopping() else: shopping() elif sh == 6: return else: shopping() gold = 100 os.system('color 0F') display.title() if int( input( colored('Type the number of the character you want to play: ', 'magenta'))) == 1: player = Knight(100, 20, 20, 35, 3, 3) else: player = Wizard(70, 10, 10, 20, 4, 4) display.gift() g = int(input(colored('Type the number of the gift you want: ', 'magenta'))) if g == 1: player.set_hp(player.get_hp() + 25) elif g == 2: gold += 150 elif g == 4: player.set_luck(player.get_luck() + 20) elif g == 5: player.set_energy(player.get_energy() + 1) x = 0 while player.get_hp() > 0: sf.clear() x = x + 1 y = 0 g = -4
def test_wizard_strike(self): wizard = Wizard('Dumbledore', 100, 10, 20) opponent = Character('TestCharacter', 100, 10) wizard.strike(opponent) self.assertEqual(opponent.hp, 70) self.assertEqual(wizard.manna, 15)
def test_strike_and_manna(self): wizard = Wizard('Diablo', 100, 10, 5) opponent = Character('TestCharacter', 100, 10) wizard.strike(opponent) self.assertEqual(opponent.hp, 90) self.assertEqual(wizard.manna, 0)