# magic attacks
    elif choice == 1:
        player.choose_magic()
        magic_move = int(input("Enter your Choice no: "))
        magic_move -= 1
        spell = player.magic[magic_move]
        spell_name = spell.name

        if current_mp >= spell.cost:
            dmg = spell.get_spell_damage()
            if spell.type == "attack":
                enemy.take_damage(dmg)
                print("You attacked the enemy with", spell_name, " for ", dmg,
                      " points")
            if spell.type == "heal":
                player.heal(dmg)
                print(bgcolor.OKMAGENTA + "You healed with", spell_name,
                      " for ", dmg, " points" + bgcolor.ENDC)

        player.reduce_mp(spell.cost)

        if current_mp < spell.cost:
            print(bgcolor.FAIL + bgcolor.BOLD + "You cannot use", spell.name,
                  "cause you don't have enough magic left" + bgcolor.ENDC)
            continue

    elif choice == 2:
        player.choose_portion()
        potion_move = int(input("Enter your Choice no: "))
        potion_move -= 1
        potion = player.item[potion_move]["item"]
Exemple #2
0
        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()
        item_choice = int(input(" Choose item: ")) - 1

        if item_choice == -1:
            continue

        item = player.items[item_choice]["item"]
        player.items[item_choice]["quantity"] -= 1
Exemple #3
0
                print(
                    enemy.name.replace(" ", "") + " attacked " +
                    players[target].name.replace(" ", "") + " for", enemy_dmg)
                print("----------------------------------")

        elif enemy_choice == 1:
            magic_choice = random.randrange(0, len(enemy_spells))
            spell = enemy_spells[magic_choice]
            spell_dmg = spell.generate_damage()
            if spell.cost <= enemy.mp:

                enemy.reduce_mp(spell.cost)

                if spell.category == "white":
                    enemy.heal(spell_dmg)
                    print(
                        Bcolors.OKBLUE + "\n" + enemy.name.replace(" ", "") +
                        " casted " + spell.name + " and healed for",
                        str(spell_dmg), "HP." + Bcolors.ENDC)

                elif spell.category == "black":
                    if len(players) == 0:
                        print(Bcolors.FAIL + "You loose!" + Bcolors.ENDC)
                        running = False
                    else:
                        target = random.randrange(0, len(players))
                        print(str(len(players)))
                        players[target].take_damage(spell_dmg)

                        print(