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.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) elif index == 2: player.choose_item() item_choice = int(input("Choose item: ")) - 1 if item_choice == -1: continue item = player.items[item_choice]["item"] if player.items[item_choice]["quantity"] == 0: print(bcolors.FAIL + "\n" + "None left...." + bcolors.ENDC) continue player.items[item_choice]["quantity"] -= 1 if item.type == "potion": player.heal(item.prop) print(bcolors.OKGREEN + "\n" + item.name + "heals for", str(item.prop), "HP" + bcolors.ENDC)
if len(players) != 0: choice = int(random.randrange(0, 3) - 1) if choice == 0: target = random.randrange(0, (len(players))) enemy_dmg = enemy.generate_damage() players[target].take_damage(enemy_dmg) print("{} is attacked by the {}. You take {} points of damage".format(players[target].name, enemy.name, enemy_dmg)) if players[target].get_hp() == 0: print("\n") print(bcolors.FAIL + "{} has died!".format(players[target].name) + bcolors.END_C) del players[target] elif choice == 1: enemy.choose_item() magic_choice = int(random.randrange(0, len(enemy.magic)) - 1) if magic_choice == -1: continue else: spell = enemy.magic[magic_choice] magic_dmg = spell.generate_damage() current_mp = enemy.get_mp() if spell.cost > current_mp: print(bcolors.FAIL + "\nNot Enough MP\n" + bcolors.END_C) continue enemy.reduce_mp(spell.cost)
if spell.cost > current_mp: print(bcolors.FAIL + "\nNot enough MP\n" + bcolors.ENDC) continue pla.reduce_mp(spell.cost) if spell.type == "white": pla.heal(dmg) print(bcolors.OKBLUE + spell.name + " type heals for " + str(dmg)+ "points") elif spell.type == "black": enemy.take_damage(dmg) print(bcolors.OKBLUE + "\n" + spell.name + "deals",str(dmg), "points of damage" + bcolors.ENDC) elif index==2: pla.choose_item() item_choice = int(input("Choose Item!"))-1 if item_choice == -1: continue item = pla.items[item_choice] if item.type == "potion": pla.heal(item.prop) print(bcolors.OKGREEN + "\n" + item.name + "heals for", str(item.prop), "HP" + bcolors.ENDC) elif item.type == "elixir": pla.mp=pla.maxmp pla.hp=pla.maxmp print(bcolors.OKGREEN + "\n" + item.name + " fully heals for HP/MP" + bcolors.ENDC) elif item.type == "attack": #running = False
print(" ") print(bcolors.fail + bcolors.bold + "==============" + bcolors.endc) print(bcolors.fail + bcolors.bold + "= ENEMY DIED =" + bcolors.endc) print(bcolors.fail + bcolors.bold + "==============" + bcolors.endc) break if hero.hp == 0: print(" ") print(bcolors.fail + bcolors.bold + "=============" + bcolors.endc) print(bcolors.fail + bcolors.bold + "= HERO DIED =" + bcolors.endc) print(bcolors.fail + bcolors.bold + "=============" + bcolors.endc) break elif int(choose) == 3: hero.choose_item() item_chooise = int(input("choose item: ")) - 1 item = hero.items[item_chooise] if item["quantity"] >= 1 : if item["item"].type == "potion": item["quantity"] -= 1 hero.hp += item["item"].prop if hero.hp > hero.max_hp: item["quantity"] += 1 print(bcolors.fail + bcolors.bold + "your hp wont be more then your max hp" + bcolors.endc) hero.hp -= item["item"].prop elif item["item"].type == "elexir": item["quantity"] -= 1
print(bcolors.FAIL + "\nNot Enough MP\n" + bcolors.ENDC) continue player1.reduce_mp(spell.cost) if spell.type == "white": player1.heal(magic_dmg) print( bcolors.OKGREEN + "\n" + spell.name + " heals for " + str(magic_dmg), "HP" + bcolors.ENDC) elif spell.type == "black": enemy1.take_damage(magic_dmg) print(bcolors.WARNING + "\n" + spell.name + " deals", str(magic_dmg), "point of damage", bcolors.ENDC) elif index == 2: player1.choose_item() item_choice = int(input("Choose item: ")) - 1 if item_choice == -1: continue item = player1.items[item_choice]["item"] if player1.items[item_choice]["quantity"] == 0: print(bcolors.FAIL + '\n' + "None left..." + bcolors.ENDC) continue player1.items[item_choice]["quantity"] -= 1 if item.type == "potion": player1.heal(item.prop)
continue if spell.type == 'white': player.heal(magic_dmg) print(bcolors.WARNING + spell.name + " Heals for ", magic_dmg, bcolors.ENDC ) elif spell.type == 'black': player.reduce_mp(cost) enemy.take_damage(magic_dmg) print(bcolors.OKBLUE + "\n" + spell.name + " deals", magic_dmg, "points of damage" + bcolors.ENDC) print("You attacked for: ", magic_dmg, "Enemy health is ", enemy.get_hp()) elif index == 2: player.choose_item() # shows players items item_choice = int(input("Choose item"))-1 # gets players choice if item_choice == -1: continue item = player.items[item_choice]["item"] #choosing item from players_item next taking name and choosing item with class to get type if player.items[item_choice]["quantity"] == 0: print(bcolors.FAIL+"You haven't got enough items"+bcolors.ENDC+"\n") player.items[item_choice]["quantity"] =0 continue player.reduce_quantity(item_choice) if item.type == 'potion':