Пример #1
0
def generate_negaslimeoid_name():
    titles = [
        "Angel", "Emissary", "Gaping Maw", "Apostle", "Nemesis", "Harbinger",
        "Reaper", "Incarnation", "Wanderer", "Berserker", "Outcast", "Monarch",
        "Anomaly"
    ]
    domains = [
        "Curses", "Doom", "Oblivion", "Darkness", "Madness", "the Void",
        "the Deep", "Nightmares", "Wrath", "Pestilence", "the End", "Terror",
        "Sorrow", "Pain", "Despair", "Souls", "Secrets", "Ruin", "Hatred",
        "Shadows", "the Night"
    ]
    title = "{} of {}".format(random.choice(titles), random.choice(domains))
    name_length = random.randrange(5, min(10, 30 - len(title)))
    consonants = random.choice(["chlt", "crwx", "fhlt", "bghl", "brpq"])
    vowels = "aeuuooyy"
    num_vowels = random.randrange(int(name_length / 4),
                                  int(name_length / 3) + 1)
    name_list = []
    for i in range(name_length):
        if i < num_vowels:
            name_list.append(random.choice(vowels))
        else:
            name_list.append(random.choice(consonants))
    random.shuffle(name_list)
    apostrophe = random.randrange(1, name_length)
    name = ewutils.flattenTokenListToString(
        name_list[:apostrophe]) + "'" + ewutils.flattenTokenListToString(
            name_list[apostrophe:])
    name = name.capitalize()
    full_name = "{}, {}".format(name, title)
    return full_name
Пример #2
0
async def dye(cmd):
    hat_id = ewutils.flattenTokenListToString(cmd.tokens[1:2])
    dye_id = ewutils.flattenTokenListToString(cmd.tokens[2:])

    try:
        hat_id_int = int(hat_id)
    except:
        hat_id_int = None

    try:
        dye_id_int = int(dye_id)
    except:
        dye_id_int = None

    if hat_id != None and len(hat_id) > 0 and dye_id != None and len(dye_id) > 0:
        response = "You don't have one."

        items = bknd_item.inventory(
            id_user=cmd.message.author.id,
            id_server=cmd.guild.id,
        )

        cosmetic = None
        dye = None
        for item in items:

            if int(item.get('id_item')) == hat_id_int or hat_id in ewutils.flattenTokenListToString(item.get('name')):
                if item.get('item_type') == ewcfg.it_cosmetic and cosmetic is None:
                    cosmetic = item

            if int(item.get('id_item')) == dye_id_int or dye_id in ewutils.flattenTokenListToString(item.get('name')):
                if item.get('item_type') == ewcfg.it_item and item.get('name') in static_items.dye_map and dye is None:
                    dye = item

            if cosmetic != None and dye != None:
                break

        if cosmetic != None:
            if dye != None:
                cosmetic_item = EwItem(id_item=cosmetic.get("id_item"))
                dye_item = EwItem(id_item=dye.get("id_item"))

                hue = hue_static.hue_map.get(dye_item.item_props.get('id_item'))

                response = "You dye your {} in {} paint!".format(cosmetic_item.item_props.get('cosmetic_name'), hue.str_name)
                cosmetic_item.item_props['hue'] = hue.id_hue

                cosmetic_item.persist()
                bknd_item.item_delete(id_item=dye.get('id_item'))
            else:
                response = 'Use which dye? Check your **!inventory**.'
        else:
            response = 'Dye which cosmetic? Check your **!inventory**.'

        await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
    else:
        await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, 'You need to specify which cosmetic you want to paint and which dye you want to use! Check your **!inventory**.'))
Пример #3
0
 def test_flattenTokenListToString(self):
     self.assertEqual(
         ewutils.flattenTokenListToString(['Test', ':Success']),
         'testsuccess')
     self.assertEqual(
         ewutils.flattenTokenListToString(" '\"!@#$%^&*().,/?{}[];:"), "")
     self.assertEqual(
         ewutils.flattenTokenListToString(['Test', '<@1234>', 'Success']),
         'testsuccess')
Пример #4
0
async def dedorn(cmd):
    user_data = EwUser(member=cmd.message.author)
    # ewutils.moves_active[cmd.message.author.id] = 0

    # Check to see if you even have the item you want to repair
    item_id = ewutils.flattenTokenListToString(cmd.tokens[1:])

    try:
        item_id_int = int(item_id)
    except:
        item_id_int = None

    if item_id is not None and len(item_id) > 0:
        response = "You don't have one."

        cosmetic_items = bknd_item.inventory(
            id_user=cmd.message.author.id,
            id_server=cmd.guild.id,
            item_type_filter=ewcfg.it_cosmetic
        )

        item_sought = None
        already_adorned = False

        # Check all cosmetics found
        for item in cosmetic_items:
            i = EwItem(item.get('id_item'))

            # Search for desired cosmetic
            if item.get('id_item') == item_id_int or item_id in ewutils.flattenTokenListToString(item.get('name')):
                if i.item_props.get("adorned") == 'true':
                    already_adorned = True
                    item_sought = i
                    break

        # If the cosmetic you want to adorn is found
        if item_sought != None:

            # Unadorn the cosmetic
            if already_adorned:
                item_sought.item_props['adorned'] = 'false'

                unadorn_response = str(item_sought.item_props['str_unadorn'])

                response = unadorn_response.format(item_sought.item_props['cosmetic_name'])

                item_sought.persist()
                user_data.persist()

            # That garment has not be adorned..
            else:
                response = "You haven't adorned that garment in the first place! How can you dedorn something you haven't adorned? You disgust me."

        await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
    else:
        await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, 'Adorn which cosmetic? Check your **!inventory**.'))
