Exemple #1
0
def combat_check(P):
    # Called every time the player moves, combat only occurs if combatRoll == 1
    # To change combat frequency, increase/decrease combatRoll's range.

    combatRoll = random.randint(1, 100)
    # combatRoll = 1

    skele = ["Skeleton", 25 + (5 * P.getLevel()), 10, 5 + (5 * P.getLevel())]
    zombie = ["Zombie", 40 + (5 * P.getLevel()), 20, 15 + (5 * P.getLevel())]
    ogre = ["Ogre", 50 + (10 * P.getLevel()), 20, 20 + (10 * P.getLevel())]

    if combatRoll <= 5:
        mobList = [skele, skele, skele, skele, skele, skele,
                   zombie, zombie, zombie,
                   ogre]

        randomMob = random.choice(mobList)

        transition(P, 1)
        system('cls')
        print("\n\n\n\n\n")
        vc = ["An" if randomMob[0][0].lower() in "aeiou" else "A"]
        encounterText = ["   {} {} appeared!".format(vc[0], randomMob[0].lower()),
                         "   {} {} rises out of the darkness...".format(vc[0], randomMob[0].lower()),
                         "   {} {} comes up from behind you!".format(vc[0], randomMob[0].lower()),
                         "   {} {}'s cry echoes throughout the cave!".format(vc[0], randomMob[0].lower())]
        intro.slow_type([random.choice(encounterText)])
        sleep(.5)
        combat_loop(P, characterClass.Enemy(randomMob[0], randomMob[1], randomMob[2], randomMob[3]))
        refresh_map(P)
