Exemple #1
0
async def levelup(ctx, *abil_nums):
    author = ctx.message.author.name
    character = Character(author)
    ch_abil_count = len(character.abilities)

    for abil_num in abil_nums:
        if ch_abil_count < character.lvl - 1:
            abil_num = abil_num.strip(',')
            ability = Ability(abil_num)

            if character.lvl < int(ability.lvl):

                message = f"That card ({ability.lvl}) is above your level ({character.lvl}). You must select a card of your current level or lower.\n Abilities: {character.abil_nums}"

            else:

                if character.charclass != ability.charclass:
                    message = f"Please choose an ability card from your own dang class."

                else:

                    if ability.ability['id'] in character.abilities:

                        message = f"Ability {ability.number} is already in your pool. Please choose again.\n Abilities: {character.abil_nums}"

                    else:

                        character.abil_transaction('gain', abil_num)
                        ch_abil_count += 1
                        message = f"Level {ability.lvl} - {ability.name} [{ability.number}] added to your pool."

        else:
            message = f"You have added too many abilities. You are Level {character.lvl} so you can only have {character.lvl-1} level 2+ abilities in your pool."
        await ctx.send(f"```{message}```")

    await ctx.send(
        f"```{character.name}\n Abilities: {sorted(character.abil_nums)}```")
Exemple #2
0
async def lose(ctx, thing_to_lose, *thing):
    author = ctx.message.author.name
    character = Character(author)
    world = World(character.campaign[0])
    party = Party(character.party[0])

    if thing_to_lose == 'item':
        item_num = thing[0].strip(',')

        item = Item(item_num)

        if int(item.number) in character.item_nums:

            character.item_transaction('lose', item.number)

            message = f"Item {item.number} has been removed from your inventory.\nItems: {sorted(character.item_nums)}"

        else:

            message = f"You don't own that item. Please try again.\nItems: {sorted(character.item_nums)}"

    elif thing_to_lose == 'ability':
        ability_num = thing[0].strip(',')
        ability = Ability(ability_num)

        if int(ability.number) in character.abil_nums:

            character.abil_transaction('lose', ability.number)

            message = f"Ability {ability.number} has been remove from your pool.\nAbilities: {sorted(character.abil_nums)}"

        else:
            message = f"That ability is not in your pool.\nAbilities: {sorted(character.abil_nums)}"

    elif 'pros' in thing_to_lose:

        if world.pticks in world.prosperity_levels:

            message = f"You're in luck. Prosperity cannot be descreased below its current cost."

        else:

            world.lose_ptick()

            message = f"{world.name} -1 Prosperity\nProsperity: {world.pticks}/{world.prosperity_levels[world.prosperity]}    Overall: {world.prosperity}"

    elif 'rep' in thing_to_lose:

        party.lose_reputation()

        message = f"{party.name} -1 Reputation\nReputation: {party.reputation}     Discount: {party.discount}"

    elif 'xp' in thing_to_lose:

        xp = int(re.sub("[^0-9]", "", thing_to_lose))

        lvl_up = character.gain_xp(-xp)

        message = f"{character.name} lost {xp}xp\n{character.xp}xp {character.gold}gp {character.checks}{character.ch}"

        if lvl_up == True:

            message = f"{message}\nYou reached Level {character.lvl}! You may level up when you return to Gloomhaven."

    elif 'gold' in thing_to_lose or 'gp' in thing_to_lose:

        gold = int(re.sub("[^0-9]", "", thing_to_lose))

        character.gain_gold(-gold)

        message = f"{character.name} lost {gold}gp\n{character.xp}xp {character.gold}gp {character.checks}{character.ch}"

    elif 'ch' in thing_to_lose:

        checks = int(re.sub("[^0-9]", "", thing_to_lose))

        if character.checks % 3 == 0:

            message = f"You cannot lose a check because it would break up a compelte triplet."

        else:

            character.gain_checks(-checks)

            message = f"{character.name} lost {checks}checks\n{character.xp}xp {character.gold}gp {character.checks}{character.ch}"

    await ctx.send(f"```{message}```")
