Esempio n. 1
0
def warriorBattle(player,level):
    enemy = Boss(level)
    print(f"You are up against a level {level} boss. Good luck!\n")
    counter = 0
    while player.health > 0:
        attack = input("Would you like to jab (10 energy), use strike (25 energy), rest (gives 50 energy), or use invincibility (50 energy)? ")
        if attack == 'jab':
            player.jab()
            print(f"That did {player.damage} damage!\n")
            print(f"You now have {player.energy} energy left.\n")
            enemy.health -= player.damage
            print(f"The boss has {enemy.health} HP left.\n")
            player.damage = 0
        elif attack == 'strike':
            player.strike()
            print(f"That did {player.damage} damage!\n")
            print(f"You now have {player.energy} energy left.\n")
            enemy.health -= player.damage
            print(f"The boss has {enemy.health} HP left.\n")
            player.damage = 0
        elif attack == 'rest':
            player.rest()
            print("Ah! You're awake!\n")
            print(f"You now have {player.energy} energy left.\n")
        elif attack == 'invincibility':
            player.invincibility()
            print("You now have a 75% damage reduction for 2 turns.\n")
            print(f"You have {player.energy} energy left\n")
        if player.invincible:
            counter+= 1
        if counter == 2:
            player.invincible = False
            counter = 0
        time.sleep(1)
        boss_attack = random.randint(0, 1)
        if enemy.health < 0:
            print(f"\nCongratulations {player.name}! You defeated the boss!\n")
            player.coins += enemy.coins
            print(f"You earned {enemy.coins} coins!\n")
            break
        while True:
            if boss_attack:
                enemy.smash()
                if enemy.enough_energy:
                    if random.random() < player.agility:
                        time.sleep(1)
                        print("But he misses!\n")
                    else:
                        time.sleep(1)
                        if player.invincible:
                            print(f"That only did {enemy.damage * 0.25} damage!\n")
                            player.health -= (enemy.damage * 0.25)
                            time.sleep(1)
                            print(f"You have {player.health} HP left.\n")
                        else:
                            print(f"That did {enemy.damage} damage!\n")
                            player.health -= enemy.damage
                            time.sleep(1)
                            print(f"You have {player.health} HP left.\n")
                    enemy.damage = 0
                    enemy.enough_energy = None
                    break
                elif not enemy.enough_energy:
                    enemy.enough_energy = None
                    boss_attack = 0
            if not boss_attack:
                enemy.stomp()
                if enemy.other_energy:
                    if random.random() < player.agility:
                        time.sleep(1)
                        print("But he misses!\n")
                    else:
                        time.sleep(1)
                        if player.invincible:
                            print(f"That only did {enemy.damage * 0.25} damage!\n")
                            player.health -= (enemy.damage * 0.25)
                            time.sleep(1)
                            print(f"You have {player.health} HP left.\n")
                        else:
                            print(f"That did {enemy.damage} damage!\n")
                            player.health -= enemy.damage
                            time.sleep(1)
                            print(f"You have {player.health} HP left.\n")
                    enemy.damage = 0
                    enemy.other_energy = None
                    break
                elif not enemy.other_energy:
                    enemy.other_energy = None
                    boss_attack = 1
            if enemy.energy < 15:
                enemy.rest()
                print("The boss takes a rest.\n")
                break
    if player.health <= 0:
        print("You have died. Game over.\n")
        win = 0
Esempio n. 2
0
def sorcererBattle(player,level):
    enemy = Boss(level)
    print(f"You are up against a level {level} boss. Good luck!")
    counter = 0
    while player.health > 0:
        attack = input("Would you like to blast (10 energy), use fireball (30 energy), rest (gives 50 energy), or use invisibility (60 energy)? ")
        if attack == 'blast':
            player.blast()
            print(f"That did {player.damage} damage!\n")
            print(f"You now have {player.energy} energy left.\n")
            enemy.health -= player.damage
            print(f"The boss has {enemy.health} HP left.\n")
            player.damage = 0
        elif attack == 'fireball':
            player.fireball()
            print(f"That did {player.damage} damage!\n")
            print(f"You now have {player.energy} energy left.\n")
            enemy.health -= player.damage
            print(f"The boss has {enemy.health} HP left.\n")
            player.damage = 0
        elif attack == 'rest':
            player.rest()
            print("Ah! You're awake!")
            print(f"\nYou now have {player.energy} energy left.\n")
        elif attack == 'invisibility':
            player.invisibility()
            print("You are now invisible for 2 turns.\n")
            print(f"You have {player.energy} energy left.\n")
            player.agility = 1
        if player.invisible:
            counter+= 1
        if counter == 2:
            print("You are no longer invisible.\n")
            player.invisible = False
            player.agility = player.speed
            counter = 0
        time.sleep(1)
        boss_attack = random.randint(0, 1)
        if enemy.health < 0:
            print(f"\nCongratulations {player.name}! You defeated the boss!\n")
            player.coins += enemy.coins
            print(f"You earned {enemy.coins} coins!\n")
            break
        while True:
            if boss_attack:
                enemy.smash()
                if enemy.enough_energy:
                    if random.random() < player.agility:
                        time.sleep(1)
                        print("But he misses!\n")
                    else:
                        time.sleep(1)
                        print(f"That did {enemy.damage} damage!\n")
                        player.health -= enemy.damage
                        time.sleep(1)
                        print(f"You have {player.health} HP left.\n")
                    enemy.damage = 0
                    enemy.enough_energy = None
                    break
                elif not enemy.enough_energy:
                    enemy.enough_energy = None
                    boss_attack = 0
            if not boss_attack:
                enemy.stomp()
                if enemy.other_energy:
                    if random.random() < player.agility:
                        time.sleep(1)
                        print("But he misses!\n")
                    else:
                        time.sleep(1)
                        print(f"That did {enemy.damage} damage!\n")
                        player.health -= enemy.damage
                        time.sleep(1)
                        print(f"You have {player.health} HP left.\n")
                    enemy.damage = 0
                    enemy.other_energy = None
                    break
                elif not enemy.other_energy:
                    enemy.other_energy = None
                    boss_attack = 1
            if enemy.energy < 15:
                enemy.rest()
                print("The boss takes a rest.\n")
                break
    if player.health<= 0:
        print("You have died. Game over.\n")
        win = 0