Beispiel #1
0
async def eat_item(cmd):
    user_data = EwUser(member=cmd.message.author)
    mutations = user_data.get_mutations()
    item_search = ewutils.flattenTokenListToString(cmd.tokens[1:])

    food_item = None

    # look for a food item if a name was given
    if item_search:
        item_sought = bknd_item.find_item(item_search=item_search,
                                          id_user=user_data.id_user,
                                          id_server=user_data.id_server,
                                          item_type_filter=ewcfg.it_food)
        if item_sought:
            food_item = EwItem(id_item=item_sought.get('id_item'))
        else:
            item_sought = bknd_item.find_item(item_search=item_search,
                                              id_user=user_data.id_user,
                                              id_server=user_data.id_server)
            if item_sought and ewcfg.mutation_id_trashmouth in mutations:
                return await devour(cmd=cmd)

    # otherwise find the first useable food
    else:
        food_inv = bknd_item.inventory(id_user=user_data.id_user,
                                       id_server=user_data.id_server,
                                       item_type_filter=ewcfg.it_food)

        for food in food_inv:
            food_item = EwItem(id_item=food.get('id_item'))

            # check if the user can eat this item
            if float(getattr(food_item, "time_expir", 0)) > time.time() or \
                    food_item.item_props.get('perishable') not in ['true', '1'] or \
                    ewcfg.mutation_id_spoiledappetite in user_data.get_mutations():
                break

    if food_item != None:
        response = user_data.eat(food_item)
        user_data.persist()
    else:
        if item_search:
            response = "Are you sure you have that item?"
        else:
            response = "You don't have anything to eat."

    await fe_utils.send_message(
        cmd.client, cmd.message.channel,
        fe_utils.formatMessage(cmd.message.author, response))
Beispiel #2
0
async def sacrifice(cmd):
    user_data = EwUser(member=cmd.message.author)

    if len(cmd.tokens) == 1:
        response = "Hey, don't hesitate now. You better cough up something to sacrifice."
        return await fe_utils.send_message(
            cmd.client, cmd.message.channel,
            fe_utils.formatMessage(cmd.message.author, response))

    item_search = ewutils.flattenTokenListToString(cmd.tokens[1:])

    item_sought = bknd_item.find_item(item_search=item_search,
                                      id_user=cmd.message.author.id,
                                      id_server=cmd.guild.id)
    item_property = ''

    if ewcfg.dh_active:
        if user_data.poi != 'endlesswar':
            response = 'The altars are next to ENDLESS WAR. Sacrifice your worldly possessions over there.'
        elif not item_sought:
            response = "Are you sure you have that item?"
        else:
            item = EwItem(item_sought.get('id_item'))
            if item.soulbound == True:
                response = "You try to unbind the {} from your soul to place it on the altar, but it refuses to let go of you. It's crazy that even inanimate objects are smarter than you."
            else:
                item.id_owner = '{}sacrificed'.format(user_data.id_user)
                item.persist()
                property_type = ewcfg.id_item_convert.get(item.item_type)
                print('')
                if item.item_props.get('context') == 'slimeoidheart':
                    property_type = 'slimeoidheart'
                elif property_type is None:
                    property_type = 'normal'
                else:
                    pass

                item_name = item.item_props.get(property_type)
                if property_type == 'normal':
                    item_name = 'normal'
                arr_sac = ewcfg.sacrifice_rates.get(item_name)

                if arr_sac == None and item.item_type == ewcfg.it_food:
                    arr_sac = [3, "Tasty."]
                if arr_sac == None:
                    arr_sac = [
                        1, "You toss your worldly posessions to the altar."
                    ]

                response = "{} The {} bursts into flames, vanishing before your very eyes. Favor increased by {}.".format(
                    arr_sac[1], item_sought.get('name'), arr_sac[0])
                ewstats.change_stat(id_server=cmd.guild.id,
                                    id_user=cmd.message.author.id,
                                    metric='sacrificerate',
                                    n=arr_sac[0])
    else:
        response = "Now's a bad time for that."
    return await fe_utils.send_message(
        cmd.client, cmd.message.channel,
        fe_utils.formatMessage(cmd.message.author, response))
Beispiel #3
0
async def store(cmd):
    user_data = EwUser(member=cmd.message.author)
    response = ""

    poi = poi_static.id_to_poi.get(user_data.poi)
    if poi.community_chest == None:
        response = "There is no community chest here."
        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
    else:
        if len(poi.factions) > 0 and user_data.faction not in poi.factions:
            response = "Get real, asshole. You haven't even enlisted into this gang yet, so it's not like they'd trust you with a key to their valubles."
            return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

    item_search = ewutils.flattenTokenListToString(cmd.tokens[1:])

    item_sought = bknd_item.find_item(item_search=item_search, id_user=cmd.message.author.id, id_server=cmd.guild.id if cmd.guild is not None else None)

    if item_sought:
        item = EwItem(id_item=item_sought.get("id_item"))

        if not item.soulbound:
            if item.item_type == ewcfg.it_weapon:
                if user_data.weapon >= 0 and item.id_item == user_data.weapon:
                    if user_data.weaponmarried:
                        weapon = static_weapons.weapon_map.get(item.item_props.get("weapon_type"))
                        response = "Your cuckoldry is appreciated, but your {} will always remain faithful to you.".format(item_sought.get('name'))
                        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
                    else:
                        user_data.weapon = -1
                        user_data.persist()
                elif item.id_item == user_data.sidearm:
                    user_data.sidearm = -1
                    user_data.persist()

            if item.item_type == ewcfg.it_cosmetic:
                if "adorned" in item.item_props:
                    item.item_props["adorned"] = "false"
                if "slimeoid" in item.item_props:
                    item.item_props["slimeoid"] = "false"

            item.persist()
            bknd_item.give_item(id_item=item.id_item, id_server=item.id_server, id_user=poi.community_chest)

            response = "You store your {} in the community chest.".format(item_sought.get("name"))

        else:
            response = "You can't {} soulbound items.".format(cmd.tokens[0])
    else:
        if item_search:
            response = "You don't have one"
        else:
            response = "{} which item? (check **!inventory**)".format(cmd.tokens[0])

    await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
async def preserve(cmd):
    user_data = EwUser(member=cmd.message.author)
    mutations = user_data.get_mutations()
    item_search = ewutils.flattenTokenListToString(cmd.tokens[1:])

    item_sought = bknd_item.find_item(item_search=item_search, id_user=cmd.message.author.id, id_server=cmd.guild.id if cmd.guild is not None else None)

    if item_sought:
        item_obj = EwItem(id_item=item_sought.get('id_item'))

        if item_obj.item_props.get('preserved') == None:
            preserve_id = 0
        else:
            preserve_id = int(item_obj.item_props.get('preserved'))

        if ewcfg.mutation_id_rigormortis not in mutations:
            response = "You can't just preserve something by saying you're going to. Everything ends eventually."
            return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
        elif item_obj.soulbound == True:
            response = "This thing's bound to your soul. There's no need to preserve it twice."
            return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
        elif preserve_id == int(user_data.id_user):
            response = "Didn't you already preserve this? You're so paranoid."
            return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
        elif item_obj.item_props.get('preserved') == "nopreserve":
            response = "You shove it into your body but it just won't fit for some reason. That phrasing was completely intentional, by the way."
            return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
        else:

            rigor = EwMutation(id_user=cmd.message.author.id, id_server=cmd.message.guild.id, id_mutation=ewcfg.mutation_id_rigormortis)

            if rigor.data.isdigit() == False:
                num = 0
            else:
                num = int(rigor.data)

            if num >= 5:
                response = "Your body's dried up, it's lost its ability to preserve objects."
            else:
                response = "You take the {} and embrace it with all your might. As you squeeze, it slowly but surely begins to phase inside your body. That won't get stolen anytime soon!".format(item_sought.get('name'))
                num += 1
                rigor.data = str(num)
                item_obj.item_props['preserved'] = user_data.id_user
                rigor.persist()
                item_obj.persist()
            return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
    else:
        response = "Preserve what?"
        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
Beispiel #5
0
def item_commands(cmd):
    response = "\n**IN YOUR INVENTORY:**"
    items_to_find = ewcfg.item_unique_commands.keys()
    user_data = EwUser(member=cmd.message.author)

    for lookup in items_to_find:
        item_sought = bknd_item.find_item(item_search=lookup,
                                          id_user=user_data.id_user,
                                          id_server=user_data.id_server)
        if item_sought:
            response += "\n" + ewcfg.item_unique_commands.get(lookup)
    if response != "\n**IN YOUR INVENTORY:**":
        return response
    else:
        return ""
Beispiel #6
0
async def smeltsoul(cmd):
    item = bknd_item.find_item(item_search="reanimatedcorpse", id_user=cmd.message.author.id, id_server=cmd.guild.id)
    if not item:
        response = "You can't rip a soul out of a nonexistent object."
    else:
        item_obj = EwItem(id_item=item.get('id_item'))
        if item_obj.item_props.get('target') != None and item_obj.item_props.get('target') != "":
            targetid = item_obj.item_props.get('target')
            if bknd_item.give_item(id_user=cmd.message.author.id, id_item=targetid, id_server=cmd.guild.id):
                response = "You ripped the soul out of the reanimated corpse. It's in mangled bits now."
                bknd_item.item_delete(id_item=item.get('id_item'))
            else:
                response = "You reach for the soul in the reanimated corpse, but your hands are full of cosmetics! Get rid of a few, freak."
        else:
            response = "That's not a reanimated corpse. It only looks like one. Get rid of the fake shit and we'll get started."
    await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
async def longdrop(cmd):
    user_data = EwUser(member=cmd.message.author)
    mutations = user_data.get_mutations()
    poi = poi_static.id_to_poi.get(user_data.poi)

    destination = ewutils.flattenTokenListToString(cmd.tokens[1])
    dest_poi = poi_static.id_to_poi.get(destination)

    item_search = ewutils.flattenTokenListToString(cmd.tokens[2:])
    item_sought = bknd_item.find_item(item_search=item_search, id_user=cmd.message.author.id, id_server=user_data.id_server)

    if ewcfg.mutation_id_longarms not in mutations:
        response = "As if anything on you was long enough to do that."
    elif cmd.tokens_count == 1:
        response = "You'll need for information that that. Try !longdrop <location> <item>."
    elif not item_sought:
        response = "You don't have that item."
    elif dest_poi == None:
        response = "Never heard of it."
    elif poi_utils.inaccessible(user_data=user_data, poi=dest_poi) or dest_poi.is_street:
        response = "Your arm hits a wall before it can make the drop off. Shit, probably can't take it over there."
    elif user_data.poi not in dest_poi.neighbors.keys() and dest_poi.id_poi not in poi.mother_districts:
        response = "You can't take it that far. What if a bird or car runs into your hand?"
    else:
        item_obj = EwItem(item_sought.get('id_item'))
        if item_obj.soulbound == True and item_obj.item_props.get('context') != 'housekey':
            response = "You still can't drop a soulbound item. Having really long arms doesn't grant you that ability."
        elif item_obj.item_type == ewcfg.it_weapon and user_data.weapon >= 0 and item_obj.id_item == user_data.weapon:
            if user_data.weaponmarried:
                weapon = static_weapons.weapon_map.get(item_obj.item_props.get("weapon_type"))
                response = "As much as it would be satisfying to just chuck your {} down an alley and be done with it, here in civilization we deal with things *maturely.* You’ll have to speak to the guy that got you into this mess in the first place, or at least the guy that allowed you to make the retarded decision in the first place. Luckily for you, they’re the same person, and he’s at the Dojo.".format(
                    weapon.str_weapon)
                return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
            else:
                user_data.weapon = -1
                user_data.persist()

        itm_utils.item_drop(id_item=item_sought.get('id_item'), other_poi=dest_poi.id_poi)
        response = "You stretch your arms and drop your " + item_sought.get("name") + ' into {}.'.format(dest_poi.str_name)
        await ewrolemgr.updateRoles(client=cmd.client, member=cmd.message.author)
    await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