Пример #5
0
async def offer_item(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))

    user_trade = ewutils.active_trades.get(user_data.id_user)

    if user_trade != None and len(user_trade) > 0 and user_trade.get("state") > ewcfg.trade_state_proposed:
        item_search = ewutils.flattenTokenListToString(cmd.tokens[1:])

        try:
            item_id_int = int(item_search)
        except:
            item_id_int = None

        if item_search != None and len(item_search) > 0:
            item_sought = None

            inventory = bknd_item.inventory(
                id_user=user_data.id_user,
                id_server=user_data.id_server
            )

            for item in inventory:
                if (item.get('id_item') == item_id_int or item_search in ewutils.flattenTokenListToString(item.get('name'))) \
                        and item not in ewutils.trading_offers.get(user_data.id_user):
                    item_sought = item

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

                if not item.soulbound or EwItem(id_item=item_sought.get('id_item')).item_props.get("context") == "housekey":

                    if item.id_item == user_data.weapon and user_data.weaponmarried:
                        response = "Unfortunately for you, the contract you signed before won't let you trade your partner away. You'll have to get your cuckoldry fix from somewhere else."
                        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

                    ewutils.trading_offers[user_data.id_user].append(item_sought)
                    response = "You add a {} to your offers.".format(item_sought.get("name"))

                    user_trade["state"] = ewcfg.trade_state_ongoing
                    ewutils.active_trades.get(user_trade.get("trader"))["state"] = ewcfg.trade_state_ongoing

                else:
                    response = "You can't trade soulbound items."
            else:
                if item_search:
                    response = "You don't have one."
        else:
            response = "Offer which item? (check **!inventory**)"
    else:
        response = "You need to be trading with someone to offer an item."

    await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
Пример #6
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))
Пример #7
0
async def pa_command(cmd):
    user_data = EwUser(member=cmd.message.author)
    if not cmd.message.author.guild_permissions.administrator and user_data.life_state != ewcfg.life_state_executive:
        return await cmd_utils.fake_failed_command(cmd)
    else:
        if cmd.tokens_count >= 3:
            poi = ewutils.flattenTokenListToString(cmd.tokens[1])

            poi_obj = poi_static.id_to_poi.get(poi)
            if poi == "auditorium":
                channel = "auditorium"
            else:
                channel = poi_obj.channel

            loc_channel = fe_utils.get_channel(cmd.guild, channel)

            if poi is not None:
                patext = re.sub(
                    "<.+>", "",
                    cmd.message.content[(len(cmd.tokens[0]) +
                                         len(cmd.tokens[1]) + 1):]).strip()
                if len(patext) > 500:
                    patext = patext[:-500]
                return await fe_utils.send_message(cmd.client, loc_channel,
                                                   patext)
Пример #8
0
async def blockparty(cmd):
    if not cmd.message.author.guild_permissions.administrator:
        return
    else:
        blockstate = EwGamestate(id_server=cmd.guild.id, id_state='blockparty')
        if cmd.tokens_count > 1:
                if cmd.tokens[1] == 'slimegen':
                    blockstate.bit = 1
                    blockstate.persist()
                    response = "Slimegen turned on."
                elif cmd.tokens[1] == 'close':
                    blockstate.bit = 0
                    blockstate.value = ''
                    blockstate.persist()
                    response = "OK, closing up."
                else:
                    poi_sought = ewutils.flattenTokenListToString(cmd.tokens[1:])
                    poi = poi_static.id_to_poi.get(poi_sought)
                    if poi is not None:
                        time_end = int(time()) + (60 * 60 * 6) # 6 hours
                        blockstate.value = "{}{}".format(poi.id_poi, time_end)
                        blockstate.persist()
                        response = "Block party in {}! Everybody in!".format(poi.str_name)
                    else:
                        response = "Never heard of it."
        else:
            response = "I see you haven't gotten any smarter. Try !blockparty <setting>. Settings include 'close', 'slimegen', and any POI."
    return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