Exemple #2
0
    def attack(self, target):
        damage = self.getDamage()

        if "Brace" in target.getBuffs() and "Counter" not in target.getBuffs():
            damage = round(damage * .8)

        if "Bubble" in target.getBuffs():
            if target.getBuffs()["Bubble"] == 3:
                damage -= 15
            elif target.getBuffs()["Bubble"] == 2:
                damage -= 10
            elif target.getBuffs()["Bubble"] == 1:
                damage -= 5

        # If the player is a thief, check to see if they dodge, then calculate damage
        if target.getProf() == "Thief" and randint(1,
                                                   100) <= target.dodgeChance:
            intro.slow_type([
                "\n\tYou dodged the incoming attack from the {}!".format(
                    self.getName().lower())
            ])
        else:
            # If the player has a shield equipped, reduce damage taken and damage shield
            if "Counter" in target.getBuffs():
                intro.slow_type([
                    "\n\tThe {} attacks you for {} damage!".format(
                        self.getName().lower(), damage),
                    "\n\tYou counter the attack, and reflect the {} damage back!"
                    .format(damage)
                ])
                self.setHP(self.getHP() - damage)
                target.removeBuff("Counter")
            elif len(target.armor) > 0:
                damage -= (target.getArmor() // 2)
                intro.slow_type([
                    "\n\tThe {} attacks you for {} damage!".format(
                        self.getName().lower(), damage)
                ])
                if damage < 0:
                    damage = 0
                target.setHP(target.getHP() - damage)
                target.armor[0].setDur(target.armor[0].getDur() - 1)
            else:
                intro.slow_type([
                    "\n\tThe {} attacks you for {} damage!".format(
                        self.getName().lower(), damage)
                ])
                target.setHP(target.getHP() - damage)

        if "Brace" in target.getBuffs() and "Counter" not in target.getBuffs():
            reflect = round(damage * .2)
            intro.slow_type([
                "{} damage is reflected back to the {}!".format(
                    reflect,
                    self.getName().lower())
            ])
            self.setHP(self.getHP() - reflect)
Exemple #3
0
def combat_loop(P, E):
    global didRegen

    playerTurn = True
    P.resetCombat()
    P.clearBuffs()
    didRegen = False
    # While player and enemy health are above 0, and the player hasn't stopped combat.

    while P.getHP() > 0 and E.getHP() > 0 and not P.isCombatStopped():

        if playerTurn:

            # Call the combat screen to perform player's turn
            combat_screen(P, E)

            # If the player did an action, flag their turn as over.
            if P.actionCheck():
                if E.getHP() > 0:
                    P.checkBuff(E)
                    P.buffDown()
                playerTurn = False

        elif not playerTurn and isinstance(E, characterClass.Enemy):
            if "Freeze" in P.getBuffs():
                intro.slow_type(["The {} is frozen solid!".format(E.getName().lower())])
            else:
                # Roll for the enemy's action: <= 3 attacks, 4 heals.
                enemyChoice = random.randint(1, 4)

                if enemyChoice <= 3:
                    E.attack(P)

                # Enemy heal
                elif enemyChoice == 4:
                    if E.getHP() != E.maxHP():
                        E.selfHeal()
                    else:
                        E.attack(P)

            sleep(1)
            playerTurn = True

        elif not playerTurn and isinstance(E, characterClass.Boss):
            if "Freeze" in P.getBuffs():
                intro.slow_type(["{} is frozen solid!".format(E.getName())])
            else:
                E.attack(P, E.getDamage())
            playerTurn = True

        if E.getHP() <= 0:
            P.addExp(E)

    P.didBattle = True
Exemple #4
0
 def addExp(self, target):
     if self.getLevel() < 5:
         intro.slow_type(
             ["You gained {} experience.".format(target.expValue)])
         sleep(.5)
         self.__exp += target.expValue
         if self.__exp >= self.__expRequired:
             self.levelUp()
             overflow = self.__exp - self.__expRequired
             self.__expRequired += 50
             self.__exp = overflow
Exemple #5
0
def make_player():
    from os import system

    defaultHP = 150
    defaultMP = 50

    finished = False

    charName = ""
    charProf = ""

    while not finished:
        print("\n -== Enter your character's name: ==-")
        while charName == "":
            charName = input("\t >> ").title()
        print("\n -== Available Professions: ==-\n")
        for i in profList[:3]:
            print("\t" + i)
            if i == "Warrior":
                print(
                    "\t >  With over a dozen battles conquered, warriors deal additional damage with attacks."
                )
                print(
                    "\t\t  (Gain an additional 5 base damage on top of weapon.)"
                )
            elif i == "Mage":
                print(
                    "\t >  After many years of study, magi regenerate a small amount of mana during combat."
                )
                print(
                    "\t\t  (Regenerate 5 MP at the beginning of every turn.)")
            elif i == "Thief":
                print(
                    "\t >  Light on their feet, thieves have a small chance to avoid damage entirely."
                )
                print("\t\t  (Gain a 15% chance to dodge all attack damage.)")
        print("\n -== Choose your profession: ==-")
        while charProf == "" or charProf not in profList[:3]:
            charProf = input("\t >> ").title()

        intro.slow_type(
            ["\n Thank you, {} the {}.".format(charName, charProf)])
        intro.slow_type(["\n\n Continue with this setup? (yes/no)"])
        playerInput = input(" >> ")
        if "y" in playerInput.lower():
            finished = True
        else:
            system('cls')
            charName = ""
            charProf = ""

    return Player(charName, defaultHP, defaultMP, charProf)
Exemple #6
0
 def callDeath():
     from os import system
     from pygame import mixer
     mixer.music.fadeout(5000)
     sleep(2)
     system('cls')
     intro.slow_type(["\n\n\tThanks for playing!", "\n", "\tPlay again?:"])
     ans = input("\t >> ")
     if "y" in ans:
         from TextRPG import main
         main()
     else:
         quit()
Exemple #7
0
def outro():
    system('cls')
    intro.slow_type(["\n\n\n\tImpossible...",
                     "\n\n\tI ", "won't ", "be", ".", ".", ".",
                     "\n\n\t   Ugh..."])
    sleep(2)
    system('cls')
    intro.slow_type(["\n\n\n\n\t  V", " ", "I", " ", "C", " ", "T", " ", "O", " ", "R", " ", "Y", " ", "!",
                     "\n\n\tThanks for playing!", "",
                     "\n\t   Play again?:"])
    ans = input("\t     >> ")
    if "y" in ans.lower():
        main()
    else:
        quit()
Exemple #8
0
 def levelUp(self):
     self.__level += 1
     intro.slow_type([
         "You leveled up! You are now Level {}!".format(self.getLevel()),
         "\nYou regained half your missing HP & MP!"
     ])
     if self.getLevel() == 5:
         intro.slow_type([
             "You've reached the maximum level of 5, your passive trait has doubled."
         ])
         self.dodgeChance = 30
     self.__maxHP += 20
     self.__maxMP += 10
     self.setHP(self.getHP() + ((self.__maxHP - self.getHP()) // 2))
     self.setMP(self.getMP() + ((self.__maxMP - self.getMP()) // 2))
     sleep(.5)
Exemple #9
0
    def checkBuff(self, E):
        buff = ""
        damage = 0

        cond = ["The " if E.getProf() == "Monster" else ""]
        name = [
            E.getName().lower() if E.getProf() == "Monster" else E.getName()
        ]

        if "Bleed" in self.getBuffs():
            damage = randint(4, 12)
            buff += "\n\t{}{} bleeds for an additional {} damage.".format(
                cond[0], name[0], damage)
        if "Burn" in self.getBuffs():
            damage = randint(6, 12)
            buff += "\n\t{}{} burns for an additional {} damage.".format(
                cond[0], name[0], damage)
        if "Poison" in self.getBuffs():
            damage = randint(10, 15)
            buff += "\n\t{}{} suffers an additional {} poison damage.".format(
                cond[0], name[0], damage)
        if "Shadow" in self.getBuffs():
            if self.dodgeChance == 15 or self.dodgeChance == 30:
                self.dodgeChance += 35
            buff += "\n\tYour chance to dodge is increased."
        if "Bubble" in self.getBuffs():
            if self.getBuffs()["Bubble"] == 4:
                buff += "\n\tYour protective bubble is at full strength"
            elif 2 <= self.getBuffs()["Bubble"] >= 3:
                buff += "\n\tYour protective bubble fades slightly."
            elif self.getBuffs()["Bubble"] == 1:
                buff += "\n\tYour protective bubble fades completely."
        if "Brace" in self.getBuffs():
            if self.getBuffs()["Brace"] > 1:
                buff += "\n\tYour defenses are increased."
            elif self.getBuffs()["Brace"] == 1:
                buff += "\n\tYour defense boost fades."

        if buff:
            intro.slow_type([buff])

        if damage:
            E.setHP(E.getHP() - damage)
Exemple #10
0
    def attack(self, target):
        if isinstance(self.__inv[0], itemGen.Weapon):
            cond = [" the" if target.getProf() == "Monster" else ""]
            name = [
                target.getName().lower()
                if target.getProf() == "Monster" else target.getName()
            ]

            intro.slow_type([
                "\n\tYou attack{} {} for {} damage!".format(
                    cond[0], name[0], self.getDamage())
            ])
            target.setHP(target.getHP() - self.getDamage())
            self.__inv[0].setDur(self.__inv[0].getDur() - 1)
            self.didAction(True)
            sleep(.5)
        else:
            intro.slow_type(
                ["You try to attack, but don't have a weapon equipped!"])
            sleep(1)
Exemple #11
0
    def setHP(self, newHP):
        from time import sleep

        # Input validation: health above 0.
        if newHP > 0:
            self.__hp = newHP
            if isinstance(self, Player) and newHP > self.getMaxHP():
                self.__hp = self.getMaxHP()
        elif newHP <= 0:
            self.__hp = newHP
            if self.getProf() == "Monster":
                intro.slow_type(
                    ["\n\tThe " + self.__name.lower() + " has died.\n"])
            else:
                intro.slow_type(["\n\t" + self.__name + " has died.\n"])
            sleep(.5)

            if isinstance(self, Player):
                sleep(1)
                Player.callDeath()
Exemple #12
0
 def selfHeal(self):
     if self.getName() == "Skeleton":
         healAmount = randint(5, 10)
         intro.slow_type([
             "\n\tThe skeleton reaches down and grabs a bone off the floor...",
             "\n\tAttaching a piece of itself back on, it regains {} health!"
             .format(str(healAmount))
         ])
         self.setHP(self.getHP() + healAmount)
     elif self.getName() == "Zombie":
         healAmount = randint(10, 15)
         intro.slow_type([
             "\n\tThe zombie grabs a NeuroShake\u2122 and takes a huge slurp...",
             "\n\tEnergized with fresh brain matter, it regains {} health!".
             format(str(healAmount))
         ])
         self.setHP(self.getHP() + healAmount)
     elif self.getName() == "Ogre":
         healAmount = randint(15, 20)
         intro.slow_type([
             "\n\tThe ogre pulls out a vial of human blood from it's belt loop...",
             "\n\tGuzzling down the ichor, it regains {} health!".format(
                 str(healAmount))
         ])
         self.setHP(self.getHP() + healAmount)
Exemple #13
0
def combat_screen(P, E):
    global didRegen

    P.didAction(False)
    system('cls')

    # Check if player is a mage, if they don't have max mana, add 5.
    if P.getProf() == "Mage" and P.getMP() < P.getMaxMP() and not didRegen:
        if P.getLevel() < 5:
            P.setMP(P.getMP() + 5)
        else:
            P.setMP(P.getMP() + 10)
        didRegen = True

        # If they regenerated over maximum amount (50), set mana to 50.

    combatMenu1 = ["{}{}".format(P.getName(), " " * (23 - (len(P.getName())))),
                   "the{}{}".format(" " * (20 - len(E.getName())), E.getName()),
                   "{}{}".format(P.getProf(), " " * (23 - len(P.getProf()))),
                   "                       ",
                   "HP: {}/{}{}HP: {}".format(
                       P.getHP(), P.getMaxHP(), " " * (11 - len(str(P.getHP())) - len(str(E.getHP()))), E.getHP()),
                   "MP: {}/{}{}".format(P.getMP(), P.getMaxMP(), " " * (16 - len(str(P.getMP())))),
                   "                       ",
                   "                       ",
                   "                       ",
                   "                       ",
                   "                       ",
                   "1: Attack      3: Items",
                   "2: Spells      4:  Run "]

    combatMenu2 = ["{}{}{}".format(P.getName(), " " * (23 - len(P.getName()) - len(E.getName())), E.getName()),
                   "the                 the",
                   "{}{}{}".format(P.getProf(), " " * (23 - len(P.getProf()) - len(E.getProf())), E.getProf()),
                   "                       ",
                   "HP: {}/{}{}HP: {}".format(
                       P.getHP(), P.getMaxHP(), " " * (11 - len(str(P.getHP())) - len(str(E.getHP()))), E.getHP()),
                   "MP: {}/{}{}MP: {}".format(
                       P.getMP(), P.getMaxMP(), " " * (12 - len(str(P.getMP())) - len(str(E.getMP()))), E.getMP()),
                   "                       ",
                   "                       ",
                   "                       ",
                   "                       ",
                   "                       ",
                   "1: Attack     2: Spells",
                   "        3: Items       "]

    if E.getProf() == "Monster":
        print_menu(combatMenu1)
        acceptableAnswers = ["b'1'", "b'2'", "b'3'", "b'4'"]
    else:
        print_menu(combatMenu2)
        acceptableAnswers = ["b'1'", "b'2'", "b'3'"]

    if didRegen:
        intro.slow_type(["\n You regenerated some mana..."])

    flush_input()

    # ans = input(" >> ")
    ans = str(getch()).lower()

    while ans not in acceptableAnswers:
        ans = str(getch()).lower()

    if ans == "b'1'":
        P.attack(E)
        didRegen = False
    elif ans == "b'2'":
        if P.castSpell(E):
            didRegen = False
    elif ans == "b'3'":
        P.checkInv()
    elif ans == "b'4'" and E.getProf() == "Monster":
        escapeChance = random.randint(1, 10)
        if escapeChance <= 5:
            intro.slow_type(["\n\tYou just barely escaped!"])
            P.stopCombat()
        else:
            lines = ["\n\tAttempting to escape, you trip and fall in the darkness!",
                     "\n\tIn attempt to run away, the monster grabs you!",
                     "\n\tYou find yourself too winded to run away..."]
            intro.slow_type([random.choice(lines)])
            P.didAction(True)
            sleep(1)
        didRegen = False
Exemple #14
0
    def castSpell(self, E):
        importName, importDesc = getSpellData("spellData.txt")
        spellNames = []
        spellDescs = []

        if self.getProf() == "Warrior":
            spellNames = importName[0:4]
            spellDescs = importDesc[0:4]
        elif self.getProf() == "Mage":
            if self.getLevel() > 1:
                spellNames = importName[4:7]
                spellDescs = importDesc[4:7]
            spellNames.insert(0, importName[0])
            spellDescs.insert(0, importDesc[0])
        else:
            if self.getLevel() > 1:
                spellNames = importName[7:]
                spellDescs = importDesc[7:]
            spellNames.insert(0, importName[0])
            spellDescs.insert(0, importDesc[0])

        spellNames = spellNames[:self.getLevel()]
        spellDescs = spellDescs[:self.getLevel()]

        print("\nSpells:")
        for spell in range(len(spellNames)):
            print("\t{}) {}   {}".format(spell + 1, spellNames[spell],
                                         spellDescs[spell]))
        print("\n0) Return to previous menu")

        # Practicing some list comprehension
        # This little guy cut down on a TON of lines!
        cond = [" the" if E.getProf() == "Monster" else ""]
        name = [
            E.getName().lower()
            if E.getProf() == "Monster" else E.getName().title()
        ]

        finished = False
        while not finished:
            try:
                # Flush input
                while kbhit():
                    getch()

                ans = getch().decode()
                ans = int(ans)

                # ans = int(input(">> "))

                while ans > len(spellNames):
                    ans = int(getch().decode())

                if ans == 0:
                    return False
                elif ans == 1:
                    if self.getMP() >= 10:
                        healAmount = randint(10, 20)
                        self.setMP(self.getMP() - 10)
                        intro.slow_type([
                            "\n\tA restorative mist begins to rise around you...",
                            "\n\tYou cast a healing spell, restoring {} health."
                            .format(str(healAmount))
                        ])
                        self.setHP(self.getHP() + healAmount)
                        sleep(.5)
                        self.didAction(True)
                    else:
                        print("Not enough mana!")
                        sleep(1)
                elif ans == 2:
                    if self.getMP() >= 15:
                        damage = randint(20, 30)
                        self.setMP(self.getMP() - 15)

                        if self.getProf() == "Warrior":
                            intro.slow_type([
                                "\n\tYou wind up an attack, preparing to cut deep into your enemy...",
                                "\n\tYou strike{} {} with expert precision, doing {} damage!"
                                .format(cond[0], name[0], str(damage))
                            ])
                            E.setHP(E.getHP() - damage)
                            self.addBuff("Bleed", 2)

                        elif self.getProf() == "Mage":
                            intro.slow_type([
                                "\n\tFire swirls amongst your fingertips as you begin to concentrate...",
                                "\n\tYou cast a fireball at{} {}, doing {} damage!"
                                .format(cond[0], name[0], str(damage))
                            ])
                            E.setHP(E.getHP() - damage)
                            self.addBuff("Burn", 2)

                        elif self.getProf() == "Thief":
                            intro.slow_type([
                                "\n\tYou begin to sink into the shadows surrounding you...",
                                "\n\tYou appear behind{} {} and strike, doing {} damage!"
                                .format(cond[0], name[0],
                                        round(self.getDamage() * 1.5))
                            ])
                            E.setHP(E.getHP() - round(self.getDamage() * 1.5))

                        sleep(.5)
                        self.didAction(True)
                    else:
                        print("Not enough mana!")
                        sleep(1)
                elif ans == 3:
                    if self.getMP() >= 20:
                        self.setMP(self.getMP() - 20)

                        if self.getProf() == "Warrior":
                            intro.slow_type([
                                "\n\tReflecting on your years of battle, your posture stiffens.",
                                "\n\tYou brace yourself for incoming attacks."
                            ])
                            self.addBuff("Brace", 3)

                        elif self.getProf() == "Mage":
                            damage = randint(15, 25)
                            intro.slow_type([
                                "\n\tThe cold vapor in the air around you begins to crystallize...",
                                "\n\tIce materializes around you, barraging{} {} for {} damage."
                                .format(cond[0], name[0], damage)
                            ])
                            E.setHP(E.getHP() - damage)
                            self.addBuff("Freeze", 2)

                        elif self.getProf() == "Thief":
                            intro.slow_type([
                                "\n\tThe lines between your body and the light begin to fade...",
                                "\n\tYou become seemingly invisible amongst the darkness."
                            ])
                            self.addBuff("Shadow", 3)

                        sleep(.5)
                        self.didAction(True)
                    else:
                        print("Not enough mana!")
                        sleep(1)
                elif ans == 4:
                    if self.getMP() >= 25:
                        self.setMP(self.getMP() - 25)

                        if self.getProf() == "Warrior":
                            intro.slow_type([
                                "\n\tYour experience tells you that{} {} will soon expose itself."
                                .format(cond[0], name[0]),
                                "\n\tYou assume a defensive stance, preparing to counterattack."
                            ])
                            self.addBuff("Counter", 10)

                        elif self.getProf() == "Mage":
                            damage = randint(15, 25)
                            intro.slow_type([
                                "\n\tYou conjure a slowly fading protective bubble around yourself...",
                                "\n\tIncoming damage is reduced for the next three turns."
                                .format(cond[0], name[0], damage)
                            ])
                            E.setHP(E.getHP() - damage)
                            self.addBuff("Bubble", 4)

                        elif self.getProf() == "Thief":
                            intro.slow_type([
                                "\n\tYou coat your equipped weapon with a deadly poison...",
                                "\n\tYour attacks become even more efficient and deadly."
                            ])
                            self.addBuff("Poison", 3)

                        sleep(.5)
                        self.didAction(True)
                    else:
                        print("Not enough mana!")
                        sleep(1)

                finished = True
            except ValueError:
                print("Invalid input.")
Exemple #15
0
    def checkInv(self):
        print(
            "\n\nSelect a weapon to use/equip:\n\n\tCurrently equipped weapon:"
        )
        print("\n\t\t" + str(self.__inv[0]) + "\n")
        if len(self.armor) > 0:
            print("\tCurrently equipped shield:")
            print("\n\t\t" + str(self.armor[0]) + "\n")
        for i in range(len(self.__inv[1:])):
            print("\t{}) {}".format(i + 1, self.__inv[i + 1]))
        print(
            "\nD: Discard Item\nU: Unequip Offhand\n0) Return to previous menu"
        )

        finished = False
        while not finished:
            try:
                # ans = input("\t >> ")
                ans = getch().decode()

                if ans in "du0123456789":
                    if ans == "0":
                        break

                    elif ans == "d":
                        intro.slow_type(
                            ["\t\tPress number of the item to discard."])
                        print(
                            "\t  (This cannot be undone, 0 to return to previous menu.)"
                        )
                        tempAns = getch().decode()
                        if int(tempAns) != 0 and int(tempAns) <= len(
                                self.__inv):
                            self.__inv.pop(int(tempAns))

                    elif ans == "u":
                        if len(self.__inv) <= 8:
                            self.addItem(self.armor.pop(0))

                    elif "Potion" in self.__inv[int(ans)].getName():
                        self.__inv[int(ans)].usePotion(self)
                        temp = [
                            "HP" if "Health" in self.__inv[int(ans)].getName()
                            else "MP"
                        ]
                        intro.slow_type([
                            "\tYou drank a {}, restoring {} {}.".format(
                                self.__inv[int(ans)].getName().lower(),
                                self.__inv[int(ans)].getPower(), temp[0])
                        ])
                        self.__inv.pop(int(ans))
                        sleep(.5)
                        self.didAction(True)

                    elif "Great" in self.__inv[int(ans)].getName() and len(
                            self.armor) > 0:
                        if len(self.__inv) <= 8:
                            # Add the armor and current weapon at the beginning of the list to the end,
                            self.__inv.append(self.armor.pop(0))
                            self.__inv.append(self.__inv.pop(0))
                            # Add the chosen weapon to the front (-1 because [0] moved right, shifting list left)
                            self.__inv.insert(0, self.__inv.pop(int(ans) - 1))
                        else:
                            intro.slow_type(["Too many items in inventory!"])
                            sleep(1)

                    elif "Shield" in self.__inv[int(ans)].getName():
                        if "Great" in self.__inv[0].getName():
                            intro.slow_type(
                                ["Please equip a 1 handed weapon first."])
                            sleep(1)
                        else:
                            self.addArmor(self.__inv[int(ans)])
                            self.__inv.pop(int(ans))

                    else:
                        self.__inv.insert(0, self.__inv.pop(int(ans)))

                    self.didAction(True)

                    finished = True
            except ValueError:
                print("Invalid input.")
Exemple #16
0
    def castSpell(self, E):
        from random import choice

        if self.getProf() == "Guardian":
            spellList = ["holy bolt", "empower", "ethereal blade"]

        else:
            spellList = ["demonic spear", "leech", "dark vortex"]

        if self.getMP() >= 20:
            moveChoice = randint(1, 15)
        elif self.getMP() >= 15:
            moveChoice = randint(1, 10)
        elif self.getMP() >= 10:
            moveChoice = randint(1, 5)
        else:
            moveChoice = 0

        hit = choice(["hitting", "grazing", "clipping", "injuring"])
        side = choice(["left", "right"])
        limb = choice(["arm", "leg"])

        if moveChoice <= 5:
            if self.getProf() == "Guardian":
                damage = randint(30, 40)
                intro.slow_type([
                    "\n\t{} casts a {} at you, {} your {} {}.".format(
                        self.getName(), spellList[0], hit, side, limb),
                    "\n\tYou take {} damage from the spell.".format(damage)
                ])
                E.setHP(E.getHP() - damage)
            else:
                damage = randint(35, 45)
                intro.slow_type([
                    "\n\t{} summons a {} and hurls it at you, {} your {} {}.".
                    format(self.getName(), spellList[0], hit, side, limb),
                    "\n\tYou take {} damage from the pike.".format(damage)
                ])
                E.setHP(E.getHP() - damage)
            sleep(.5)
            self.setMP(self.getMP() - 15)
        elif 5 < moveChoice <= 10:
            if self.getProf() == "Guardian":
                intro.slow_type([
                    "\n\t{} casts {} on his weapon, increasing the damage of it's next attack."
                    .format(self.getName(), spellList[1])
                ])
                self.__buffCount += 1
            else:
                damage = randint(15, 25)
                intro.slow_type([
                    "\n\n\t{} casts {} on you, siphoning {} health from you.".
                    format(self.getName(), spellList[1], damage)
                ])
                E.setHP(E.getHP() - damage)
                self.setHP(self.getHP() + damage)
            sleep(.5)
            self.setMP(self.getMP() - 15)
        elif 10 < moveChoice <= 15:
            if self.getProf() == "Guardian":
                damage = randint(35, 45)
                intro.slow_type([
                    "\n\n\t{} summons an {} from the void, it pierces your {} {} with ease."
                    .format(self.getName(), spellList[2], side, limb),
                    "\n\tYou take {} damage from the wound.".format(damage)
                ])
                E.setHP(E.getHP() - damage)
            else:
                damage = randint(40, 50)
                intro.slow_type([
                    "\n\n\t{} summons a {} around you, you can feel your mind begin to wither."
                    .format(self.getName(), spellList[2]),
                    "\n\tYou take {} damage from the torment.".format(damage)
                ])
                E.setHP(E.getHP() - damage)
            sleep(.5)
            self.setMP(self.getMP() - 20)
Exemple #17
0
    def attack(self, target, damage):
        moveChoice = randint(1, 2)

        if self.__buffCount > 0:
            damage += 5
        elif self.__buffCount < 0:
            self.__buffCount = 0

        if "Brace" in target.getBuffs() and "Counter" not in target.getBuffs():
            damage = round(damage * .8)

        if "Bubble" in target.getBuffs():
            if target.getBuffs()["Bubble"] == 3:
                damage -= 15
            elif target.getBuffs()["Bubble"] == 2:
                damage -= 10
            elif target.getBuffs()["Bubble"] == 1:
                damage -= 5

        if moveChoice == 1 and self.getMP() >= 10:
            self.castSpell(target)
        else:
            if target.getProf() == "Thief" and randint(
                    1, 100) <= target.dodgeChance:
                intro.slow_type([
                    "\n\tYou dodged the incoming attack from {}!".format(
                        self.getName())
                ])
            else:
                if "Counter" in target.getBuffs():
                    intro.slow_type([
                        "\n\t{} attacks you for {} damage!".format(
                            self.getName(), damage),
                        "\n\tYou counter the attack, and reflect the {} damage back!"
                        .format(damage)
                    ])
                    self.setHP(self.getHP() - damage)
                    target.removeBuff("Counter")
                elif len(target.armor) > 0:
                    damage -= (target.getArmor() // 2)
                    intro.slow_type([
                        "\n\t{} attacks you for {} damage!".format(
                            self.getName(), damage)
                    ])
                    if damage < 0:
                        damage = 0
                    target.setHP(target.getHP() - damage)
                    target.armor[0].setDur(target.armor[0].getDur() - 1)
                else:
                    intro.slow_type([
                        "\n\t{} attacks you for {} damage!".format(
                            self.getName(), damage)
                    ])
                    target.setHP(target.getHP() - damage)

                if "Brace" in target.getBuffs(
                ) and "Counter" not in target.getBuffs():
                    reflect = round(damage * .2)
                    intro.slow_type([
                        "{} damage is reflected back to {}!".format(
                            reflect, self.getName())
                    ])
                    self.setHP(self.getHP() - reflect)

            self.__buffCount -= 1

        sleep(.5)
Exemple #18
0
def player_move(P):
    bossBattle = False
    # print("\t\t\t\tLvl. {}".format(P.getLevel()))
    controls = ["\n\n W: UP\t   S: DOWN",
                "\n A: LEFT   D: RIGHT\t           HP:{}{} /{}\t\t         Lvl. {}"
                .format(" " * (5 - len(str(P.getHP()))), P.getHP(), P.getMaxHP(), P.getLevel()),
                "\n\t\t\t           MP:{}{} /{}"
                .format(" " * (5 - len(str(P.getMP()))), P.getMP(), P.getMaxMP()),
                "\n E: USE\t   B: INVENTORY\t           XP:{}{} /{}\t\t     {} the {}"
                .format(" " * (5 - len(str(P.getExp()))), P.getExp(), P.getExpReq(), P.getName(), P.getProf()),
                "\n X: MUSIC  M: MAP\t         KEYS:    {} /2  ".format(P.getKeys())]
    for i in controls:
        print(i, end="")

    # Flush input
    flush_input()

    playerInput = str(getch()).lower()
    # playerInput = input(" >> ")

    nullChars = "BXO#=-+/|\\"

    checkSpot = [gameMap[P.getX() - 1][P.getY()],
                 gameMap[P.getX() + 1][P.getY()],
                 gameMap[P.getX()][P.getY() - 1],
                 gameMap[P.getX()][P.getY() + 1]]

    # Input checking - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    # getch() returns "b'<key>'" when changed to a string, unless you use .decode() on it (it usually returns bytecode)
    # I had trouble getting ESC as input once decoded, however. I decided to just use the "b'<key>'" string for checks.
    # - checkSpot refers to all the locations within 1 space of the player

    if playerInput == "b'e'":
        if "O" in checkSpot:
            print("\n\n\tTravel to the next area? (yes/no)")
            if "y" in input("\t >> "):
                for portal in portalList:
                    portal.checkPortal(P)

                transition(P)
                refresh_map(P)
                map_setup()
                for i in range(len(gameMap)):
                    for j in range(len(gameMap[i])):
                        if gameMap[i][j] == "O":
                            P.setX(i)
                            P.setY(j - 1)
                        elif gameMap[i][j] == "x":
                            P.setX(i)
                            P.setY(j)

        elif "=" in checkSpot and P.getLoc() == 0:
            intro.slow_type(["\n\tThere appears to be two keyholes on the wall here..."])
            if P.getKeys() >= 2:
                intro.slow_type(["\tInsert keys?"])
                ans = input("\t >> ")
                if "y" in ans:
                    intro.slow_type(["\n\tThe wall seemingly caves upon itself as a pathway opens..."])
                    sleep(.5)
                    for portal in portalList:
                        portal.checkPortal(P)

                    transition(P)
                    refresh_map(P)
                    for i in range(len(gameMap)):
                        for j in range(len(gameMap[i])):
                            if gameMap[i][j] == "O":
                                P.setX(i)
                                P.setY(j - 1)
                            elif gameMap[i][j] == "x":
                                P.setX(i)
                                P.setY(j)

                    for _ in range(2):
                        P.removeKey()
            else:
                intro.slow_type(["\tMaybe you should return after you've found something that fits."])
                sleep(1)

        elif "X" in checkSpot:
            print("\n\tOpen the chest? (yes/no)")
            ans = input("\t >> ")

            if "y" in ans:
                for chest in chestList:
                    chest.checkChest(P)
                    print("\n\tLoot the items? (yes/no)")
                    ans = input("\t >> ")
                    if "y" in ans:
                        if isinstance(chest, mapItemClass.Chest):
                            chest.moveItems(P)

        elif "B" in checkSpot:
            bossBattle = True
            transition(P)
            system('cls')
            if not bossChestList[0].bossDefeated():
                bossNames = ["Hadriel", "Aphaelon", "Erathol", "Asteroth"]

                randName = random.choice(bossNames)

                introLines = [
                    ["\n\n\n\tFeeble {}, you think yourself powerful enough to face me?".format(P.getProf().lower()),
                     "\n\n\tI, {}, will destroy you!".format(randName)],
                    ["\n\n\n\tFoolish {}, you feel fit to challenge the mighty {}?!".format(P.getProf().lower(), randName),
                     "\n\n\tPrepare to be crushed!"],
                    ["\n\n\n\tI will leave your body amongst this rubble, {}!".format(P.getProf().lower()),
                     "\n\n\tMy name is {}, and I take no prisoners.".format(randName)],
                    ["\n\n\n\tYou were unwise to come here, {}. I cannot allow you to progress any further.".format(
                     P.getProf().lower()),
                     "\n\n\tI am {}, and I guard this treasure with my life!".format(randName)]]

                randLines = random.choice(introLines)

                intro.slow_type(randLines)
                sleep(1)

                combat_loop(P, characterClass.Boss(randName, 65 + (P.getLevel() * 10), 50, 40 + (10 * P.getLevel()), "Guardian"))
                intro.slow_type(["You gained a KEY!"])
                P.addKey()

            print("\n\tOpen the chest? (yes/no)")
            ans = input("\t >> ")

            if "y" in ans:
                for chest in bossChestList:
                    chest.checkChest(P)
                    print("\n\tLoot the items? (yes/no)")
                    ans = input("\t >> ")
                    if "y" in ans:
                        chest.moveItems(P)

            refresh_map(P)

    elif playerInput == "b'h'":
        import helpScreen
        helpScreen.menu()
        ans = input("\n")
        if ans == "gimmiedaloot":
            P.addItem(itemGen.Weapon("Obsidian Greatsword", 150, 3, 100, 50))
            P.addItem(itemGen.Potion("Superior Health Potion", 50))
            P.addKey()
            P.addKey()
        elif ans == "theonetrueking":
            P.setMaxHP(1000)
            P.setHP(P.getMaxHP())
        elif ans == "enoughofthismadness":
            mixer.music.fadeout(6000)
            system('cls')
            intro.slow_type(["\n\n\n\tHa..", "Ha..", "Ha...",
                             "\n\n\tYou thought you could escape so easily, impudent mortal?",
                             "\n\n\tYour soul... it will be mine, like all the rest!"])
            mixer.music.load("insomnia.mp3")
            mixer.music.play()
            E = characterClass.Boss("Kilvath", 1, 0, 100, "Soulkeeper")
            combat_loop(P, E)
            if E.getHP() <= 0:
                mixer.music.fadeout(6500)
                outro()

    elif playerInput == "b'w'":
        if P.getLoc() == 9 and gameMap[P.getX()][P.getY()] == gameMap[13][6]:
            transition(P, 1)
            mixer.music.fadeout(10000)
            system('cls')
            intro.slow_type(["\n\n\n\tThose who would travel any further...",
                             "\n\n", "\tBe wary", ".", ".", "of the darkness", ".", ".", "."])
            sleep(1)
            refresh_map(P)
            P.setX(P.getX() - 1)

        elif P.getLoc() == 9 and gameMap[P.getX()][P.getY()] == gameMap[6][6]:
            system('cls')
            intro.slow_type(["\n\n\n\tHa..", "Ha..", "Ha...",
                             "\n\n\tYou thought you could escape so easily, impudent mortal?",
                             "\n\n\tYour soul... it will be mine, like all the rest!"])
            mixer.music.load("insomnia.mp3")
            if musicOn:
                mixer.music.play()
            sleep(.5)
            E = characterClass.Boss("Kilvath", 85 + (15 * P.getLevel()), 60, 100, "Soulkeeper")
            combat_loop(P, E)
            if E.getHP() <= 0:
                mixer.music.fadeout(6500)
                outro()

        elif checkSpot[0] not in nullChars:
            gameMap[P.getX()][P.getY()] = " "
            P.setX(P.getX() - 1)

    elif playerInput == "b'a'" and checkSpot[2] not in nullChars:
        gameMap[P.getX()][P.getY()] = " "
        P.setY(P.getY() - 1)

    elif playerInput == "b's'" and checkSpot[1] not in nullChars:
        gameMap[P.getX()][P.getY()] = " "
        P.setX(P.getX() + 1)

    elif playerInput == "b'd'" and checkSpot[3] not in nullChars:
        gameMap[P.getX()][P.getY()] = " "
        P.setY(P.getY() + 1)

    elif playerInput == "b'b'":
        P.checkInv()

    elif playerInput == "b'x'":
        music_switch()

    elif playerInput == "b'm'":
        display_map(P)

    elif playerInput == "b'p'":
        saveGame(P)

    elif playerInput == "b'\\x1b'":
        print("\n\n >> Thanks for playing!")
        sleep(2)
        quit()

    if P.getLoc() != 0 and P.getLoc() != 9 and not bossBattle and not P.didBattle:
        combat_check(P)

    P.didBattle = False
    sleep(.01)
Exemple #19
0
 def breakWep(self):
     from intro import slow_type
     self.__damage = 0
     slow_type(["\n\tYour {} broke!".format(self.getName())])
     self.setName("Broken " + self.getName())