Beispiel #1
0
 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.")
Beispiel #2
0
 def voodooFetishProc(wearer, target):
     if random.random() < 0.05:
         output.say(
             wearer.the.capitalize() +
             "'s voodoo fetish begins wailing softly, disorienting " +
             target.the + ".")
         target.addEffect(effect.StrengthBuff("voodoo stun", 2, -0.2))
Beispiel #3
0
    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)
Beispiel #4
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 #5
0
 def tick(self):
     output.say(self.player.inspect())
     output.say(self.monster.inspect())
     self.player.attack(self.monster)
     self.monster.attack(self.player)
     self.player.update()
     self.monster.update()
     output.separate()
Beispiel #6
0
 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("---------------------------------------")
Beispiel #7
0
def getInt(prompt, lowerBound, upperBound):
    choice = getInput(prompt)
    while not isInt(
            choice) or int(choice) < lowerBound or int(choice) > upperBound:
        output.say("Please enter an integer between 1 and " + str(upperBound) +
                   ".")
        choice = getInput(prompt)
    return int(choice)
Beispiel #8
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 #9
0
def yesNo():
    while True:
        choice = getInput("yes/no").lower()
        if choice == "yes" or choice == "y":
            return True
        elif choice == "no" or choice == "n":
            return False
        else:
            output.say("Please enter yes or no.")
Beispiel #10
0
 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()
Beispiel #11
0
 def mutterNonsense(self):
     vocabulary = [
         "fizzle", "crack", "wow", "water", "fun", "bam", "shahoo",
         "wapwalee", "pow", "rats", "netter", "crab", "mast", "crazy",
         "polar", "braid", "blubber", "dollop", "doozy", "finagle",
         "gargoyle", "giggle", "shenanigans", "squabble", "wipee"
     ]
     gibberish = []
     for i in range(6):
         gibberish.append(random.choice(vocabulary))
     output.say("Graglis the Gremlin bursts out into gleeful nonsense: " +
                ' '.join(gibberish).capitalize() + "!")
Beispiel #12
0
 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]) + ".")
Beispiel #13
0
 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])
Beispiel #14
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))
Beispiel #15
0
 def update(self, target):
     if self.ticked:
         return
     if self.count == 0:
         self.start(target)
         if self.notify:
             output.say(self.startNotification(target))
     elif self.count >= self.duration:
         self.end(target)
         target.effects.remove(self)
         if self.notify:
             output.say(self.endNotification(target))
         return
     self.tick(target)
     self.ticked = True
     self.count = self.count + 1
Beispiel #16
0
    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()
Beispiel #17
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 #18
0
def inputFromOptions(prompt,
                     options,
                     mapOption=lambda option: str(option),
                     condition=lambda option: True,
                     warning="",
                     debug=False):
    if len(options) == 0:
        return None
    output.outputList(options, mapOption)
    choice = getInput(prompt)
    while not isInt(choice) or int(choice) > len(options) or int(
            choice) < 1 or not condition(options[int(choice) - 1]):
        if debug and choice == "debug":
            return "debug"
        if not isInt(choice) or int(choice) > len(options) or int(choice) < 1:
            output.say("Please enter an integer between 1 and " +
                       str(len(options)) + ".")
        else:
            output.say(warning)
        choice = getInput(prompt)
    return options[int(choice) - 1]
Beispiel #19
0
 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)
Beispiel #20
0
 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("---------------------------------------")
Beispiel #21
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 #22
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 #23
0
 def sell(self):
     if len(self.player.inventory.items) == 0:
         output.say("You don't have anything you can sell.")
         return
     while True:
         output.say("What do you want to sell? You have " +
                    str(self.player.inventory.gold) + " gold.")
         choice = input.inputFromOptions(
             "sell", ["back"] + self.player.inventory.items,
             lambda choice: "sell " + str(choice) + " for " + str(
                 choice.sellCost) + " gold" + (" each"
                                               if choice.number > 1 else "")
             if isinstance(choice, item.Item) else str(choice))
         if choice == "back":
             break
         if choice.number == 1:
             self.player.inventory.removeItem(choice)
             self.player.inventory.addGold(choice.sellCost)
         else:
             output.say("How many do you want to sell?")
             number = input.getInt("amount", 1, choice.number)
             self.player.inventory.removeItem(choice, number)
             self.player.inventory.addGold(choice.sellCost * number)
Beispiel #24
0
 def voodoo(self):
     output.say(
         "Graglis begins to dance frantically, screaming gibberish all the while. Black mist forms reptilian strands in the air."
     )
     self.addEffect(effect.StrengthBuffAdd("voodoo ritual", 6, 8))
Beispiel #25
0
 def poisonLogic(ablty, player, target):
     # poison can only be cast when stealthed
     exitStealth(player)
     player.states["daggerPoisoned"] = True
     output.say("You coat your dagger in poison.")
Beispiel #26
0
 def evocateLogic(ablty, player, target):
     player.states["mana"] = 100
     output.say("You evocate to refill your mana.")
Beispiel #27
0
 def stumble(self):
     output.say(
         "The drunken trainee stumbles and attempts to regain balance.")
Beispiel #28
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 #29
0
 def activate(self):
     output.say("Are you sure you want to quit?")
     if input.yesNo():
         self.player.alive = False
         output.bellow("Thank you for playing!")