async def store(cmd):
    user_data = EwUser(member=cmd.message.author)
    response = ""

    poi = poi_static.id_to_poi.get(user_data.poi)
    if poi.community_chest == None:
        response = "There is no community chest here."
        return await fe_utils.send_message(
            cmd.client, cmd.message.channel,
            fe_utils.formatMessage(cmd.message.author, response))
    else:
        if len(poi.factions) > 0 and user_data.faction not in poi.factions:
            response = "Get real, asshole. You haven't even enlisted into this gang yet, so it's not like they'd trust you with a key to their valuables."
            return await fe_utils.send_message(
                cmd.client, cmd.message.channel,
                fe_utils.formatMessage(cmd.message.author, response))

    if cmd.tokens[1] == 'all':
        cmd.tokens[1] = '100'

    multistow = 1
    startparse = 1

    items = []

    if cmd.tokens[1].isnumeric() and cmd.tokens_count > 2:
        startparse = 2
        multistow = int(cmd.tokens[1])
        if multistow > 100:
            multistow = 100

    item_search = ewutils.flattenTokenListToString(cmd.tokens[startparse:])

    item_sought = bknd_item.find_item(
        item_search=item_search,
        id_user=cmd.message.author.id,
        id_server=cmd.guild.id if cmd.guild is not None else None)

    if item_sought:

        if not item_sought.get('soulbound'):
            items_had = 0
            loop_sought = item_sought.copy()

            item_cache = bknd_core.get_cache(obj_type="EwItem")

            while multistow > 0 and loop_sought is not None:
                item = EwItem(id_item=loop_sought.get("id_item"))
                item_search = ewutils.flattenTokenListToString(
                    loop_sought.get('name'))
                if item.item_type == ewcfg.it_weapon:
                    if user_data.weapon >= 0 and item.id_item == user_data.weapon:
                        if user_data.weaponmarried:
                            weapon = static_weapons.weapon_map.get(
                                item.item_props.get("weapon_type"))
                            response = "Your cuckoldry is appreciated, but your {} will always remain faithful to you.".format(
                                item_sought.get('name'))
                            return await fe_utils.send_message(
                                cmd.client, cmd.message.channel,
                                fe_utils.formatMessage(cmd.message.author,
                                                       response))
                        else:
                            user_data.weapon = -1
                            user_data.persist()
                    elif item.id_item == user_data.sidearm:
                        user_data.sidearm = -1
                        user_data.persist()

                if item.item_type == ewcfg.it_cosmetic:
                    if "adorned" in item.item_props:
                        item.item_props["adorned"] = "false"
                    if "slimeoid" in item.item_props:
                        item.item_props["slimeoid"] = "false"

                item.persist()
                #bknd_item.give_item(id_item=loop_sought.get('id_item'), id_server=item.id_server, id_user=poi.community_chest)
                items.append(int(loop_sought.get('id_item')))

                cache_item = item_cache.get_entry(
                    unique_vals={"id_item": int(loop_sought.get('id_item'))})
                cache_item.update({'id_owner': poi.community_chest})
                item_cache.set_entry(data=cache_item)

                #= await event_loop.run_in_executor(None, item_cache.find_entries, criteria)
                func = partial(
                    bknd_item.find_item,
                    item_search=item_search,
                    id_user=cmd.message.author.id,
                    id_server=cmd.guild.id if cmd.guild is not None else None)
                event_loop = asyncio.get_event_loop()
                loop_sought = await event_loop.run_in_executor(None, func)

                items_had += 1
                multistow -= 1

            if items_had > 1:
                name_string = "{}(x{})".format(item_sought.get("name"),
                                               items_had)
            else:
                name_string = item_sought.get("name")

            bknd_item.give_item_multi(id_list=items,
                                      destination=poi.community_chest)
            response = "You store your {} in the community chest.".format(
                name_string)

        else:
            response = "You can't {} soulbound items.".format(cmd.tokens[0])
    else:
        if item_search:
            response = "You don't have one"
        else:
            response = "{} which item? (check **!inventory**)".format(
                cmd.tokens[0])

    return await fe_utils.send_message(
        cmd.client, cmd.message.channel,
        fe_utils.formatMessage(cmd.message.author, response))
async def take(cmd):
    user_data = EwUser(member=cmd.message.author)
    response = ""
    admin = 0
    if cmd.message.author.guild_permissions.administrator:
        admin = 1

    poi = poi_static.id_to_poi.get(user_data.poi)
    if poi.community_chest == None:
        response = "There is no community chest here."
        return await fe_utils.send_message(
            cmd.client, cmd.message.channel,
            fe_utils.formatMessage(cmd.message.author, response))
    else:
        if len(poi.factions) > 0 and user_data.faction not in poi.factions:
            response = "Get real, asshole. You haven't even enlisted into this gang yet, so it's not like they'd trust you with a key to their valubles."
            return await fe_utils.send_message(
                cmd.client, cmd.message.channel,
                fe_utils.formatMessage(cmd.message.author, response))

    item_search = ewutils.flattenTokenListToString(cmd.tokens[1:])

    item_sought = bknd_item.find_item(
        item_search=item_search,
        id_user=poi.community_chest,
        id_server=cmd.guild.id if cmd.guild is not None else None,
        admin=admin)

    if item_sought:
        if item_sought.get('item_type') == ewcfg.it_food:
            food_items = bknd_item.inventory(id_user=cmd.message.author.id,
                                             id_server=cmd.guild.id,
                                             item_type_filter=ewcfg.it_food)

            if len(food_items) >= user_data.get_food_capacity():
                del food_items
                response = "You can't carry any more food items."
                return await fe_utils.send_message(
                    cmd.client, cmd.message.channel,
                    fe_utils.formatMessage(cmd.message.author, response))

        elif item_sought.get('item_type') == ewcfg.it_weapon:
            weapons_held = bknd_item.inventory(
                id_user=cmd.message.author.id,
                id_server=cmd.guild.id,
                item_type_filter=ewcfg.it_weapon)

            if user_data.life_state == ewcfg.life_state_corpse:
                del weapons_held
                response = "Ghosts can't hold weapons."
                return await fe_utils.send_message(
                    cmd.client, cmd.message.channel,
                    fe_utils.formatMessage(cmd.message.author, response))
            elif len(weapons_held) >= user_data.get_weapon_capacity():
                del weapons_held
                response = "You can't carry any more weapons."
                return await fe_utils.send_message(
                    cmd.client, cmd.message.channel,
                    fe_utils.formatMessage(cmd.message.author, response))

        else:
            other_items = bknd_item.inventory(
                id_user=cmd.message.author.id,
                id_server=user_data.id_server,
                item_type_filter=item_sought.get('item_type'))
            if len(other_items) >= ewcfg.generic_inv_limit:
                del other_items
                response = ewcfg.str_generic_inv_limit.format(
                    item_sought.get('item_type'))
                return await fe_utils.send_message(
                    cmd.client, cmd.message.channel,
                    fe_utils.formatMessage(cmd.message.author, response))

        bknd_item.give_item(id_item=item_sought.get('id_item'),
                            id_server=user_data.id_server,
                            id_user=user_data.id_user)

        response = "You retrieve a {} from the community chest.".format(
            item_sought.get("name"))

        del item_sought

    else:
        if item_search:
            response = "There isn't one here."
        else:
            response = "{} which item? (check **{}**)".format(
                cmd.tokens[0], ewcfg.cmd_communitychest)

    return await fe_utils.send_message(
        cmd.client, cmd.message.channel,
        fe_utils.formatMessage(cmd.message.author, response))
async def take(cmd):
    user_data = EwUser(member=cmd.message.author)
    response = ""
    admin = 0
    if cmd.message.author.guild_permissions.administrator:
        admin = 1

    poi = poi_static.id_to_poi.get(user_data.poi)
    if poi.community_chest == None:
        response = "There is no community chest here."
        return await fe_utils.send_message(
            cmd.client, cmd.message.channel,
            fe_utils.formatMessage(cmd.message.author, response))
    else:
        if len(poi.factions) > 0 and user_data.faction not in poi.factions:
            response = "Get real, asshole. You haven't even enlisted into this gang yet, so it's not like they'd trust you with a key to their valubles."
            return await fe_utils.send_message(
                cmd.client, cmd.message.channel,
                fe_utils.formatMessage(cmd.message.author, response))

    multisnag = 1
    startparse = 1
    if cmd.tokens[1] == 'all':
        cmd.tokens[1] = '100'

    if cmd.tokens[1].isnumeric() and cmd.tokens_count > 2:
        startparse = 2
        multisnag = int(cmd.tokens[1])
        if multisnag > 100:
            multisnag = 100

    item_search = ewutils.flattenTokenListToString(cmd.tokens[startparse:])

    item_sought = bknd_item.find_item(
        item_search=item_search,
        id_user=poi.community_chest,
        id_server=cmd.guild.id if cmd.guild is not None else None,
        admin=admin)

    items_snagged = 0
    item_list = []
    item_cache = bknd_core.get_cache(obj_type="EwItem")

    if item_sought:
        item_search = ewutils.flattenTokenListToString(item_sought.get('name'))
        loop_sought = item_sought.copy()
        while multisnag > 0 and loop_sought is not None:
            if items_snagged == 0:
                inv_response = bknd_item.check_inv_capacity(
                    user_data=user_data,
                    item_type=loop_sought.get('item_type'),
                    return_strings=True,
                    pronoun="You")

                if inv_response != "":
                    return await fe_utils.send_message(
                        cmd.client, cmd.message.channel,
                        fe_utils.formatMessage(cmd.message.author,
                                               inv_response))

                list_items = bknd_item.inventory(
                    id_user=cmd.message.author.id,
                    id_server=cmd.guild.id,
                    item_type_filter=loop_sought.get('item_type'))

                if loop_sought.get('item_type') == ewcfg.it_food:
                    food_items = bknd_item.inventory(
                        id_user=cmd.message.author.id,
                        id_server=cmd.guild.id,
                        item_type_filter=ewcfg.it_food)

                    if user_data.get_food_capacity() - len(
                            food_items) < multisnag:
                        multisnag = user_data.get_food_capacity() - len(
                            food_items)
                        del food_items
                elif loop_sought.get('item_type') == ewcfg.it_weapon:
                    weapons_held = bknd_item.inventory(
                        id_user=cmd.message.author.id,
                        id_server=cmd.guild.id,
                        item_type_filter=ewcfg.it_weapon)

                    if user_data.life_state == ewcfg.life_state_corpse:
                        del weapons_held
                        response = "Ghosts can't hold weapons."
                        return await fe_utils.send_message(
                            cmd.client, cmd.message.channel,
                            fe_utils.formatMessage(cmd.message.author,
                                                   response))
                    elif user_data.get_weapon_capacity() - len(
                            weapons_held) < multisnag:
                        multisnag = user_data.get_weapon_capacity() - len(
                            weapons_held)
                        del weapons_held

                else:
                    other_items = bknd_item.inventory(
                        id_user=cmd.message.author.id,
                        id_server=user_data.id_server,
                        item_type_filter=loop_sought.get('item_type'))
                    if ewcfg.generic_inv_limit - len(other_items) < multisnag:
                        multisnag = ewcfg.generic_inv_limit - len(other_items)
                        del other_items

            items_snagged += 1
            multisnag -= 1

            bknd_item.give_item(id_item=loop_sought.get('id_item'),
                                id_server=user_data.id_server,
                                id_user=user_data.id_user)
            item_list.append(loop_sought.get('id_item'))

            cache_item = item_cache.get_entry(
                unique_vals={"id_item": loop_sought.get('id_item')})
            cache_item.update({'id_owner': cmd.message.author.id})
            item_cache.set_entry(data=cache_item)

            #loop_sought = bknd_item.find_item(item_search=item_search, id_user=poi.community_chest, id_server=cmd.guild.id if cmd.guild is not None else None, admin=admin)

            func = partial(
                bknd_item.find_item,
                item_search=item_search,
                id_user=poi.community_chest,
                id_server=cmd.guild.id if cmd.guild is not None else None,
                admin=admin)
            event_loop = asyncio.get_event_loop()
            loop_sought = await event_loop.run_in_executor(None, func)

        if items_snagged > 1:
            name_string = "{}(x{})".format(item_sought.get("name"),
                                           items_snagged)
        else:
            name_string = item_sought.get('name')

        response = "You retrieve a {} from the community chest.".format(
            name_string)

        del item_sought

    else:
        if item_search:
            response = "There isn't one here."
        else:
            response = "{} which item? (check **{}**)".format(
                cmd.tokens[0], ewcfg.cmd_communitychest)

    return await fe_utils.send_message(
        cmd.client, cmd.message.channel,
        fe_utils.formatMessage(cmd.message.author, response))
