예제 #1
0
 def showMoves(self):
     out.output("\nIndex: Move:           Raw Damage:")
     temp = 0
     for i in self.learnedMoves:
         temp += 1
         out.output(
             box.stringSolver(7, str(temp)) + box.stringSolver(15, i[0]) +
             " " + str(i[1]))
     del temp
예제 #2
0
def console():
    consolecont = 1
    while consolecont == 1:
        request = out.feed("Command me. ")
        #general executioner
        if ("exec" in request):
            execCode = request[5:len(request)]
            try:
                eval(execCode)
            except Exception as e:
                print("Try again: An error was raised in your statement:")
                print(e)

        #battle initialization
        elif ("rbattle init" in request
              ):  #battle init | your monster | enemy monster{specieID,level}
            try:
                request = request.split()
                #make the arguents that entertain the generated monster.
                request[3] = request[3].split(",")
                request[3] = list(request[3])
                #make an enemy monster using given arguments
                enemy = monster(0, int(request[3][0]))
                enemy.levelTo(int(request[3][1]))
                enemy.showDetails()
                #attempt a battle()
                #out.output (str(request[2]))
                execCode = ("battle(" + str(request[2]) + ", enemy , 0)")
                #out.output(execCode)
                exec(execCode)
                #battle(p1.monster1, enemy, 0)
            except Exception as e:
                print("Try again: An error was raised in your statement:")
                print(e)

                #makequickvar is a deprecated thing
                """
        elif ("makequickvar" in request[:14]):
            try:
                request = request.split()
                if not(request[2] in qms):
                    qms[str(request[2])] = getattr(__main__,request[1])
            except Exception as e:
                print("Try again: An error was raised in your statement:")
                print(e)
                """

        #exit
        elif (("quit" in request[:4]) or ("exit" in request[:4])
              or ("stop" in request[:4])):
            consolecont = 0
        else:
            out.output("Try again: Entered console command did not work.")
        #leveling up didn't work so now we have the beautiful and versatile exec.
        """elif ("level to" in request):
예제 #3
0
def xpAdder(
        m1,
        m2):  #does xp math comparing two monsters. m1 is the one gaining xp.
    if m1.level < m2.level:
        m1.xp += math.floor(m2.level * 1.35) * m1.level
    elif m1.level > m2.level:
        m1.xp += math.ceil(m2.level * (0.9 / (m1.level - m2.level)))
    elif m1.level == m2.level:
        m1.xp += math.ceil(m2.level * 1.25) * m1.level
    else:
        out.output("xp broken, pls fix daddy!")
예제 #4
0
    def __init__(self, nicked, givenSpecie):
        n = len(specienames) - 1
        #out.output (n)
        self.specie = random.randint(1, n)
        del n
        if (int(givenSpecie) != 0):
            self.specie = int(givenSpecie)
        self.xp = 0
        self.xpreq = 25
        self.level = 1
        self.speciename = specienames[self.specie]

        #naming conventions. On monster setup, you can do monster(1), 0, or "ask".
        #1 commands you to title your monster, 0 gives it no title, and "ask" asks the user.
        #I personally have the feeling that 1 will never be used, 0 will be for enemies, and
        #"ask" will be the most common, as it will be for every monster the user captures.
        if nicked == 1:
            out.output("You got a new monster with specie ID " +
                       str(self.specie) + ". It's a " + self.speciename + "!")
            self.nickname = box.nameFormatter(
                box.nameMaker(out.feed("Enter your monster's name. "), 15))
        elif nicked == "ask":
            littleTempString = (
                ("You got a new monster with specie ID " + str(self.specie) +
                 ". It's a " + self.speciename + "!\n") +
                "Do you wish to nickname your " + self.speciename + "? ")
            if ((out.feed(littleTempString)).lower() == "yes"):
                self.nickname = box.nameFormatter(
                    box.nameMaker(out.feed("Enter your monster's name. "), 15))
            else:
                self.nickname = self.speciename
            del littleTempString
        else:
            self.nickname = self.speciename

        self.health = 25
        self.maxhealth = 25
        self.defense = 1
        self.attack = 1
        self.potion = 1
        self.availableMoves = allAttacks[self.specie]
        self.learnedMoves = []

        for i in self.availableMoves:
            if i[2] <= self.level:
                self.learnedMoves.append(i)
        #out.output ("Monster's learned moves are:" + self.learnedMoves)    #this is a debugging command for moves
        #out.output ("Monster's available moves are:" + self.availableMoves)    #this is a debugging command for moves
        """
