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": player.heal(magic_dmg) print(bcolors.OKBLUE + spell.name + " heal for ", str(magic_dmg), "HP" + bcolors.ENDC) elif spell.type == "Offensive": enemy = player.choose_target(enemies) enemies[enemy].take_damage(magic_dmg) print(spell.name + " deals ", str(magic_dmg), " point of damage to " + enemies[enemy].name + ".") if enemies[enemy].get_hp() == 0: print(enemies[enemy].name + " has died.") print("\n")
#action process if index == 0: dmg = player.hit_damage() enemy.take_damage(dmg) print("You hit for", dmg, "points!") enemy_dmg = enemy.hit_damage() player.take_damage(enemy_dmg) print("Enemy hit for", enemy_dmg, "points!") print("\nEnemy's hp: ", bcolors.FAIL, str(enemy.get_hp()) + "/" + str(enemy.get_maxhp()), bcolors.ENDC) print("\nYour hp: ", bcolors.OKGREEEN, str(player.get_hp()) + "/" + str(player.get_maxhp()), bcolors.ENDC) print("Your mp: ", bcolors.OKBLUE, str(player.get_mp()) + "/" + str(player.get_maxmp()), bcolors.ENDC) print("===================================================") #magic process elif index == 1: player.choose_magic() magic_choice = int(input("Choose magic: ")) - 1 #method 1 starts here cost = magic[magic_choice]["cost"] current_mp = player.get_mp() if cost > current_mp: print(bcolors.FAIL, "You don't have enough mp!", bcolors.ENDC) continue dmgl = magic[magic_choice]["dmg"] - 5 dmgh = magic[magic_choice]["dmg"] + 5