Exemplo n.º 1
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
        """
Exemplo n.º 2
0
    def __init__(self):
        self.name = box.nameFormatter(
            box.nameMaker((out.feed("What is your name? ")), 10))

        self.inv = ["null"]
        self.monster1 = monster("ask", 0)
        self.monster2 = monster("ask", 0)
        self.monster3 = monster("ask", 0)
Exemplo n.º 3
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):
Exemplo n.º 4
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!")
Exemplo n.º 5
0
 def rename(self):
     self.nickname = out.feed("Enter " + self.nickname + "'s new name.")