Пример #9
0
async def remove_offer(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))

    user_trade = ewutils.active_trades.get(user_data.id_user)

    if user_trade != None and len(user_trade) > 0 and user_trade.get("state") > ewcfg.trade_state_proposed:
        item_search = ewutils.flattenTokenListToString(cmd.tokens[1:])

        try:
            item_id_int = int(item_search)
        except:
            item_id_int = None

        if item_search != None and len(item_search) > 0:
            item_sought = None

            inventory = bknd_item.inventory(
                id_user=user_data.id_user,
                id_server=user_data.id_server
            )

            for item in inventory:
                if (item.get('id_item') == item_id_int or item_search in ewutils.flattenTokenListToString(item.get('name'))) \
                        and item in ewutils.trading_offers.get(user_data.id_user):
                    item_sought = item

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

                ewutils.trading_offers[user_data.id_user].remove(item_sought)
                response = "You remove {} from your offers.".format(item_sought.get("name"))

                user_trade["state"] = ewcfg.trade_state_ongoing
                ewutils.active_trades.get(user_trade.get("trader"))["state"] = ewcfg.trade_state_ongoing

            else:
                if item_search:
                    response = "You don't have one."
        else:
            response = "Remove which offer? (check **!trade**)"
    else:
        response = "You need to be trading with someone to remove an offer."

    await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
Пример #10
0
async def name_slimeoid(cmd):
    user_data = EwUser(member=cmd.message.author)
    slimeoid_data = EwSlimeoid(member=cmd.message.author)
    command_used = ""

    # Check if player is in the labs and has a slimeoid incubating
    response = basic_slimeoid_incubation_checks(
        channel_name=cmd.message.channel.name,
        user_data=user_data,
        slimeoid_data=slimeoid_data)
    # If response returns None go to final response

    # Lifestate check for flavor text
    if slimeoid_data.sltype == ewcfg.sltype_nega:
        slimeoidtype = "Negaslimeoid"
    else:
        slimeoidtype = "Slimeoid"

    if response is None:  # Slimeoid is incubating

        # Check if player has specified a name
        if cmd.tokens_count < 2:
            response = "You must specify a name."
            # Go to final response

        else:

            # Turn entire message minus "!nameslimeoid" in to name variable
            command_used = ewutils.flattenTokenListToString(cmd.tokens[0])
            name = cmd.message.content[(len(command_used) +
                                        len(ewcfg.cmd_prefix)):].strip()

            # Limit name length to 32 characters
            if len(name) > 32:
                response = "That name is too long. ({:,}/32)".format(len(name))
                # Go to final response

            else:
                # Save slimeoid name
                slimeoid_data.name = str(name)

                user_data.persist()
                slimeoid_data.persist()

                if slimeoidtype == "Slimeoid":
                    response = "You enter the name {} into the console.".format(
                        str(name))
                else:
                    response = "You move the planchette between letters, spelling out the name {}.".format(
                        str(name))
                # Go to final response

    # Final response
    await send_response(response, cmd)
