コード例 #1
0
ファイル: moveutils.py プロジェクト: Froggg/endless-war
async def one_eye_dm(id_user = None, id_server = None, poi = None):
    poi_obj = poi_static.id_to_poi.get(poi)
    client = ewutils.get_client()
    server = client.get_guild(id_server)

    server = client.get_guild(str(id_server))

    server = client.get_guild(int(id_server))

    id_player = EwPlayer(id_user=id_user, id_server=id_server)

    if poi_obj.pvp:
        try:
            recipients = bknd_core.execute_sql_query(
                "SELECT {id_user} FROM mutations WHERE {id_server} = %s AND {mutation} = %s and {data} = %s".format(
                    data=ewcfg.col_mutation_data,
                    id_server=ewcfg.col_id_server,
                    id_user=ewcfg.col_id_user,
                    mutation=ewcfg.col_id_mutation,
                ), (
                    id_server,
                    ewcfg.mutation_id_oneeyeopen,
                    str(id_user),
                ))
            for recipient in recipients:
                member = server.get_member(int(recipient[0]))
                mutation = EwMutation(id_server=id_server, id_user=recipient[0], id_mutation=ewcfg.mutation_id_oneeyeopen)
                mutation.data = ""
                mutation.persist()
                await fe_utils.send_message(client, member, fe_utils.formatMessage(member, "{} is stirring...".format(id_player.display_name)))

        except:
            ewutils.logMsg("Failed to do OEO notificaitons for {}.".format(id_user))
コード例 #2
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))
コード例 #3
0
async def track_oneeyeopen(cmd):
    user_data = EwUser(id_user=cmd.message.author.id, id_server=cmd.message.guild.id)
    if cmd.mentions_count > 0:
        target_data = EwUser(member=cmd.mentions[0])
    mutations = user_data.get_mutations()

    if ewcfg.mutation_id_oneeyeopen not in mutations:
        response = "No can do. Your third eye is feeling pretty flaccid today."
    elif cmd.mentions_count == 0:
        response = "Who are you tracking?"
    elif cmd.mentions_count > 1:
        response = "Nice try, but you're not the NSA. Limit your espionage to one poor sap."
    elif cmd.mentions[0] == cmd.message.author:
        response = "You set your third eye to track yourself. However, you are too uncomfortable with your body to keep it there. Better try something else."
    else:
        response = "Your third eye slips out of your forehead and wanders its way to {}'s location. Just a matter of time...".format(cmd.mentions[0].display_name)
        mutation_data = EwMutation(id_user=user_data.id_user, id_server=user_data.id_server, id_mutation=ewcfg.mutation_id_oneeyeopen)
        mutation_data.data = target_data.id_user
        mutation_data.persist()

    return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
