コード例 #1
0
 def Take(self, counter):
     damage = index.player.attack
     crit = index.player.Crit()
     if crit != 1:
         printing.PrintHitByPlayerCrit("Critical! 2x damage!")
         damage = damage * crit
     if counter:
         damage = damage * 2
         printing.PrintHitByPlayer(self.name +  " tries to attack but " + index.player.name + " counters " + self.name + " for " + str(damage))
     else:
         printing.PrintHitByPlayer(index.player.name + self.flavour[random.randint(0,len(self.flavour) - 1)] + self.name + " for " + str(damage))
     self.health = self.health - damage
コード例 #2
0
ファイル: fight.py プロジェクト: mrmelonson/small-forest
def Fight(name, health, damage, player):
    enemy = enemypg.Enemy(name, health, damage)

    printing.Print("A wild " + enemy.name + " has appeared!")

    while enemy.health > 0:
        choice = ''

        printing.PrintHitByPlayer("Your health is " + str(player.health))
        printing.PrintHitByEnemy(enemy.name + "'s health is " +
                                 str(enemy.health))

        printing.PrintOpt("Attack")
        printing.PrintOpt("Counter")
        printing.PrintOpt("Run")

        choice = input().lower()

        if choice == "attack":
            enemy.Take(player, False)
            enemy.Deal(player, False)
        elif choice == "counter":
            enemy.Deal(player, True)
        elif choice == "run":
            printing.Print("You try to make a break for it...")
            if CanRun():
                Run(player)
            else:
                printing.Print("The " + enemy.name + " catches up to you")
                enemy.Deal(player, False)
        else:
            printing.Print("You stumble giving the " + enemy.name +
                           " a chance to attack")
            enemy.Deal(player, False)
    printing.Print("You defeated the " + enemy.name)
    printing.Print("Some coins appear infront of you")
    printing.Print("You pick them up")
    player.AddToInv("gold coin", random.randint(3, 6))
コード例 #3
0
def Fight(name, health, damage):
    enemy = enemypg.Enemy(name, health, damage)

    printing.Print("A wild " + enemy.name + " has appeared!")

    while enemy.health > 0:
        choice = ''

        printing.PrintHitByPlayer("Your health is " + str(index.player.health))
        printing.PrintHitByEnemy(enemy.name + "'s health is " +
                                 str(enemy.health))

        printing.PrintOpt("Attack")
        printing.PrintOpt("Counter")
        printing.PrintOpt("Run")

        choice = input().lower()

        if choice == "attack":
            enemy.Take(False)
            enemy.Deal(False)
        elif choice == "counter":
            enemy.Deal(True)
        elif choice == "run":
            printing.Print("You try to make a break for it...")
            if CanRun():
                Run()
            else:
                printing.Print("The " + enemy.name + " catches up to you")
                enemy.Deal(False)
        else:
            printing.Print("You stumble giving the " + enemy.name +
                           " a chance to attack")
            enemy.Deal(False)
    printing.Print("You defeated the " + enemy.name)
    explore.Idle()
コード例 #4
0
 def Heal(self, amount):
     oldhealth = self.health
     self.health += amount
     if self.health > self.maxhealth:
         self.health = self.maxhealth
     printing.PrintHitByPlayer("You healed " + str(self.health - oldhealth) + " health")
コード例 #5
0
 def PrintStatus(self):
     printing.PrintHitByPlayer("Your health is " + str(self.health)) 
     printing.PrintHitByPlayer("Your attack is " + str(self.attack + self.weapons[self.equipped]))
     printing.PrintHitByPlayer("Your equiped weapon is " + str(self.equipped))