Beispiel #11
0
async def order_zine(cmd):
    user_data = EwUser(member=cmd.message.author)
    if user_data.life_state == ewcfg.life_state_shambler:
        response = "You lack the higher brain functions required to {}.".format(cmd.tokens[0])
        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

    poi = poi_static.id_to_poi.get(user_data.poi)

    if not poi.write_manuscript:
        response = "You can't buy zines here! Try going to the cafe. If you're looking for educational books, try the colleges. If you can't read, then you might want to try the comic shop."

    elif len(cmd.tokens) == 1:
        response = "Specify a zine to purchase. Find zine IDs with !browse."

    elif not bknd_item.check_inv_capacity(user_data=user_data, item_type=ewcfg.it_book):
        response = "You can't carry any more zines."

    else:
        if cmd.tokens[1].isdigit():
            id_book = int(cmd.tokens[1])

            if int_is_zine(id_book, cmd.guild.id):
                book = EwBook(id_book=id_book)
                accepted = True
                if book.genre == 3:
                    accepted = False
                    response = "THIS ZINE IS PORNOGRAPHY. CONFIRM THAT YOU ARE AT LEAST 18 YEARS OLD. **!accept** or **!refuse**"

                    await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

                    try:
                        message = await cmd.client.wait_for('message', timeout=20, check=lambda message: message.author == cmd.message.author and
                                                                                                         message.content.lower() in [ewcfg.cmd_accept, ewcfg.cmd_refuse])

                        if message != None:
                            if message.content.lower() == ewcfg.cmd_accept:
                                accepted = True
                            if message.content.lower() == ewcfg.cmd_refuse:
                                accepted = False
                    except:
                        accepted = False

                if not accepted:
                    response = "No p**n for you."

                elif accepted:
                    if book.genre != 10 and poi.id_poi == ewcfg.poi_id_clinicofslimoplasty:
                        response = "Specify a zine to purchase. Find zine IDs with !browse."
                        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

                    user_data = EwUser(member=cmd.message.author)

                    #if book.genre != 10:
                    #    price = ewcfg.zine_cost
                    #else:
                    #    price = ewcfg.zine_cost / 4

                    #if user_data.slimes < price:
                    poudrins = bknd_item.find_item(item_search="slimepoudrin", id_user=cmd.message.author.id, id_server=cmd.guild.id if cmd.guild is not None else None, item_type_filter=ewcfg.it_item)

                    if poudrins == None:
                        response = "YOU CAN'T AFFORD IT. YOU NEED A POUDRIN."

                    else:
                        bknd_item.item_create(
                            item_type=ewcfg.it_book,
                            id_user=user_data.id_user,
                            id_server=cmd.guild.id,
                            item_props={
                                "title": book.title,
                                "author": book.author,
                                "date_published": book.date_published,
                                "id_book": book.id_book,
                                "book_desc": "A book by {}, published on {}.".format(book.author, book.date_published)
                            })
                        book_sale = EwBookSale(id_book=book.id_book, member=cmd.message.author)

                        if book.id_user != user_data.id_user:
                            if book_sale.bought == 0:
                                book_sale.bought = 1
                                book.sales += 1
                                book_sale.persist()
                                book.persist()

                        bknd_item.item_delete(id_item=poudrins.get('id_item'))
                        #user_data.change_slimes(n=-(price), source=ewcfg.source_spending)

                        user_data.persist()

                        if book.genre != 10:
                            author = EwUser(id_user=book.id_user, id_server=book.id_server)

                            if author.id_user != user_data.id_user and bknd_item.check_inv_capacity(user_data=user_data, item_type=ewcfg.it_item):
                                bknd_item.item_create(
                                    item_type=ewcfg.it_item,
                                    id_user=author.id_user,
                                    id_server=cmd.guild.id,
                                    item_props={
                                        'context': 'poudrin',
                                        'item_name': 'Royalty Poudrin',
                                        'item_desc': 'You received this less powerful poudrin from some fool who decided to buy your zine. !crush it for 5k slime.',
                                        'id_item': 'royaltypoudrin'
                                    })

                        response = "You manage to locate {} by {} in the vast array of zines on the bookshelf, so you bring it to the counter and hand over {:,} slime to the employee. Now it's time to !read it.".format(book.title, book.author, ewcfg.zine_cost)

            else:
                response = "Specify a zine to purchase. Find zine IDs with !browse."

        else:
            response = "Specify a zine to purchase. Find zine IDs with !browse."

    await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
Beispiel #12
0
async def read_book(cmd):
    dm = cmd.message.guild is None

    user_data = EwUser(member=cmd.message.author)
    if user_data.life_state == ewcfg.life_state_shambler:
        response = "You lack the higher brain functions required to {}.".format(cmd.tokens[0])
        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

    if not dm:
        response = "ENDLESS WAR politely asks that you !read in his DMs."

    elif len(cmd.tokens) < 2:
        response = "What zine do you want to read?"

    else:
        if len(cmd.tokens) < 3:
            book_title = ewutils.flattenTokenListToString(cmd.tokens)
            page_number = 0
        else:
            book_title = ewutils.flattenTokenListToString(cmd.tokens[1:len(cmd.tokens) - 1])
            page_number = ewutils.getIntToken(cmd.tokens)

        book_sought = bknd_item.find_item(item_search=book_title, id_user=cmd.message.author.id, id_server=cmd.guild.id if cmd.guild is not None else None, item_type_filter=ewcfg.it_book)

        if book_sought:
            book = EwItem(id_item=book_sought.get('id_item'))
            id_book = book.item_props.get("id_book")
            book = EwBook(id_book=id_book)

            if page_number not in range(0, book.pages + 1):
                page_number = 0

            accepted = True
            if book.genre == 3:

                accepted = False
                response = "ENDLESS WAR sees you about to open up a p**n zine and wants to make sure you're 18 years or older. Use **!accept** to open or **!refuse** to abstain."

                await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

                try:
                    message = await cmd.client.wait_for('message', timeout=20, check=lambda message: message.author == cmd.message.author and
                                                                                                     message.content.lower() in [ewcfg.cmd_accept, ewcfg.cmd_refuse])

                    if message != None:
                        if message.content.lower() == ewcfg.cmd_accept:
                            accepted = True
                        if message.content.lower() == ewcfg.cmd_refuse:
                            accepted = False
                except:
                    accepted = False

            if book.book_state < 0:
                response = "You simply can't make out the letters on the page. Maybe it's better this way."

            elif accepted:
                page_contents = get_page(id_book, page_number)

                if page_number == 0 and page_contents == "":
                    page_contents = get_page(id_book, 1)

                page_text = "turn to page {}".format(page_number)

                if page_number == 0:
                    page_text = "look at the cover"

                response = "You {} and begin to read.\n\n\"{} \"".format(page_text, page_contents)
                readers[user_data.id_user] = (id_book, page_number)

                if page_contents == "":
                    response = "You open up to page {} only to find that it's blank!".format(page_number)

                if page_number != 0:
                    response += "\n\nUse **!previouspage** to go back one page."

                if page_number != book.pages:
                    response += "\n\nUse **!nextpage** to go forward one page."

            else:
                response = "You decide not to indulge yourself."

        else:
            response = "You don't have that zine. Make sure you use **!read [zine title] [page]**"

    await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
Beispiel #13
0
async def mill(cmd):
    user_data = EwUser(member=cmd.message.author)
    if user_data.life_state == ewcfg.life_state_shambler:
        response = "You lack the higher brain functions required to {}.".format(
            cmd.tokens[0])
        return await fe_utils.send_message(
            cmd.client, cmd.message.channel,
            fe_utils.formatMessage(cmd.message.author, response))

    market_data = EwMarket(id_server=user_data.id_server)
    item_search = ewutils.flattenTokenListToString(cmd.tokens[1:])
    item_sought = bknd_item.find_item(
        item_search=item_search,
        id_user=cmd.message.author.id,
        id_server=cmd.guild.id if cmd.guild is not None else None,
        item_type_filter=ewcfg.it_food)

    # Checking availability of milling
    if user_data.life_state != ewcfg.life_state_juvenile:
        response = "Only Juveniles of pure heart and with nothing better to do can mill their vegetables."
    elif cmd.message.channel.name not in [
            ewcfg.channel_jr_farms, ewcfg.channel_og_farms,
            ewcfg.channel_ab_farms
    ]:
        response = "Alas, there doesn’t seem to be an official SlimeCorp milling station anywhere around here. Probably because you’re in the middle of the f*****g city. Try looking where you reaped your vegetable in the first place, dumbass."

    # elif user_data.slimes < ewcfg.slimes_permill:
    # 	response = "It costs {} to !mill, and you only have {}.".format(ewcfg.slimes_permill, user_data.slimes)

    elif item_sought:
        poi = poi_static.id_to_poi.get(user_data.poi)
        district_data = EwDistrict(district=poi.id_poi,
                                   id_server=user_data.id_server)

        if district_data.is_degraded():
            response = "{} has been degraded by shamblers. You can't {} here anymore.".format(
                poi.str_name, cmd.tokens[0])
            return await fe_utils.send_message(
                cmd.client, cmd.message.channel,
                fe_utils.formatMessage(cmd.message.author, response))
        items = []
        vegetable = EwItem(id_item=item_sought.get('id_item'))

        for result in vendors.mill_results:
            if type(result.ingredients) == str:
                if vegetable.item_props.get('id_food') != result.ingredients:
                    pass
                else:
                    items.append(result)
            elif type(result.ingredients) == list:
                if vegetable.item_props.get(
                        'id_food') not in result.ingredients:
                    pass
                else:
                    items.append(result)

        if len(items) > 0:
            item = random.choice(items)

            item_props = itm_utils.gen_item_props(item)

            bknd_item.item_create(item_type=item.item_type,
                                  id_user=cmd.message.author.id,
                                  id_server=cmd.guild.id,
                                  item_props=item_props)

            response = "You walk up to the official ~~SlimeCorp~~ Garden Gankers Milling Station and shove your irradiated produce into the hand-crank. You begin slowly churning them into a glorious, pastry goo. As the goo tosses and turns inside the machine, it solidifies, and after a few moments a {} pops out!".format(
                item.str_name)

            # market_data.donated_slimes += ewcfg.slimes_permill
            market_data.persist()

            bknd_item.item_delete(id_item=item_sought.get('id_item'))
            # user_data.change_slimes(n = -ewcfg.slimes_permill, source = ewcfg.source_spending)
            # user_data.slime_donations += ewcfg.slimes_permill
            user_data.persist()
        else:
            response = "You can only mill fresh vegetables! SlimeCorp obviously wants you to support local farmers."

    else:
        if item_search:  # if they didn't forget to specify an item and it just wasn't found
            response = "You don't have one."
        else:
            response = "Mill which item? (check **!inventory**)"

    await fe_utils.send_message(
        cmd.client, cmd.message.channel,
        fe_utils.formatMessage(cmd.message.author, response))
Beispiel #14
0
async def rate_zine(cmd):
    if len(cmd.tokens) < 2:
        response = "What zine do you want to rate?"

    else:
        if len(cmd.tokens) >= 3:
            rating = ewutils.getIntToken(cmd.tokens)
            book_title = ewutils.flattenTokenListToString(cmd.tokens[1:len(cmd.tokens) - 1])

            if rating == None:
                response = "How many f***s do you want to give the zine? (1-5)"

            elif rating not in range(1, 6):
                response = "Easy now, keep your f***s between 1 and 5."

            else:
                book_sought = bknd_item.find_item(item_search=book_title, id_user=cmd.message.author.id, id_server=cmd.guild.id if cmd.guild is not None else None)

                if book_sought:
                    book_item = EwItem(id_item=book_sought.get('id_item'))
                    id_book = book_item.item_props.get("id_book")
                    book = EwBook(id_book=id_book)
                    sale = EwBookSale(id_book=id_book, member=cmd.message.author)

                    if sale.bought == 1:
                        if sale.rating == 0:
                            book.rates += 1
                        sale.rating = rating
                        sale.persist()
                        try:
                            conn_info = bknd_core.databaseConnect()
                            conn = conn_info.get('conn')
                            cursor = conn.cursor()

                            cursor.execute((
                                "SELECT {} FROM book_sales WHERE {} = %s AND {} = %s AND {} != 0".format(
                                    ewcfg.col_rating,
                                    ewcfg.col_id_server,
                                    ewcfg.col_id_user,
                                    ewcfg.col_rating,
                                )
                            ), (
                                cmd.guild.id,
                                cmd.message.author.id,
                            ))

                            data = cursor.fetchall()
                            ratings = []
                            total_rating = 0

                            if data != None:
                                for row in data:
                                    ratings.append(row)
                                    total_rating += row[0]

                        finally:
                            # Clean up the database handles.
                            cursor.close()
                            bknd_core.databaseClose(conn_info)

                        book.rating = str(total_rating / len(ratings))[:4]

                        # zine is excluded from normal browsing
                        if book.book_state == 1:
                            if book.rates >= 10 and float(book.rating) <= 2.0:
                                book.book_state = 2
                            elif book.rates >= 4 and float(book.rating) <= 1.5:
                                book.book_state = 2

                        # zine is included back into normal browsing
                        elif book.book_state == 2:
                            if float(book.rating) > 2.0 and book.rates > 10:
                                book.book_state = 1
                            elif float(book.rating) > 1.5 and book.rates > 5:
                                book.book_state = 1

                        book.persist()

                        response = "{}, you carve a {} into the back of the zine in order to indicate how many f***s you give about it.".format(ewcfg.rating_flavor[rating], rating)

                    else:
                        response = "You've never bought this book."

                else:
                    response = "You don't have that zine on you."
        else:
            response = "How many f***s do you want to give the zine? (1-5)"

    await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
