示例#1
0
def get_weapon_collection(id_item, id_server):
    item = EwItem(id_item=id_item)
    if 'decorate' not in str(item.id_owner):
        return "It's a weapon rack. You can't admire its splendor while it's on your back, though."

    id_item_col = "{}collection".format(id_item)
    weapon_inv = bknd_item.inventory(id_server=id_server, id_user=id_item_col)

    if len(weapon_inv) == 0:
        return "There are no weapons in here. Arms are meant to be used, not preserved."

    response = "You take a look at the archive of your violent history...\n\n"

    for wep in weapon_inv:
        weapon_item = EwItem(id_item=wep.get('id_item'))
        kills = weapon_item.item_props.get('totalkills')
        if kills is None:
            kills = 0
        name = weapon_item.item_props.get('weapon_name')
        if name is None or name == '':
            name = 'Generic {}'.format(
                weapon_item.item_props.get('weapon_type'))

        response += "{}: {} KILLS\n".format(name, kills)

    return response
示例#2
0
def get_soul_collection(id_item, id_server):
    item = EwItem(id_item=id_item)
    if 'decorate' not in str(item.id_owner):
        return 'It\'s a soul cylinder. You can\'t really tell whose soul is whose. You\'ve been carrying this thing around and all the souls are jostled and queasy.'

    id_item_col = "{}collection".format(id_item)

    soul_inv = bknd_item.inventory(id_server=id_server, id_user=id_item_col)

    if len(soul_inv) == 0:
        return "No souls. Just ask anyone."

    response = "You look into the cylinder to check how the souls are doing.\n\n"
    for soul in soul_inv:
        soul_item = EwItem(id_item=soul.get('id_item'))
        soul_user = EwUser(id_server=id_server,
                           id_user=soul_item.item_props.get('user_id'))
        if soul_user.race is None or soul_user.race == '':
            soul_user.race = ewcfg.race_humanoid  #do not persist this!

        soul_text = ewcfg.defined_races.get(
            soul_user.race).get('soul_behavior')
        soul_name = soul_item.item_props.get('cosmetic_name')
        response += "{} {}\n".format(soul_name, soul_text)

    return response
示例#3
0
def get_random_prank_item(user_data, district_data):
    response = ""

    items_in_poi = bknd_item.inventory(id_user=user_data.poi,
                                       id_server=district_data.id_server)

    prank_items = []

    for item in items_in_poi:
        id_item = item.get("id_item")
        possible_prank_item = EwItem(id_item=id_item)

        context = possible_prank_item.item_props.get('context')
        food_item_id = possible_prank_item.item_props.get('id_food')

        if (context == ewcfg.context_prankitem
                or food_item_id == "defectivecreampie"):
            prank_items.append(id_item)

    if len(prank_items) > 0:
        id_item = random.choice(prank_items)

        prank_item = EwItem(id_item=id_item)

        item_name = prank_item.item_props.get('item_name')
        if item_name == None:
            item_name = prank_item.item_props.get('food_name')

        response = "\n\nYou think you can spot a {} lying on the ground somewhere...".format(
            item_name)

    return response
示例#4
0
def get_scalp_collection(id_item, id_server):
    item = EwItem(id_item=id_item)
    if 'decorate' not in str(item.id_owner):
        return 'It\'s a scalp board, detailing the people you\'ve eliminated. Somehow, show and tell in public seems like a bad idea.'

    id_item_col = "{}collection".format(id_item)

    scalp_inv = bknd_item.inventory(id_server=id_server, id_user=id_item_col)
    response = "You take a gander at all these marks.\n             __**SHIT LIST**__:"

    if len(scalp_inv) == 0:
        return "Soon. This board will fill someday."

    for scalp in scalp_inv:
        scalp_item = EwItem(scalp.get('id_item'))
        victim_name = scalp_item.item_props.get('cosmetic_name').replace(
            '\'s scalp', '').capitalize()
        victim_death = scalp_item.item_props.get('cosmetic_desc').replace(
            'A scalp.', '')
        for weapon in weapon_list:
            if weapon.str_scalp == victim_death:
                victim_death = "{}{}".format(
                    weapon.str_killdescriptor.capitalize(), '.')
                break
        response += "\n~~{}~~     *{}*".format(victim_name, victim_death)

    return response
