def activate(self): output.proclaim(self.message) output.say("You have " + str(self.player.inventory.gold) + " gold.") while True: choice = input.inputFromOptions( "buy", ["leave", "sell"] + self.wares, self.itemString, self.itemValid, "Please buy an item you can afford.") if choice == "leave": break elif choice == "sell": self.sell() else: # Check whether the player can afford multiple of the item; if they can, offer buying more than one. canAfford = self.player.inventory.gold // choice.buyCost cost = choice.buyCost if canAfford < 2: self.player.inventory.addItem(copy.deepcopy(choice)) output.say("Purchased " + str(choice) + " for " + str(choice.buyCost) + " gold!") else: output.say( "How many do you want to buy? You can afford between 1 and " + str(canAfford) + ".") number = input.getInt("amount", 1, canAfford) numberedCopy = copy.deepcopy(choice) numberedCopy.number = number cost *= number self.player.inventory.addItem(numberedCopy) output.say("Purchased " + str(numberedCopy) + " for " + str(cost) + " gold!") self.player.inventory.removeGold(cost) output.say("Now you have " + str(self.player.inventory.gold) + " gold.")
def activate(self): output.proclaim("") output.say("-------------- Inventory --------------") output.proclaim("You have " + str(self.player.inventory.gold) + " gold.\n") output.outputList(self.player.inventory.items, lambda i: str(i) + ": " + str(i.description)) output.say("---------------------------------------")
def activate(self): output.proclaim(self.message) if len(self.locations) > 1: choice = input.inputFromOptions("go", ["stay"] + self.locations) if choice != "stay": self.player.changeLocation(choice) else: if input.yesNo(): self.player.changeLocation(self.locations[0])
def enter(): sequel = "" if monsters[0].canRespawn(): # if Aricnea is alive... sequel = "A faint light glows in distance. A huge skeleton turns to face you." else: # if Aricnea is dead... sequel = "Aricnea's bones lie untouched, scattered across the floor." output.proclaim( "Damp Lair: Cave moss grows on the arched ceiling of the cavern. " + sequel)
def activate(self): output.proclaim( "You are level " + str(self.player.level) + "" + (" with " + str(self.player.experience) + "/" + str(self.player.levelUpExperience[self.player.level - 1]) + " experience." if self.player.level < self.player.maxLevel else ", maximum level.")) output.say("---------------- Stats ----------------") output.say(str(self.player.stats)) output.say("---------------------------------------")
def attack(self, target): if self.health > 0: self.abilities.getOption( lambda ability: not ability.onCooldown()).activate( self, target) elif self.size > 1: self.size -= 1 self.stats.health.value /= 2 self.health = self.stats.health.getValue() output.proclaim( "The unholy ooze sheds a layer of goo and rises again!")
def levelUp(self): self.experience -= self.levelUpExperience[self.level - 1] self.level += 1 output.proclaim("A gentle wind restores your health.") output.say("You leveled up to level " + str(self.level) + "!" + (" You need " + str(self.levelUpExperience[self.level - 1]) + " experience to level up again." if self.level < self.maxLevel else "")) self.levelBonus.activate() self.health = self.stats.health.getValue()
def activate(self): output.say("Toggle any of the following settings.") while True: option = input.inputFromOptions( "option", ["back"] + list(self.player.settings), lambda setting: setting if setting == "back" else str( setting) + " = " + str(self.player.settings[setting])) if option == "back": break self.player.settings[option] = not self.player.settings[option] output.proclaim( str(option).capitalize() + " toggled to " + str(self.player.settings[option]) + ".")
def activate(self): output.proclaim("-- " + self.name + " --") if self.autoGive: self.given = True if not self.given: output.proclaim(self.openerText) while True: choice = input.inputFromOptions("quest", ["decline", "accept"]) if choice == "accept": self.given = True break elif choice == "decline": output.say("Are you sure you want to decline the quest?") if input.yesNo(): break return player = globals.get_player() if self.completionCheck(player): output.proclaim(self.completeText) output.exclaim("You have completed the quest " + self.name + "!") self.rewards.activate() self.condition = lambda player: False player.completedQuests[self.name] = True else: output.proclaim(self.incompleteText)
def activate(self): output.proclaim(self.greeting) if len(self.locations) == 0: return output.say("You have " + str(self.player.inventory.gold) + " gold.") location = input.inputFromOptions( self.name, self.locations, lambda location: self.locationToString(location[0], location[1]), lambda location: self.player.inventory.gold >= location[1], "Please select an option that you can afford.") if location[0].name != self.player.location.name: # If the player chooses to travel to a new location, move them and charge them. self.player.inventory.removeGold(location[1]) self.player.changeLocation(location[0])
def init(self): # THREE STEPS: class, difficulty, mode # initialize player's class (e.g. mage) output.say("What class do you want to play?") class_name = input.inputFromOptions("class", classes.get_classes()) # base stats self.stats = classes.get_stats(class_name) # abilities for level 1 self.abilities = self.abilities + classes.get_abilities(class_name) # abilities for higher levels self.levelBonus.abilities = classes.get_levelBonus(class_name) # extra states (i.e. stealth or mana) self.states = classes.get_states(class_name) # extra inspect (i.e. "Stealthed" or "Mana 100/100") self.classInspect = classes.get_classInspect(class_name) # update at the end of each turn (i.e. set stealth to false or regen mana) self.classUpdate = classes.get_classUpdate(class_name) # update at the end of each turn of combat (i.e. regen mana for mage) self.combatUpdate = classes.get_combatUpdate(class_name) # get difficulty before outputting class info output.proclaim("What difficulty level do you want?") difficulty = input.inputFromOptions( "difficulty", ["easy", "normal", "hard", "expert", "master", "torment"], debug=True) if difficulty == "debug": self.debug() output.bellow("GOD MODE ENABLED.") output.say("What difficulty level do you want?") difficulty = input.inputFromOptions( "difficulty", ["easy", "normal", "hard", "expert", "master", "torment"]) modifier = { "easy": 1.2, "normal": 1.0, "hard": 0.9, "expert": 0.8, "master": 0.7, "torment": 0.6 }[difficulty] self.stats.health.difficultyModifier = modifier self.stats.strength.difficultyModifier = modifier self.stats.armor.difficultyModifier = modifier self.health = self.stats.health.getValue() # output class information output.proclaim(classes.get_classIntro(class_name))
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.")
def activate(self): output.proclaim(self.name + ":") output.say(self.opener) quests = self.getQuests() if len(quests) == 0: return output.proclaim("Quests:") choice = input.inputFromOptions( "quest", ["back"] + quests, lambda quest: quest if quest == "back" else str(quest.getName())) if choice == "back": return choice.activate()
def enter(): output.proclaim( "Trainee Valley: Sparse trees occupy rolling expanses of lush grass. Fort Morning is barely visible in the distant north, while the Silent Forest looms to the east." )
def exit(): output.proclaim("You have left Damp Lair.")
def enter(): output.proclaim( "Fort Morning: Rough cobblestones pattern the streets of Fort Morning. The din of the market carries loudly to the Southern gate, whose wall protrudes ten feet from the earth below. Merchants frequent the fort, but the eastern wizards rarely visit." )
def exit(): output.proclaim("You have left Skeleton Cave.")
def enter(): output.proclaim( "Skeleton Cave: The stone walls smell of rotted flesh. Something here chafes with life." )
def exit(): output.proclaim("You have left the Silent Forest.")
def enter(): output.proclaim( "The Silent Forest: Great oaks sway endlessly to the southerly winds. The air's oppression is lifted but briefly at the occasional rustle. Trees obscure the view to Trainee Valley." )
def exit(): output.proclaim("You have left the Fort Morning.")
def exit(): output.proclaim("You have left Trainee Valley.")
def start(self): output.proclaim("You stumble upon " + self.mysteryWords.getOption() + " " + self.shrineAdjectives.getOption() + " " + self.shrineNouns.getOption() + " near " + self.nearWords.getOption() + ".") self.use()