Beispiel #15
0
async def barter(cmd):
    user_data = EwUser(member=cmd.message.author)
    mutations = user_data.get_mutations()

    if ewutils.channel_name_is_poi(cmd.message.channel.name) == False:
        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, "You must {} in a zone's channel.".format(cmd.tokens[0])))

    market_data = EwMarket(id_server=user_data.id_server)
    item_search = ewutils.flattenTokenListToString(cmd.tokens[1:])
    item_sought = bknd_item.find_item(item_search=item_search, id_user=cmd.message.author.id, id_server=cmd.guild.id if cmd.guild is not None else None)

    # Checking availability of appraisal
    # if market_data.clock < 8 or market_data.clock > 17:
    #	response = "You ask the bartender if he knows someone who would want to trade you something for your recently caught fish. Apparently, at night, an old commodore by the name of Captain Albert Alexander comes to drown his sorrows at this very tavern. You guess you’ll just have to sit here and wait for him, then."

    if cmd.message.channel.name != ewcfg.channel_speakeasy:
        if user_data.poi in poi_static.piers:
            response = 'You ask a nearby fisherman if he wants to trade you anything for this fish you just caught. He tells you to f**k off, but also helpfully informs you that there’s an old sea captain that frequents the Speakeasy that might be able to help you. What an inexplicably helpful/grouchy fisherman!'
        else:
            response = 'What random passerby is going to give two shits about your fish? You’ll have to consult a fellow fisherman… perhaps you’ll find some on a pier?'
        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

    if user_data.life_state == ewcfg.life_state_corpse:
        response = 'Captain Albert Alexander hits the table with his glass and shouts "Nay laddy, you can fool me once but not twice! I dont do deals with spirits, get out of my sight!"'
        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

    elif item_sought:

        name = item_sought.get('name')
        fish = EwItem(id_item=item_sought.get('id_item'))
        id_fish = fish.id_item
        # str_fish = fish.item_props.get('str_name')
        item_props = fish.item_props
        acquisition = item_props.get('acquisition')
        response = "You approach a man of particularly swashbuckling appearance, adorned in an old sea captain's uniform and bicorne cap, and surrounded by empty glass steins. You ask him if he is Captain Albert Alexander and he replies that he hasn’t heard that name in a long time. You submit your {} for bartering".format(name)

        if acquisition != ewcfg.acquisition_fishing:
            response += '. \n"Have you lost yer mind, laddy? That’s not a fish!! Just what’re you trying to pull??"'

        else:
            value = int(item_props['value'])

            items = []

            # Filters out all non-generic items without the current fish as an ingredient.
            for result in vendors.appraise_results:
                if result.ingredients == fish.item_props.get('id_item') or result.ingredients == "generic" and result.acquisition == ewcfg.acquisition_bartering:  # Generic means that it can be made with any fish.
                    items.append(result)
                else:
                    pass

            # Filters out items of greater value than your fish.
            for value_filter in items:
                if value < value_filter.context:
                    items.remove(value_filter)
                else:
                    pass

            else:
                offer = EwOffer(
                    id_server=cmd.guild.id,
                    id_user=cmd.message.author.id,
                    offer_give=id_fish
                )

                cur_time_min = time.time() / 60
                time_offered = cur_time_min - offer.time_sinceoffer

                if offer.time_sinceoffer > 0 and time_offered < ewcfg.fish_offer_timeout:
                    offer_receive = str(offer.offer_receive)

                    if offer_receive.isdigit() == True and ewcfg.mutation_id_onemansjunk in mutations:
                        item = random.choice(items)

                        if hasattr(item, 'id_item'):
                            offer.offer_receive = item.id_item

                        if hasattr(item, 'id_food'):
                            offer.offer_receive = item.id_food

                        if hasattr(item, 'id_cosmetic'):
                            offer.offer_receive = item.id_cosmetic

                        response = '\n"Well, back again I see! That fish certainly looked better the last time I saw it. Best I’ll do is trade ya a {} for your {}."'.format(item.str_name, name)
                    elif offer_receive.isdigit() == True:
                        slime_gain = int(offer.offer_receive)

                        response = '\n"Well, back again I see! My offer still stands, I’ll trade ya {} slime for your {}"'.format(slime_gain, name)

                    elif ewcfg.mutation_id_davyjoneskeister in mutations and item_props.get('noslime') != "true":
                        max_value = value * 6000  # 600,000 slime for a colossal promo fish, 120,000 for a miniscule common fish.
                        min_value = max_value / 10  # 60,000 slime for a colossal promo fish, 12,000 for a miniscule common fish.

                        slime_gain = round(random.triangular(min_value, max_value, min_value * 2))

                        offer.offer_receive = slime_gain
                        offer.persist()
                        response = '\n"You know what, laddy? I like the cut of your jib. I\'ll change my offer. How about {} slime for your {}?"'.format(slime_gain, name)

                    else:
                        for result in vendors.appraise_results:
                            if hasattr(result, 'id_item'):
                                if result.id_item != offer.offer_receive:
                                    pass
                                else:
                                    item = result

                            if hasattr(result, 'id_food'):
                                if result.id_food != offer.offer_receive:
                                    pass
                                else:
                                    item = result

                            if hasattr(result, 'id_cosmetic'):
                                if result.id_cosmetic != offer.offer_receive:
                                    pass
                                else:
                                    item = result

                        response = '\n"Well, back again I see! My offer still stands, I’ll trade ya a {} for your {}"'.format(item.str_name, name)

                    response += "\n**!accept** or **!refuse** Captain Albert Alexander's deal."

                    await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

                else:
                    # Random choice between 0, 1, and 2
                    offer_decision = random.randint(0, 2)

                    if (offer_decision != 2 or ewcfg.mutation_id_davyjoneskeister in mutations) and item_props.get('noslime') != "true" and ewcfg.mutation_id_onemansjunk not in mutations:  # If Captain Albert Alexander wants to offer you slime for your fish. 66% chance.
                        max_value = value * 6000  # 600,000 slime for a colossal promo fish, 120,000 for a miniscule common fish.
                        min_value = max_value / 10  # 60,000 slime for a colossal promo fish, 12,000 for a miniscule common fish.

                        slime_gain = round(random.triangular(min_value, max_value, min_value * 2))

                        offer.offer_receive = slime_gain

                        response = '"Hm, alright… for this {}... I’ll offer you {} slime! Trust me, you’re not going to get a better deal anywhere else, laddy."'.format(name, slime_gain)

                    else:  # If Captain Albert Alexander wants to offer you an item for your fish. 33% chance. Once there are more unique items, we'll make this 50%.
                        item = random.choice(items)

                        if hasattr(item, 'id_item'):
                            offer.offer_receive = item.id_item

                        if hasattr(item, 'id_food'):
                            offer.offer_receive = item.id_food

                        if hasattr(item, 'id_cosmetic'):
                            offer.offer_receive = item.id_cosmetic

                        response = '"Hm, alright… for this {}... I’ll offer you a {}! Trust me, you’re not going to get a better deal anywhere else, laddy."'.format(name, item.str_name)

                    offer.time_sinceoffer = int(time.time() / 60)
                    offer.persist()

                    response += "\n**!accept** or **!refuse** Captain Albert Alexander's deal."

                    await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

                # Wait for an answer
                accepted = False

                try:
                    message = await cmd.client.wait_for('message', timeout=20, check=lambda message: message.author == cmd.message.author and
                                                                                                     message.content.lower() in [ewcfg.cmd_accept, ewcfg.cmd_refuse])

                    if message != None:
                        if message.content.lower() == ewcfg.cmd_accept:
                            accepted = True
                        if message.content.lower() == ewcfg.cmd_refuse:
                            accepted = False
                except:
                    accepted = False

                offer = EwOffer(
                    id_server=cmd.guild.id,
                    id_user=cmd.message.author.id,
                    offer_give=id_fish
                )

                user_data = EwUser(member=cmd.message.author)
                fish = EwItem(id_item=id_fish)

                # cancel deal if fish is no longer in user's inventory
                if fish.id_owner != str(user_data.id_user):
                    accepted = False

                # cancel deal if the user has left Vagrant's Corner
                if user_data.poi != ewcfg.poi_id_speakeasy:
                    accepted = False

                # cancel deal if the offer has been deleted
                if offer.time_sinceoffer == 0:
                    accepted = False

                if accepted == True:
                    offer_receive = str(offer.offer_receive)

                    response = ""

                    if offer_receive.isdigit() == True:
                        slime_gain = int(offer_receive)

                        user_initial_level = user_data.slimelevel

                        levelup_response = user_data.change_slimes(n=slime_gain, source=ewcfg.source_fishing)

                        was_levelup = True if user_initial_level < user_data.slimelevel else False

                        # Tell the player their slime level increased.
                        if was_levelup:
                            response += levelup_response
                            response += "\n\n"

                    else:
                        item_props = itm_utils.gen_item_props(item)

                        bknd_item.item_create(
                            item_type=item.item_type,
                            id_user=cmd.message.author.id,
                            id_server=cmd.guild.id,
                            item_props=item_props
                        )

                    bknd_item.item_delete(id_item=item_sought.get('id_item'))

                    user_data.persist()

                    offer.deal()

                    response += '"Pleasure doing business with you, laddy!"'

                else:
                    response = '"Ah, what a shame. Maybe you’ll change your mind in the future…?"'

    else:
        if item_search:  # If they didn't forget to specify an item and it just wasn't found.
            response = "You don't have one."
        else:
            response = "Offer Captain Albert Alexander which fish? (check **!inventory**)"

    await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
Beispiel #16
0
async def cast(cmd):
    time_now = round(time.time())
    has_reeled = False
    user_data = EwUser(member=cmd.message.author)
    mutations = user_data.get_mutations()

    if ewutils.channel_name_is_poi(cmd.message.channel.name) == False:
        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, "You must {} in a zone's channel.".format(cmd.tokens[0])))

    market_data = EwMarket(id_server=cmd.message.author.guild.id)
    statuses = user_data.getStatusEffects()

    if cmd.message.author.id not in fishutils.fishers.keys():
        fishutils.fishers[cmd.message.author.id] = EwFisher()

    fisher = fishutils.fishers[cmd.message.author.id]

    # Ghosts cannot fish.
    if user_data.life_state == ewcfg.life_state_corpse:
        response = "You can't fish while you're dead. Try {}.".format(ewcfg.cmd_revive)

    # Players who are already cast a line cannot cast another one.
    elif fisher.fishing == True:
        response = "You've already cast a line."

    # Only fish at The Pier
    elif user_data.poi in poi_static.piers:
        poi = poi_static.id_to_poi.get(user_data.poi)
        district_data = EwDistrict(district=poi.id_poi, id_server=user_data.id_server)

        rod_possession = user_data.get_possession('rod')
        if rod_possession:
            fisher.inhabitant_id = rod_possession[0]

        elif user_data.hunger >= user_data.get_hunger_max():
            response = "You're too hungry to fish right now."
        elif (not fisher.inhabitant_id) and (poi.id_poi == ewcfg.poi_id_blackpond):
            response = "You cast your fishing line into the pond, but your hook bounces off its black waters like hard concrete."
        else:
            has_fishingrod = False

            if user_data.weapon >= 0:
                weapon_item = EwItem(id_item=user_data.weapon)
                weapon = static_weapons.weapon_map.get(weapon_item.item_props.get("weapon_type"))
                if weapon.id_weapon == "fishingrod":
                    has_fishingrod = True

            if ewcfg.status_high_id in statuses:
                fisher.high = True
            fisher.fishing = True
            fisher.bait = False
            fisher.bait_id = 0
            fisher.pier = poi
            fisher.current_fish = gen_fish(market_data, fisher, has_fishingrod)

            high_value_bait_used = False

            # global fishing_counter
            fishutils.fishing_counter += 1
            current_fishing_id = fisher.fishing_id = fishutils.fishing_counter

            item_search = ewutils.flattenTokenListToString(cmd.tokens[1:])
            author = cmd.message.author
            server = cmd.guild

            item_sought = bknd_item.find_item(item_search=item_search, id_user=author.id, id_server=server.id)

            if item_sought:
                item = EwItem(id_item=item_sought.get('id_item'))

                if item.item_type == ewcfg.it_food:

                    str_name = item.item_props['food_name']
                    id_food = item.item_props.get('id_food')
                    fisher.bait = True

                    if id_food in static_food.plebe_bait:
                        fisher.current_fish = "plebefish"

                    elif id_food == "doublestuffedcrust":
                        if random.randrange(5) == 3:
                            fisher.current_fish = "doublestuffedflounder"

                    elif id_food in ["chickenbucket", "familymeal"]:
                        if random.randrange(5) == 3:
                            fisher.current_fish = "seacolonel"

                    elif id_food in ["steakvolcanoquesomachorito", "nachosupreme"]:
                        if random.randrange(5) == 3:
                            fisher.current_fish = "marlinsupreme"

                    elif id_food in "blacklimesour":
                        if random.randrange(2) == 1:
                            fisher.current_fish = "blacklimesalmon"

                    elif id_food in "pinkrowdatouille":
                        if random.randrange(2) == 1:
                            fisher.current_fish = "thrash"

                    elif id_food in "purplekilliflowercrustpizza":
                        if random.randrange(2) == 1:
                            fisher.current_fish = "dab"

                    elif id_food == "kingpincrab":
                        if random.randrange(5) == 1:
                            fisher.current_fish = "uncookedkingpincrab"

                    elif id_food == "masterbait":
                        high_value_bait_used = True

                    elif id_food == "ferroslimeoid":
                        fisher.current_fish = "seaitem"

                    elif float(item.time_expir if item.time_expir is not None else 0) < time.time():
                        if random.randrange(2) == 1:
                            fisher.current_fish = "plebefish"
                    fisher.bait_id = item_sought.get('id_item')

            if fisher.current_fish == "item":
                fisher.current_size = "item"

            else:
                mastery_bonus = 0
                # Git gud.
                if has_fishingrod:
                    mastery_bonus += user_data.weaponskill - 4 #
                else:
                    mastery_bonus += -4
                
                if rod_possession:
                    mastery_bonus += 1

                mastery_bonus = max(0, mastery_bonus)

                fisher.length = gen_fish_size(mastery_bonus)
                fisher.current_size = length_to_size(fisher.length)

            if fisher.bait == False:
                response = "You cast your fishing line into the "
            else:
                response = "You attach your {} to the hook as bait and then cast your fishing line into the ".format(str_name)

            if fisher.pier.pier_type == ewcfg.fish_slime_saltwater:
                response += "vast Slime Sea."
            elif fisher.pier.pier_type == ewcfg.fish_slime_freshwater:
                response += "glowing Slime Lake."
            elif fisher.pier.pier_type == ewcfg.fish_slime_void:
                response += "pond's black waters."

            user_data.hunger += ewcfg.hunger_perfish * ewutils.hunger_cost_mod(user_data.slimelevel)
            user_data.persist()

            await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

            bite_text = gen_bite_text(fisher.current_size)

            # User has a 1/10 chance to get a bite
            fun = 100

            if fisher.bait == True:
                # Bait attatched, chance to get a bite increases from 1/10 to 1/7
                fun -= 30
            if fisher.pier == ewcfg.poi_id_ferry:
                # Fisher is on the ferry, chance to get a bite increases from 1/10 to 1/9
                fun -= 10
            if ewcfg.mutation_id_lucky in mutations:
                fun -= 20
            if fisher.inhabitant_id:
                # Having your rod possessed increases your chance to get a bite by 50%
                fun = int(fun // 2)
            if high_value_bait_used:
                fun = 5

            bun = 0

            while not ewutils.TERMINATE:

                if fun <= 0:
                    fun = 1
                else:
                    damp = random.randrange(fun)

                if fisher.high:
                    await asyncio.sleep(30)
                elif high_value_bait_used:
                    await asyncio.sleep(5)
                else:
                    await asyncio.sleep(60)

                # Cancel if fishing was interrupted
                if current_fishing_id != fisher.fishing_id:
                    return
                if fisher.fishing == False:
                    return

                user_data = EwUser(member=cmd.message.author)

                if fisher.pier == "" or user_data.poi != fisher.pier.id_poi:
                    fisher.stop()
                    return
                if user_data.life_state == ewcfg.life_state_corpse:
                    fisher.stop()
                    return

                if damp > 10:
                    await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, random.choice(comm_cfg.void_fishing_text if fisher.pier.pier_type == ewcfg.fish_slime_void else comm_cfg.normal_fishing_text)))
                    fun -= 2
                    bun += 1
                    if bun >= 5:
                        fun -= 1
                    if bun >= 15:
                        fun -= 1
                    continue
                else:
                    break

            fisher.bite = True
            await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, bite_text))

            await asyncio.sleep(8)

            if fisher.bite != False:
                response = "The fish got away..."
                response += cancel_rod_possession(fisher, user_data)
                fisher.stop()
                return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
            else:
                has_reeled = True

    else:
        response = "You can't fish here. Go to a pier."

    # Don't send out a response if the user actually reeled in a fish, since that gets sent by the reel command instead.
    if has_reeled == False:
        await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