Пример #11
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))
Пример #12
0
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))
Пример #13
0
async def ufo_observe(cmd):
    user_data = EwUser(member = cmd.message.author)

    cosmetics = bknd_item.inventory(id_user=user_data.id_user, id_server=cmd.guild.id, item_type_filter=ewcfg.it_cosmetic)

    protected = False
    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_state='shipstate', id_server=cmd.guild.id)

    if user_data.poi != 'ufoufo':
        return await ewdebug.scrutinize(cmd=cmd)
    elif not protected:
        response = "Those aliens would probably ass-probe the f**k out of you if you messed with their equipment. Better not."
    elif shipstate.bit == 1:
        response = "The ship is grounded. Can't see much from here."
    elif cmd.tokens_count <= 1:
        response = "Observe what?"
    elif not ewcfg.dh_active or ewcfg.dh_stage != 3:
        response = "Wait, your alien espionage is waaaay out of season."
    else:
        poi_seek = ewutils.flattenTokenListToString(cmd.tokens[1:])
        poi_sought = poi_static.id_to_poi.get(poi_seek)
        if poi_sought is None:
            response = "The aliens know all the district names. You don't have to make up weird shit."
        elif poi_sought.id_poi == 'ufoufo':
            return await ewdebug.scrutinize(cmd=cmd)
        elif poi_sought.is_street:
            response = "You try to zoom in on a specific street, but you're a little too high up to get that level of detail."
        elif poi_sought.id_poi == 'blackpond' or (not poi_sought.is_district and not poi_sought.is_outskirts and not poi_sought.is_pier and poi_sought.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 X-ray vision on this viewport sucks. You can't really see indoors."
        elif poi_sought.id_poi in [ewcfg.poi_id_rowdyroughhouse, ewcfg.poi_id_copkilltown]:
            response = "Do you want to blow your cover, dumbass? Stop acting like a gangster. The gang bases are mostly indoors anyway."
        else:
            new_permissions = {"ufo-ufo": ["read", "send", "connect"]}
            new_permissions[poi_sought.channel] = ["read"]
            current_poi = poi_static.id_to_poi.get('ufoufo')
            response = ""
            if current_poi is not None:
                response = 'You point the observation reticle over at {}.'.format(poi_sought.str_name)
                district_data = EwDistrict(id_server=cmd.guild.id, district='ufoufo')
                poi_static.id_to_poi['ufoufo'].permissions = new_permissions
                players_in_district = district_data.get_players_in_district(min_slimes=0, life_states=[ewcfg.life_state_enlisted, ewcfg.life_state_corpse, ewcfg.life_state_juvenile, ewcfg.life_state_shambler], ignore_offline=True)
                server = ewcfg.server_list[cmd.guild.id]
                for playerid in players_in_district:
                    member_object = server.get_member(playerid)
                    await ewrolemgr.updateRoles(client=cmd.client, member=member_object)
    return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
Пример #14
0
async def create(cmd):
    # if not cmd.message.author.guild_permissions.administrator:
    if EwUser(
            member=cmd.message.author
    ).life_state != ewcfg.life_state_kingpin and not cmd.message.author.guild_permissions.administrator:
        response = 'Lowly Non-Kingpins cannot hope to create items with their bare hands.'
        return await fe_utils.send_message(
            cmd.client, cmd.message.channel,
            fe_utils.formatMessage(cmd.message.author, response))

    if len(cmd.tokens) not in [4, 5, 6]:
        response = 'Usage: !create "<item_name>" "<item_desc>" <recipient> <rarity(optional)>, <context>(optional)'
        return await fe_utils.send_message(
            cmd.client, cmd.message.channel,
            fe_utils.formatMessage(cmd.message.author, response))

    item_name = cmd.tokens[1]
    item_desc = cmd.tokens[2]
    rarity = cmd.tokens[4] if len(
        cmd.tokens) >= 5 and ewutils.flattenTokenListToString(
            cmd.tokens[4]) in ['princeps', 'plebeian', 'patrician'
                               ] else 'princeps'
    context = cmd.tokens[5] if len(cmd.tokens) >= 6 else ''

    if cmd.mentions[0]:
        recipient = cmd.mentions[0]
    else:
        response = 'You need to specify a recipient. Usage: !create "<item_name>" "<item_desc>" <recipient>'
        return await fe_utils.send_message(
            cmd.client, cmd.message.channel,
            fe_utils.formatMessage(cmd.message.author, response))

    item_props = {
        "cosmetic_name": item_name,
        "cosmetic_desc": item_desc,
        "adorned": "false",
        "rarity": rarity,
        "context": context
    }

    new_item_id = bknd_item.item_create(id_server=cmd.guild.id,
                                        id_user=recipient.id,
                                        item_type=ewcfg.it_cosmetic,
                                        item_props=item_props)

    itm_utils.soulbind(new_item_id)

    response = 'Item "{}" successfully created.'.format(item_name)
    return await fe_utils.send_message(
        cmd.client, cmd.message.channel,
        fe_utils.formatMessage(cmd.message.author, response))
Пример #15
0
async def graft(cmd):
    user_data = EwUser(member=cmd.message.author)

    if cmd.message.channel.name != ewcfg.channel_clinicofslimoplasty:
        response = "Chemotherapy doesn't just grow on trees. You'll need to go to the clinic in Crookline to get some."
        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_corpse:
        response = '"You get out of here, dirty nega. We don\'t serve your kind." \n\n Auntie Dusttrap threatingly flails a jar of cole slaw at you. Looks like you need a body to mutate a body.'
        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
    elif len(cmd.tokens) <= 1:
        response = '"What, just anything? I love a good improv surgery! I had to leave town the last one I did though, so you\'ll have to pick an actual surgical procedure. Sorry, sonny."'
        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

    target_name = ewutils.flattenTokenListToString(cmd.tokens[1:])
    target = ewutils.get_mutation_alias(target_name)

    mutations = user_data.get_mutations()
    incompatible = False

    if target == 0:
        response = '"What? My ears aren\'t what they used to be. I thought you suggested I give you {}. Only braindead squicks would say that."'.format(' '.join(cmd.tokens[1:]))
        incompatible = True
    elif target in mutations:
        response = '"Nope, you already have that mutation. Hey, I thought I was supposed to be the senile one here!"'
        incompatible = True
    elif user_data.get_mutation_level() + static_mutations.mutations_map[target].tier > min([user_data.slimelevel, 50]):
        response = '"Your body\'s already full of mutations. Your sentient tumors will probably start bitin\' once I take out my scalpel."\n\nLevel:{}/50\nMutation Levels Added:{}/{}'.format(user_data.slimelevel, user_data.get_mutation_level(), min(user_data.slimelevel, 50))
        incompatible = True
    elif static_mutations.mutations_map.get(target).tier * 10000 > user_data.slimes:
        response = '"We\'re not selling gumballs here. It\'s cosmetic surgery. It\'ll cost at least {} slime, ya idjit!"'.format(static_mutations.mutations_map.get(target).tier * 10000)
        incompatible = True

    for mutation in mutations:
        mutation = static_mutations.mutations_map[mutation]
        if target in mutation.incompatible:
            response = mutation.incompatible[target]
            incompatible = True
            break

    if incompatible:
        return await fe_utils.send_response(response, cmd)
    else:
        price = static_mutations.mutations_map.get(target).tier * 10000
        user_data.change_slimes(n=-price, source=ewcfg.source_spending)
        user_data.persist()

        user_data.add_mutation(id_mutation=target, is_artificial=1)
        response = static_mutations.mutations_map[target].str_transplant + "\n\nMutation Levels Added:{}/{}".format(user_data.get_mutation_level(), min(user_data.slimelevel, 50))
        await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
Пример #16
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))
Пример #17
0
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))
Пример #18
0
async def rate(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))

    response = ""

    if cmd.message.channel.name != ewcfg.channel_stockexchange:
        # Only allowed in the stock exchange.
        response = "You must go to the Slime Stock Exchange to check the current stock exchange rates ."
        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

    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))

        stock = ""

        if cmd.tokens_count > 0:
            stock = ewutils.flattenTokenListToString(cmd.tokens[1:])

        if stock in ewcfg.stocks:
            stock = EwStock(id_server=cmd.guild.id, stock=stock)
            response = "The current value of {stock} stocks is {cred:,} SlimeCoin per 1000 Shares.".format(stock=ewcfg.stock_names.get(stock.id_stock), cred=stock.exchange_rate)
        elif stock == "":
            for stock in ewcfg.stocks:
                stock = EwStock(id_server=cmd.guild.id, stock=stock)
                response += "\nThe current value of {stock} stocks is {cred:,} SlimeCoin per 1000 Shares.".format(stock=ewcfg.stock_names.get(stock.id_stock), cred=stock.exchange_rate)

        else:
            response = "That's not a valid stock name, please use a proper one, you c**t: {}".format(ewutils.formatNiceList(ewcfg.stocks))

        # Send the response to the player.
        await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
