def end(self): if self.player.health > 0: output.declare("You have defeated " + self.monster.the + "!") self.monster.die() return False else: return True
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)
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)
def start(self): if self.gold == 0 and self.experience == 0 and len(self.items) == 0: return # Output the gold and experience first because the player might level up after adding the experience. if self.gold != 0: output.declare("You collect " + str(self.gold) + " gold.") output.declare("You collect " + str(self.experience) + " experience.") self.player.inventory.addGold(self.gold) self.player.addExperience(self.experience) if len(self.items) > 0: if not self.dropAll: self.dropItem(self.items.getOption()) else: allDrops = self.items.getAll() for i in allDrops: self.dropItem(i)
def start(self): self.initGame() while self.player.alive: try: self.player.act() self.player.interact() except Exception: output.bar() output.declare("! ERROR !") output.bar() output.bellow("Adventure has crashed. The program will quit after you answer this question. See Python traceback?") if input.yesNo(): traceback.print_exc() input.getInput("end") break input.close()
def activate(self): stats = self.player.stats.getStats() output.say("Which stat do you want to boost?") while True: stat = input.inputFromOptions( self.name, stats, lambda stat: stat.name + " by " + str( self.bonuses[stat.name] * stat.difficultyModifier) + ", currently at " + str(stat) + ".") output.say("Are you sure you want to boost " + str(stat.name) + " by " + str(self.bonuses[stat.name] * stat.difficultyModifier) + "?") if input.yesNo(): stat.add(self.bonuses[stat.name]) break if len(self.abilities) > 0 and self.player.level == self.abilities[0][ 2]: # check if level is correct output.exclaim("You learn a new ability: " + str(self.abilities[0][0]).upper() + "!") output.declare(self.abilities[0][1]) # ability description self.player.abilities.append(self.abilities[0][0]) self.abilities.pop(0)
def stabLogic(ablty, player, target): # stab deals 50% more damage if stealthed if player.states["stealth"]: ability.damage(ablty, player, target, 13, 17) else: ability.damage(ablty, player, target, 8, 12) # if the player coated their dagger with poison, apply it if player.states["daggerPoisoned"]: player.states["daggerPoisoned"] = False target.addEffect( effect.DamageOverTime("poison", duration=3, lowerBound=6, upperBound=9, caster=player)) # stab takes the player out of stealth exitStealth(player) # stab also has a chance (increased with dodge) to put the player in stealth if random.random() < 0.25 + player.stats.dodge.value: enterStealth(player) output.declare("Stab triggers stealth!")
def smiteLogic(ablty, player, target): ability.damage(ablty, player, target, 6, 10) generateHolyPower(player, 1) if random.random() < player.stats.criticalChance.getValue(): output.declare("Smite grants an additional holy power!") generateHolyPower(player, 1)
def start(self): self.monster.reset( ) # the same instance of the monster may have already been fought output.bar() output.declare("You have been attacked by " + self.monster.a + "!") output.bar()