Example #1
0
    def combat(self):
        """
        The main loop for combat. Handles updating HP/AP bars, updating the actual AP stats,
        checking for buffered player input and checking for death. Terminates combat upon death.
        :return: None
        """
        self.win.addstr((self.screenY - 13), 1, "Prepare to face the {}!".format(self.mob.name).ljust(self.screenX - 2))
        self.printAllBars()
        self.win.refresh()
        while self.player.currentHP > 0 and self.mob.currentHP > 0:
            while self.player.ap < 100 and self.mob.ap < 100:
                self.player.ap += self.player.agi
                self.mob.ap += self.mob.agi
                self.barPrint(self.player, self.APbar)
                self.barPrint(self.mob, self.mobAPbar)
                sleep(.5)

            if self.player.ap >= 100 and self.mob.ap < 100:
                text = self.actionCheck()
            elif self.mob.ap >= 100 and self.player.ap < 100:
                text = skills.attack(self.mob, self.player)
            elif self.player.ap >= 100 and self.mob.ap >= 100:
                if self.player.agi > self.mob.agi:
                    text = self.actionCheck()
                elif self.player.agi < self.mob.agi:
                    text = skills.attack(self.mob, self.player)
                else:
                    if mechanics.roll(2) == 1:
                        text = self.actionCheck()
                    else:
                        text = skills.attack(self.mob, self.player)
            self.printAllBars()
            self.printWin(text)

        if self.mob.currentHP <= 0:
            text = self.mob.defeat(self.room)
            for t in text:
                self.printWin(t)
            self.player.ap = 0
            self.running = False
            sleep(2)
            self.cleanUp()
        elif self.player.currentHP <= 0:
            self.printWin("You have been defeated by the {}!".format(self.mob.name))
            self.running = False
            sleep(2)
            self.cleanUp()
Example #2
0
 def runCommand(self):
     commandFull = self.inputBuffer.pop(0)
     parts = commandFull.lower().split(" ")
     command = parts[0]
     args = parts[1:]
     self.print_buffer()
 
     if command in ("a", "attack"):
         return skills.attack(self.player, self.mob)
     elif command in ("k", "kick"):
         return skills.kick(self.player, self.mob)
Example #3
0
 def actionCheck(self):
     if len(self.inputBuffer) > 0:
         return self.runCommand()
     elif len(self.inputBuffer) < 1:
         return skills.attack(self.player, self.mob)