예제 #1
0
 async def setup(self, characters, type, pvpBoss=''):
     global ENCOUTNERS
     ENCOUNTERS.append(self)
     for character in characters:
         self.characters.append(character)
         self.players.append(character)
         character.state = State.ENCOUNTER
         character.team = 1
         character.lastmessage = ''
     if type == EncType.NORMAL:
         enemy = self.players[0].location.loadEnemy()
         self.characters.append(enemy)
         self.enemy = enemy
     elif type == EncType.BOSS:
         enemy = self.players[0].location.loadBoss()
         self.characters.append(enemy)
         self.enemy = enemy
     elif type == EncType.RAID:
         enemy = copy.deepcopy(MONSTER[pvpBoss])
         self.characters.append(enemy)
         self.enemy = enemy
     for character in self.characters:
         character.energy = 0
     self.characters.sort(key=sortEncounterList, reverse=True)
     if type != EncType.PVP:
         await asyncio.sleep(1)
         for player in self.players:
             await idchat(player.id, ("%s\nYou have encountered %s!" %
                                      (enemy.opening, enemy.name)))
     else:
         await idchat(player.id,
                      "You are dueling %s!" % (bold(self.players[1].name)))
         await idchat(player.id,
                      "You are dueling %s!" % (bold(self.players[0].name)))
     await self.loop()
예제 #2
0
 async def useItemBattle(self, enc, player, target, players, escape):
     if self.battleitem is False:
         await idchat(self.id, "You can't use %s in this way." % (bold(self.name)))
     else:
         for p in players:
             if p.name == player.name:
                 await idchat(player.id, ("You use %s!" % (bold(self.name))))
                 await idchat(player.id, "%s" % (self.usedtext))
             else:
                 await idchat(player.id, "%s used %s!" % (player.name, bold(self.name)))
         player.energy -= self.energyuse
         player.life = min(player.life + ceil(player.get('maxlife') * (self.curelife / 100)), player.get('maxlife'))
         player.focus = min(player.focus + ceil(player.get('maxfocus') * (self.curefocus / 100)), player.get('maxfocus'))
         player.mana = min(player.mana + ceil(player.get('maxmana') * (self.curemana / 100)), player.get('maxmana'))
         if self.curestatus == 0:
             await player.clearStatusEffects()
         elif self.curestatus != -1:
             i = 0
             for status in player.status:
                 i += 1
                 if i == self.curestatus:
                     player.status[status] = False
         for stat in player.statchange:
             player.statchange[stat] += self.buff[stat]
         await enc.evaluateStatus(target, self.statusinflict, self.statuschance)
         player.inventory.remove(self)
         if self.name == 'Flask of Shadows':
             await idchat(self.id, "You escape!")
             player.runaway += 1
             player.lastmessage = ''
             return True
예제 #3
0
 async def discarditem(self, itemname):
     if itemname not in ITEM:
         await idchat(self.id, "'%s' does not exist!" % itemname)
     elif ITEM[itemname] in self.inventory:
         self.inventory.remove(ITEM[itemname])
         await idchat(self.id, "You discard %s." % (bold(itemname)))
     elif itemname in [self.weapon.name, self.shield.name, self.armor.name, self.charm.name]:
         await idchat(self.id, "You can't discard something you have equipped!")
     else:
         await idchat(self.id, "You don't have %s!" % (bold(itemname)))
예제 #4
0
 async def useSkill(self, player):
     await idchat(player.id, ("You use %s!" % (bold(self.name))))
     await idchat(player.id, ("%s!" % (self.usedtext)))
     player.life = min(player.life + ceil(player.get('maxlife') * (self.curelife / 100)), player.get('maxlife'))
     player.focus = min(player.focus + ceil(player.get('maxfocus') * (self.curefocus / 100)), player.get('maxfocus'))
     player.mana = min(player.mana + ceil(player.get('maxmana') * (self.curemana / 100)), player.get('maxmana'))
     player.save()
예제 #5
0
def tackle_number(length):
    os.system('clear')
    task = ''.join(random.choice(string.digits) for i in range(length))
    print(task, bold('← type this'), '(⌃C to quit)')
    entry = ''
    while task != entry:
        entry = input()
예제 #6
0
 async def useItem(self, player):
     for item in player.inventory:
         if item.name == self.name:
             player.inventory.remove(item)
             break
     await idchat(player.id, ("You use %s!" % (bold(self.name))))
     await idchat(player.id, ("%s!" % (self.usedtext)))
     player.life = min(player.life + ceil(player.get('maxlife') * (self.curelife / 100)), player.get('maxlife'))
     player.focus = min(player.focus + ceil(player.get('maxfocus') * (self.curefocus / 100)), player.get('maxfocus'))
     player.mana = min(player.mana + ceil(player.get('maxmana') * (self.curemana / 100)), player.get('maxmana'))