Beispiel #17
0
async def incubate_negaslimeoid(cmd):
    user_data = EwUser(member=cmd.message.author)
    slimeoid_data = EwSlimeoid(member=cmd.message.author)

    # Check for if the player is a corpse
    if user_data.life_state != ewcfg.life_state_corpse:
        if cmd.message.channel.name == ewcfg.channel_wafflehouse:
            response = "You feel as though there is some ancient power here, but the slime coursing through your veins prevents you from using it."
        else:
            response = "Huh? What'd you say?"

    # Check for if the player is at Waffle House
    elif cmd.message.channel.name != ewcfg.channel_wafflehouse:
        response = "You can't exactly summon anything in {}. Go to Waffle House first.".format(
            cmd.message.channel.name)

    # Check if the player already has a Slimeoid or a Negaslimeoid.
    elif slimeoid_data.life_state == ewcfg.slimeoid_state_active:
        if slimeoid_data.sltype == ewcfg.sltype_nega:
            response = "You already have a Negaslimeoid by your side. Destroy your current Negaslimeoid before you commune with the Ancient Ones yet again."
        else:
            response = "You wish to summon a Negaslimeoid, yet you have a Slimeoid that still calls you its master. !destroyslimeoid if you wish to commune with the Ancient Ones properly."

    # Check if the player is already incubating a Slimeoid or Negaslimeoid
    elif slimeoid_data.life_state == ewcfg.slimeoid_state_forming:
        if slimeoid_data.sltype == ewcfg.sltype_nega:
            response = "You are already in the process of conjuring a Negaslimeoid."
        else:
            response = "You wish to summon a Negaslimeoid, yet you have a Slimeoid that is still yet to call you its master. !destroyslimeoid if you wish to commune with the Ancient Ones properly."

    else:

        #Check if player has too many slimeoids
        slimeoid_count = get_slimeoid_count(user_id=cmd.message.author.id,
                                            server_id=cmd.guild.id)

        if slimeoid_count >= 3:
            response = "You have too many slimeoids."
            # Go to final response

        else:
            #Check if player has a negapoudrin
            negapoudrin = bknd_item.find_item(
                item_search=ewcfg.item_id_negapoudrin,
                id_user=cmd.message.author.id,
                id_server=cmd.guild.id if cmd.guild is not None else None,
                item_type_filter=ewcfg.it_item)
            if negapoudrin is None:
                response = "You need a negapoudrin to bind a Negaslimeoid to your command."
                # Go to final response

            else:
                # Get argument for how big the negaslimeoid should be made
                sacrificed_negaslime = None
                if cmd.tokens_count > 1:
                    # -1 from getIntToken() could possibly be gotten from player input, so do a check here.
                    if cmd.tokens[1] == "all":
                        if user_data.slimes < 0:
                            sacrificed_negaslime = -user_data.slimes

                    else:
                        print(cmd.tokens[0])
                        sacrificed_negaslime = ewutils.getIntToken(
                            tokens=cmd.tokens)
                        if sacrificed_negaslime < 0:
                            sacrificed_negaslime = -sacrificed_negaslime

                # Check if player sacrificed any negaslime or if they have enough to sacrifice.
                if sacrificed_negaslime == None:
                    response = "You must sacrifice your own negaslime to conjure a Negaslimeoid. Specify how much negaslime you will sacrifice."
                    # Go to final response

                elif -sacrificed_negaslime < user_data.slimes:
                    response = "You do not have that much negaslime to sacrifice."
                    # Go to final response

                else:
                    # delete a negapoudrin from the player's inventory
                    bknd_item.item_delete(id_item=negapoudrin.get('id_item'))

                    # Remove negaslime
                    user_data.change_slimes(n=+sacrificed_negaslime)

                    # Establish these stats for conjuring the negaslimeoid
                    level = len(str(sacrificed_negaslime))
                    slimeoid_data.life_state = ewcfg.slimeoid_state_forming
                    slimeoid_data.level = level
                    slimeoid_data.sltype = ewcfg.sltype_nega
                    slimeoid_data.hue = ewcfg.hue_id_negative
                    slimeoid_data.id_user = str(user_data.id_user)
                    slimeoid_data.id_server = user_data.id_server

                    # Save changes
                    slimeoid_data.persist()
                    user_data.persist()

                    response = "Floating in front of the Ouija® Board, you place both of your ghastly appendages on the planchette. {sacrificed_negaslime:,} negaslime rises from your body, flowing towards your negapoudrin. The negapoudrin appears to lift into the air, held up by a pool of rising negaslime. Whispers awake around you, indiscernible and unknowable. It feels as though the planchette beneath your ghastly fingers has more than one set of hands on it. \n\nThe conjuration of a Negaslimeoid has begun! {negaslime_emote}".format(
                        sacrificed_negaslime=sacrificed_negaslime,
                        negaslime_emote=ewcfg.emote_negaslime)
                    # Go to final response

    # Final response
    await send_response(response, cmd)
Beispiel #18
0
async def appraise(cmd):
    user_data = EwUser(member=cmd.message.author)

    if ewutils.channel_name_is_poi(cmd.message.channel.name) == False:
        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, "You must {} in a zone's channel.".format(cmd.tokens[0])))

    market_data = EwMarket(id_server=user_data.id_server)
    item_search = ewutils.flattenTokenListToString(cmd.tokens[1:])
    item_sought = bknd_item.find_item(item_search=item_search, id_user=cmd.message.author.id, id_server=cmd.guild.id if cmd.guild is not None else None)
    payment = bknd_item.find_item(item_search="manhattanproject", id_user=cmd.message.author.id, id_server=cmd.guild.id if cmd.guild is not None else None, item_type_filter=ewcfg.it_food)

    # Checking availability of appraisal
    # if market_data.clock < 8 or market_data.clock > 17:
    #	response = "You ask the bartender if he knows someone who would want to trade you something for your recently caught fish. Apparently, at night, an old commodore by the name of Captain Albert Alexander comes to drown his sorrows at this very tavern. You guess you’ll just have to sit here and wait for him, then."

    if cmd.message.channel.name != ewcfg.channel_speakeasy:
        if user_data.poi in poi_static.piers:
            response = 'You ask a nearby fisherman if he could appraise this fish you just caught. He tells you to f**k off, but also helpfully informs you that there’s an old sea captain that frequents the Speakeasy that might be able to help you. What an inexplicably helpful/grouchy fisherman!'
        else:
            response = 'What random passerby is going to give two shits about your fish? You’ll have to consult a fellow fisherman… perhaps you’ll find some on a pier?'
        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
    elif item_sought:
        name = item_sought.get('name')
        fish = EwItem(id_item=item_sought.get('id_item'))
        item_props = fish.item_props
        # str_fish = fish.item_props.get('str_name')
        # id_fish = item_props['id_food']
        acquisition = item_props.get('acquisition')

        response = "You approach a man of particularly swashbuckling appearance, adorned in an old sea captain's uniform and bicorne cap, and surrounded by empty glass steins. You ask him if he is Captain Albert Alexander and he replies that he hasn’t heard that name in a long time. You submit your {} for appraisal".format(name)

        if acquisition != ewcfg.acquisition_fishing:
            response += '. \n"Have you lost yer mind, laddy? That’s not a fish!! Just what’re you trying to pull??"'.format(name)

        else:

            if payment == None:
                response += ", but he says he won’t provide his services for free... but, if you bring him a Manhattan Project, you might be able to get an appraisal."

            else:
                item_props = fish.item_props
                rarity = item_props['rarity']
                size = item_props['size']
                value = int(item_props['value'])

                response += ' and offer him a Manhattan Project as payment. \n"Hm, alright, let’s see here...'

                if rarity == ewcfg.fish_rarity_common:
                    response += "Ah, a {}, that’s a pretty common fish... ".format(name)

                if rarity == ewcfg.fish_rarity_uncommon:
                    response += "Interesting, a {}, that’s a pretty uncommon fish you’ve got there... ".format(name)

                if rarity == ewcfg.fish_rarity_rare:
                    response += "Amazing, it’s a {}! Consider yourself lucky, that’s a pretty rare fish! ".format(name)

                if rarity == ewcfg.fish_rarity_promo:
                    response += "Shiver me timbers, is that a {}?? Unbelievable, that’s an extremely rare fish!! It was only ever released as a promotional item in Japan during the late ‘90s. ".format(name)

                if size == ewcfg.fish_size_miniscule:
                    response += "Or, is it just a speck of dust? Seriously, that {} is downright miniscule! ".format(name)

                if size == ewcfg.fish_size_small:
                    response += "Hmmm, it’s a little small, don’t you think? "

                if size == ewcfg.fish_size_average:
                    response += "It’s an average size for the species. "

                if size == ewcfg.fish_size_big:
                    response += "Whoa, that’s a big one, too! "

                if size == ewcfg.fish_size_huge:
                    response += "Look at the size of that thing, it’s huge! "

                if size == ewcfg.fish_size_colossal:
                    response += "By Neptune’s beard, what a sight to behold, this {name} is absolutely colossal!! In all my years in the Navy, I don’t think I’ve ever seen a {name} as big as yours!! ".format(name=name)

                response += "So, I’d say this fish "

                if value <= 20:
                    response += 'is absolutely worthless."'

                if value <= 40 and value >= 21:
                    response += 'isn’t worth very much."'

                if value <= 60 and value >= 41:
                    response += 'is somewhat valuable."'

                if value <= 80 and value >= 61:
                    response += 'is highly valuable!"'

                if value <= 99 and value >= 81:
                    response += 'is worth a fortune!!"'

                if value >= 100:
                    response += 'is the most magnificent specimen I’ve ever seen!"'

                bknd_item.item_delete(id_item=payment.get('id_item'))

                user_data.persist()
    else:
        if item_search:  # If they didn't forget to specify an item and it just wasn't found.
            response = "You don't have one."

        else:
            response = "Ask Captain Albert Alexander to appraise which fish? (check **!inventory**)"

    await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
