player = Person(460, 65, 60, 34, magic) enemy = Person(1200, 65, 45, 25, magic) running = True i = 1 print(bcolors.FAIL + bcolors.BOLD + "AN ENEMY ATTACKS !" + bcolors.ENDC) while running: print("=====================") player.choose_action() choice = input("Choose your action: ") index = int(choice) - 1 if index == 0: dmg = player.gen_damage() enemy.take_dmg(dmg) print("You attacked ", dmg, "points of damage.") elif index == 1: player.choose_magic() magic_choice = int(input("Choose magic: ")) - 1 magic_dmg = player.gen_magic_damage(magic_choice) spell = player.get_magic_name(magic_choice) cost = player.get_magic_cost(magic_choice) current_mp = player.get_mp() if cost > current_mp: print(bcolors.FAIL + "\nYou don't have enough magic points to do that!\n" + bcolors.ENDC) continue
if item.type == "potion": player.heal(item.prop) print(bcolors.OKGREEN + "\n" + item.name + " heals for", str(item.prop), "HP" + bcolors.ENDC) elif item.type == "elixir": player.HP = player.max_HP player.MP = player.max_MP print(bcolors.OKGREEN + "\n" + item.name + " fully restores HP/MP" + bcolors.ENDC) elif item.type == "attack": enemy.take_dmg(item.prop) print(bcolors.FAIL + "\n" + item.name + " deals", str(item.prop), "points of DMG" + bcolors.ENDC) enemy_choice = 1 enemy_dmg = enemy.gen_damage() player1.take_dmg(enemy_dmg) print("----------------------------------") print("Enemy HP:" + bcolors.FAIL + str(enemy.get_HP()) + "/" + str(enemy.get_max_HP()) + bcolors.ENDC + "\n") print("Player HP:" + bcolors.OKGREEN + str(player.get_HP()) + "/" + str(player.get_max_HP()) + bcolors.ENDC) print("Player MP:" + bcolors.OKBLUE + str(player.get_MP()) + "/" + str(player.get_max_MP()) + bcolors.ENDC + "\n") print("----------------------------------") print("Enemy strikes for", str(enemy_dmg) + ".\nYour HP:", player.get_HP()) if enemy.get_HP() == 0: print(bcolors.OKGREEN + "You Win!" + bcolors.ENDC) elif player.get_HP() == 0: print(bcolors.FAIL + "Enemy has defeated you. You lose :(" + bcolors.ENDC)