Пример #19
0
async def trade(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))

    user_trade = ewutils.active_trades.get(user_data.id_user)

    if user_trade != None and len(user_trade) > 0:
        if user_trade.get("state") > ewcfg.trade_state_proposed:

            stacking = True if 'stack' in ewutils.flattenTokenListToString(cmd.tokens[1:]).lower() else False
            sort_by_name = True if 'name' in ewutils.flattenTokenListToString(cmd.tokens[1:]).lower() else False

            stacked_item_map = {}

            # print info about the current trade
            trade_partner = EwPlayer(id_user=user_trade.get("trader"), id_server=user_data.id_server)

            # print player's offers
            response = "Your offers:\n"
            items = ewutils.trading_offers.get(user_data.id_user) if not sort_by_name else sorted(ewutils.trading_offers.get(user_data.id_user), key=lambda item: item.get("name").lower)
            for item in items:
                if not stacking:
                    response_part = "{id_item}: {name} {quantity}\n".format(id_item=item.get("id_item"), name=item.get("name"), quantity=(" x{:,}".format(item.get("quantity")) if (item.get("quantity") > 1) else ""))

                    if len(response) + len(response_part) > 1492:
                        await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
                        response = ""

                    response += response_part

                else:
                    if item.get("name") in stacked_item_map:
                        stacked_item = stacked_item_map.get(item.get("name"))
                        stacked_item["quantity"] += item.get("quantity")
                    else:
                        stacked_item_map[item.get("name")] = deepcopy(item)

            if stacking:
                item_names = stacked_item_map.keys() if not sort_by_name else sorted(stacked_item_map.keys())

                for item_name in item_names:
                    item = stacked_item_map.get(item_name)
                    quantity = item.get('quantity')
                    response_part = "{soulbound_style}{name}{soulbound_style}{quantity}\n".format(
                        name=item.get('name'),
                        soulbound_style=("**" if item.get('soulbound') else ""),
                        quantity=(" **x{:,}**".format(quantity) if (quantity > 0) else "")
                    )

                    if len(response) + len(response_part) > 1492:
                        await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
                        response = ""

                    response += response_part

            if user_trade.get("state") == ewcfg.trade_state_complete:
                response_part = "**You are ready to complete the trade.**"

                if len(response) + len(response_part) > 1492:
                    await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
                    response = ""

                response += response_part

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

            # print partner's offers
            stacked_item_map = {}

            response = trade_partner.display_name + "'s offers:\n"
            items = ewutils.trading_offers.get(trade_partner.id_user) if not sort_by_name else sorted(ewutils.trading_offers.get(trade_partner.id_user), key=lambda item: item.get("name").lower)
            for item in items:
                if not stacking:
                    response_part = "{id_item}: {name} {quantity}\n".format(id_item=item.get("id_item"), name=item.get("name"), quantity=(" x{:,}".format(item.get("quantity")) if (item.get("quantity") > 1) else ""))

                    if len(response) + len(response_part) > 1492:
                        await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
                        response = ""

                    response += response_part

                else:
                    if item.get("name") in stacked_item_map:
                        stacked_item = stacked_item_map.get(item.get("name"))
                        stacked_item["quantity"] += item.get("quantity")
                    else:
                        stacked_item_map[item.get("name")] = deepcopy(item)

            if stacking:
                item_names = stacked_item_map.keys() if not sort_by_name else sorted(stacked_item_map.keys())

                for item_name in item_names:
                    item = stacked_item_map.get(item_name)
                    quantity = item.get('quantity')
                    response_part = "{soulbound_style}{name}{soulbound_style}{quantity}\n".format(
                        name=item.get('name'),
                        soulbound_style=("**" if item.get('soulbound') else ""),
                        quantity=(" **x{:,}**".format(quantity) if (quantity > 0) else "")
                    )

                    if len(response) + len(response_part) > 1492:
                        await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
                        response = ""

                    response += response_part

            if ewutils.active_trades.get(trade_partner.id_user).get("state") == ewcfg.trade_state_complete:
                response_part = '**They are ready to complete the trade.**'

                if len(response) + len(response_part) > 1492:
                    await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
                    response = ""

                response += response_part

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

    else:
        if cmd.mentions_count == 0:
            return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, "Who do you want to trade with?"))

        if cmd.mentions_count > 1:
            return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, "You can only trade with one person at a time."))

        trade_partner = EwUser(member=cmd.mentions[0])

        if user_data.id_user == trade_partner.id_user:
            return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, "Huh?"))

        if user_data.poi != trade_partner.poi:
            return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, "You must be in the same location as someone to trade with them."))

        if ewutils.active_trades.get(trade_partner.id_user) != None and len(ewutils.active_trades.get(trade_partner.id_user)) > 0:
            return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, "Wait for them to finish their business before trying to trade with them."))

        ewutils.active_trades[user_data.id_user] = {"state": ewcfg.trade_state_proposed, "trader": trade_partner.id_user}
        ewutils.active_trades[trade_partner.id_user] = {"state": ewcfg.trade_state_proposed, "trader": user_data.id_user}

        await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.mentions[0], "{user} wants to trade with you. Do you {accept} or {refuse}?".format(user=cmd.message.author.display_name, accept=ewcfg.cmd_accept, refuse=ewcfg.cmd_refuse)))

        accepted = False

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

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

        if accepted:
            ewutils.active_trades[user_data.id_user] = {"state": ewcfg.trade_state_ongoing, "trader": trade_partner.id_user}
            ewutils.active_trades[trade_partner.id_user] = {"state": ewcfg.trade_state_ongoing, "trader": user_data.id_user}

            ewutils.trading_offers[user_data.id_user] = []

            ewutils.trading_offers[trade_partner.id_user] = []

            response = "You both head into a shady alleyway nearby to conduct your business."

        else:
            ewutils.active_trades[user_data.id_user] = {}
            ewutils.active_trades[trade_partner.id_user] = {}
            response = "They didn't respond in time."

        await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