async def devour(cmd):
    user_data = EwUser(member=cmd.message.author)
    item_search = ewutils.flattenTokenListToString(cmd.tokens[1:])
    item_sought = bknd_item.find_item(id_server=cmd.message.guild.id, id_user=cmd.message.author.id, item_search=item_search)
    mutations = user_data.get_mutations()
    is_brick = 0
    time_now = int(time.time())
    mutation_data = EwMutation(id_user=user_data.id_user, id_server=user_data.id_server, id_mutation=ewcfg.mutation_id_trashmouth)

    if len(mutation_data.data) > 0:
        time_lastuse = int(mutation_data.data)
    else:
        time_lastuse = 0


    if ewcfg.mutation_id_trashmouth not in mutations:
        response = "Wait, what? Quit trying to put everything in your mouth."
    elif item_sought:
        item_obj = EwItem(id_item=item_sought.get('id_item'))
        if time_lastuse + 60 > time_now:
            response = "You're still picking stuff out of your teeth from the last weird shit you ate. Try again in {} seconds.".format(time_lastuse + 60 - time_now)
        elif (item_obj.item_type not in [ewcfg.it_cosmetic, ewcfg.it_furniture, ewcfg.it_food] and item_obj.item_props.get('id_item') != 'slimepoudrin') or item_obj.item_props.get('id_cosmetic') == 'soul':
            response = "You swallow the {} whole, but after realizing this might be a mistake, you cough it back up.".format(item_sought.get('name'))
        elif item_obj.soulbound == True:
            response = "You attempt to consume the {}, but you realize it's soulbound and that you were about to eat your own existnece. Your life flashes before your eyes, so you decide to stop.".format(item_sought.get('name'))
        else:

            str_eat = "You unhinge your gaping maw and shove the {} right down, no chewing or anything. It's about as nutritious as you'd expect.".format(item_sought.get('name'))

            if item_obj.item_type == ewcfg.it_cosmetic:
                recover_hunger = 100
            elif item_obj.item_type == ewcfg.it_furniture:
                furn = static_items.furniture_map.get(item_obj.item_props.get('id_furniture'))
                acquisition = None
                if furn is not None:
                    acquisition = furn.acquisition
                    if furn.id_furniture == 'brick':
                        brickeat(item_obj=item_obj)
                        is_brick = 1
                        recover_hunger = 50
                        response = str_eat
                    elif acquisition != ewcfg.acquisition_bazaar:
                        recover_hunger = 100
                    elif furn.price < 500:
                        recover_hunger = 0
                    elif furn.price < 5000:
                        recover_hunger = 50
                    elif furn.price < 1000000:
                        recover_hunger = 320
                    else:
                        recover_hunger = 16000
                else:
                    # This only happens in the case of propstanded items, so we just set it to the lowest possible
                    recover_hunger = 50
            elif item_obj.item_type == ewcfg.it_food:
                if item_obj.item_props.get('perishable') != None:
                    perishable_status = item_obj.item_props.get('perishable')
                    if perishable_status == 'true' or perishable_status == '1':
                        item_is_non_perishable = False
                    else:
                        item_is_non_perishable = True
                else:
                    item_is_non_perishable = False

                user_has_spoiled_appetite = ewcfg.mutation_id_spoiledappetite in mutations
                item_has_expired = float(getattr(item_obj, "time_expir", 0)) < time.time()

                if item_has_expired and not (user_has_spoiled_appetite or item_is_non_perishable):
                    response = "You realize that the {} you were trying to eat is already spoiled. Ugh, not eating that.".format(item_sought.get('name'))
                    return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
                # ewitem.item_drop(food_item.id_item)

                recover_hunger = item_obj.item_props.get('recover_hunger')

            else:
                recover_hunger = 100

            item_obj.item_props = {
                'id_food': "convertedfood",
                'food_name': "",
                'food_desc': "",
                'recover_hunger': recover_hunger,
                'inebriation': 0,
                'str_eat': str_eat,
                'time_expir': time.time() + ewcfg.std_food_expir,
                'time_fridged': 0,
                'perishable': True,
            }
            if item_obj.item_type != ewcfg.it_food:
                mutation_data.data = '{}'.format(time_now)
            if is_brick == 0:
                response = user_data.eat(item_obj)
            user_data.persist()
    elif item_search == "":
        response = "Devour what?"
    else:
        response = "Are you sure you have that item?"
    return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
Beispiel #20
0
async def embiggen(cmd):
    user_data = EwUser(member=cmd.message.author)

    market_data = EwMarket(id_server=user_data.id_server)
    item_search = ewutils.flattenTokenListToString(cmd.tokens[1:])
    item_sought = bknd_item.find_item(item_search=item_search, id_user=cmd.message.author.id, id_server=cmd.guild.id if cmd.guild is not None else None)

    if cmd.message.channel.name != ewcfg.channel_slimeoidlab:
        response = "How are you going to embiggen your fish on the side of the street? You’ve got to see a professional for this, man. Head to the SlimeCorp Laboratory, they’ve got dozens of modern day magic potions ‘n shit over there."

    elif item_sought:
        name = item_sought.get('name')
        fish = EwItem(id_item=item_sought.get('id_item'))
        acquisition = fish.item_props.get('acquisition')

        if fish.item_props.get('id_furniture') == "singingfishplaque":

            poudrins_owned = itm_utils.find_item_all(item_search="slimepoudrin", id_user=user_data.id_user, id_server=user_data.id_server, item_type_filter=ewcfg.it_item)
            poudrin_amount = len(poudrins_owned)

            if poudrin_amount < 2:
                response = "You don't have the poudrins for it."
            else:
                for delete in range(2):
                    poudrin = poudrins_owned.pop()
                    bknd_item.item_delete(id_item=poudrin.get("id_item"))
                fish.item_props['id_furniture'] = "colossalsingingfishplaque"
                fish.item_props['furniture_look_desc'] = "There's a fake fish mounted on the wall. Hoo boy, it's a whopper."
                fish.item_props['furniture_place_desc'] = "You take a nail gun to the wall to force it to hold this fish. Christ,  this thing is your f*****g Ishmael. Er, Moby Dick. Whatever."
                fish.item_props['furniture_name'] = "colossal singing fish plaque"
                fish.item_props['furniture_desc'] = "You press the button on your gigantic plaque.\n***" + fish.item_props.get('furniture_desc')[38:-87].upper().replace(":NOTES:", ":notes:") + "***\nYou abruptly turn the fish off before you rupture an eardrum."
                fish.persist()
                response = "The elevator ride down to the embiggening ward feels like an eterninty. Are they going to find out the fish you're embiggening is fake? God, you hope not. But eventually, you make it down, and place the plaque in the usual reclined surgeon's chair. A stray spark from one of the defibrilators nearly gives you a heart attack. But even so, the embiggening process begins like usual. You sign the contract, and they take a butterfly needle to your beloved wall prop. And sure enough, it begins to grow. You hear the sounds of cracked plastic and grinding electronics, and catch a whiff of burnt wires. It's growing. It's 6 feet, no, 10 feet long. Good god. You were hoping for growth, but science has gone too far. Eventually, it stops. Although you raise a few eyebrows with ths anomaly, you still get back the colossal fish plaque without a hitch."
        elif acquisition != ewcfg.acquisition_fishing:
            response = "You can only embiggen fishes, dummy. Otherwise everyone would be walking around with colossal nunchucks and huge chicken buckets. Actually, that gives me an idea..."

        elif fish.item_props.get('embiggened') is not None:
            response = "After several minutes long elevator descents, in the depths of some basement level far below the laboratory's lobby, you lay down your {} on a reclined medical chair. An NLACU med student finishes the novel length terms of service they were reciting and asks you if you have any questions. You weren’t listening so you just tell them to get on with it so you can go back to haggling prices with Captain Albert Alexander. They oblige.\nThey grab a butterfly needle and carefully stab your fish with it, avoiding the rumbling tumors it's grown from its previous embiggening. All of a sudden, before the surgeon can inject, the {}'s heart rate monitor starts going f*****g nuts. The nurses begin to panic and duck behind equipment as the syringe flies out of the fish and sprays caustic rainbow goop over all the expensive machinery. Some of it lands on your pinky, and it expands into a second thumb. You are escorted out of the basement with a combination of fury and embarrassment.\n\nWelp, guess you can't embiggen the same fish twice. Too many...surgical complications.".format(
                name, name)
        else:
            size = fish.item_props.get('size')

            poudrin_cost = 0

            if size == ewcfg.fish_size_miniscule:
                poudrin_cost = 2

            if size == ewcfg.fish_size_small:
                poudrin_cost = 4

            if size == ewcfg.fish_size_average:
                poudrin_cost = 8

            if size == ewcfg.fish_size_big:
                poudrin_cost = 16

            if size == ewcfg.fish_size_huge:
                poudrin_cost = 32

            if size == ewcfg.fish_size_colossal:
                poudrin_cost = 32

            poudrins_owned = itm_utils.find_item_all(item_search="slimepoudrin", id_user=user_data.id_user, id_server=user_data.id_server, item_type_filter=ewcfg.it_item)
            poudrin_amount = len(poudrins_owned)

            if poudrin_cost == 0:
                response = "Your {} is already as colossal as a fish can get!".format(name)

            elif poudrin_amount < poudrin_cost:
                response = "You need {} poudrins to embiggen your {}, but you only have {}!!".format(poudrin_cost, name, poudrin_amount)

            else:
                if fish.item_props.get('length') is None:
                    fish.item_props['length'] = float((ewcfg.fish_size_range.get(fish.item_props.get('size'))[0] + ewcfg.fish_size_range.get(fish.item_props.get('size'))[1])/2)

                fish.item_props['length'] =  float(fish.item_props['length']) + random.randint(5 + poudrin_cost, 15 + poudrin_cost)

                fish.item_props['size'] = fishutils.length_to_size(size_number=float(fish.item_props['length']))
                fish.item_props['embiggened'] = 'illegal'

                fish.persist()

                for delete in range(poudrin_cost):
                    poudrin = poudrins_owned.pop()
                    bknd_item.item_delete(id_item=poudrin.get("id_item"))

                market_data.donated_poudrins += poudrin_cost
                market_data.persist()

                response = "After several minutes long elevator descents, in the depths of some basement level far below the laboratory's lobby, you lay down your {} on a reclined medical chair. An NLACU med student finishes the novel length terms of service they were reciting and asks you if you have any questions. You weren’t listening so you just tell them to get on with it so you can go back to haggling prices with Captain Albert Alexander. They oblige.\nThey grab a butterfly needle and carefully stab your fish with it, injecting filled with some bizarre, multi-colored serum you’ve never seen before. Sick, it’s bigger now!!".format(
                    name)

    else:
        if item_search:  # If they didn't forget to specify an item and it just wasn't found.
            response = "You don't have one."
        else:
            response = "Embiggen which fish? (check **!inventory**)"

    await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
Beispiel #21
0
async def smoke(cmd):
    usermodel = EwUser(member=cmd.message.author)
    # item_sought = bknd_item.find_item(item_search="cigarette", id_user=cmd.message.author.id, id_server=usermodel.id_server)
    item_sought = None
    space_adorned = 0

    item_seek = ewutils.flattenTokenListToString(cmd.tokens[1:])
    item = bknd_item.find_item(item_search=item_seek, id_user=cmd.message.author.id, id_server=cmd.guild.id)
    if item:
        if item.get('name') == debugsmoke:
            return await debug22(cmd=cmd)

    item_stash = bknd_item.inventory(id_user=cmd.message.author.id, id_server=usermodel.id_server)
    for item_piece in item_stash:
        item = EwItem(id_item=item_piece.get('id_item'))
        if item.item_props.get('adorned') == 'true':
            space_adorned += int(item.item_props.get('size'))

        if item_piece.get('item_type') == ewcfg.it_cosmetic and (item.item_props.get('id_cosmetic') == "cigarette" or item.item_props.get('id_cosmetic') == "cigar") and "lit" not in item.item_props.get('cosmetic_desc'):
            item_sought = item_piece

    if item_sought:
        item = EwItem(id_item=item_sought.get('id_item'))
        if item_sought.get('item_type') == ewcfg.it_cosmetic and item.item_props.get('id_cosmetic') == "cigarette":
            if int(item.item_props.get('size')) > 0:
                space_adorned += int(item.item_props.get('size'))

            usermodel.change_crime(n=ewcfg.cr_underage_smoking_points)
            response = "You light a cig and bring it to your mouth. So relaxing. So *cool*. All those naysayers and PSAs in Health class can go f**k themselves."
            item.item_props['cosmetic_desc'] = "A single lit cigarette sticking out of your mouth. You huff these things down in seconds but you’re never seen without one. Everyone thinks you’re really, really cool."
            if space_adorned < ewutils.max_adornspace_bylevel(usermodel.slimelevel):
                item.item_props['adorned'] = "true"
            item.persist()
            usermodel.persist()

            await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
            await asyncio.sleep(60)
            item = EwItem(id_item=item_sought.get('id_item'))

            response = "The cigarette fizzled out."

            item.item_props['cosmetic_desc'] = "It's a cigarette butt. What kind of hoarder holds on to these?"
            item.item_props['adorned'] = "false"
            item.item_props['id_cosmetic'] = "cigarettebutt"
            item.item_props['cosmetic_name'] = "cigarette butt"
            item.persist()



        elif item_sought.get('item_type') == ewcfg.it_cosmetic and item.item_props.get('id_cosmetic') == "cigar":
            if int(item.item_props['size']) > 0:
                space_adorned += int(item.item_props['size'])

            usermodel.change_crime(n=ewcfg.cr_underage_smoking_points)
            response = "You light up your stogie and bring it to your mouth. So relaxing. So *cool*. All those naysayers and PSAs in Health class can go f**k themselves."
            item.item_props['cosmetic_desc'] = "A single lit cigar sticking out of your mouth. These thing take their time to kick in, but it's all worth it to look like a supreme gentleman."
            if space_adorned < ewutils.max_adornspace_bylevel(usermodel.slimelevel):
                item.item_props['adorned'] = "true"

            item.persist()

            usermodel.persist()

            await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
            await asyncio.sleep(300)
            item = EwItem(id_item=item_sought.get('id_item'))

            response = "The cigar fizzled out."

            item.item_props['cosmetic_desc'] = "It's a cigar stump. It's seen better days."
            item.item_props['adorned'] = "false"
            item.item_props['id_cosmetic'] = "cigarstump"
            item.item_props['cosmetic_name'] = "cigar stump"
            item.persist()


        else:
            response = "You can't smoke that."
    else:
        response = "There aren't any usable cigarettes or cigars in your inventory."
    return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