示例#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 clowncar(cmd):  #shoves everyone not there into JR or the sewers
    if not cmd.message.author.guild_permissions.administrator:
        return

    id_server = cmd.guild.id
    server = ewcfg.server_list[cmd.guild.id]
    gellphones = itm_utils.find_item_all(item_search=ewcfg.item_id_gellphone,
                                         id_server=id_server,
                                         item_type_filter=ewcfg.it_item)

    for phone in gellphones:
        phone_data = EwItem(id_item=phone.get('id_item'))
        phone_data.item_props['gellphoneactive'] = 'false'
        phone_data.persist()
        if phone_data.id_owner.isnumeric() and int(phone_data.id_owner) > 0:
            print(phone_data.id_owner)
            member_object = server.get_member(int(phone_data.id_owner))
            if member_object is None:
                continue
            user_data = EwUser(member=member_object)
            print('{}{}'.format('clowning:', user_data.id_user))
            user_data.poi = 'juviesrow'
            user_data.persist()
            await ewrolemgr.updateRoles(client=cmd.client,
                                        member=member_object)

    if id_server != None:
        try:

            selection = bknd_core.execute_sql_query(
                "SELECT {id_user} FROM users WHERE id_server = %s AND {poi} NOT IN('juviesrow', 'thesewers', 'rowdyroughhouse', 'copkilltown')"
                .format(id_user=ewcfg.col_id_user,
                        poi=ewcfg.col_poi), ([str(id_server)]))

            bknd_core.execute_sql_query(
                "UPDATE users SET {poi} = %s WHERE id_server = %s AND {poi} NOT IN('juviesrow', 'thesewers', 'rowdyroughhouse', 'copkilltown')"
                .format(poi=ewcfg.col_poi), ('juviesrow', [str(id_server)]))
            iterator = 0
            for member in selection:
                iterator += 1
                if iterator % 20 == 0:
                    await asyncio.sleep(5)
                member_object = server.get_member(member[0])
                await ewrolemgr.updateRoles(client=cmd.client,
                                            member=member_object)

        except:
            ewutils.logMsg('server {}: failed to clowncar.'.format(
                cmd.message.guild.id, cmd.message.author.id))
示例#7
0
async def toss_squatters(user_id=None, server_id=None, keepKeys=False):
    player_info = EwPlayer(id_user=user_id)
    apt_info = EwApartment(id_user=user_id, id_server=server_id)

    client = ewutils.get_client()
    server = client.get_guild(server_id)

    member_data = server.get_member(player_info.id_user)

    if player_info.id_server != None and member_data != None:
        try:
            conn_info = bknd_core.databaseConnect()
            conn = conn_info.get('conn')
            cursor = conn.cursor()
            client = ewutils.get_client()

            # get all players visiting an evicted apartment and kick them out
            cursor.execute(
                "SELECT {} FROM users WHERE {} = %s AND {} = %s".format(
                    ewcfg.col_id_user,
                    ewcfg.col_visiting,
                    ewcfg.col_id_server,
                ), (
                    member_data.id,
                    server_id,
                ))

            squatters = cursor.fetchall()
            key_1 = EwItem(id_item=apt_info.key_1).id_owner
            key_2 = EwItem(id_item=apt_info.key_2).id_owner
            for squatter in squatters:
                sqt_data = EwUser(id_user=squatter[0],
                                  id_server=player_info.id_server)
                if keepKeys and (sqt_data.id_user == key_1
                                 or sqt_data.id_user == key_2):
                    pass
                else:
                    server = ewcfg.server_list[sqt_data.id_server]
                    member_object = server.get_member(squatter[0])
                    sqt_data.poi = sqt_data.poi[3:] if sqt_data.poi[
                        3:] in poi_static.id_to_poi.keys() else sqt_data.poi
                    sqt_data.visiting = ewcfg.location_id_empty
                    sqt_data.persist()
                    await ewrolemgr.updateRoles(client=client,
                                                member=member_object)
        finally:
            # Clean up the database handles.
            cursor.close()
            bknd_core.databaseClose(conn_info)
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))
示例#9
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))
示例#10
0
async def launch(cmd):
    user_data = EwUser(member=cmd.message.author)
    protected = False
    cosmetics = bknd_item.inventory(id_user=user_data.id_user, id_server=cmd.guild.id, item_type_filter=ewcfg.it_cosmetic)
    for cosmetic in cosmetics:
        cosmetic_data = EwItem(id_item=cosmetic.get('id_item'))
        if cosmetic_data.item_props.get('id_cosmetic') == 'skinsuit':
            if cosmetic_data.item_props.get('adorned') == 'true':
                protected = True

    if user_data.poi != 'ufoufo':
        response = "Launch what, dumbass? My patience?"
    elif not protected:
        response = "The aliens aren't gonna let you start the ship. You're basically their captive now."
    elif not ewcfg.dh_active or ewcfg.dh_stage != 3:
        response = "Wait, your alien espionage is waaaay out of season."
    else:
        launchstate = EwGamestate(id_state='shipstate', id_server=cmd.guild.id)
        if launchstate.bit == 1:
            response = "PCHOOOOOOOOOO! Weird bleeps and bloops begin to increase in frequency as the ship rises back into the air!"
            launchstate.bit = 0
            launchstate.persist()
        else:
            response = "WHOOOOOOOO -CRASH! Your poor piloting crashes the ship back down. Your fellow alien crew seems excited, like you just chugged a whole bottle of their galactic lager or something. Good thing the hull is so shock resistant or you wouldn't be able to joyride again."
            launchstate.bit = 1
            launchstate.persist()
    return await fe_utils.send_message(cmd.client, cmd.message.channel,fe_utils.formatMessage(cmd.message.author, response))