예제 #7
0
 async def travel(self, location):
     if location == self.location.name:
         await idchat(self.id, "You are already here!")
     else:
         await idchat(self.id, "You traveled to %s! %s" % (bold(location), LOCATION[location].traveltext))
         self.encountersinsamearea = 0
         self.location = LOCATION[location]
         self.life = self.maxlife + self.statchange['maxlife']
         if self.location.name in townlocationlist:
             self.lasttown = self.location.name
         await self.save()
예제 #8
0
 async def drops(self, droplist):
     self.state = State.NORMAL
     for item in droplist:
         if randint(1, 100) <= (droplist[item] + (100 - droplist[item]) * (0.01 * self.encountersinsamearea) + (self.luck / 15)):
             await idchat(self.id, ("You find %s!" % (bold(item))))
             self.tempslot.append(ITEM[item])
             if await self.checkinventoryslots() > 0:
                 self.inventory.insert(0, ITEM[item])
                 await idchat(self.id, ("You take %s!" % (bold(item))))
             else:
                 await idchat(self.id, ("You forfeit %s." % (bold(item))))
             self.tempslot.remove(ITEM[item])
     if self.life > (self.maxlife + self.statchange['maxlife']) * .75:
         await idchat(self.id, ("With a feeling of triumph, you press on."))
     elif self.life > (self.maxlife + self.statchange['maxlife']) * .5:
         await idchat(self.id, ("Wounded, but not discouraged, you press on."))
     elif self.life > (self.maxlife + self.statchange['maxlife']) * .25:
         await idchat(self.id, ("After the trying conflict, you pick yourself up and press on."))
     else:
         await idchat(self.id, ("Holding on by a thread, you drag yourself to your feet and press on."))
     await self.save()
예제 #9
0
 async def levelUp(self, droplist):
     while self.exp >= self.level ** 2:
         await asyncio.sleep(.25)
         self.exp -= self.level ** 2
         self.level += 1
         await idchat(self.id, "You hit level %s! You gain 5 Potential and 10 Life!" % (self.level))
         await rpgChat("%s hit level %s!" % (bold(self.name), self.level))
         self.potential += 5
         self.maxlife += 10
         self.life += 10
         if randint(1, 100) < self.luck:
             await idchat(self.id, "What luck! You gain 1 extra Potential!")
             self.potential += 1
     await self.drops(droplist)
예제 #10
0
 async def useTechBattle(self, player, chars, players, message, target, escape):
     if self.battle is False:
         await idchat(self.id, "You can't use %s in this way." % (bold(self.name)))
     else:
         for p in players:
             if p.name == player.name:
                 await idchat(player.id, ("You use %s!" % (bold(self.name))))
             else:
                 await idchat(player.id, "%s used %s!" % (player.name, bold(self.name)))
         player.energy -= self.energyuse
         player.life = min(player.life + ceil(player.get('maxlife') * (self.curelife / 100)), player.get('maxlife'))
         player.focus = min(player.focus + ceil(player.get('maxfocus') * (self.curefocus / 100)), player.get('maxfocus'))
         player.mana = min(player.mana + ceil(player.get('maxmana') * (self.curemana / 100)), player.get('maxmana'))
         if self.curestatus == 0:
             await self.clearStatusEffects()
             await self.clearStatChanges()
         for stat in player.statchange:
             player.statchange[stat] += self.buff[stat]
         await target.evaluateStatus(player, message, self.statusinflict, self.statuschance)
         if self.name == 'ESCAPE SKILL/SPELL':
             await idchat(self.id, "You escape!")
             player.runaway += 1
             player.lastmessage = ''
             return True
예제 #11
0
 async def equipitem(self, itemname):
     if self.state == State.ENCOUNTER:
         await idchat(self.id, "You don't have time for that!")
     else:
         if itemname not in ITEM:
             await idchat(self.id, "'%s' does not exist!" % itemname)
             return
         elif ITEM[itemname] in self.inventory:
             item = ITEM[itemname]
             if item.typeof == 'Weapons':
                 self.inventory.remove(item)
                 self.inventory.insert(0, self.weapon)
                 self.weapon = item
                 await idchat(self.id, ("You equip %s" % (bold(itemname))))
                 return
             elif item.typeof == 'Armor':
                 self.inventory.remove(item)
                 self.inventory.insert(0, self.armor)
                 self.armor = item
                 await idchat(self.id, ("You equip %s" % (bold(itemname))))
                 return
             elif item.typeof == 'Shields':
                 self.inventory.remove(item)
                 self.inventory.insert(0, self.shield)
                 self.shield = item
                 await idchat(self.id, ("You equip %s" % (bold(itemname))))
                 return
             elif item.typeof == 'Charms':
                 self.inventory.remove(item)
                 self.inventory.insert(0, self.charm)
                 self.charm = item
                 await idchat(self.id, ("You equip %s" % (bold(itemname))))
                 return
             else:
                 await idchat(self.id, ("%s cannot be equipped!" % (bold(itemname))))
         await idchat(self.id, ("You don't have %s!" % (bold(itemname))))