Beispiel #22
0
async def sow(cmd):
    user_data = EwUser(member=cmd.message.author)
    if user_data.life_state == ewcfg.life_state_shambler:
        response = "You lack the higher brain functions required to {}.".format(
            cmd.tokens[0])
        return await fe_utils.send_message(
            cmd.client, cmd.message.channel,
            fe_utils.formatMessage(cmd.message.author, response))

    # check if the user has a farming tool equipped
    weapon_item = EwItem(id_item=user_data.weapon)
    weapon = static_weapons.weapon_map.get(
        weapon_item.item_props.get("weapon_type"))
    has_tool = False
    if weapon is not None:
        if ewcfg.weapon_class_farming in weapon.classes:
            has_tool = True

    # Checking availability of sow action
    if user_data.life_state != ewcfg.life_state_juvenile:
        response = "Only Juveniles of pure heart and with nothing better to do can farm."

    elif cmd.message.channel.name not in [
            ewcfg.channel_jr_farms, ewcfg.channel_og_farms,
            ewcfg.channel_ab_farms
    ]:
        response = "The cracked, filthy concrete streets around you would be a pretty terrible place for a farm. Try again on more arable land."

    else:
        poi = poi_static.id_to_poi.get(user_data.poi)
        district_data = EwDistrict(district=poi.id_poi,
                                   id_server=user_data.id_server)

        if district_data.is_degraded():
            response = "{} has been degraded by shamblers. You can't {} here anymore.".format(
                poi.str_name, cmd.tokens[0])
            return await fe_utils.send_message(
                cmd.client, cmd.message.channel,
                fe_utils.formatMessage(cmd.message.author, response))
        if user_data.poi == ewcfg.poi_id_jr_farms:
            farm_id = ewcfg.poi_id_jr_farms
        elif user_data.poi == ewcfg.poi_id_og_farms:
            farm_id = ewcfg.poi_id_og_farms
        else:  # if it's the farm in arsonbrook
            farm_id = ewcfg.poi_id_ab_farms

        farm = EwFarm(id_server=cmd.guild.id,
                      id_user=cmd.message.author.id,
                      farm=farm_id)

        if farm.time_lastsow > 0:
            response = "You’ve already sown something here. Try planting in another farming location. If you’ve planted in all three farming locations, you’re shit out of luck. Just wait, asshole."
        else:
            it_type_filter = None

            # gangsters can only plant poudrins
            if cmd.tokens_count > 1 and user_data.life_state == ewcfg.life_state_juvenile:
                item_search = ewutils.flattenTokenListToString(cmd.tokens[1:])

                # if the item selected was a vegetable, use a food only filter in find_item
                for v in static_food.vegetable_list:
                    if item_search in v.id_food or item_search in v.str_name:
                        it_type_filter = ewcfg.it_food
                        break
            else:
                item_search = "slimepoudrin"

            item_sought = bknd_item.find_item(
                item_search=item_search,
                id_user=cmd.message.author.id,
                id_server=cmd.guild.id if cmd.guild is not None else None,
                item_type_filter=it_type_filter)

            if item_sought == None:
                response = "You don't have anything to plant! Try collecting a poudrin."
            else:
                slimes_onreap = ewcfg.reap_gain
                item_data = EwItem(id_item=item_sought.get("id_item"))
                if item_data.item_type == ewcfg.it_item:
                    if item_data.item_props.get(
                            "id_item") == ewcfg.item_id_slimepoudrin:
                        vegetable = random.choice(static_food.vegetable_list)
                        slimes_onreap *= 2
                    elif item_data.item_props.get(
                            "context") == ewcfg.context_slimeoidheart:
                        vegetable = random.choice(static_food.vegetable_list)
                        slimes_onreap *= 2

                        slimeoid_data = EwSlimeoid(
                            id_slimeoid=item_data.item_props.get("subcontext"))
                        slimeoid_data.delete()

                    else:
                        response = "The soil has enough toxins without you burying your trash here."
                        return await fe_utils.send_message(
                            cmd.client, cmd.message.channel,
                            fe_utils.formatMessage(cmd.message.author,
                                                   response))
                elif item_data.item_type == ewcfg.it_food:
                    food_id = item_data.item_props.get("id_food")
                    vegetable = static_food.food_map.get(food_id)
                    if ewcfg.vendor_farm not in vegetable.vendors:
                        response = "It sure would be nice if {}s grew on trees, but alas they do not. Idiot.".format(
                            item_sought.get("name"))
                        return await fe_utils.send_message(
                            cmd.client, cmd.message.channel,
                            fe_utils.formatMessage(cmd.message.author,
                                                   response))
                    elif user_data.life_state != ewcfg.life_state_juvenile:
                        response = "You lack the knowledge required to grow {}.".format(
                            item_sought.get("name"))
                        return await fe_utils.send_message(
                            cmd.client, cmd.message.channel,
                            fe_utils.formatMessage(cmd.message.author,
                                                   response))

                else:
                    response = "The soil has enough toxins without you burying your trash here."
                    return await fe_utils.send_message(
                        cmd.client, cmd.message.channel,
                        fe_utils.formatMessage(cmd.message.author, response))

                mutations = user_data.get_mutations()
                growth_time = ewcfg.crops_time_to_grow
                if user_data.life_state == ewcfg.life_state_juvenile:
                    growth_time /= 2
                if ewcfg.mutation_id_greenfingers in mutations:
                    growth_time /= 1.5

                hours = int(growth_time / 60)
                minutes = int(growth_time % 60)

                str_growth_time = "{} hour{}{}".format(
                    hours, "s" if hours > 1 else "",
                    " and {} minutes".format(minutes) if minutes > 0 else "")

                # Sowing
                response = "You sow a {} into the fertile soil beneath you. It will grow in about {}.".format(
                    item_sought.get("name"), str_growth_time)

                farm.time_lastsow = int(time.time() /
                                        60)  # Grow time is stored in minutes.
                farm.time_lastphase = int(time.time())
                farm.slimes_onreap = slimes_onreap
                farm.crop = vegetable.id_food
                farm.phase = ewcfg.farm_phase_sow
                farm.action_required = ewcfg.farm_action_none
                farm.sow_life_state = user_data.life_state
                if ewcfg.mutation_id_greenfingers in mutations:
                    if user_data.life_state == ewcfg.life_state_juvenile:
                        farm.sow_life_state = ewcfg.farm_life_state_juviethumb
                    else:
                        farm.sow_life_state = ewcfg.farm_life_state_thumb

                bknd_item.item_delete(
                    id_item=item_sought.get('id_item'))  # Remove Poudrins

                farm.persist()

    await fe_utils.send_message(
        cmd.client, cmd.message.channel,
        fe_utils.formatMessage(cmd.message.author, response))
Beispiel #23
0
async def incubate_slimeoid(cmd):
    user_data = EwUser(member=cmd.message.author)
    slimeoid_data = EwSlimeoid(member=cmd.message.author)

    if cmd.message.channel.name != ewcfg.channel_slimeoidlab:
        response = "You must go to the NLACU Laboratories in Brawlden to create a Slimeoid."
        # Go to final response

    elif user_data.life_state == ewcfg.life_state_corpse:
        response = "Ghosts cannot interact with the NLACU Lab apparati."
        # Go to final response

    #TODO: change this because player can have more than one slimeoid now
    # this is f*****g brutal. poor slimeoid
    elif slimeoid_data.life_state == ewcfg.slimeoid_state_active:
        response = "You have already created a Slimeoid. Bottle or dissolve your current slimeoid before incubating a new one."
        # Go to final response

    elif slimeoid_data.life_state == ewcfg.slimeoid_state_forming:
        response = "You are already in the process of incubating a Slimeoid."
        # Go to final response

    else:

        #Check if player has too many slimeoids
        slimeoid_count = get_slimeoid_count(user_id=cmd.message.author.id,
                                            server_id=cmd.guild.id)

        if slimeoid_count >= 3:
            response = "You have too many slimeoids."
            # Go to final response

        else:
            #Check if player has a poudrin
            poudrin = bknd_item.find_item(
                item_search=ewcfg.item_id_slimepoudrin,
                id_user=cmd.message.author.id,
                id_server=cmd.guild.id if cmd.guild is not None else None,
                item_type_filter=ewcfg.it_item)
            if poudrin is None:
                response = "You need a slime poudrin."
                # Go to final response

            else:
                # Get arguement for how big the slimeoid should be made
                injected_slime = None
                if cmd.tokens_count > 1:
                    injected_slime = ewutils.getIntToken(tokens=cmd.tokens,
                                                         allow_all=True)
                    # -1 from getIntToken() means use all slime
                    if injected_slime == -1:
                        injected_slime = user_data.slimes

                if injected_slime == None:
                    response = "You must contribute some of your own slime to create a Slimeoid. Specify how much slime you will sacrifice."
                    # Go to final response

                elif injected_slime > user_data.slimes:
                    response = "You do not have that much slime to sacrifice."
                    # Go to final response

                else:
                    # delete a slime poudrin from the player's inventory
                    bknd_item.item_delete(id_item=poudrin.get('id_item'))

                    # Remove slime
                    user_data.change_slimes(n=-injected_slime)

                    # Setup gestating slimeoid
                    level = len(str(injected_slime))
                    slimeoid_data.life_state = ewcfg.slimeoid_state_forming
                    slimeoid_data.level = level
                    slimeoid_data.id_user = str(user_data.id_user)
                    slimeoid_data.id_server = user_data.id_server

                    # Save changes
                    slimeoid_data.persist()
                    user_data.persist()

                    response = "You place a poudrin into a small opening on the console. As you do, a needle shoots up and pricks your finger, intravenously extracting {injected_slime:,} slime from your body. The poudrin is then dropped into the gestation tank. Looking through the observation window, you see what was once your slime begin to seep into the tank and accrete around the poudrin. The incubation of a new Slimeoid has begun! {slime_emote}".format(
                        injected_slime=injected_slime,
                        slime_emote=ewcfg.emote_slime2)
                    # Go to final response

    # Final response
    await send_response(response, cmd)
Beispiel #24
0
async def donate(cmd):
    user_data = EwUser(member=cmd.message.author)
    if user_data.life_state == ewcfg.life_state_shambler:
        response = "You lack the higher brain functions required to {}.".format(cmd.tokens[0])
        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

    market_data = EwMarket(id_server=user_data.id_server)

    time_now = round(time.time())

    if user_data.poi == ewcfg.poi_id_slimecorphq:
        poi = poi_static.id_to_poi.get(user_data.poi)
        district_data = EwDistrict(district=poi.id_poi, id_server=user_data.id_server)

        if district_data.is_degraded():
            response = "{} has been degraded by shamblers. You can't {} here anymore.".format(poi.str_name, cmd.tokens[0])
            return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

        value = None
        if cmd.tokens_count > 1:
            value = ewutils.getIntToken(tokens=cmd.tokens, allow_all=True)

        if value != None:
            if value < 0:
                value = user_data.slimes
            if value <= 0:
                value = None

        if value != None and value < ewcfg.slimecoin_exchangerate:
            response = "You must volunteer to donate at least %d slime to receive compensation." % ewcfg.slimecoin_exchangerate

        elif value != None:
            # Amount of slime invested.
            cost_total = round(value)
            coin_total = round(value / ewcfg.slimecoin_exchangerate)

            if user_data.slimes < cost_total:
                response = "Acid-green flashes of light and bloodcurdling screams emanate from small window of SlimeCorp HQ. Unfortunately, you did not survive the procedure. Your body is dumped down a disposal chute to the sewers."
                market_data.donated_slimes += user_data.slimes
                market_data.persist()
                user_data.trauma = ewcfg.trauma_id_environment
                die_resp = user_data.die(cause=ewcfg.cause_donation)
                user_data.persist()
                # Assign the corpse role to the player. He dead.
                await ewrolemgr.updateRoles(client=cmd.client, member=cmd.message.author)
                await die_resp.post()
            else:
                # Do the transfer if the player can afford it.
                market_data.donated_slimes += cost_total
                market_data.persist()
                user_data.change_slimes(n=-cost_total, source=ewcfg.source_spending)
                user_data.change_slimecoin(n=coin_total, coinsource=ewcfg.coinsource_donation)
                user_data.slime_donations += cost_total

                # Persist changes
                user_data.persist()

                response = "You stumble out of a Slimecorp HQ vault room in a stupor. You don't remember what happened in there, but your body hurts and you've got {slimecoin:,} shiny new SlimeCoin in your pocket.".format(slimecoin=coin_total)

        else:
            response = ewcfg.str_exchange_specify.format(currency="slime", action="donate")

    elif user_data.poi == ewcfg.poi_id_slimeoidlab:
        poi = poi_static.id_to_poi.get(user_data.poi)
        district_data = EwDistrict(district=poi.id_poi, id_server=user_data.id_server)

        if district_data.is_degraded():
            response = "{} has been degraded by shamblers. You can't {} here anymore.".format(poi.str_name, cmd.tokens[0])
            return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

        poudrins = bknd_item.find_item(item_search="slimepoudrin", id_user=cmd.message.author.id, id_server=cmd.guild.id if cmd.guild is not None else None, item_type_filter=ewcfg.it_item)

        if poudrins == None:
            response = "You have to own a poudrin in order to donate a poudrin. Duh."

        else:
            bknd_item.item_delete(id_item=poudrins.get('id_item'))  # Remove Poudrins
            market_data.donated_poudrins += 1
            market_data.persist()
            user_data.poudrin_donations += 1
            user_data.persist()

            response = "You hand off one of your hard-earned poudrins to the front desk receptionist, who is all too happy to collect it. Pretty uneventful, but at the very least you’re glad donating isn’t physically painful anymore."

    else:
        response = "To donate slime, go to the SlimeCorp HQ in Downtown. To donate poudrins, go to the N.L.A.C.U. Lab in Brawlden."

    # Send the response to the player.
    await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