示例#11
0
def get_slimeoid_count(user_id=None, server_id=None):
    if user_id != None and server_id != None:
        count = 0
        slimeoid_data = EwSlimeoid(id_user=user_id, id_server=server_id)
        secondary_user = str(user_id) + "freeze"
        name_list = []
        if slimeoid_data.name != "":
            count += 1

        items = bknd_item.inventory(id_user=user_id,
                                    id_server=server_id,
                                    item_type_filter=ewcfg.it_item)

        bottles = []
        for item in items:
            item_data = EwItem(id_item=item.get('id_item'))
            if item_data.item_props.get(
                    'context') == ewcfg.context_slimeoidbottle:
                count += 1

        try:
            conn_info = bknd_core.databaseConnect()
            conn = conn_info.get('conn')
            cursor = conn.cursor()

            sql = "SELECT {} FROM slimeoids WHERE {} = %s"
            cursor.execute(sql.format(ewcfg.col_name, ewcfg.col_id_user),
                           [secondary_user])

            count += cursor.rowcount
        finally:
            # Clean up the database handles.
            cursor.close()
            bknd_core.databaseClose(conn_info)
            return count
示例#12
0
def item_drop(id_item=None, other_poi=None):
    try:
        item_data = EwItem(id_item=id_item)
        user_data = EwUser(id_user=item_data.id_owner,
                           id_server=item_data.id_server)
        if other_poi == None:
            dest = user_data.poi
        else:
            dest = other_poi

        if item_data.item_type == ewcfg.it_cosmetic:
            item_data.item_props["adorned"] = "false"
        item_data.persist()
        bknd_item.give_item(id_user=dest,
                            id_server=item_data.id_server,
                            id_item=item_data.id_item)
    except:
        ewutils.logMsg("Failed to drop item {}.".format(id_item))
示例#13
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**.'))
async def dedorn_all_costumes():
    costume_count = 0
    # Grab costumes from the cache if enabled
    item_cache = bknd_core.get_cache(obj_type="EwItem")
    if item_cache is not False:
        # separate search criteria for adorned or slimeoided
        p1 = {"context": "costume", "adorned": "true"}
        p2 = {"context": "costume", "slimeoid": "true"}
        # compile both results
        costumes_data = item_cache.find_entries(criteria={"item_props": p1})
        costumes_data += item_cache.find_entries(criteria={"item_props": p2})

        # Build a list that'll be handled in the same way
        costumes = list(map(lambda dat: dat.get("id_item"), costumes_data))
    else:
        costumes = bknd_core.execute_sql_query(
            "SELECT id_item FROM items_prop WHERE name = 'context' AND value = 'costume' AND id_item IN (SELECT id_item FROM items_prop WHERE (name = 'adorned' OR name = 'slimeoid') AND value = 'true')"
        )

    for costume_id in costumes:
        costume_item = EwItem(id_item=costume_id)

        costume_item.item_props['adorned'] = 'false'
        costume_item.item_props['slimeoid'] = 'false'

        costume_item.persist()

        costume_count += 1

    ewutils.logMsg(
        "Dedorned {} costumes after full moon ended.".format(costume_count))