예제 #12
0
 async def playerTurn(self, player, target, escape):
     # commands = ['-fight', '-attack', '-check', '-use', '-escape']
     # notFound = True
     if player.lastmessage == '-fight' or player.lastmessage == '-attack':
         await self.damageRoll(player, target)
         player.energy -= player.weapon.energyuse
         if player.energy >= 1000 and target.life > 0:
             await idchat(player.id,
                          ("You still have %s energy!" % (player.energy)))
         player.lastmessage = ''
         player.chargecount = 1
     elif player.lastmessage == '-check':
         for player in self.players:
             if player.name == player.name:
                 await idchat(
                     player.id,
                     blockify((
                         "%s\n Life: %s\n Will: %s\nPower: %s\nGuard: %s\nSpeed: %s\n Luck: %s\n%s"
                         % (unbold(target.name), target.life,
                            (target.will + target.statchange['will']),
                            (target.power + target.statchange['power']),
                            (target.guard + target.statchange['guard']),
                            (target.speed + target.statchange['speed']),
                            (target.luck + target.statchange['luck']),
                            target.description))))
             elif player.name == target.name:
                 await idchat(player.id,
                              "%s is checking you out!" % (player.name))
             else:
                 await idchat(
                     player.id,
                     "%s is checking out %s!" % (player.name, target.name))
         player.energy -= 100
         if player.energy >= 1000 and target.life > 0:
             await idchat(player.id,
                          ("You still have %s energy!" % (player.energy)))
         player.lastmessage = ''
     elif player.lastmessage[:5] == '-use ':
         itemname = smartCapitalize(player.lastmessage[5:])
         if itemname not in ITEM:
             await idchat(self.id, "'%s' does not exist!" % itemname)
         elif ITEM[itemname] in player.inventory:
             item = ITEM[itemname]
             if await item.useItemBattle(self, player, target, self.players,
                                         escape):
                 return True
         else:
             await idchat(player.id,
                          "You don't have %s!" % (bold(itemname)))
         if player.energy >= 1000 and target.life > 0:
             await idchat(player.id,
                          "You still have %s energy!" % (player.energy))
         player.lastmessage = ''
     elif player.lastmessage[:6] == '-cast ':
         spellname = smartCapitalize(player.lastmessage[6:])
         if spellname not in TECH:
             await idchat(player.id, "This spell does not exist!")
         elif TECH[spellname] in player.spells:
             spell = TECH[spellname]
             if spell.battle is False:
                 await idchat(
                     player.id,
                     "You can't use %s in this way." % (bold(spellname)))
             else:
                 for player in self.players:
                     if player.name == player.name:
                         await idchat(player.id, "%s" % (spell.usedtext))
                     else:
                         await idchat(
                             player.id, "%s used %s!" %
                             (player.name, bold(spell.name)))
                 player.energy -= item.energyuse
                 player.life = min(
                     player.life +
                     ceil(player.get('maxlife') * (spell.curelife / 100)),
                     player.get('maxlife'))
                 if spell.curestatus == 0:
                     await player.clearStatusEffects()
                     await player.clearStatChanges()
                 for stat in player.statchange:
                     player.statchange[stat] += spell.buff[stat]
                 await target.evaluateStatus(target, spell.statusinflict,
                                             spell.statuschance)
         else:
             await idchat(player.id,
                          "You don't know %s!" % (bold(spellname)))
         if player.energy >= 1000 and target.life > 0:
             await idchat(player.id,
                          "You still have %s energy!" % (player.energy))
         player.lastmessage = ''
     elif player.lastmessage == '-escape':
         if escape is True:
             escaperoll = randint(1, 100)
             escapechance = ((player.life / player.get('maxlife')) *
                             (player.get('speed') / target.get('speed')) +
                             player.get('luck') * 0.002) * 100
             if escapechance >= escaperoll:
                 await idchat(player.id, "You escape!")
                 player.runaway += 1
                 player.lastmessage = ''
                 return True
             else:
                 await idchat(player.id, "You fail to escape!")
                 player.energy -= 200
                 if player.energy >= 1000 and target.life > 0:
                     await idchat(
                         player.id,
                         "You still have %s energy!" % (player.energy))
         else:
             await idchat(player.id, "You can not escape!")
         player.lastmessage = ''
     return False
