print(Bcolors.OKGREEN + "You win!" + Bcolors.ENDC) running = False # enemy phase for enemy in enemies: enemy_choice = random.randrange(0, 2) if enemy_choice == 0: if len(players) == 0: print(Bcolors.FAIL + "You loose!" + Bcolors.ENDC) running = False else: target = random.randrange(0, len(players)) print("Player " + players[target].name.replace(" ", "") + " has been hit!") enemy_dmg = enemy.generate_damage() players[target].take_damage(enemy_dmg) print( enemy.name.replace(" ", "") + " attacked " + players[target].name.replace(" ", "") + " for", enemy_dmg) print("----------------------------------") elif enemy_choice == 1: magic_choice = random.randrange(0, len(enemy_spells)) spell = enemy_spells[magic_choice] spell_dmg = spell.generate_damage() if spell.cost <= enemy.mp: enemy.reduce_mp(spell.cost)
enemy = Person(1200, 65, 45, 25, [], []) running = True i = 0 print(bcolors.FAIL + bcolors.BOLD + "AN ENEMY ATTACKS" + bcolors.ENDC) while running: print("=========================") player.choose_action() choice = input("Choose action: ") index = int(choice) - 1 if index == 0: dmg = player.generate_damage() enemy.take_damage(dmg) print("You Attacked for ", dmg, "points of damage.", enemy.get_hp()) elif index == 1: player.choose_magic() magic_choice = int(input("Choose magic: ")) - 1 if magic_choice == -1: continue spell = player.magic[magic_choice] magic_dmg = spell.generate_damage() current_mp = player.get_mp() if spell.cost > current_mp:
while running: print("\n*********************************************************************************************************" "*\nRound #", round_count,"\n") # Choose action to take player.choose_action() choice = input("Choose action:") if choice == "quit": break index = int(choice) - 1 # Attack physically if index == 0: dmg = player.generate_damage() enemy.take_damage(dmg) print("You attacked for", dmg, "damage.\nEnemy HP:", enemy.get_hp()) # Attack with magic elif index == 1: player.choose_magic() magic_choice = int(input("Choose magic:")) - 1 if magic_choice == -1: continue spell = player.magic[magic_choice] magic_dmg = spell.generate_damage() current_mp = player.get_mp()