示例#15
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))
示例#16
0
def item_off(id_item, id_server, item_name="", is_pushed_off=False):
    item_obj = EwItem(id_item=id_item)
    districtmodel = EwDistrict(id_server=id_server,
                               district=ewcfg.poi_id_slimesendcliffs)
    slimetotal = 0

    if item_obj.item_props.get('id_furniture') == 'sord':
        response = "You toss the sord off the cliff, but for whatever reason, the damn thing won't go down. It just keeps going up and up, as though gravity itself blocked this piece of shit jpeg artifact on Twitter. It eventually goes out of sight, where you assume it flies into the sun."
        bknd_item.item_delete(id_item=id_item)
    elif random.randrange(500) < 125 or item_obj.item_type in ([
            ewcfg.it_questitem, item_obj.item_type == ewcfg.it_medal,
            ewcfg.it_relic
    ]) or item_obj.item_props.get(
            'rarity') == ewcfg.rarity_princeps or item_obj.item_props.get(
                'id_cosmetic'
            ) == "soul" or item_obj.item_props.get(
                'id_furniture'
            ) == "propstand" or item_obj.item_props.get(
                'id_furniture'
            ) in static_items.furniture_collection or item_obj.item_props.get(
                'acquisition') == 'relic':
        response = "You toss the {} off the cliff. It sinks into the ooze disappointingly.".format(
            item_name)
        if item_obj.item_props.get('id_item') in [
                ewcfg.item_id_oldboot, ewcfg.item_id_seaweed,
                ewcfg.item_id_tincan, ewcfg.item_id_slimepoudrin
        ] or item_obj.item_props.get(
                'acquisition') == ewcfg.acquisition_fishing:
            bknd_item.item_delete(id_item=id_item)
        else:
            bknd_item.give_item(id_item=id_item,
                                id_server=id_server,
                                id_user=ewcfg.poi_id_slimesea)

    elif random.randrange(500) < 498:
        response = "You toss the {} off the cliff. A nearby kraken swoops in and chomps it down with the cephalapod's equivalent of a smile. Your new friend kicks up some sea slime for you. Sick!".format(
            item_name)
        slimetotal = 2000 + random.randrange(10000)
        bknd_item.item_delete(id_item=id_item)

    else:
        response = "{} Oh f**k. FEEDING FRENZY!!! Sea monsters lurch down on the spoils like it's f*****g christmas, and a ridiculous level of slime debris covers the ground. {}".format(
            ewcfg.emote_slime1, ewcfg.emote_slime1)
        slimetotal = 100000 + random.randrange(900000)

        bknd_item.item_delete(id_item=id_item)

    districtmodel.change_slimes(n=slimetotal)
    districtmodel.persist()
    return response
示例#17
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**.'))
示例#18
0
def get_random_prank_item(user_data, district_data):
    response = ""

    items_in_poi = bknd_core.execute_sql_query(
        "SELECT {id_item} FROM items WHERE {id_owner} = %s AND {id_server} = %s".format(
            id_item=ewcfg.col_id_item,
            id_owner=ewcfg.col_id_user,
            id_server=ewcfg.col_id_server
        ), (
            user_data.poi,
            district_data.id_server
        ))

    prank_items = []

    for item in items_in_poi:
        id_item = item[0]
        possible_prank_item = EwItem(id_item=id_item)

        context = possible_prank_item.item_props.get('context')
        food_item_id = possible_prank_item.item_props.get('id_food')

        if (context == ewcfg.context_prankitem or food_item_id == "defectivecreampie"):
            prank_items.append(id_item)

    if len(prank_items) > 0:
        id_item = random.choice(prank_items)

        prank_item = EwItem(id_item=id_item)

        item_name = prank_item.item_props.get('item_name')
        if item_name == None:
            item_name = prank_item.item_props.get('food_name')

        response = "\n\nYou think you can spot a {} lying on the ground somewhere...".format(item_name)

    return response
示例#19
0
async def beam_me_up(cmd):
    user_data = EwUser(member=cmd.message.author)
    protected = False
    cosmetics = bknd_item.inventory(id_user=user_data.id_user,
                                    id_server=cmd.guild.id,
                                    item_type_filter=ewcfg.it_cosmetic)
    for cosmetic in cosmetics:
        cosmetic_data = EwItem(id_item=cosmetic.get('id_item'))

        print(cosmetic_data.item_props)
        if cosmetic_data.item_props.get('id_cosmetic') == 'skinsuit':
            if cosmetic_data.item_props.get('adorned') == 'true':
                protected = True

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

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

    if not protected:
        response = "Why would aliens abduct you? What makes you so special?"
    elif poi_sought.id_poi == 'ufoufo':
        response = 'You\'re already in here.'
    elif poi_sought.id_poi != ewcfg.poi_id_west_outskirts:
        response = "Hey, get a bit closer. The ship's in the West Outskirts. Beam up power doesn't grow on trees, you know."
    elif shipstate.bit == 1:
        response = 'The ship\'s on the ground right now, it can\'t beam shit.'
    else:
        await fe_utils.send_message(
            cmd.client, cmd.message.channel,
            fe_utils.formatMessage(
                cmd.message.author,
                "You are being abducted by aliens. The ship is 20 seconds away."
            ))
        ewutils.active_restrictions[user_data.id_user] = 2
        await asyncio.sleep(20)

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

        await ewrolemgr.updateRoles(client=ewutils.get_client(),
                                    member=cmd.message.author)
        await user_data.move_inhabitants(id_poi='ufoufo')

    return await fe_utils.send_message(
        cmd.client, cmd.message.channel,
        fe_utils.formatMessage(cmd.message.author, response))
