Beispiel #1
0
def heal(ability, caster, target, lowerBound, upperBound):
    amount = caster.recoverHealth(lowerBound + random() *
                                  (upperBound - lowerBound))
    output.say("You restore " + output.formatNumber(amount) +
               " health to yourself with " + ability.name +
               "." if caster.isPlayer else caster.the.capitalize() +
               " restores " + output.formatNumber(amount) +
               " health to itself with " + ability.name + ".")
Beispiel #2
0
def damage(ability, caster, target, lowerBound, upperBound):
    amount = caster.dealDamage(
        target, lowerBound + random() * (upperBound - lowerBound))
    if amount != 0:  # the enemy can dodge
        output.say("You deal " + output.formatNumber(amount) + " damage to " +
                   target.the + " with " + ability.name +
                   "!" if caster.isPlayer else "The " + str(caster) +
                   " does " + output.formatNumber(amount) +
                   " damage to you with " + ability.name + "!")
Beispiel #3
0
 def activate(self):
     amount = self.player.recoverHealth(
         randint(self.lowerBound, self.upperBound))
     if self.player.health == self.player.stats.health.getValue():
         output.declare("You are at full health after resting!")
     else:
         output.declare("You recover " + output.formatNumber(amount) +
                        " health from resting. You now have " +
                        output.formatNumber(self.player.health) + "/" +
                        str(self.player.stats.health.getValue()) +
                        " health.")
     # check player setting: auto-rest
     if self.player.settings["auto-rest"]:
         if self.player.health < self.player.stats.health.getValue():
             self.player.attemptAutoAct(self)
Beispiel #4
0
 def drink(self, target):
     target.health += self.amount  # bypass armor because steel can't stop potions
     if target.health > target.stats.health.getValue():
         target.health = target.stats.health.getValue()
     if self.amount > 0:
         output.proclaim("The " + str(target) + " recovers " +
                         str(self.amount) + " health after using " +
                         self.name + ". You now have " +
                         output.formatNumber(target.health) + "/" +
                         str(target.stats.health.getValue()) + " health.")
     elif self.amount < 0:
         output.proclaim("The " + str(target) + " is drained " +
                         str(self.amount) + " health after using " +
                         self.name + ". You now have " +
                         output.formatNumber(target.health) + "/" +
                         str(target.stats.health.getValue()) + " health.")
Beispiel #5
0
 def activate(self):
     amount = randint(self.lowerBound, self.upperBound)
     self.player.inventory.addGold(amount)
     if amount == 0:
         output.declare("You find nothing while scavenging.")
     else:
         output.declare("You find " + output.formatNumber(amount) +
                        " gold while scavenging.")
     # check player setting: auto-scavenge
     if self.player.settings["auto-scavenge"]:
         self.player.attemptAutoAct(self)
Beispiel #6
0
 def addBonus(self):
     stats = self.player.stats.getStats()
     output.say("Which stat do you want to boost for " +
                str(self.duration) + " turns?")
     while True:
         stat = input.inputFromOptions(
             "shrine", stats,
             lambda stat: stat.name + " by " + output.formatNumber(
                 self.amounts[stats.index(stat)] * stat.difficultyModifier)
             + ", currently at " + str(stat) + ".")
         index = stats.index(stat)
         output.say("Are you sure you want to boost " + stat.name + " by " +
                    output.formatNumber(self.amounts[index] *
                                        stat.difficultyModifier) + " for " +
                    str(self.duration) + " turns?")
         if input.yesNo():
             self.player.addEffect(self.buffs[index](
                 "shrine bonus", self.duration,
                 self.amounts[index] * stat.difficultyModifier))
             return
Beispiel #7
0
    def __init__(self, name, description, sellCost, buyCost, stats, category,
                 proc):
        item.UsableItem.__init__(self, name, description, sellCost, buyCost,
                                 lambda creature: creature.gear.equip(self))
        self.stats = stats
        self.category = category  # type of equipment
        self.proc = proc  # optional function that triggers special functionality (takes the wearer and the target)

        # add stats to the description (sorted alphabetically by stat name)
        for stat, value in sorted(self.stats.items(), key=lambda x: x[0]):
            self.description += "\n\t" + stat + (
                " +" if value > 0 else " -") + output.formatNumber(value, 2)
Beispiel #8
0
 def __init__(self,
              name,
              duration,
              lowerBound,
              upperBound,
              stackable=False,
              notify=True):
     Effect.__init__(
         self, name, duration, lambda target: None, lambda target: None,
         lambda target: output.say(target.the.capitalize(
         ) + " recovers " + output.formatNumber(
             target.recoverHealth(lowerBound + random() *
                                  (upperBound - lowerBound))
         ) + " health from " + self.name + "."), stackable, notify)
     self.lowerBound = lowerBound
     self.upperBound = upperBound
Beispiel #9
0
 def __init__(self,
              name,
              duration,
              lowerBound,
              upperBound,
              caster,
              stackable=False,
              notify=True):
     Effect.__init__(
         self, name, duration, lambda target: None, lambda target: None,
         lambda target: output.say(target.the.capitalize(
         ) + " takes " + output.formatNumber(
             caster.dealDamage(target,
                               lowerBound + random() *
                               (upperBound - lowerBound),
                               dodgeable=False)) + " damage from " + self.
                                   name + "."), stackable, notify)
     self.lowerBound = lowerBound
     self.upperBound = upperBound
Beispiel #10
0
def mageInspect(player):
    return "Mana " + output.formatNumber(player.states["mana"]) + "/100"
Beispiel #11
0
 def stingProc(wearer, target):
     if random.random() < 0.05:
         amount = wearer.dealDamage(target, 4 + random.random() * 6)
         output.say("Dark tendrils burst from Sting, crushing " +
                    target.the + " and dealing " +
                    output.formatNumber(amount) + " damage to it.")
Beispiel #12
0
 def __str__(self):
     # use two decimals of precision for stats
     return output.formatNumber( ( (self.value + self.base + self.addition) * self.multiplication - self.base) * self.difficultyModifier, 2 )
Beispiel #13
0
 def startNotification(self, target):
     return self.name.capitalize(
     ) + ": " + target.the + "'s armor is " + self.verb + " by " + output.formatNumber(
         abs(100 * self.amount)) + "% for " + str(self.duration) + " turns."
Beispiel #14
0
 def startNotification(self, target):
     return self.name.capitalize(
     ) + ": " + target.the + " will take between " + output.formatNumber(
         abs(self.lowerBound)) + " and " + output.formatNumber(
             abs(self.upperBound)) + " base damage for " + str(
                 self.duration) + " turns."
Beispiel #15
0
 def inspect(self):
     return ("" if self.unique else "The " ) + self.name + " has " + output.formatNumber(self.health) + "/" + str(self.stats.health) + " health."
Beispiel #16
0
 def percent(self):
     return output.formatNumber( ( (self.value + self.base + self.addition) * self.multiplication - self.base ) * 100 * self.difficultyModifier)
Beispiel #17
0
 def inspect(self):
     extra = self.classInspect(self)
     return "You have " + output.formatNumber(self.health) + "/" + str(
         self.stats.health) + " health." + (" -- " + extra.upper() +
                                            " --" if len(extra) > 0 else "")
Beispiel #18
0
 def startNotification(self, target):
     return self.name.capitalize(
     ) + ": " + target.the + "'s critical hit damage is " + self.verb + " by " + output.formatNumber(
         abs(self.amount)) + " for " + str(self.duration) + " turns."