예제 #13
0
 async def takeDamage(self, character, amount):
     character.life -= amount
     if character.life <= 0:
         self.characters.remove(character)
         for player in self.players:
             if player.name == character.name:
                 await idchat(player.id, "You collapse!")
                 print(character.name + " died")
             else:
                 await idchat(player.id, "%s dies!" % (character.name))
         if character.isplayer is False:
             for player in self.players:
                 moneyfound = floor(character.moneyaward *
                                    (1 + (player.luck / 100)))
                 print(player.name + ' has defeated ' +
                       unbold(character.name))
                 if character.isboss is True and character.name in player.bossesbeaten:
                     player.money += floor(moneyfound / 3)
                     player.exp += floor(character.expaward / 3)
                     money = floor(moneyfound / 3)
                     exp = floor(character.expaward / 3)
                 else:
                     player.money += moneyfound
                     player.exp += character.expaward
                     money = moneyfound
                     exp = character.expaward
                 if character.isboss:
                     if character.name not in player.bossesbeaten:
                         player.bossesbeaten.append(character.name)
                         await idchat(player.id,
                                      "%s" % (character.bossoutro))
                         await rpgChat(
                             "%s has cleared %s!" %
                             (bold(player.name), bold(player.location.name))
                         )
                 if character.israidboss:
                     if character.name not in player.raidbossesbeaten:
                         player.raidbossesbeaten.append(character.name)
                         await idchat(player.id,
                                      "%s" % (character.bossoutro))
                 await idchat(
                     player.id,
                     "You got %s ides and %s experience!" % (money, exp))
                 if len(character.unlocklocations) > 0:
                     addedlocations = []
                     for location in character.unlocklocations:
                         if location not in player.allowedlocations:
                             player.allowedlocations.append(location)
                             addedlocations.append(location)
                     if len(addedlocations) > 0:
                         await idchat(
                             player.id,
                             "You've unlocked new destinations: %s" %
                             (', '.join(bold(addedlocations))))
                 player.encountersinsamearea += 1
                 player.kills += 1
                 if player.encountersinsamearea > player.killstreak:
                     player.killstreak = player.encountersinsamearea
                 await player.cleanUp(character.droplist, False)
         else:
             character.state = State.NORMAL
             await character.clearStatChanges()
             await character.clearStatusEffects()
             character.life = (character.maxlife +
                               character.statchange['maxlife'])
             self.players.remove(character)
             moneyloss = ceil(character.money / 10)
             character.money = character.money - moneyloss
             character.encountersinsamearea = 0
             character.deaths += 1
             if len(character.allowedlocations) == 1:
                 if moneyloss > 0:
                     await idchat(
                         character.id,
                         "A guard drags you back to your cell. He smirks as he pilfers a portion of your ides (%s). After some time, you return to your feet."
                         % (moneyloss))
                 else:
                     await idchat(
                         character.id,
                         "A guard drags you back to your cell. Finding no ides on you, he gives you a solid kick to the ribs and leaves. After some time, you return to your feet."
                     )
             else:
                 character.location = getLocation(character.lasttown)
                 if moneyloss > 0:
                     await idchat(
                         character.id,
                         "A mysterious figure approaches as you lose consciousness. You awaken in the %s inn clutching a note, \"Your generous payment of %s ides is accepted. Be vigilant, stranger.\""
                         % (bold(character.location.name), moneyloss))
                 else:
                     await idchat(
                         character.id,
                         "A mysterious figure approaches as you lose consciousness. You awaken in the %s inn clutching a note, \"You owe me, stranger. Dearly.\""
                         % (bold(character.location.name)))
             await character.save()
             await character.cleanUp({}, True)
예제 #14
0
        "While this is in play, when you buy a Victory card, gain a "
        "Gold."
    }
}

# Starting deck for each player
starting_deck = {copper: 7, estate: 3}

initial_treasures = [gold, silver, copper]
initial_victory_cards = [province, duchy, estate]

