# Attack if index == 0: dmg = player.gen_damage() enemy = player.choose_target(enemies) enemies[enemy].take_damage(dmg) print("\nYou attacked " + enemies[enemy].name + " for ", dmg, " point of damage.") print("\n") if enemies[enemy].get_hp() == 0: print(enemies[enemy].name + " has died.") del enemies[enemy] defeated_enemies += 1 # 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() if spell.cost > current_mp: print(bcolors.FAIL + "Not enough MP " + bcolors.ENDC) continue player.reduce_mp(spell.cost) if spell.type == "Defensive":
print("Choose your action: ") player.choose_action() try: choice = int(input(">>>: ")) except ValueError: print("Choose a number") continue action_index = choice - 1 if action_index == 0: damage = player.generate_atk_damage() enemy.take_damage(damage) print("You attacked {} and dealt {} damage".format(enemy.name, damage)) if action_index == 1: damage = player.choose_magic() magic_choice = int(input(">>>: ")) else: print("Choose a correct number") continue #Enemy's turn enemy_choice = 0 if enemy_choice == 0: enemy_damage = enemy.generate_atk_damage() player.take_damage(enemy_damage) print("{} attacked {} and dealt {} damage".format(enemy.name,player.name,enemy_damage) print("-------------------")