Пример #20
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))
Пример #21
0
async def slimeball(cmd):
    user_data = EwUser(member=cmd.message.author)

    if not ewutils.channel_name_is_poi(cmd.message.channel.name):
        response = "You have to go into the city to play Slimeball."
        return await fe_utils.send_message(
            cmd.client, cmd.message.channel,
            fe_utils.formatMessage(cmd.message.author, response))

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

    if poi_data.id_poi != ewcfg.poi_id_vandalpark:
        response = "You have to go Vandal Park to play {}.".format(cmd.cmd[1:])
        return await fe_utils.send_message(
            cmd.client, cmd.message.channel,
            fe_utils.formatMessage(cmd.message.author, response))

    if poi_data.is_subzone or poi_data.is_transport:
        response = "This place is too cramped for playing {}. Go outside!".format(
            cmd.cmd[1:])
        return await fe_utils.send_message(
            cmd.client, cmd.message.channel,
            fe_utils.formatMessage(cmd.message.author, response))

    district_data = EwDistrict(district=poi_data.id_poi,
                               id_server=cmd.message.guild.id)

    # global sb_userid_to_player
    slimeball_player = sportsutils.sb_userid_to_player.get(
        cmd.message.author.id)

    game_data = None

    if slimeball_player != None:
        # global sb_games
        game_data = sports_utils.sb_games.get(slimeball_player.id_game)

        if game_data != None and game_data.poi != poi_data.id_poi:
            game_data.players.remove(slimeball_player)
            game_data = None

    if game_data == None:
        # global sb_idserver_to_gamemap

        gamemap = sportsutils.sb_idserver_to_gamemap.get(cmd.guild.id)
        if gamemap != None:
            game_data = gamemap.get(poi_data.id_poi)

        team = ewutils.flattenTokenListToString(cmd.tokens[1:])
        if team not in ["purple", "pink"]:
            response = "Please choose if you want to play on the pink team or the purple team."
            return await fe_utils.send_message(
                cmd.client, cmd.message.channel,
                fe_utils.formatMessage(cmd.message.author, response))

        if game_data == None:
            game_data = EwSlimeballGame(poi_data.id_poi, cmd.message.guild.id)
            response = "You grab a stray ball and start a new game of {game} as a {team} team player."
        else:
            response = "You join the {game} game on the {team} team."

        slimeball_player = EwSlimeballPlayer(cmd.message.author.id,
                                             cmd.message.guild.id,
                                             game_data.id_game, team)
    else:
        response = "You are playing {game} on the {team} team. You are currently at {player_coords} going in direction {player_vel}. The ball is currently at {ball_coords} going in direction {ball_vel}. The score is purple {score_purple} : {score_pink} pink."

    response = response.format(game=cmd.cmd[1:],
                               team=slimeball_player.team,
                               player_coords=slimeball_player.coords,
                               ball_coords=game_data.ball_coords,
                               player_vel=slimeball_player.velocity,
                               ball_vel=game_data.ball_velocity,
                               score_purple=game_data.score_purple,
                               score_pink=game_data.score_pink)
    return await fe_utils.send_message(
        cmd.client, cmd.message.channel,
        fe_utils.formatMessage(cmd.message.author, response))