# Dictionary for card text
card_text = {
    # Base game cards
    cellar:
    txf.bold("+1 Action") +
    "\nDiscard any number of cards, then draw that many.",
    chapel:
    "Trash up to 4 cards from your hand.",
    moat:
    txf.bold("+2 Cards") + "\n" + hl +
    "\nWhen another player plays an Attack card, you may first reveal this "
    "from your hand, to be unaffected by it.",
    chancellor:
    txf.coins(2) +
    "\nYou may immediately put your deck into your discard pile.",
    harbinger:
    txf.bold("+1 Card") + "\n" + txf.bold("+1 Action") +
    "\nLook through your discard pile. You may put a "
    "card from it onto your deck.",
    merchant:
예제 #15
0
 async def shopping(self, player):
     if self.hasshop is False:
         await idchat(player.id,
                      "There is no shop in %s!" % (bold(self.name)))
     elif player.state == State.SHOPPING:
         await idchat(player.id, "You are already shopping!")
     elif player.state == State.TRAINING:
         await idchat(player.id, "You can't shop while training!")
     elif player.state == State.ENCOUNTER:
         await idchat(player.id, "You can't shop during an encounter!")
     else:
         player.state = State.SHOPPING
         await idchat(
             player.id,
             "%s\nYou have %s Ides. What would you like to do? (-commands)"
             % (self.shopopening, player.money))
         player.lastmessage = ''
         rumorcount = 0
         buysomething = False
         while True:
             await asyncio.sleep(1)
             if player.lastmessage == "-commands" or player.lastmessage == "-cmds":
                 await idchat(
                     player.id,
                     blockify(
                         createCommandsBlock(
                             ['Shopping', 'Inventory', 'Other', 'Debug'])))
                 player.lastmessage = ''
             elif player.lastmessage[:5] == "-buy ":
                 itemname = smartCapitalize(player.lastmessage[5:])
                 splititem = itemname.split(' ')
                 amount = splititem[len(splititem) - 1]
                 if is_number(amount) and int(amount) > 0:
                     amount = int(amount)
                     itemname = ''
                     i = 0
                     j = len(splititem) - 2
                     for text in splititem:
                         if i < j:
                             itemname += text + ' '
                         elif i == j:
                             itemname += text
                         i += 1
                 else:
                     amount = 1
                 if itemname not in ITEM:
                     await idchat(player.id,
                                  "'%s' does not exist!" % itemname)
                 else:
                     itemfound = False
                     for item in self.shopitem:
                         if item == itemname:
                             check = await player.checkinventoryslots()
                             if check >= amount:
                                 if player.money > ITEM[
                                         itemname].price * amount:
                                     player.money -= ITEM[
                                         itemname].price * amount
                                     num = amount
                                     while num > 0:
                                         player.inventory.insert(
                                             0, ITEM[itemname])
                                         num -= 1
                                     await idchat(
                                         player.id,
                                         "You bought %s x%s for %s ides!" %
                                         (bold(itemname), amount,
                                          ITEM[itemname].price * amount))
                                     await player.save()
                                     buysomething = True
                                 else:
                                     await idchat(
                                         player.id,
                                         "You don't have enough ides!")
                             elif check < amount:
                                 await idchat(
                                     player.id,
                                     "You don't have enough space for %s x%s!"
                                     % (bold(itemname), amount))
                             itemfound = True
                             break
                     if itemfound is False:
                         await idchat(
                             player.id,
                             "The shop doesn't sell %s!" % (bold(itemname)))
                 player.lastmessage = ''
             elif player.lastmessage[:6] == "-sell ":
                 itemname = smartCapitalize(player.lastmessage[6:])
                 splititem = itemname.split(' ')
                 amount = splititem[len(splititem) - 1]
                 if is_number(amount) and int(amount) > 0:
                     amount = int(amount)
                     itemname = ''
                     i = 0
                     j = len(splititem) - 2
                     for text in splititem:
                         if i < j:
                             itemname += text + ' '
                         elif i == j:
                             itemname += text
                         i += 1
                 else:
                     amount = 1
                 sold = False
                 num = 0
                 for item in player.inventory:
                     if item.name == itemname:
                         num += 1
                 if itemname not in ITEM:
                     await idchat(player.id,
                                  "'%s' does not exist!" % itemname)
                 elif num >= amount:
                     item = ITEM[itemname]
                     player.money += floor(item.price * amount / 2)
                     await idchat(
                         player.id, "You sold %s x%s for %s ides!" %
                         (bold(itemname), amount,
                          floor(item.price * amount / 2)))
                     num = amount
                     while num > 0:
                         player.inventory.remove(item)
                         num -= 1
                     sold = True
                     await player.save()
                 elif itemname in [
                         player.weapon.name, player.shield.name,
                         player.armor.name, player.charm.name
                 ]:
                     await idchat(
                         player.id,
                         "You can't sell something you have equipped!")
                 elif sold is False:
                     await idchat(
                         player.id, "You do not have %s x%s" %
                         (bold(itemname), amount))
                 player.lastmessage = ''
             elif player.lastmessage == "-list all":
                 text_to_send = ''
                 imageCategories = []
                 for listname in [
                         'weapons', 'shields', 'armor', 'charms', 'items'
                 ]:
                     shopdict = {}
                     imageList = []
                     typestring = listname.capitalize()
                     for item in self.shopitem:
                         if item in ITEM and ITEM[item].typeof == typestring:
                             shopdict[item] = ITEM[item].price
                             imageList.append(ITEM[item].getImage())
                     liststring = typestring + '\n'
                     for item in shopdict:
                         liststring += ('  %s: %s\n' %
                                        (item, shopdict[item]))
                     text_to_send += liststring
                     imageCategories.append(imageList)
                 image_editor.createShop(imageCategories, player.id)
                 await idchat(player.id, blockify(text_to_send),
                              ['temp_shop_%s.jpg' % player.id])
                 os.remove('temp_shop_%s.jpg' % player.id)
                 player.lastmessage = ''
             elif player.lastmessage[:6] == "-list ":
                 listname = player.lastmessage[6:].lower()
                 shopdict = {}
                 imageList = []
                 if listname in [
                         'weapons', 'shields', 'armor', 'charms', 'items'
                 ]:
                     typestring = listname.capitalize()
                     for item in self.shopitem:
                         if item in ITEM and ITEM[item].typeof == typestring:
                             shopdict[item] = ITEM[item].price
                             imageList.append(ITEM[item].getImage())
                     liststring = ''
                     for item in shopdict:
                         liststring += ('%s: %s\n' % (item, shopdict[item]))
                     image_editor.createShop([imageList], player.id)
                     await idchat(player.id, blockify(liststring),
                                  ['temp_shop_%s.jpg' % player.id])
                     os.remove('temp_shop_%s.jpg' % player.id)
                 else:
                     await idchat(player.id, "That list does not exist!")
                 player.lastmessage = ''
             elif player.lastmessage == "-rumors":
                 await idchat(player.id,
                              "%s" % (self.shoprumor[rumorcount]))
                 if rumorcount < len(self.shoprumor) - 1:
                     rumorcount += 1
                 player.lastmessage = ''
             elif player.lastmessage == '-leave':
                 if buysomething is False:
                     await idchat(player.id, "%s" % (self.shopclosingnobuy))
                 elif buysomething is True:
                     await idchat(player.id, "%s" % (self.shopclosingbuy))
                 break
         player.state = State.NORMAL
예제 #16
0
 async def training(self, player):
     if self.hastrainer is False:
         await idchat(player.id,
                      "There is no trainer in %s!" % (bold(self.name)))
     elif player.state == State.SHOPPING:
         await idchat(player.id, "You can't train while shopping!")
     elif player.state == State.ENCOUNTER:
         await idchat(player.id, "You can't train during an encounter!")
     elif player.state == State.TRAINING:
         await idchat(player.id, "You are already training!")
     else:
         player.state = State.TRAINING
         await idchat(
             player.id,
             "%s\nYou have %s Potential! What would you like to do? (-commands)"
             % (self.traineropening, player.potential))
         player.lastmessage = ''
         rumorcount = 0
         while True:
             await asyncio.sleep(1)
             if player.lastmessage == "-commands" or player.lastmessage == "-cmds":
                 await idchat(
                     player.id,
                     blockify(
                         createCommandsBlock(
                             ['Training', 'Inventory', 'Other', 'Debug'])))
                 player.lastmessage = ''
             elif player.lastmessage[:7] == "-train ":
                 if player.lastmessage[7:].find(' ') != -1:
                     cmd = player.lastmessage[7:].split(' ')
                     attribute = cmd[0]
                     value = cmd[1]
                     attribute = attribute.lower()
                     if is_number(value) is True and int(value) > 0:
                         value = int(value)
                         if attribute in [
                                 'vigor', 'power', 'finesse', 'guard',
                                 'will', 'magic', 'luck', 'speed'
                         ] and value <= player.potential:
                             if attribute == 'vigor':
                                 player.vigor += value
                                 player.maxlife += (value * 4)
                                 player.life += (value * 4)
                                 player.respecpoints += value
                                 player.potential -= value
                                 await idchat(
                                     player.id,
                                     "You gained %s Vigor and %s Life!" %
                                     (value, (value * 4)))
                             elif attribute == 'power':
                                 player.power += value
                                 player.respecpoints += value
                                 player.potential -= value
                                 await idchat(
                                     player.id,
                                     "You gained %s Power!" % (value))
                             elif attribute == 'finesse':
                                 player.finesse += value
                                 player.maxfocus += value
                                 player.focus += value
                                 player.respecpoints += value
                                 player.potential -= value
                                 await idchat(
                                     player.id,
                                     "You gained %s Finesse and %s Focus!" %
                                     (value, value))
                             elif attribute == 'guard':
                                 player.guard += value
                                 player.respecpoints += value
                                 player.potential -= value
                                 await idchat(
                                     player.id,
                                     "You gained %s Guard!" % (value))
                             elif attribute == 'will':
                                 player.will += value
                                 player.respecpoints += value
                                 player.potential -= value
                                 await idchat(
                                     player.id,
                                     "You gained %s Will!" % (value))
                             elif attribute == 'speed':
                                 player.speed += value
                                 player.respecpoints += value
                                 player.potential -= value
                                 await idchat(
                                     player.id,
                                     "You gained %s Speed!" % (value))
                             elif attribute == 'magic':
                                 player.magic += value
                                 player.maxmana += value
                                 player.mana += value
                                 player.respecpoints += value
                                 player.potential -= value
                                 await idchat(
                                     player.id,
                                     "You gained %s Magic and %s Mana!" %
                                     (value, value))
                             elif attribute == 'luck':
                                 player.luck += value
                                 player.respecpoints += value
                                 player.potential -= value
                                 await idchat(
                                     player.id,
                                     "You gained %s Luck!" % (value))
                             await idchat(
                                 player.id,
                                 "You have %s Potential remaining!" %
                                 (player.potential))
                         elif value > player.potential:
                             await idchat(
                                 player.id,
                                 "You don't have enough potential for that!"
                             )
                         else:
                             await idchat(
                                 player.id,
                                 "You need to input an attribute and a number of points greater than zero (example: -train power 3 )!"
                             )
                     else:
                         await idchat(
                             player.id,
                             "You need to input an attribute and a number of points greater than zero (example: -train power 3 )!"
                         )
                 else:
                     await idchat(
                         player.id,
                         "You need to input an attribute and a number of points greater than zero (example: -train power 3 )!"
                     )
                 player.lastmessage = ''
                 await player.save()
             elif player.lastmessage[:7] == "-learn ":
                 if self.name == 'Prison of Hope':
                     await idchat(
                         player.id,
                         "I am afraid my frailty prevents me from teaching you some of my greater techniques."
                     )
                 else:
                     itemname = smartCapitalize(player.lastmessage[7:])
                     if itemname not in TECH:
                         await idchat(player.id,
                                      "%s is not a spell nor skill.")
                     else:
                         itemfound = False
                         for item in self.traineritem:
                             if item == itemname:
                                 if item not in player.skills and item not in player.spells:
                                     if (TECH[itemname].prereq
                                             in player.skills
                                             or TECH[itemname].prereq
                                             in player.skills
                                         ) or TECH[itemname].prereq is None:
                                         if player.potential >= TECH[
                                                 itemname].potentialcost:
                                             player.potential -= TECH[
                                                 itemname].potentialcost
                                             player.respecpoints += TECH[
                                                 itemname].potentialcost
                                             if TECH[itemname].type == 'Spell':
                                                 player.spells.append(
                                                     TECH[itemname])
                                             else:
                                                 player.skills.append(
                                                     TECH[itemname])
                                             await idchat(
                                                 player.id,
                                                 "You learned %s for %s Potential!"
                                                 % (bold(itemname),
                                                    TECH[itemname].
                                                    potentialcost))
                                             await player.save()
                                             await idchat(
                                                 player.id,
                                                 "You have %s Potential left!"
                                                 % (player.potential))
                                         else:
                                             await idchat(
                                                 player.id,
                                                 "You don't have enough Potential!"
                                             )
                                     else:
                                         await idchat(
                                             player.id,
                                             "You need to learn %s before I can teach you %s."
                                             % (bold(TECH[itemname].prereq),
                                                bold(itemname)))
                                 else:
                                     await idchat(
                                         player.id,
                                         "I can't teach you what you already know!"
                                     )
                                 itemfound = True
                                 break
                         if itemfound is False:
                             await idchat(
                                 player.id,
                                 "Sorry, I can't teach %s to you." %
                                 (bold(itemname)))
                 player.lastmessage = ''
             elif player.lastmessage[:6] == "-list ":
                 if self.name == 'Prison of Hope':
                     await idchat(
                         player.id,
                         "I am afraid my frailty prevents me from teaching you some of my greater techniques."
                     )
                 elif player.lastmessage == "-list all":
                     text_to_send = ''
                     for listname in ['spells', 'skills']:
                         trainerdict = {}
                         typestring = listname.capitalize()
                         for item in self.traineritem:
                             if item in TECH and TECH[
                                     item].typeof == typestring:
                                 trainerdict[item] = TECH[
                                     item].potentialcost
                         liststring = typestring + '\n'
                         for item in trainerdict:
                             liststring += ('  %s: %s\n' %
                                            (item, trainerdict[item]))
                         text_to_send += liststring
                     await idchat(player.id, blockify(text_to_send))
                     player.lastmessage = ''
                 else:
                     listname = player.lastmessage[6:].lower()
                     trainerdict = {}
                     if listname in ['spells', 'skills']:
                         typestring = listname.capitalize()
                         for item in self.traineritem:
                             if item in TECH and TECH[
                                     item].typeof == typestring:
                                 trainerdict[item] = TECH[
                                     item].potentialcost
                         liststring = ''
                         for item in trainerdict:
                             liststring += ('%s: %s\n' %
                                            (item, trainerdict[item]))
                         await idchat(player.id, blockify(liststring))
                     else:
                         await idchat(
                             player.id,
                             "That list does not exist!" % (liststring))
                 player.lastmessage = ''
             elif player.lastmessage == "-rumors":
                 await idchat(player.id,
                              "%s" % (self.trainerrumor[rumorcount]))
                 if rumorcount < len(self.trainerrumor) - 1:
                     rumorcount += 1
                 player.lastmessage = ''
             elif player.lastmessage == "-respec":
                 await idchat(
                     player.id,
                     "Are you sure you wish to return all your potential? You will have to relearn all your spells and skills as well as retrain all of your attributes. Also, it's not cheap at 2500 ides (-accept|-decline)."
                 )
                 while True:
                     await asyncio.sleep(1)
                     if player.lastmessage == '-accept' and player.money >= 2500:
                         player.potential = player.potential + player.respecpoints
                         player.respecpoints = 0
                         player.maxlife = 40 + (player.level - 1) * 10
                         player.life = 40 + (player.level - 1) * 10
                         player.maxmana = 10
                         player.mana = 10
                         player.maxfocus = 10
                         player.focus = 10
                         player.vigor = 10
                         player.power = 10
                         player.finesse = 10
                         player.will = 10
                         player.guard = 10
                         player.magic = 10
                         player.speed = 10
                         player.luck = 10
                         player.skills = []
                         player.spells = []
                         await player.clearStatChanges()
                         player.money -= 2500
                         await player.save()
                         await idchat(
                             player.id,
                             "Your mind and body feel the same now as when you first picked up your sword and decided to carve your own fate. A world of potential is laid before you. (Don't forget to spend your points!)"
                         )
                         break
                     elif player.lastmessage == '-accept':
                         await idchat(
                             player.id,
                             "You cannot afford this special training.")
                         break
                     elif player.lastmessage == '-decline':
                         await idchat(player.id,
                                      "Ahh, maybe another time then.")
                         break
                 player.lastmessage = ''
             elif player.lastmessage == '-leave':
                 await idchat(player.id, "%s" % (self.trainerclosing))
                 break
         player.state = State.NORMAL
예제 #17
0
 async def setMonster(self):
     if self.name not in MONSTER:
         MONSTER[self.name] = self
         self.name = bold(self.name)
예제 #18
0
 async def handleCharacterCommand(self, RPGTestMode):
     if self.lastmessage[:9] == '-examine ':
         item = smartCapitalize(self.lastmessage[9:])
         await self.examineItem(item, PLAYER)
     elif self.lastmessage[:5] == '-use ' and self.state != State.ENCOUNTER:
         item = smartCapitalize(self.lastmessage[5:])
         await self.useItem(item)
     elif self.lastmessage == '-shop':
         await self.location.shopping(self)
     elif self.lastmessage == '-trainer':
         await self.location.training(self)
     elif self.lastmessage == '-travel':
         await self.displayTravel()
     elif self.lastmessage == '-location' or self.lastmessage == '-loc':
         await idchat(self.id, ("You are at %s!" % (bold(PLAYER[self.name].location.name))))
     elif self.lastmessage == '-commands all' or self.lastmessage == '-cmds all':
         await allCommands(self.id)
     elif self.lastmessage == '-commands' or self.lastmessage == '-cmds':
         if self.state == State.ENCOUNTER:
             await idchat(self.id, blockify(createCommandsBlock(['Battle', 'Inventory', 'Other', 'Debug'])))
         elif self.state != State.SHOPPING and self.state != State.TRAINING and self.state != State.ENCOUNTER:
             await idchat(self.id, blockify(createCommandsBlock(['Inventory', 'Travel', 'Instance', 'Other', 'Debug'])))
     elif self.lastmessage[:8] == '-travel ':
         if self.state == State.NORMAL:
             location = smartCapitalize(self.lastmessage[8:])
             if location in PLAYER[self.name].allowedlocations and location != PLAYER[self.name].location:
                 await self.travel(location)
             elif location == PLAYER[self.name].location:
                 await idchat(self.id, ("You are already at %s!" % (bold(location))))
             else:
                 await idchat(self.id, ("You don't know how to get to %s!" % (bold(location))))
         elif PLAYER[self.name].state == State.SHOPPING:
             await idchat(self.id, ("You can't travel while in the shop!"))
         elif PLAYER[self.name].state == State.TRAINING:
             await idchat(self.id, ("You can't travel while training!"))
         else:
             await idchat(self.id, ("You can't travel during an encounter!"))
     elif self.lastmessage == '-surroundings' or self.lastmessage == '-look':
         await idchat(self.id, "%s" % (self.location.surroundings))
     elif self.lastmessage == '-stats':
         await self.displayStats()
     elif self.lastmessage == '-inv' or self.lastmessage == '-inventory':
         await self.displayInventory()
     elif self.lastmessage[:9] == '-discard ':
         itemname = smartCapitalize(self.lastmessage[9:])
         await self.discarditem(itemname)
     elif self.lastmessage[:7] == '-equip ':
         itemname = smartCapitalize(self.lastmessage[7:])
         await self.equipitem(itemname)
     elif self.lastmessage == '-encounter' or self.lastmessage == '-enc':
         if self.location.name in hostilelocationlist:
             if self.state == State.SHOPPING:
                 await idchat(self.id, ("You are busy shopping!"))
             elif self.state == State.TRAINING:
                 await idchat(self.id, ("You are busy training!"))
             else:
                 enc = Encounter.Encounter()
                 await enc.setup([self], EncType.NORMAL)
         else:
             await idchat(self.id, ("You can't get in encounters in %s!" % bold(self.location.name)))
     elif self.lastmessage == '-encounter boss' or self.lastmessage == '-enc boss':
         if self.location.name in hostilelocationlist:
             if self.state == State.SHOPPING:
                 await idchat(self.id, ("You are busy shopping!"))
             elif self.state == State.TRAINING:
                 await idchat(self.id, ("You are busy training!"))
             else:
                 enc = Encounter.Encounter()
                 await enc.setup([self], EncType.BOSS)
         else:
             await idchat(self.id, ("You can't get in encounters in %s!" % bold(self.location.name)))
     elif self.lastmessage[:7] == '-meditate ' or self.lastmessage[:13] == '-concentrate ' or self.lastmessage[:5] == '-med ' or self.lastmessage[:5] == '-con ':
         cmd = self.lastmessage.split(' ')
         command = cmd[0]
         amount = cmd[1]
         await self.meditateconcentrate(command, amount)
     elif self.lastmessage == '-imstuck':
         for encounter in ENCOUNTERS:
             if self in encounter.players:
                 await encounter.end()
         self.state = State.NORMAL
         await idchat(self.id, "Pulled you out of combat/shop/trainer! Careful with this command as it could break things!")
     self.lastmessage == ''