Exemple #3
0
async def gain(ctx, thing_to_gain, *thing):
    author = ctx.message.author.name
    character = Character(author)
    world = World(character.campaign[0])
    party = Party(character.party[0])

    if thing_to_gain == 'item':
        item_num = thing[0].strip(',')
        item = Item(item_num)
        if item.unlocked == True:
            if item.number not in character.item_nums:
                if item.numberAvailable > 0:
                    character.item_transaction('gain', item.number)
                    message = f"{character.name} gained {item.num_name}.\n  Items: {character.item_nums}"

                else:
                    message = f"There are no copies of {item.num_name} available in the store."

            else:
                message = f"You already own {item.num_name}! You cannot own two copies.I should striek you down right here, so help me Blood God!"
        else:
            message = f"Item {item.number} is not unlocked. Use !loot to add scenario loot or items unlocked via road or city event."

    elif thing_to_gain == 'ability':
        if len(character.abilities) < character.lvl - 1:
            ability_num = thing[0].strip(',')
            ability = Ability(ability_num)

            if character.lvl < int(ability.lvl):
                message = f"That card ({ability.lvl}) is above your level. Please select an ability of Level {character.lvl} or lower to add to your pool."

            else:
                if character.charclass != ability.charclass:
                    message = f"Please choose an ability card from your own dang class."
                else:
                    if ability.ability['id'] in character.abilities:
                        message = f"Ability {ability.number} is already in your pool. Please choose again."

                    else:
                        character.abil_transaction('gain', ability.number)
                        message = f"Level {ability.lvl} - {ability.name} [{ability.number}] added to your pool.\nAbilities: {sorted(character.abil_nums)}"
        else:
            message = f"You have added too many abilities. You are Level {character.lvl} so you can only have {character.lvl-1} level 2+ abilities in your pool."

    elif 'rep' in thing_to_gain:
        party.gain_reputation()
        message = f"{party.name} +1 Reputation:\nReputation: {party.reputation}    Discount: {party.discount}"

    elif 'pros' in thing_to_gain:
        world.gain_prosperity()
        message = f"{world.name} +1 Prosperity:\nProsperity: {world.pticks}/{world.prosperity_levels[world.prosperity]}    Overall: {world.prosperity}"

        if world.pticks == world.prosperity_levels[world.prosperity - 1]:
            message = f"{message}\nThe Overall Prosperity has increased to {world.prosperity}\nNew items are now available in the item store.\nAll characters may level up to Lvl{world.prosperity} while in Gloomhaven."

    elif 'xp' in thing_to_gain:
        xp = int(re.sub("[^0-9]", "", thing_to_gain))
        lvl_up = character.gain_xp(xp)
        message = f"{character.name} gained {xp}xp\n{character.xp}xp {character.gold}gp {character.checks}{character.ch}"
        if lvl_up == True:
            message = f"{message}\nYou reached Level {character.lvl}! You may level up when you return to Gloomhaven."

    elif 'gold' in thing_to_gain or 'gp' in thing_to_gain:
        gold = int(re.sub("[^0-9]", "", thing_to_gain))
        character.gain_gold(gold)
        message = f"{character.name} gained {gold}gp\n{character.xp}xp {character.gold}gp {character.checks}{character.ch}"

    elif 'ch' in thing_to_gain:
        checks = int(re.sub("[^0-9]", "", thing_to_gain))
        character.gain_checks(checks)
        message = f"{character.name} gained {checks}checks\n{character.xp}xp {character.gold}gp {character.checks}{character.ch}"
        if character.checks % 3 == 0:
            message = f"{message}\nYou earned your 3rd check. Gain a Perk!"

    await ctx.send(f"```{message}```")