Пример #22
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))
Пример #23
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))
Пример #24
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))
Пример #25
0
async def smelt(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))

    # Find sought recipe.
    if cmd.tokens_count > 1:
        sought_result = ewutils.flattenTokenListToString(cmd.tokens[1:])
        found_recipe = smelting.smelting_recipe_map.get(sought_result)

        if found_recipe != None:
            if 'soul' in found_recipe.products:
                return await smeltsoul(cmd=cmd)

            # Checks what ingredients are needed to smelt the recipe.
            necessary_ingredients = found_recipe.ingredients
            necessary_ingredients_list = []

            owned_ingredients = []

            # Seeks out the necessary ingredients in your inventory.
            missing_ingredients = []

            for matched_item in necessary_ingredients:
                necessary_items = necessary_ingredients.get(matched_item)
                necessary_str = "{} {}".format(necessary_items, matched_item)
                if necessary_items > 1:
                    necessary_str += "s"
                necessary_ingredients_list.append(necessary_str)

                sought_items = itm_utils.find_item_all(item_search=matched_item, id_user=user_data.id_user, id_server=user_data.id_server)
                missing_items = necessary_items - len(sought_items)
                if missing_items > 0:
                    missing_str = "{} {}".format(missing_items, matched_item)
                    if missing_items > 1:
                        missing_str += "s"
                    missing_ingredients.append(missing_str)
                else:
                    for i in range(necessary_ingredients.get(matched_item)):
                        sought_item = sought_items.pop()
                        owned_ingredients.append(sought_item.get('id_item'))

            # If you don't have all the necessary ingredients.
            if len(missing_ingredients) > 0:
                response = "You've never done this before, have you? To smelt {}, you’ll need to combine *{}*.".format(found_recipe.str_name, ewutils.formatNiceList(names=necessary_ingredients_list, conjunction="and"))

                response += " You are missing *{}*.".format(ewutils.formatNiceList(names=missing_ingredients, conjunction="and"))

            else:
                # If you try to smelt a random cosmetic, use old smelting code to calculate what your result will be.
                if found_recipe.id_recipe == "coolcosmetic" or found_recipe.id_recipe == "toughcosmetic" or found_recipe.id_recipe == "smartcosmetic" or found_recipe.id_recipe == "beautifulcosmetic" or found_recipe.id_recipe == "cutecosmetic":

                    if not bknd_item.check_inv_capacity(user_data=user_data, item_type=ewcfg.it_cosmetic):
                        response = "You can't carry anymore cosmetic items."
                        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

                    patrician_rarity = 100
                    patrician_smelted = random.randint(1, patrician_rarity)
                    patrician = False

                    if patrician_smelted <= 5:
                        patrician = True

                    cosmetics_list = []

                    if found_recipe.id_recipe == "toughcosmetic":
                        style = ewcfg.style_tough
                    elif found_recipe.id_recipe == "smartcosmetic":
                        style = ewcfg.style_smart
                    elif found_recipe.id_recipe == "beautifulcosmetic":
                        style = ewcfg.style_beautiful
                    elif found_recipe.id_recipe == "cutecosmetic":
                        style = ewcfg.style_cute
                    else:
                        style = ewcfg.style_cool

                    for result in static_cosmetics.cosmetic_items_list:
                        if result.style == style and result.acquisition == ewcfg.acquisition_smelting:
                            cosmetics_list.append(result)
                        else:
                            pass

                    items = []

                    for cosmetic in cosmetics_list:
                        if patrician and cosmetic.rarity == ewcfg.rarity_patrician:
                            items.append(cosmetic)
                        elif not patrician and cosmetic.rarity == ewcfg.rarity_plebeian:
                            items.append(cosmetic)

                    item = items[random.randint(0, len(items) - 1)]

                    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
                    )

                # If you're trying to smelt a specific item.
                else:
                    possible_results = []

                    # Matches the recipe's listed products to actual items.
                    for result in vendors.smelt_results:
                        if hasattr(result, 'id_item'):
                            if result.id_item not in found_recipe.products:
                                pass
                            else:
                                possible_results.append(result)
                        if hasattr(result, 'id_food'):
                            if result.id_food not in found_recipe.products:
                                pass
                            else:
                                possible_results.append(result)
                        if hasattr(result, 'id_cosmetic'):
                            if result.id_cosmetic not in found_recipe.products:
                                pass
                            else:
                                possible_results.append(result)
                        if hasattr(result, 'id_weapon'):
                            if result.id_weapon not in found_recipe.products:
                                pass
                            else:
                                possible_results.append(result)
                        if hasattr(result, 'id_furniture'):
                            if result.id_furniture not in found_recipe.products:
                                pass
                            else:
                                possible_results.append(result)
                    # If there are multiple possible products, randomly select one.
                    item = random.choice(possible_results)

                    if not bknd_item.check_inv_capacity(user_data=user_data, item_type=item.item_type):
                        response = "You can't carry any more {}s.".format(item.item_type)
                        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

                    item_props = itm_utils.gen_item_props(item)

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

                for id_item in owned_ingredients:
                    item_check = EwItem(id_item=id_item)
                    if item_check.item_props.get('id_cosmetic') != 'soul':
                        bknd_item.item_delete(id_item=id_item)
                    else:
                        newitem = EwItem(id_item=newitem_id)
                        newitem.item_props['target'] = id_item
                        newitem.persist()
                        bknd_item.give_item(id_item=id_item, id_user='******', id_server=cmd.guild.id)

                name = ""
                if hasattr(item, 'str_name'):
                    name = item.str_name
                elif hasattr(item, 'id_weapon'):
                    name = item.id_weapon

                response = "You sacrifice your {} to smelt a {}!!".format(ewutils.formatNiceList(names=necessary_ingredients_list, conjunction="and"), name)

                user_data.persist()

        else:
            response = "There is no recipe by the name."

    else:
        response = "Please specify a desired smelt result."

    # Send response
    await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