示例#20
0
def toss_items(id_user=None, id_server=None, poi=None):
    if id_user != None and id_server != None and poi != None:
        inv_toss = bknd_item.inventory(id_user=id_user, id_server=id_server)
        for stuff in inv_toss:  # toss all items out
            stuffing = EwItem(id_item=stuff.get('id_item'))
            stuffing.id_owner = poi.id_poi
            if stuff.get('item_type') == ewcfg.it_food and id_user[
                    -6:] == ewcfg.compartment_id_fridge:
                if int(float(stuffing.item_props.get('time_fridged'))) != 0:
                    stuffing.item_props['time_expir'] = str(
                        int(float(stuffing.item_props.get('time_expir'))) +
                        (int(time.time()) -
                         int(float(stuffing.item_props.get('time_fridged')))))
                else:
                    stuffing.item_props['time_expir'] = str(
                        int(float(stuffing.item_props.get('time_fridged'))) +
                        43200)
                stuffing.time_expir = int(
                    float(stuffing.item_props.get('time_expir')))
                stuffing.item_props['time_fridged'] = '0'
            stuffing.persist()
示例#21
0
async def smeltsoul(cmd):
    item = bknd_item.find_item(item_search="reanimatedcorpse", id_user=cmd.message.author.id, id_server=cmd.guild.id)
    if not item:
        response = "You can't rip a soul out of a nonexistent object."
    else:
        item_obj = EwItem(id_item=item.get('id_item'))
        if item_obj.item_props.get('target') != None and item_obj.item_props.get('target') != "":
            targetid = item_obj.item_props.get('target')
            if bknd_item.give_item(id_user=cmd.message.author.id, id_item=targetid, id_server=cmd.guild.id):
                response = "You ripped the soul out of the reanimated corpse. It's in mangled bits now."
                bknd_item.item_delete(id_item=item.get('id_item'))
            else:
                response = "You reach for the soul in the reanimated corpse, but your hands are full of cosmetics! Get rid of a few, freak."
        else:
            response = "That's not a reanimated corpse. It only looks like one. Get rid of the fake shit and we'll get started."
    await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
示例#22
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))
示例#23
0
async def store(cmd):
    user_data = EwUser(member=cmd.message.author)
    response = ""

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

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

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

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

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

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

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

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

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

    await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
async def 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))
示例#25
0
def get_general_collection(id_item, id_server):
    item = EwItem(id_item=id_item)
    if 'decorate' not in str(item.id_owner):
        return "It's a multi-item display case. Best viewed when placed."

    id_item_col = "{}collection".format(id_item)
    item_inv = bknd_item.inventory(id_server=id_server, id_user=id_item_col)

    if len(item_inv) == 0:
        return "There's nothing in here at the moment."

    response = "You examine your preserved collection. Inside is "
    item_arr = []

    for gen_item in item_inv:
        item_arr.append("a {} ({})".format(gen_item.get('name'),
                                           gen_item.get('id_item')))

    response += "{}{}".format(ewutils.formatNiceList(names=item_arr), ".")

    return response
async def skullbash(cmd):
    user_data = EwUser(member=cmd.message.author)
    item_stash = bknd_item.inventory(id_user=cmd.message.author.id, id_server=user_data.id_server)
    item_sought = None
    for item_piece in item_stash:
        item = EwItem(id_item=item_piece.get('id_item'))
        if item_piece.get('item_type') == ewcfg.it_furniture and item.item_props.get('id_furniture') == "brick":
            item_sought = item_piece

    if item_sought:
        if user_data.life_state == ewcfg.life_state_corpse:
            response = "Your head is too incorporeal to do that."
        else:
            ewutils.active_restrictions[user_data.id_user] = 2
            response = "You suck in your gut and mentally prepare to lose a few brain cells. 3...2...1...WHACK! Ugh. You're gonna need a minute."
            await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
            await asyncio.sleep(600)
            ewutils.active_restrictions[user_data.id_user] = 0
            response = "The stars slowly begin to fade from your vision. Looks like you're lucid again."
    else:
        response = "You don't have a hard enough brick to bash your head in."

    return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
