예제 #1
0
        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

        if magic[magic_choice]["type"] == "black":
            magic_dmg = random.randrange(dmgl, dmgh)
            enemy.take_damage(magic_dmg)
            player.reduce_mp(cost)
            print(magic[magic_choice]["name"], "hit for", magic_dmg, "points!")
        elif magic[magic_choice]["type"] == "white":
            heal = random.randrange(dmgl, dmgh)
            player.heal_player(heal)
            player.reduce_mp(cost)
            print(magic[magic_choice]["name"], "heals for", heal, "hp!")

        #method 2nd for magics
        """   
        player.choose_magic()
        magic_choice=int(input("Choose magic: "))-1
        cost=player.get_spell_cost(magic_choice)
        current_mp=player.get_mp()
        if cost>current_mp:
            print(bcolors.FAIL,"You don't have enough mp!",bcolors.ENDC)
예제 #2
0
            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")
                        del enemies[enemy]
                        defeated_enemies += 1
            # Item
            elif index == 2:
                player.choose_item()
예제 #3
0
        magic_index = magic_choice - 1

        magic = player.magic[magic_index]

        # generate magical damage
        magic_damage = magic.generate_magic()
        magic_name = magic.name
        magic_cost = magic.mp_cost

        #check if player has enough MP to use
        if magic_cost > player.mp:
            print("not enough MP")
            continue

        else:
            player.reduce_mp(magic_cost)
            enemy.take_damage(magic_damage)
            print("================")
            print(
                f"You attacked with {magic_name} and dealt to {enemy.name} {magic_damage} points of damage"
            )

    else:
        print("This is easy mode, you cannot choose another option")
        continue

    # enemy turn
    print("================")
    print(f"{enemy.name.upper()}")
    # enemy_choice = random.randrange(0, len(enemy.action))
    enemy_choice = 0