예제 #5
0
def attack(m1, move, m2):
    #example: attack(p1.monster1, 1-n, enemy1)

    #raw damage stat from moves list
    #My comments down there bugtest that everything was done globally. It works!! Thanks Python for being so lovely and intuitive!
    rawdmg = m1.learnedMoves[(move - 1)][1]
    #out.output ("rawdmg: " + str(rawdmg))
    moddedDmg = math.floor((rawdmg * m1.attack) * m2.defense)
    #out.output ("moddedDmg: " + str(moddedDmg))
    m2.health -= moddedDmg
    #m2.showBattleCard(1)
    out.output(m1.nickname + " used " + m1.learnedMoves[move - 1][0] +
               " for " + str(moddedDmg) + " damage!")
    if (m2.health < 0):
        m2.health = 0
예제 #6
0
 def showBattleCard(self, enemy):
     if enemy:
         out.output(
             "\n\n======================================\n        Enemy " +
             self.nickname + ":\n    " + str(self.health) + "/" +
             str(self.maxhealth) + "HP\n    lvl " + str(self.level) +
             "\n    " + str(self.xp) + "/" + str(self.xpreq) +
             "XP\n======================================")
     else:
         out.output("\n\n======================================\n        " +
                    p1.name + "\'s " + self.nickname + ":\n    " +
                    str(self.health) + "/" + str(self.maxhealth) +
                    "HP\n    lvl " + str(self.level) + "\n    " +
                    str(self.xp) + "/" + str(self.xpreq) +
                    "XP\n======================================")
예제 #7
0
def battle(m1, m2, pvp):
    if (pvp == 0):
        box.clearScreen()
        out.output(p1.name + "\'s " + m1.nickname + " is battling enemy " +
                   m2.nickname + "!")
        m1.showBattleCard(0)
        m2.showBattleCard(1)
        box.pause()
        box.clearScreen()
        while ((m1.health >= 1) and (m2.health >= 1)):
            m2.showBattleCard(1)
            m1.showBattleCard(0)
            m1.showMoves()
            if m1.health > 0:
                inp = out.feed("\nWhat will " + m1.nickname + " do?\n")
                again = 1
                while again == 1:
                    try:
                        int(inp)
                    except ValueError:
                        out.output("\nNumbers only!")
                        again = 1
                        inp = out.feed("Try again:\nWhat will " + m1.nickname +
                                       " do?\n")
                    except:
                        out.output(
                            "\nSomething went wrong with what you said!")
                        again = 1
                        inp = out.feed("Try again:\nWhat will " + m1.nickname +
                                       " do?\n")
                    else:
                        if (int(inp) > m1.howManyMoves()):
                            again = 1
                            out.output("\nNumber out of range!")
                            inp = out.feed("Try again:\nWhat will " +
                                           m1.nickname + " do?\n")
                        else:
                            again = 0
                            break

                attack(m1, int(inp), m2)
                del inp
                del again
            if m2.health > 0:
                attack(m2, random.randint(1, len(m2.learnedMoves)), m1)

            box.pause()
            box.clearScreen()

        if (m1.health > 0):
            xpAdder(m1, m2)
            m2.showBattleCard(1)
            m1.showBattleCard(0)
            out.output("You win!")

        elif (m2.health > 0):
            xpAdder(m2, m1)
            m2.showBattleCard(1)
            m1.showBattleCard(0)
            out.output("You lose!")
        else:
            out.output("You broke the game and should not see this message!")
예제 #8
0
 def help(self):
     out.output(
         "Vars:\n	name\n	inv\n	monster1\n	monster2\n	monster3\n\nFunctions:\n	showCard()"
     )
예제 #9
0
 def showCard(self):
     out.output("\n\n\n\n\n")
     out.output(
         "- - = . ~ .-=-=#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#=-=-. ~ . = - -")
     out.output("			" + self.name + "\'s Stats")
     out.output("")
     self.monster1.showDetails()
     out.output("")
     self.monster2.showDetails()
     out.output("")
     self.monster3.showDetails()
     out.output(
         "\n- - = . ~ .-=-=#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#=-=-. ~ . = - -"
     )
예제 #10
0
 def help(self):
     out.output(
         "Vars:\n	xp\n	xpreq\n	level\n	speciename\n	health\n	nickname\n	maxhealth\n	defense\n	attack\n	potion\n	availableMoves\n	learnedMoves\n\nFunctions:\n	rename()\n	levelUp()\n	howManyMoves()\n	showMoves()\n	showDetails()\n	levelTo(desired)\n	showBattleCard(enemy)"
     )
예제 #11
0
 def showDetails(self):
     out.output("            " + self.nickname + ":\n        Level " +
                str(self.level) + " " + self.speciename +
                "\n        with " + str(self.health) + "/" +
                str(self.maxhealth) + " HP\n        and " + str(self.xp) +
                "/" + str(self.xpreq) + " XP until next level.")