コード例 #4
0
async def slap(cmd):
    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])))

    time_now = int(time.time())
    user_data = EwUser(member=cmd.message.author)

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

    target_data = -1

    mutations = user_data.get_mutations()
    resp_cont = EwResponseContainer(id_server=cmd.guild.id)

    if cmd.tokens_count < 3:
        response = "You'll need to specify who and where you're slapping. Try !slap <target> <location>."
        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

    dest_poi = cmd.tokens[2].lower()
    dest_poi_obj = poi_static.id_to_poi.get(dest_poi)

    response = ""

    if cmd.mentions_count == 0:
        response = "Who are you slapping?"
    elif cmd.mentions_count > 1:
        response = "Nobody's that good at slapping. Do it to one person at a time."
    else:
        target_data = EwUser(member=cmd.mentions[0])

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

    if target_data.poi != user_data.poi:
        response = "Not right now. You can't slap what you can't see."
    elif user_data.id_user == target_data.id_user:
        response = "Stop hitting yourself."
    elif ewutils.active_restrictions.get(target_data.id_user) != None and ewutils.active_restrictions.get(target_data.id_user) > 0:
        response = "They're in the middle of something, be patient."
    elif target_data.life_state == ewcfg.life_state_corpse:
        response = "You give {} a good whack. They're a ghost though, so your hand passes straight through.".format(cmd.mentions[0].display_name)
    elif ewcfg.mutation_id_ditchslap not in mutations:
        response = "You wind up your good arm and tacoom {} hard in the {}. The air gets knocked out of them but they stay firmly in place.".format(cmd.mentions[0].display_name, random.choice(['face', 'face', 'face', 'ass']))
    else:
        mutation_data = EwMutation(id_mutation=ewcfg.mutation_id_ditchslap, id_user=cmd.message.author.id, id_server=cmd.message.guild.id)

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

        if dest_poi_obj.id_poi not in user_poi.neighbors.keys():
            response = "You can't hit them that far."
        elif move_utils.inaccessible(user_data=target_data, poi=dest_poi_obj):
            response = "That place is locked up good. You can't get a good launch angle to send them there."
        # elif time_lastuse + 180 * 60 > time_now:
        # response = "Your arm is spent from the last time you obliterated someone. Try again in {} minutes.".format(math.ceil((time_lastuse + 180*60 - time_now)/60))
        elif user_data.faction != target_data.faction:
            response = "You try to slap {}, but they realize what you're doing and jump back. Welp, back to the drawing board.".format(cmd.mentions[0].display_name)
        elif user_poi.id_poi in [ewcfg.poi_id_rowdyroughhouse, ewcfg.poi_id_copkilltown] or user_poi.is_apartment:
            response = "They're currently in their room. You'd have to carry {} out of it to slap them, which would be gay.".format(cmd.mentions[0].display_name)
        elif ewcfg.status_slapped_id in target_data.getStatusEffects():
            response = "Don't turn this into domestic abuse now. Can't you see they're still reeling from the last time?"
        elif (ewutils.clenched.get(target_data.id_user) == None or ewutils.clenched.get(target_data.id_user) == 0) and (user_poi.is_subzone or user_poi.is_district):
            response = "You wind up your slappin' hand and take a swing, but {} is all relaxed and you can't get a good angle. They end up flying into the wall. Better not touch people who aren't prepared to get hit...".format(cmd.mentions[0].display_name)
        else:
            response = "You wind up your slap. This one's gonna hurt. Steady as she goes...WHAM! {} is sent flying helplessly into {}!".format(cmd.mentions[0].display_name, dest_poi_obj.str_name)
            target_data.applyStatus(id_status=ewcfg.status_slapped_id)
            dm_response = "WHAP! {} smacked you into {}!".format(cmd.message.author.display_name, dest_poi_obj.str_name)
            target_response = "**CRAAAAAAAAAAAASH!** You arrive in {}!".format(dest_poi_obj.str_name)
            ewutils.moves_active[cmd.message.author.id] = 0
            target_data.poi = dest_poi_obj.id_poi
            user_data.time_lastenter = int(time.time())

            mutation_data.data = str(time_now)
            mutation_data.persist()

            if target_data.poi == ewcfg.poi_id_thesewers:
                target_data.die(cause=ewcfg.cause_suicide)
                target_response += " But you hit your head really hard! Your precious little dome explodes into bits and pieces and you die!"

            user_data.persist()

            await ewrolemgr.updateRoles(client=ewutils.get_client(), member=cmd.mentions[0], new_poi=target_data.poi)
            target_data.persist()

            await user_data.move_inhabitants(id_poi=dest_poi_obj.id_poi)

            await prank_utils.activate_trap_items(dest_poi_obj.id_poi, user_data.id_server, target_data.id_user)

            await fe_utils.send_message(cmd.client, cmd.mentions[0], fe_utils.formatMessage(cmd.mentions[0], dm_response))
            await fe_utils.send_message(cmd.client, fe_utils.get_channel(server=cmd.mentions[0].guild, channel_name=dest_poi_obj.channel), fe_utils.formatMessage(cmd.mentions[0], target_response))

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

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


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

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

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

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

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

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

            else:
                recover_hunger = 100

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