示例#27
0
def dedorn_all_costumes():
    costumes = bknd_core.execute_sql_query(
        "SELECT id_item FROM items_prop WHERE name = 'context' AND value = 'costume' AND id_item IN (SELECT id_item FROM items_prop WHERE (name = 'adorned' OR name = 'slimeoid') AND value = 'true')"
    )
    costume_count = 0

    for costume_id in costumes:
        costume_item = EwItem(id_item=costume_id)

        costume_item.item_props['adorned'] = 'false'
        costume_item.item_props['slimeoid'] = 'false'

        costume_item.persist()

        costume_count += 1

    ewutils.logMsg(
        "Dedorned {} costumes after full moon ended.".format(costume_count))
示例#28
0
def get_fish_collection(id_item, id_server):
    item = EwItem(id_item=id_item)
    if 'decorate' not in str(item.id_owner):
        return 'It\'s a large aquarium, built for whole schools of fish. You can\'t see what\'s inside because you\'re nearly killing yourself carrying it.'

    id_item_col = "{}collection".format(id_item)

    fish_inv = bknd_item.inventory(id_server=id_server, id_user=id_item_col)

    response = ""

    if len(fish_inv) == 0:
        return "Look at all these- wait, you don't have any fish in here."
    elif len(fish_inv) == 1:
        response += "There's just one fish in here. It's feeling very loved."
    elif len(fish_inv) < 6:
        response += "It's pretty spacious in here!"
    elif len(fish_inv) < 43:
        response += "Look at all these fish!"
    else:
        response += "This thing is packed!"

    response += " There's "

    fish_arr = []

    for fish in fish_inv:
        fish_item = EwItem(fish.get('id_item'))
        length = fish_item.item_props.get('length')
        if length is None:
            length = float(
                (ewcfg.fish_size_range.get(fish_item.item_props.get('size'))[0]
                 + ewcfg.fish_size_range.get(
                     fish_item.item_props.get('size'))[1]) / 2)
            fish_item.item_props['length'] = length
            fish_item.persist()
        fish_arr.append("a {} ({} in)".format(fish.get('name'), length))

    response += "{}{}".format(ewutils.formatNiceList(names=fish_arr), ".")
    return response