Пример #26
0
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))
Пример #27
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 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))
Пример #28
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))
Пример #29
0
async def find_recipes_by_item(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))

    used_recipe = None

    # if the player specifies an item name
    if cmd.tokens_count > 1:
        sought_item = ewutils.flattenTokenListToString(cmd.tokens[1:])

        # Allow for the use of recipe aliases
        found_recipe = smelting.smelting_recipe_map.get(sought_item)
        if found_recipe != None:
            used_recipe = found_recipe.id_recipe

        # item_sought_in_inventory = bknd_item.find_item(item_search=sought_item, id_user=cmd.message.author.id, id_server=cmd.guild.id if cmd.guild is not None else None)
        makes_sought_item = []
        uses_sought_item = []

        # if the item name is an item in the player's inventory, we're assuming that the player is looking up information about this item specifically.
        # if item_sought_in_inventory is not None:
        # sought_item = item_sought_in_inventory.id_item
        # print(item_sought_in_inventory['item_def'])
        # man i could NOT get this to work . maybe another day

        # finds the recipes in questions that applys
        for name in smelting.recipe_names:
            # find recipes that this item is used as an ingredient in
            if smelting.smelting_recipe_map[name].ingredients.get(sought_item) is not None:
                uses_sought_item.append(name)

            # find recipes used to create this item
            elif sought_item in smelting.smelting_recipe_map[name].products:
                makes_sought_item.append(smelting.smelting_recipe_map[name])

            # finds recipes based on possible recipe aliases
            elif used_recipe in smelting.smelting_recipe_map[name].products:
                makes_sought_item.append(smelting.smelting_recipe_map[name])

        # zero matches in either of the above:
        if len(makes_sought_item) < 1 and len(uses_sought_item) < 1:
            response = "No recipes found for *{}*.".format(sought_item)

        # adds the recipe list to a response
        else:
            response = "\n"
            number_recipe = 1
            list_length = len(makes_sought_item)
            for item in makes_sought_item:
                if (item.id_recipe == "toughcosmetic" and cosmetics.cosmetic_map[sought_item].style != ewcfg.style_tough
                        or item.id_recipe == "smartcosmetic" and cosmetics.cosmetic_map[sought_item].style != ewcfg.style_smart
                        or item.id_recipe == "beautifulcosmetic" and cosmetics.cosmetic_map[sought_item].style != ewcfg.style_beautiful
                        or item.id_recipe == "cutecosmetic" and cosmetics.cosmetic_map[sought_item].style != ewcfg.style_cute
                        or item.id_recipe == "coolcosmetic" and cosmetics.cosmetic_map[sought_item].style != ewcfg.style_cool):
                    list_length -= 1
                    continue
                else:
                    # formats items in form "# item" (like "1 poudrin" or whatever)
                    ingredients_list = []
                    ingredient_strings = []
                    for ingredient in item.ingredients:
                        ingredient_strings.append("{} {}".format(item.ingredients.get(ingredient), ingredient))

                    if number_recipe == 1:
                        response += "To smelt this item, you'll need *{}*. ({})\n".format(ewutils.formatNiceList(names=ingredient_strings, conjunction="and"), item.id_recipe)
                    else:
                        response += "Alternatively, to smelt this item, you'll need *{}*. ({})\n".format(ewutils.formatNiceList(names=ingredient_strings, conjunction="and"), item.id_recipe)
                    number_recipe += 1

            if len(uses_sought_item) > 0:
                response += "This item can be used to smelt *{}*.".format(ewutils.formatNiceList(names=uses_sought_item, conjunction="and"))



    # if the player doesnt specify a 2nd argument
    else:
        response = "Please specify an item you would like to look up usage for."

    # send response to player
    await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
Пример #30
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))