Beispiel #25
0
async def crush(cmd):
    member = cmd.message.author
    user_data = EwUser(member=member)
    response = ""  # if it's not overwritten
    crush_slimes = ewcfg.crush_slimes

    command = "crush"
    if cmd.tokens[0] == (ewcfg.cmd_prefix + 'crunch'):
        command = "crunch"

    if user_data.life_state == ewcfg.life_state_corpse:
        response = "Alas, your ghostly form cannot {} anything. Lame.".format(command)
        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

    item_search = ewutils.flattenTokenListToString(cmd.tokens[1:])
    item_sought = bknd_item.find_item(item_search=item_search, id_user=user_data.id_user, id_server=user_data.id_server)

    if item_sought:
        sought_id = item_sought.get('id_item')
        item_data = EwItem(id_item=sought_id)

        response = "The item doesn't have !{} functionality".format(command)  # if it's not overwritten

        if item_data.item_props.get("id_item") == ewcfg.item_id_slimepoudrin:
            # delete a slime poudrin from the player's inventory
            bknd_item.item_delete(id_item=sought_id)

            levelup_response = user_data.change_slimes(n=crush_slimes, source=ewcfg.source_crush)
            user_data.persist()

            response = "You {} the hardened slime crystal with your bare teeth.\nYou gain {} slime. Sick, dude!!".format(command, crush_slimes)

            if len(levelup_response) > 0:
                response += "\n\n" + levelup_response

        elif item_data.item_props.get("id_item") == ewcfg.item_id_royaltypoudrin:
            # delete a royalty poudrin from the player's inventory
            bknd_item.item_delete(id_item=sought_id)
            crush_slimes = 5000

            levelup_response = user_data.change_slimes(n=crush_slimes, source=ewcfg.source_crush)
            user_data.persist()

            response = "You {} your hard-earned slime crystal with your bare teeth.\nYou gain {} slime. Ah, the joy of writing!".format(command, crush_slimes)

            if len(levelup_response) > 0:
                response += "\n\n" + levelup_response

        elif item_data.item_props.get("id_food") in static_food.vegetable_to_cosmetic_material.keys():
            bknd_item.item_delete(id_item=sought_id)

            crop_name = item_data.item_props.get('food_name')
            # Turn the crop into its proper cosmetic material item.
            cosmetic_material_id = static_food.vegetable_to_cosmetic_material[item_data.item_props.get("id_food")]
            new_item = static_items.item_map.get(cosmetic_material_id)

            new_item_type = ewcfg.it_item
            if new_item != None:
                new_name = new_item.str_name
                new_item_props = itm_utils.gen_item_props(new_item)
            else:
                ewutils.logMsg("ERROR: !crunch failed to retrieve proper cosmetic material for crop {}.".format(item_data.item_props.get("id_food")))
                new_name = None
                new_item_props = None

            generated_item_id = bknd_item.item_create(
                item_type=new_item_type,
                id_user=cmd.message.author.id,
                id_server=cmd.guild.id,
                item_props=new_item_props
            )

            response = "You {} your {} in your mouth and spit it out to create some {}!!".format(command, crop_name, new_name)

        elif item_data.item_props.get("id_food") in static_food.candy_ids_list:

            bknd_item.item_delete(id_item=sought_id)
            item_name = item_data.item_props.get('food_name')

            if float(getattr(item_data, "time_expir", 0)) < time.time():
                response = "The {} melts disappointingly in your hand...".format(item_name)

            else:
                gristnum = random.randrange(2) + 1
                gristcount = 0

                response = "You crush the {} with an iron grip. You gain {} piece(s) of Double Halloween Grist!".format(item_name, gristnum)

                while gristcount < gristnum:
                    grist = static_items.item_map.get(ewcfg.item_id_doublehalloweengrist)
                    grist_props = itm_utils.gen_item_props(grist)

                    bknd_item.item_create(
                        item_type=grist.item_type,
                        id_user=cmd.message.author.id,
                        id_server=cmd.message.guild.id,
                        item_props=grist_props
                    )

                    gristcount += 1
        elif item_data.item_props.get("id_item") == ewcfg.item_id_negapoudrin:
            # delete a negapoudrin from the player's inventory
            bknd_item.item_delete(id_item=sought_id)
            crush_slimes = -1000000
            # kill player if they have less than 1 million slime
            if user_data.slimes < 1000000:
                user_data.die(cause=ewcfg.cause_suicide)
            # remove 1 million slime from the player
            else:
                levelup_response = user_data.change_slimes(n = crush_slimes, source = ewcfg.source_crush)
                user_data.persist()

                response = "You {} your hard-earned slime crystal with your bare teeth.\nAs the nerve endings in your teeth explode, you realize you bit into a negapoudrin! You writhe on the ground as slime gushes from all of your orifices.".format(command)
            
                if len(levelup_response) > 0:
                    response += "\n\n" + levelup_response	

    else:
        if item_search:  # if they didnt forget to specify an item and it just wasn't found
            response = "You don't have one."
        else:
            response = "{} which item? (check **!inventory**)".format(command)

    # Send the response to the player.
    await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
async def abduct(cmd):
    user_data = EwUser(member=cmd.message.author)
    item_sought = bknd_item.find_item(item_search='batterypack', id_user=cmd.message.author.id, id_server=cmd.guild.id)

    protected = False
    cosmetics = bknd_item.inventory(id_user=user_data.id_user, id_server=cmd.guild.id,
                                    item_type_filter=ewcfg.it_cosmetic)
    for cosmetic in cosmetics:
        cosmetic_data = EwItem(id_item=cosmetic.get('id_item'))
        if cosmetic_data.item_props.get('id_cosmetic') == 'skinsuit':
            if cosmetic_data.item_props.get('adorned') == 'true':
                protected = True

    shipstate = EwGamestate(id_server=user_data.id_server, id_state='shipstate')

    if user_data.poi != 'ufoufo':
        response = "Abduct what, dumbass? My patience?"
    elif not protected:
        response = "The aliens aren't gonna let you start the ship. You're basically their captive now."
    elif not ewcfg.dh_active or ewcfg.dh_stage != 3:
        response = "Wait, your alien espionage is waaaay out of season."
    elif cmd.mentions_count == 0:
        response = "Abduct who?"
    elif cmd.mentions_count > 1:
        response = "One victim at a time, please."
    elif shipstate.bit == 1:
        response = 'The ship\'s on the ground right now, it can\'t reach you.'

    else:
        if item_sought:
            target_data = EwUser(member = cmd.mentions[0])
            target_poi = poi_static.id_to_poi.get(target_data.poi)
            target_channel = fe_utils.get_channel(cmd.message.guild, target_poi.channel)

            if target_poi.id_poi == 'blackpond' or (
                        not target_poi.is_district and not target_poi.is_outskirts and not target_poi.is_pier and target_poi.id_poi not in [
                    ewcfg.poi_id_slimesendcliffs, ewcfg.poi_id_ferry, ewcfg.poi_id_sodafountain,
                    ewcfg.poi_id_stockexchange, ewcfg.poi_id_ab_farms, ewcfg.poi_id_og_farms, ewcfg.poi_id_jr_farms]):
                response = "The tractor beam on this ship sucks. You can't really see indoors."
                return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
            elif target_poi.id_poi in [ewcfg.poi_id_rowdyroughhouse, ewcfg.poi_id_copkilltown]:
                response = "Don't do that."
                return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

            bknd_item.item_delete(id_item=item_sought.get('id_item'))
            ewutils.moves_active[target_data.id_user] = 0
            response = 'You plug in your battery pack and begin to abduct {} They\'re 20 seconds away.'.format(cmd.mentions[0].display_name)
            await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

            await fe_utils.send_message(cmd.client, target_channel, fe_utils.formatMessage(cmd.mentions[0], "You are being abducted by aliens. The ship is 20 seconds away."))
            ewutils.active_restrictions[target_data.id_user] = 2
            await asyncio.sleep(20)

            ewutils.active_restrictions[target_data.id_user] = 0
            ewutils.moves_active[cmd.message.author.id] = 0
            target_data.poi = 'ufoufo'
            user_data.persist()
            target_data.persist()

            await ewrolemgr.updateRoles(client=ewutils.get_client(), member=cmd.mentions[0])
            await target_data.move_inhabitants(id_poi='ufoufo')


        else:
            response = "The going energy cost for abduction is pretty expensive these days. You better have a battery pack before you do something like that."

    return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
Beispiel #27
0
async def embark(cmd):
    # can only use movement commands in location channels
    if ewutils.channel_name_is_poi(cmd.message.channel.name) == False:
        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, "You must {} in a zone's channel.".format(cmd.tokens[0])))

    user_data = EwUser(member=cmd.message.author)
    poi = poi_static.id_to_poi.get(user_data.poi)
    district_data = EwDistrict(district=poi.id_poi, id_server=cmd.guild.id)

    if district_data.is_degraded():
        response = "{} has been degraded by shamblers. You can't {} here anymore.".format(poi.str_name, cmd.tokens[0])
        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

    response = ""

    if ewutils.active_restrictions.get(user_data.id_user) != None and ewutils.active_restrictions.get(user_data.id_user) > 0:
        response = "You can't do that right now."
        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

    if user_data.get_inhabitee():
        # prevent ghosts currently inhabiting other players from moving on their own
        response = "You might want to **{}** of the poor soul you've been tormenting first.".format(ewcfg.cmd_letgo)
        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

    # poi = ewmap.fetch_poi_if_coordless(cmd.message.channel.name)

    # must be at a transport stop to enter a transport
    if poi != None and poi.id_poi in poi_static.transport_stops:
        transport_ids = get_transports_at_stop(id_server=user_data.id_server, stop=poi.id_poi)

        # can't embark, when there's no vehicles to embark on
        if len(transport_ids) == 0:
            response = "There are currently no transport vehicles to embark on here."
            return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

        # automatically embark on the only transport at the station, if no arguments were provided
        elif len(transport_ids) == 1 and cmd.tokens_count < 2:
            transport_data = EwTransport(id_server=user_data.id_server, poi=transport_ids[0])
            target_name = transport_data.current_line

        # get target name from command arguments
        else:
            target_name = ewutils.flattenTokenListToString(cmd.tokens[1:])

        # report failure, if the vehicle to be boarded couldn't be ascertained
        if target_name == None or len(target_name) == 0:
            return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, "Which transport line?"))

        transport_line = poi_static.id_to_transport_line.get(target_name)

        # report failure, if an invalid argument was given
        if transport_line == None:
            return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, "Never heard of it."))

        for transport_id in transport_ids:
            transport_data = EwTransport(id_server=user_data.id_server, poi=transport_id)

            # check if one of the vehicles at the stop matches up with the line, the user wants to board
            if transport_data.current_line == transport_line.id_line:
                ticket = None
                # TODO remove after double halloween
                if ewcfg.dh_active:
                    user_data = EwUser(member = cmd.message.author)
                    if user_data.poi in [ewcfg.poi_id_dt_subway_station, ewcfg.poi_id_rr_subway_station, ewcfg.poi_id_jr_subway_station]:
                        if transport_line.id_line in [ewcfg.transport_line_subway_white_eastbound, ewcfg.transport_line_subway_white_westbound]:
                            ticket = bknd_item.find_item(item_search=ewcfg.item_id_whitelineticket, id_user=cmd.message.author.id,  id_server=cmd.message.guild.id)
                            if ticket is None:

                                response = "You need a ticket to embark on the White Line."
                                return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

                last_stop_poi = poi_static.id_to_poi.get(transport_line.last_stop)
                response = "Embarking on {}.".format(transport_line.str_name)
                # schedule tasks for concurrent execution
                message_task = asyncio.ensure_future(fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response)))
                wait_task = asyncio.ensure_future(asyncio.sleep(ewcfg.time_embark))

                # Take control of the move for this player.
                move_utils.move_counter += 1
                move_current = ewutils.moves_active[cmd.message.author.id] = move_utils.move_counter
                await message_task
                await wait_task

                # check if the user entered another movement command while waiting for the current one to be completed
                if move_current == ewutils.moves_active[cmd.message.author.id]:
                    user_data = EwUser(member=cmd.message.author)

                    transport_data = EwTransport(id_server=user_data.id_server, poi=transport_id)

                    # check if the transport is still at the same stop
                    if transport_data.current_stop == poi.id_poi:
                        user_data.poi = transport_data.poi
                        user_data.persist()

                        transport_poi = poi_static.id_to_poi.get(transport_data.poi)

                        response = "You enter the {}.".format(transport_data.transport_type)
                        if ticket is not None:
                            bknd_item.item_delete(ticket.get("id_item"))
                        await ewrolemgr.updateRoles(client=cmd.client, member=cmd.message.author)
                        await user_data.move_inhabitants(id_poi=transport_data.poi)
                        return await fe_utils.send_message(cmd.client, fe_utils.get_channel(cmd.guild, transport_poi.channel), fe_utils.formatMessage(cmd.message.author, response))
                    else:
                        response = "The {} starts moving just as you try to get on.".format(transport_data.transport_type)
                        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

        response = "There is currently no vehicle following that line here."
        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))


    else:
        response = "No transport vehicles stop here. Try going to a subway station or a ferry port."
        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))