示例#29
0
async def order(cmd):
    user_data = EwUser(member=cmd.message.author)
    mutations = user_data.get_mutations()
    if user_data.life_state == ewcfg.life_state_shambler and user_data.poi != ewcfg.poi_id_nuclear_beach_edge:
        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=cmd.guild.id)
    currency_used = 'slime'
    current_currency_amount = user_data.slimes
    # poi = ewmap.fetch_poi_if_coordless(cmd.message.channel.name)
    poi = poi_static.id_to_poi.get(user_data.poi)
    if poi is None or len(poi.vendors) == 0 or ewutils.channel_name_is_poi(cmd.message.channel.name) == False:
        # Only allowed in the food court.
        response = "There’s nothing to buy here. If you want to purchase some items, go to a sub-zone with a vendor in it, like the food court, the speakeasy, or the bazaar."
    else:
        poi = poi_static.id_to_poi.get(user_data.poi)
        district_data = EwDistrict(district=poi.id_poi, id_server=user_data.id_server)

        shambler_multiplier = 1  # for speakeasy during shambler times

        if district_data.is_degraded():
            if poi.id_poi == ewcfg.poi_id_speakeasy:
                shambler_multiplier = 4
            else:
                response = "{} has been degraded by shamblers. You can't {} here anymore.".format(poi.str_name, cmd.tokens[0])
                return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
        # value = ewutils.flattenTokenListToString(cmd.tokens[1:2])

        # if cmd.tokens_count > 1:
        #	value = cmd.tokens[1]
        #	value = value.lower()

        value = None

        togo = False
        if cmd.tokens_count > 1:
            for token in cmd.tokens[1:]:
                if token.startswith('<@') == False and token.lower() not in "togo":  # togo can be spelled together or separate
                    value = token
                    break

            for token in cmd.tokens[1:]:
                if token.lower() in "togo":  # lets people get away with just typing only to or only go (or only t etc.) but whatever
                    togo = True
                    break

        # Finds the item if it's an EwGeneralItem.

        if value == "mylittleponyfigurine":
            value = random.choice(static_items.furniture_pony)

        item = static_items.item_map.get(value)

        item_type = ewcfg.it_item
        if item != None:
            item_id = item.id_item
            name = item.str_name

        # Finds the item if it's an EwFood item.
        if item == None:
            item = static_food.food_map.get(value)
            item_type = ewcfg.it_food
            if item != None:
                item_id = item.id_food
                name = item.str_name

        # Finds the item if it's an EwCosmeticItem.
        if item == None:
            item = static_cosmetics.cosmetic_map.get(value)
            item_type = ewcfg.it_cosmetic
            if item != None:
                item_id = item.id_cosmetic
                name = item.str_name

        if item == None:
            item = static_items.furniture_map.get(value)
            item_type = ewcfg.it_furniture
            if item != None:
                item_id = item.id_furniture
                name = item.str_name
                if item_id in static_items.furniture_pony:
                    item.vendors = [ewcfg.vendor_bazaar]

        if item == None:
            item = static_weapons.weapon_map.get(value)
            item_type = ewcfg.it_weapon
            if item != None:
                item_id = item.id_weapon
                name = item.str_weapon

        if item == None:
            item = static_relic.relic_map.get(value)
            item_type = ewcfg.it_relic
            if item != None and relic_utils.canCreateRelic(item.id_relic, cmd.guild.id):
                item_id = item.id_relic
                name = item.str_name
            elif item != None:
                item = None


        if item != None:
            item_type = item.item_type
            # Gets a vendor that the item is available and the player currently located in
            try:
                current_vendor = (set(item.vendors).intersection(set(poi.vendors))).pop()
            except:
                current_vendor = None

            # Check if the item is available in the current bazaar item rotation
            if current_vendor == ewcfg.vendor_bazaar:
                if item_id not in market_data.bazaar_wares.values():
                    if item_id in static_items.furniture_pony and "mylittleponyfigurine" in market_data.bazaar_wares.values():
                        pass
                    else:
                        current_vendor = None


            if current_vendor is None or len(current_vendor) < 1:
                response = "Check the {} for a list of items you can {}.".format(ewcfg.cmd_menu, ewcfg.cmd_order)

            else:
                response = ""

                value = item.price

                premium_purchase = True if item_id in ewcfg.premium_items else False
                if premium_purchase:
                    togo = True  # Just in case they order a premium food item, don't make them eat it right then and there.

                    if ewcfg.cd_premium_purchase > (int(time.time()) - user_data.time_lastpremiumpurchase):
                        response = "That item is in very limited stock! The vendor asks that you refrain from purchasing it for a day or two."
                        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

                    elif ewcfg.cd_new_player > (int(time.time()) - user_data.time_joined):
                        response = "You've only been in the city for a few days. The vendor doesn't trust you with that item very much..."
                        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

                stock_data = None
                company_data = None
                # factor in the current stocks
                for vendor in item.vendors:
                    if vendor in ewcfg.vendor_stock_map:
                        stock = ewcfg.vendor_stock_map.get(vendor)
                        company_data = EwCompany(id_server=user_data.id_server, stock=stock)
                        stock_data = EwStock(id_server=user_data.id_server, stock=stock)

                if stock_data is not None:
                    value *= (stock_data.exchange_rate / ewcfg.default_stock_exchange_rate) ** 0.2

                controlling_faction = poi_utils.get_subzone_controlling_faction(user_data.poi, user_data.id_server)

                if controlling_faction != "":
                    # prices are halved for the controlling gang
                    if controlling_faction == user_data.faction:
                        value /= 2

                    # and 4 times as much for enemy gangsters
                    elif user_data.faction != "":
                        value *= 4

                # raise shambled speakeasy price 4 times
                value *= shambler_multiplier

                # Raise the price for togo ordering. This gets lowered back down later if someone does togo ordering on a non-food item by mistake.
                if togo:
                    value *= 1.5

                if current_vendor == ewcfg.vendor_breakroom and user_data.faction == ewcfg.faction_slimecorp:
                    value = 0

                value = int(value)

                food_ordered = False
                target_data = None

                # Kingpins eat free.
                if (user_data.life_state == ewcfg.life_state_kingpin or user_data.life_state == ewcfg.life_state_grandfoe) and item_type == ewcfg.it_food:
                    value = 0

                if value > current_currency_amount:
                    # Not enough money.
                    response = "A {} costs {:,} {}, and you only have {:,}.".format(name, value, currency_used, current_currency_amount)
                else:
                    mutations = user_data.get_mutations()
                    if random.randrange(5) == 0 and ewcfg.mutation_id_stickyfingers in mutations:
                        value = 0
                        user_data.change_crime(n=ewcfg.cr_larceny_points)

                    inv_response = bknd_item.check_inv_capacity(user_data=user_data, item_type=item_type, return_strings=True, pronoun="You")
                    if inv_response != "" and (item_type != ewcfg.it_food or togo):
                        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, inv_response))

                    if item_type == ewcfg.it_food:
                        food_ordered = True

                        target = None
                        target_data = None
                        if not togo:  # cant order togo for someone else, you can just give it to them in person
                            if cmd.mentions_count == 1:
                                target = cmd.mentions[0]
                                if target.id == cmd.message.author.id:
                                    target = None

                        if target != None:
                            target_data = EwUser(member=target)
                            if target_data.life_state == ewcfg.life_state_corpse and target_data.get_possession():
                                response = "How are you planning to feed them while they're possessing you?"
                                return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
                            elif target_data.poi != user_data.poi:
                                response = "You can't order anything for them because they aren't here!"
                                return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

                    elif item_type == ewcfg.it_weapon:

                        if user_data.life_state == ewcfg.life_state_corpse:
                            response = "Ghosts can't hold weapons."
                            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)

                    # Only food should have the value multiplied. If someone togo orders a non-food item by mistake, lower it back down.
                    if not food_ordered and togo:
                        value = int(value / 1.5)

                    if currency_used == 'slime':
                        user_data.change_slimes(n=-value, source=ewcfg.source_spending)

                    if company_data is not None:
                        company_data.recent_profits += value
                        company_data.persist()

                    if item.str_name == "arcade cabinet":
                        item_props['furniture_desc'] = random.choice(ewcfg.cabinets_list)
                    elif item.item_type == ewcfg.it_furniture:
                        if "custom" in item_props.get('id_furniture'):
                            if cmd.tokens_count < 4 or cmd.tokens[2] == "" or cmd.tokens[3] == "":
                                response = "You need to specify the customization text before buying a custom item. Come on, isn't that self-evident? (!order [custom item] \"custom name\" \"custom description\")"
                                return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
                            else:
                                customname = cmd.tokens[2]

                                if len(customname) > 32:
                                    response = "That name is too long. ({:,}/32)".format(len(customname))
                                    return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

                                customdesc = cmd.tokens[3]

                                if len(customdesc) > 500:
                                    response = "That description is too long. ({:,}/500)".format(len(customdesc))
                                    return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

                                name = item_props['furniture_name'] = item_props['furniture_name'].format(custom=customname)
                                item_props['furniture_desc'] = customdesc
                                item_props['furniture_look_desc'] = item_props['furniture_look_desc'].format(custom=customname)
                                item_props['furniture_place_desc'] = item_props['furniture_place_desc'].format(custom=customname)

                    id_item = bknd_item.item_create(
                        item_type=item_type,
                        id_user=cmd.message.author.id,
                        id_server=cmd.guild.id,
                        stack_max=-1,
                        stack_size=0,
                        item_props=item_props
                    )

                    if value == 0:
                        response = "You swipe a {} from the counter at {}.".format(name, current_vendor)
                    else:
                        response = "You slam {:,} {} down on the counter at {} for {}.".format(value, currency_used, current_vendor, name)

                    if food_ordered and not togo:
                        item_data = EwItem(id_item=id_item)

                        # Eat food on the spot!
                        if target_data != None:

                            target_player_data = EwPlayer(id_user=target_data.id_user)

                            if value == 0:
                                response = "You swipe a {} from the counter at {} and give it to {}.".format(name, current_vendor, target_player_data.display_name)
                            else:
                                response = "You slam {:,} slime down on the counter at {} for {} and give it to {}.".format(value, current_vendor, name, target_player_data.display_name)

                            response += "\n\n*{}*: ".format(target_player_data.display_name) + target_data.eat(item_data)
                            target_data.persist()
                            
                        else:

                            if value == 0:
                                response = "You swipe a {} from the counter at {} and eat it right on the spot.".format(name, current_vendor)
                            else:
                                response = "You slam {:,} slime down on the counter at {} for {} and eat it right on the spot.".format(value, current_vendor, name)

                            user_player_data = EwPlayer(id_user=user_data.id_user)

                            response += "\n\n*{}*: ".format(user_player_data.display_name) + user_data.eat(item_data)
                            user_data.persist()

                    if premium_purchase:
                        user_data.time_lastpremiumpurchase = int(time.time())

                    user_data.persist()

        else:
            response = "Check the {} for a list of items you can {}.".format(ewcfg.cmd_menu, ewcfg.cmd_order)

    # Send the response to the player.
    await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
示例#30
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))