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") 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 + "\n Not enough MP \n" + Bcolors.ENDC) continue player.reduce_mp(spell.cost) if spell.type == "white": player.heal(magic_dmg) print(Bcolors.OKGREEN + "\n" + spell.name + "heals for:", str(magic_dmg), "HP." + Bcolors.ENDC) elif spell.type == "black": enemy.take_damage(magic_dmg) print(Bcolors.OKBLUE + "\n" + spell.name + "deals", str(magic_dmg), "points of damage" + Bcolors.ENDC) elif index == 2: player.choose_item()
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: print(bcolors.FAIL + "\n Not enough MP" + bcolors.ENDC) continue player.reduce_mp(spell.cost) if spell.type == "white": player.heal(magic_dmg) print(bcolors.OKBLUE + "\n" + spell.name + " heals for", str(magic_dmg), "HP." + bcolors.ENDC) elif spell.type == "black": enemy.take_damage(magic_dmg) print(bcolors.OKBLUE + "\n" + spell.name + " deals", str(magic_dmg), "points of damage" + bcolors.ENDC + "\n") elif index == 2: player.choose_item()
}] # enemy inventory enemy_bag = [] # instantiating the players player = Person(100, 100, 40, 30, player_magic, player_bag) enemy = Person(200, 200, 20, 50, enemy_magic, enemy_bag) print(bgcolor.BOLD + "NAME HP MP" + bgcolor.ENDC) print(bgcolor.BOLD + "SAM: " + str(player.get_hp()) + "/" + str(player.get_max_hp()) + bgcolor.ENDC + bgcolor.OKLIGHTGREEN + "|█████████████████████████|" + bgcolor.ENDC + " " + bgcolor.BOLD + str(player.get_mp()) + "/" + str(player.get_max_hp()) + bgcolor.OKBLUE + "|█████|" + bgcolor.ENDC) print(bgcolor.BOLD + "NIKHIL: " + str(player.get_hp()) + "/" + str(player.get_max_hp()) + bgcolor.ENDC + bgcolor.OKLIGHTGREEN + "|█████████████████████████|" + bgcolor.ENDC + " " + bgcolor.BOLD + str(player.get_mp()) + "/" + str(player.get_max_hp()) + bgcolor.OKBLUE + "|█████|" + bgcolor.ENDC) print(bgcolor.BOLD + "SID: " + str(player.get_hp()) + "/" + str(player.get_max_hp()) + bgcolor.ENDC + bgcolor.OKLIGHTGREEN + "|█████████████████████████|" + bgcolor.ENDC + " " + bgcolor.BOLD + str(player.get_mp()) + "/" + str(player.get_max_hp()) + bgcolor.OKBLUE + "|█████|" + bgcolor.ENDC) print(bgcolor.FAIL + bgcolor.BOLD + "AN ENEMY IS ABOUT TO ATTACK" + bgcolor.ENDC) print("====================================")
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() if spell.cost > current_mp: dmg = player.generate_damage(disad=2) enemy.take_damage(dmg) print("Not enough MP!\nYou attack at a disadvantage doing half melee damage\n" "You inflict", dmg, "damage. Enemy HP is now", enemy.get_hp()) elif spell.cost <= current_mp: if spell.type == "Life": player.heal(magic_dmg) print("You have healed yourself with", spell.name, "for", magic_dmg, "HP") else: enemy.take_damage(magic_dmg) player.reduce_mp(spell.cost) print("You attack with", spell.name, "for", magic_dmg, "damage.\nYou have", player.get_mp(),
#Allowing player to choose between attack and magic player.choose_action() #minus 1 as indexing starts from 0 choice=int(input("Choose action:"))-1 print("You choose {}".format(player.actions[int(choice)])) #Attack choosen if choice == 0: dmg = player.generate_damage() enemy.take_damage(dmg) print("You attaked with force ", dmg , " making your Enemy HP:", enemy.get_hp()) else: #Magic choosen #Allowing Player to choose Spell player.choose_magic() print("Your mp is:", player.get_mp()) magic_choice = int(input("Choose magic: "))-1 # magic_dmg =player.generate_spell_damage(magic_choice) # spell = player.get_spell_name(magic_choice) # cost = player.get_spell_mp_cost(magic_choice) spell=player.magic[magic_choice] magic_dmg=spell.generate_damage() current_mp= player.get_mp() if spell.cost > current_mp: print("ALERT!!!! Not enough MP") continue player.reduce_mp(spell.cost)
if index == 0: dmg = player.generate_damage() enemy.take_damage(dmg) print("You attacked for", dmg, "points of damage.") 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 + "\n NOT ENOUGH MP\n" + bcolors.END) continue player.reduce_mp(spell.cost) if spell.type == "white": player.heal(magic_dmg) print(bcolors.OKBLUE + "\n" + spell.name + " heals for", str(magic_dmg), "HP." + bcolors.END) elif spell.type == "black": enemy.take_damage(magic_dmg) print(bcolors.OKBLUE + "\n" + spell.name + " deals", str(magic_dmg), "points of damage" + bcolors.END)
cure = Spell("Cure", 12, 120, "white") cura = Spell("Cura", 18, 200, "white") player = Person(460, 65, 60, 34, [fire, thunder, blizzard, meteor, cure, cura]) enemy = Person(1200, 65, 45, 25, [fire, thunder, quake]) print(bcolors.FAIL + bcolors.BOLD + "An Enemy Attacks!" + bcolors.ENDC) while player.get_hp() > 0: print("=============================") player.choose_action() choice = input("Your turn\nChoose action:") while (choice != '1') and (choice != '2'): choice = input("Choose valid action:") if choice is '1' and player.get_mp() <= 0: choice = '1' if choice is '1': print("You chose to attack") dmg = player.generate_dmg() enemy.take_dmg(dmg) print("You attacked for " + str(dmg) + " points of damage. Enemy HP at " + str(enemy.get_hp())) else: player.choose_magic() if player.get_mp() < player.lowest_cost(): print("You do not have enough mp to use magic, attacking...") dmg = player.generate_dmg() enemy.take_dmg(dmg) print("You attacked for " + str(dmg) + " points of damage. Enemy HP at " + str(enemy.get_hp())) else: