コード例 #1
0
async def flutter(cmd):
    user_data = EwUser(member=cmd.message.author)
    if user_data.race == ewcfg.race_avian:
        district_data = EwDistrict(district=user_data.poi, id_server=cmd.guild.id)
        market_data = EwMarket(id_server=cmd.guild.id)
        response = "You flap your wings in an attempt to fly, but "
        excuses = []

        if market_data.weather == ewcfg.weather_lightning:
            excuses.append("the current weather would make that a bit dangerous, so you decide not to.")
        if ewcfg.mutation_id_bigbones in user_data.get_mutations():
            excuses.append("your bones are too big for you to get off the ground.")
        if ewcfg.mutation_id_lightasafeather in user_data.get_mutations():
            excuses.append("your wings are too skinny to generate enough lift.")

        if 6 <= market_data.clock >= 20:
            excuses.append("it's not safe to fly at night, so you decide not to.")
        else:
            excuses.append("flying in plain daylight might get you shot off the sky, so you decide not to.")

        if user_data.slimes > 1000000:
            excuses.append("you have too much slime on you, so you don't even get off the ground.")
        else:
            excuses.append("you're too weak for this right now, gonna need to get more slime.")

        if user_data.life_state == ewcfg.life_state_corpse:
            excuses.append("your incorporeal wings generate no lift.")
        elif user_data.life_state == ewcfg.life_state_juvenile:
            excuses.append("you lack the moral fiber to do so.")
        else:
            if user_data.faction == ewcfg.faction_rowdys:
                excuses.append("you end up thrashing with your wings in an unorganized fashion.")
            if user_data.faction == ewcfg.faction_killers:
                excuses.append("you end up doing rapid dabs instead.")

        if len(district_data.get_players_in_district()) > 1:
            excuses.append("it's embarassing to do so with other people around.")
        else:
            excuses.append("you can't be bothered if there's no one here to see you do it.")

        if user_data.hunger / user_data.get_hunger_max() < 0.5:
            excuses.append("you're too hungry, and end up looking for worms instead.")
        else:
            excuses.append("you're too full from your last meal for such vigorous exercise.")

        response += random.choice(excuses)
    else:
        response = "You people are not allowed to do that."

    return await fe_utils.send_response(response, cmd)
コード例 #2
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))
コード例 #3
0
async def check_farm(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 = ""
    levelup_response = ""
    mutations = user_data.get_mutations()

    # Checking availability of check farm 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 = "Do you remember planting anything here in this barren wasteland? No, you don’t. Idiot."
    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 missed a step, you haven’t planted anything here yet."
        elif farm.action_required == ewcfg.farm_action_none:
            if farm.phase == ewcfg.farm_phase_reap:
                response = "Your crop is ready for the harvest."
            elif farm.phase == ewcfg.farm_phase_sow:
                response = "You only just planted the seeds. Check back later."
            else:
                if farm.slimes_onreap < ewcfg.reap_gain:
                    response = "Your crop looks frail and weak."
                elif farm.slimes_onreap < ewcfg.reap_gain + 3 * ewcfg.farm_slimes_peraction:
                    response = "Your crop looks small and generally unremarkable."
                elif farm.slimes_onreap < ewcfg.reap_gain + 6 * ewcfg.farm_slimes_peraction:
                    response = "Your crop seems to be growing well."
                else:
                    response = "Your crop looks powerful and bursting with nutrients."

        else:
            farm_action = farm_static.id_to_farm_action.get(farm.action_required)
            response = farm_action.str_check

    await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
コード例 #4
0
async def waft(cmd):
    user_data = EwUser(member=cmd.message.author)
    mutations = user_data.get_mutations()
    if ewcfg.mutation_id_aposematicstench not in mutations:
        response = "You stink, but not that badly. Get Aposematic Stench before you try that."
    else:
        user_data.applyStatus(ewcfg.status_repelled_id)
        response = "You clench as hard as you can, and your pores excrete a mushroom cloud of pure, olive green musk. It's so caustic you might not have eyebrows anymore. You should be immune from monsters, though!"

    return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
コード例 #5
0
def mutation_commands(cmd):
    response = "\n**CURRENT MUTATIONS:**"
    user_data = EwUser(member=cmd.message.author)
    mutations = user_data.get_mutations()
    for mutation in mutations:
        if ewcfg.mutation_unique_commands.get(mutation) is not None:
            response += "\n" + ewcfg.mutation_unique_commands.get(mutation)

    if response != "\n**CURRENT MUTATIONS:**":
        return response
    else:
        return ""
コード例 #6
0
async def cultivate(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 = ""
    levelup_response = ""
    mutations = user_data.get_mutations()

    # Checking availability of irrigate action
    if user_data.life_state != ewcfg.life_state_juvenile:
        response = "Only Juveniles of pure heart and with nothing better to do can tend to their crops."
    elif cmd.message.channel.name not in [ewcfg.channel_jr_farms, ewcfg.channel_og_farms, ewcfg.channel_ab_farms]:
        response = "Do you remember planting anything here in this barren wasteland? No, you don’t. Idiot."
    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
        )

        farm_action = farm_static.cmd_to_farm_action.get(cmd.tokens[0].lower())

        if farm.time_lastsow == 0:
            response = "You missed a step, you haven’t planted anything here yet."
        elif farm.action_required != farm_action.id_action:
            response = farm_action.str_execute_fail
            farm.slimes_onreap -= ewcfg.farm_slimes_peraction
            farm.slimes_onreap = max(farm.slimes_onreap, 0)
            farm.persist()
        else:
            response = farm_action.str_execute
            # gvs - farm actions award more slime
            farm.slimes_onreap += ewcfg.farm_slimes_peraction * 2
            farm.action_required = ewcfg.farm_action_none
            farm.persist()

    await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
コード例 #7
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))
コード例 #8
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))
コード例 #9
0
async def tracker(cmd):
    user_data = EwUser(member=cmd.message.author)
    mutations = user_data.get_mutations()

    if ewcfg.mutation_id_oneeyeopen not in mutations:
        response = "Your third eye is tucked snugly into your forehead. Actually, who are you fooling? You don't have a third eye. What, are you stupid?"
    else:
        mutation = EwMutation(id_server=cmd.message.guild.id, id_user=cmd.message.author.id, id_mutation=ewcfg.mutation_id_oneeyeopen)
        if mutation.data == "":
            response = "Your third eye isn't tracking anyone right now."
        else:
            target = EwPlayer(id_server=cmd.message.guild.id, id_user=mutation.data)
            response = "You're tracking {} right now. LOL, they're lookin pretty dumb over there.".format(target.display_name)

    return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
コード例 #10
0
async def fursuit(cmd):
    user_data = EwUser(member=cmd.message.author)
    mutations = user_data.get_mutations()
    market_data = EwMarket(id_server=cmd.guild.id)

    if ewcfg.mutation_id_organicfursuit in mutations:
        days_until = -market_data.day % 31

        if days_until == 0:
            response = "Hair is beginning to grow on the surface of your skin rapidly. Your canine instincts will take over soon!"
        else:
            response = "With a basic hairy palm reading, you determine that you'll be particularly powerful in {} day{}.".format(days_until, "s" if days_until != 1 else "")

        if ewutils.check_fursuit_active(market_data):
            response = "The full moon shines above! Now's your chance to strike!"

    else:
        response = "You're about as hairless as an egg, my friend."

    await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
コード例 #11
0
async def bleedout(cmd):
    user_data = EwUser(member=cmd.message.author)
    mutations = user_data.get_mutations()

    if ewcfg.mutation_id_bleedingheart not in mutations:
        response = "You don't have an open enough wound to just gush your blood everywhere."
    elif user_data.bleed_storage == 0:
        response = "There's nothing to bleed. Sounds like someone has a persecution complex..."
    elif user_data.bleed_storage > user_data.slimes:  # don't think this is possible, but just in case
        response = "Wait, wouldn't that kill you? Better not."
    else:
        response = "You clutch your malformed heart and squeeze as hard as you can. The intense pain makes you fall to your knees, and your slime drops in spurts to the floor under you as you gasp desperately for relief. You have been bled dry."
        poi = poi_static.id_to_poi.get(user_data.poi)
        district_data = EwDistrict(id_server=cmd.message.guild.id, district=poi.id_poi)
        user_data.change_slimes(n=-user_data.bleed_storage, source=ewcfg.source_bleeding)
        district_data.change_slimes(n=user_data.bleed_storage, source=ewcfg.source_bleeding)
        user_data.bleed_storage = 0
        user_data.persist()
        district_data.persist()
    return 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 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))
コード例 #14
0
ファイル: fishcmds.py プロジェクト: C-rank/endless-war
async def barter_all(cmd):
    user_data = EwUser(member=cmd.message.author)
    mutations = user_data.get_mutations()

    # if non-zone channel, break
    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])))

    # if not in speakeasy, break
    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 corpse, break
    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))

    food_items = bknd_item.inventory(id_user=user_data.id_user, id_server=user_data.id_server, item_type_filter=ewcfg.it_food)
    offer_items = []  # list of items to create when offer goes through
    offer_slime = 0  # slime to give player when offer goes through
    fish_ids_to_remove = []  # list of fish to delete when offer goes through

    # check if food item is a fish and add to offer if it is
    for item in food_items:
        fish = EwItem(id_item=item.get('id_item'))
        # if item is a fish, add to offer
        if fish.item_props.get('acquisition') == ewcfg.acquisition_fishing:
            fish_ids_to_remove.append(fish.id_item)
            value = int(fish.item_props['value'])

            # 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 fish.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 / 5  # 120,000 slime for a colossal promo fish, 24,000 for a miniscule common fish.

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

                offer_slime += 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%.
                potential_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.
                        potential_items.append(result)
                    else:
                        pass
                # Filters out items of greater value than your fish.
                for value_filter in potential_items:
                    if value < value_filter.context:
                        potential_items.remove(value_filter)
                    else:
                        pass

                offer_items.append(random.choice(potential_items))

    # if player had some fish to offer
    if offer_slime > 0 or len(offer_items) > 0:

        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 drop all of your fish at his feet."

        items_desc = ""
        if len(offer_items) > 0:
            if len(offer_items) > 4:
                items_desc = "a handful items"
            elif len(offer_items) > 1:
                items_desc = "a few items"
            else:
                items_desc = "a {}".format(offer_items[0].str_name)

        offer_desc = "{}{}{}".format((str(offer_slime) + " slime") if (offer_slime > 0) else "", " and " if (offer_slime > 0 and len(items_desc) > 0) else "", items_desc if (len(items_desc) > 0) else "")
        response += ' \n"Hm, alright… for your fish... I’ll trade you {}!"'.format(offer_desc)

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

        response = ""

        if offer_slime > 0:
            slime_gain = offer_slime

            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"

        if len(offer_items):
            for item in offer_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
                )

        for id in fish_ids_to_remove:
            bknd_item.item_delete(id_item=id)

        user_data.persist()

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


    # player has no fish
    else:
        response = "You need some fish to barter with Captain Albert Alexander. Get out there and do some fishing!"

    await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
コード例 #15
0
ファイル: fishcmds.py プロジェクト: C-rank/endless-war
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))
コード例 #16
0
ファイル: fishcmds.py プロジェクト: C-rank/endless-war
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))
コード例 #17
0
async def piss(cmd):
    user_data = EwUser(member=cmd.message.author)
    mutations = user_data.get_mutations()

    if ewcfg.mutation_id_enlargedbladder in mutations:

        user_data.change_crime(n=1)
        user_data.persist()

        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') == 'chastitybelt':
                if cosmetic_data.item_props.get('adorned') == 'true':
                    protected = True

        if protected == True:
            response = "Reaching for your weewee, you instead hear the desolate metal clank of your hand against a steel groincage. Damn you, chastity belt. DAMN YOU TO HELL!!! "
            return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

        if cmd.mentions_count == 0:
            response = "You unzip your dick and just start pissing all over the goddamn f*****g floor. God, you’ve waited so long for this moment, and it’s just as perfect as you could have possibly imagined. You love pissing so much."
            if random.randint(1, 100) < 2:
                slimeoid = EwSlimeoid(member=cmd.message.author)
                if slimeoid.life_state == ewcfg.slimeoid_state_active:
                    hue = hue_static.hue_map.get("yellow")
                    response = "CONGRATULATIONS. You suddenly lose control of your HUGE C**K and saturate your {} with your PISS. {}".format(slimeoid.name, hue.str_saturate)
                    slimeoid.hue = (hue_static.hue_map.get("yellow")).id_hue
                    slimeoid.persist()
            return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

        if cmd.mentions_count == 1:
            target_member = cmd.mentions[0]
            target_user_data = EwUser(member=target_member)

            if user_data.id_user == target_user_data.id_user:
                response = "Your love for piss knows no bounds. You aim your urine stream sky high, causing it to land right back into your own mouth. Mmmm, tasty~!"
                return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

            if user_data.poi == target_user_data.poi:

                if target_user_data.life_state == ewcfg.life_state_corpse:
                    response = "You piss right through them! Their ghostly form ripples as the stream of urine pours endlessly unto them."
                    return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

                response = "You piss HARD and FAST right onto {}!!".format(target_member.display_name)
            else:
                response = "You can't !piss on someone who isn't there! Moron!"

        elif cmd.mentions_count > 1:
            response = "Whoa, one water-sports fetishist at a time, pal!"

    elif user_data.life_state == ewcfg.life_state_corpse:
        if cmd.mentions_count == 0:
            response = "You grow a ghost dick, unzip it, and just start ghost pissing all over the goddamn f*****g floor. God, you’ve waited so long for this moment, and it’s just as perfect as you could have possibly imagined. You love ghost pissing so much."
            if random.randint(1, 100) < 3:
                response = "You grow a gussy, unzip it, and just start ghost pissing all over the goddamn f*****g floor. God, you've waited so long for this moment, and it's just as perfect as you could have possibly imagined. You love ghost pissing so much."
            return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

        if cmd.mentions_count == 1:
            target_member = cmd.mentions[0]
            target_user_data = EwUser(member=target_member)

            if user_data.id_user == target_user_data.id_user:
                response = "Your love for negapiss knows no bounds. You aim your antiurine stream sky high, causing it to land right back into your own ghastly mouth. Mmmm, tasty~!"
                return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

            if user_data.poi == target_user_data.poi:

                if target_user_data.life_state == ewcfg.life_state_corpse:
                    response = "You ghost piss HARD and FAST right onto {}!!".format(target_member.display_name)
                    return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

                response = "Your ghost piss passes right through them! {} seems annoyed at the negapiss you're streaming at them, but they're entirely unaffected.".format(target_member.display_name)
            else:
                response = "You can't !piss on someone who isn't there! Moron!"

        elif cmd.mentions_count > 1:
            response = "Whoa, one necrophiliac at a time, pal!"

    else:
        response = "You lack the moral fiber necessary for urination."

    return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
コード例 #18
0
def get_mining_yield_bubblebreaker(cmd, grid_cont):
    user_data = EwUser(member=cmd.message.author)
    grid = grid_cont.grid

    hunger_cost_mod = ewutils.hunger_cost_mod(user_data.slimelevel)

    row = -1
    col = -1
    bubble_add = None
    if cmd.tokens_count < 2:
        response = "Please specify which Bubble Breaker vein to mine."
        return response

    for token in cmd.tokens[1:]:
        token_lower = token.lower()

        coords = token_lower
        if coords == "reset":
            user_data.hunger += int(ewcfg.hunger_perminereset *
                                    hunger_cost_mod)
            user_data.persist()
            init_grid_bubblebreaker(user_data.poi, user_data.id_server)
            return ""

        if col < 1:
            for char in token_lower:
                if char in ewcfg.alphabet:
                    col = ewcfg.alphabet.index(char)
                    token_lower = token_lower.replace(char, "")
        if bubble_add == None:
            bubble = token_lower
            if bubble in ewcfg.cell_bubbles:
                bubble_add = bubble

    row = len(grid)
    row -= 1

    if col not in range(len(grid[0])):
        response = "Invalid Bubble Breaker vein."
        return response

    if bubble_add == None:
        response = "Invalid Bubble Breaker bubble."
        return response

    mining_yield = 0
    mining_accident = False

    cells_to_clear = []

    slimes_pertile = 1.8 * get_mining_yield_default(cmd)
    if grid[row][col] != ewcfg.cell_bubble_empty:
        mining_accident = True
    else:
        grid[row][col] = bubble_add

        cells_to_check = apply_gravity(grid)

        cells_to_check.append((row, col))

        while len(cells_to_check) > 0:
            mining_yield += slimes_pertile * check_and_explode(
                grid, cells_to_check)

            cells_to_check = apply_gravity(grid)

    grid_cont.cells_mined += 1
    grid_height = get_height(grid)

    if grid_cont.cells_mined % 4 == 3 or grid_height < 5:
        if grid_height < len(grid):
            add_row(grid)
        else:
            mining_accident = True

    if mining_accident:

        response = "You have lost an arm and a leg in a mining accident. Tis but a scratch."

        if random.randrange(4) == 0:
            response = "Big John arrives just in time to save you from your mining accident!\nhttps://cdn.discordapp.com/attachments/431275470902788107/743629505876197416/mine2.jpg"
        else:
            mutations = user_data.get_mutations()
            if ewcfg.mutation_id_lightminer in mutations:
                response = "You instinctively jump out of the way of the collapsing shaft, not a scratch on you. Whew, really gets your blood pumping."
            else:
                user_data.change_slimes(n=-(user_data.slimes * 0.3))
                user_data.persist()

        init_grid_bubblebreaker(cmd.message.channel.name, user_data.id_server)

        return response
    else:
        return mining_yield
コード例 #19
0
async def haunt(cmd):
    time_now = int(time.time())
    response = ""
    resp_cont = EwResponseContainer(id_server=cmd.guild.id)

    if cmd.mentions_count > 1:
        response = "You can only spook one person at a time. Who do you think you are, the Lord of Ghosts?"
    else:
        haunted_data = None
        member = None
        if cmd.mentions_count == 0 and cmd.tokens_count > 1:
            server = cmd.guild
            member = server.get_member(ewutils.getIntToken(cmd.tokens))
            haunted_data = EwUser(member=member)
        elif cmd.mentions_count == 1:
            member = cmd.mentions[0]
            haunted_data = EwUser(member=member)

        if member:
            # Get the user and target data from the database.
            user_data = EwUser(member=cmd.message.author)
            market_data = EwMarket(id_server=cmd.guild.id)
            target_mutations = haunted_data.get_mutations()
            target_poi = poi_static.id_to_poi.get(haunted_data.poi)
            target_is_shambler = haunted_data.life_state == ewcfg.life_state_shambler
            target_is_inhabitted = haunted_data.id_user == user_data.get_inhabitee(
            )

            if user_data.life_state != ewcfg.life_state_corpse:
                # Only dead players can haunt.
                response = "You can't haunt now. Try {}.".format(
                    ewcfg.cmd_suicide)
            elif haunted_data.life_state == ewcfg.life_state_kingpin:
                # Disallow haunting of generals.
                response = "He is too far from the sewers in his ivory tower, and thus cannot be haunted."
            elif (time_now - user_data.time_lasthaunt) < ewcfg.cd_haunt:
                # Disallow haunting if the user has haunted too recently.
                response = "You're being a little TOO spooky lately, don't you think? Try again in {} seconds.".format(
                    int(ewcfg.cd_haunt -
                        (time_now - user_data.time_lasthaunt)))
            elif ewutils.channel_name_is_poi(
                    cmd.message.channel.name) == False:
                response = "You can't commit violence from here."
            elif target_poi.pvp == False:
                # Require the target to be in a PvP area, and flagged if it's a remote haunt
                response = "{} is not mired in the ENDLESS WAR right now.".format(
                    member.display_name)
            elif haunted_data.life_state == ewcfg.life_state_corpse:
                # Dead players can't be haunted.
                response = "{} is already dead.".format(member.display_name)
            elif haunted_data.life_state == ewcfg.life_state_grandfoe:
                # Grand foes can't be haunted.
                response = "{} is invulnerable to ghosts.".format(
                    member.display_name)
            elif haunted_data.life_state == ewcfg.life_state_enlisted or haunted_data.life_state == ewcfg.life_state_juvenile or haunted_data.life_state == ewcfg.life_state_shambler:
                haunt_power_multiplier = 1

                # power to the ancients
                ghost_age = time_now - user_data.time_lastdeath
                if ghost_age > 60 * 60 * 24 * 7:  # dead for longer than
                    if ghost_age > 60 * 60 * 24 * 365:  # one friggin year
                        haunt_power_multiplier *= 2.5
                    if ghost_age > 60 * 60 * 24 * 90:  # three months
                        haunt_power_multiplier *= 2
                    elif ghost_age > 60 * 60 * 24 * 30:  # one month
                        haunt_power_multiplier *= 1.5
                    else:  # one week
                        haunt_power_multiplier *= 1.25

                # vitriol as virtue
                list_ids = []
                for quadrant in ewcfg.quadrant_ids:
                    quadrant_data = EwQuadrant(id_server=cmd.guild.id,
                                               id_user=cmd.message.author.id,
                                               quadrant=quadrant)
                    if quadrant_data.id_target != -1 and quadrant_data.check_if_onesided(
                    ) is False:
                        list_ids.append(quadrant_data.id_target)
                    if quadrant_data.id_target2 != -1 and quadrant_data.check_if_onesided(
                    ) is False:
                        list_ids.append(quadrant_data.id_target2)
                if haunted_data.id_user in list_ids:  # any mutual quadrants
                    haunt_power_multiplier *= 1.2
                if haunted_data.faction and (
                    (not user_data.faction) or
                    (user_data.faction != haunted_data.faction)
                ):  # opposite faction (or no faction at all)
                    haunt_power_multiplier *= 1.2
                if user_data.id_killer == haunted_data.id_user:  # haunting your murderer/buster
                    haunt_power_multiplier *= 1.2

                # places of power.
                if haunted_data.poi in [
                        ewcfg.poi_id_thevoid, ewcfg.poi_id_wafflehouse,
                        ewcfg.poi_id_blackpond
                ]:
                    haunt_power_multiplier *= 2
                elif haunted_data.poi in get_void_connection_pois(
                        cmd.guild.id):
                    haunt_power_multiplier *= 1.25

                # glory to the vanquished
                target_kills = ewstats.get_stat(user=haunted_data,
                                                metric=ewcfg.stat_kills)
                if target_kills > 5:
                    haunt_power_multiplier *= 1.25 + (
                        (target_kills - 5) / 100)  # 1% per kill after 5
                else:
                    haunt_power_multiplier *= 1 + (target_kills * 5 / 100
                                                   )  # 5% per kill

                if time_now - haunted_data.time_lastkill < (60 * 15):
                    haunt_power_multiplier *= 1.5  #  wet hands

                # misc
                if weather_static.weather_map.get(
                        market_data.weather) == ewcfg.weather_foggy:
                    haunt_power_multiplier *= 1.1
                if not haunted_data.has_soul:
                    haunt_power_multiplier *= 1.2
                # uncomment this after moon mechanics update
                # if (market_data.day % 31 == 15 and market_data.clock >= 20) or (market_data.day % 31 == 16 and market_data.clock <= 6):
                # 	haunt_power_multiplier *= 2

                # divide haunt power by 2 if not in same area
                if user_data.poi != haunted_data.poi:
                    haunt_power_multiplier /= 2

                # Double Halloween
                if ewcfg.dh_active:
                    haunt_power_multiplier *= 4

                haunted_slimes = int(
                    (haunted_data.slimes / ewcfg.slimes_hauntratio) *
                    haunt_power_multiplier)
                slimes_lost = int(
                    haunted_slimes / 5
                )  # hauntee only loses 1/5th of what the ghost gets as antislime

                if ewcfg.mutation_id_coleblooded in target_mutations:
                    haunted_slimes = -10000
                    if user_data.slimes > haunted_slimes:
                        haunted_slimes = user_data.slimes

                haunted_data.change_slimes(n=-slimes_lost,
                                           source=ewcfg.source_haunted)
                user_data.change_slimes(n=-haunted_slimes,
                                        source=ewcfg.source_haunter)
                market_data.negaslime -= haunted_slimes

                user_data.time_lasthaunt = time_now
                user_data.clear_status(id_status=ewcfg.status_busted_id)

                resp_cont.add_member_to_update(cmd.message.author)
                # Persist changes to the database.
                user_data.persist()
                haunted_data.persist()
                market_data.persist()

                response = "{} has been haunted by the ghost of {}! Slime has been lost! {} antislime congeals within you.".format(
                    member.display_name, cmd.message.author.display_name,
                    haunted_slimes)
                if ewcfg.mutation_id_coleblooded in target_mutations:
                    response = "{} has been haunted by the ghost of {}! Their exorcising coleslaw blood purges {} antislime from your being! Better not do that again.".format(
                        member.display_name, cmd.message.author.display_name,
                        -haunted_slimes)

                haunted_channel = poi_static.id_to_poi.get(
                    haunted_data.poi).channel
                haunt_message = "You feel a cold shiver run down your spine"
                if cmd.tokens_count > 2:
                    haunt_message_content = re.sub(
                        "<.+>" if cmd.mentions_count == 1 else "\d{17,}", "",
                        cmd.message.content[(len(cmd.tokens[0])):]).strip()
                    # Cut down really big messages so discord doesn't crash
                    if len(haunt_message_content) > 500:
                        haunt_message_content = haunt_message_content[:-500]
                    haunt_message += " and faintly hear the words \"{}\"".format(
                        haunt_message_content)
                haunt_message += ". {} slime evaporates from your body.".format(
                    slimes_lost)
                if ewcfg.mutation_id_coleblooded in target_mutations:
                    haunt_message += " The ghost that did it wails in agony as their ectoplasm boils in your coleslaw blood!"

                haunt_message = fe_utils.formatMessage(member, haunt_message)
                resp_cont.add_channel_response(haunted_channel, haunt_message)
        else:
            # No mentions, or mentions we didn't understand.
            response = "Your spookiness is appreciated, but ENDLESS WAR didn\'t understand that name."

    # Send the response to the player.
    resp_cont.add_channel_response(cmd.message.channel.name, response)
    await resp_cont.post()
コード例 #20
0
async def cultivate(cmd):
    user_data = EwUser(member=cmd.message.author)

    response = ""
    levelup_response = ""
    mutations = user_data.get_mutations()

    # Checking availability of irrigate action

    if cmd.message.channel.name not in [
            ewcfg.channel_jr_farms, ewcfg.channel_og_farms,
            ewcfg.channel_ab_farms
    ] and cmd.tokens[0].lower() == '!weed':
        rand1 = random.randrange(100)
        rand2 = random.randrange(5)
        response = ""
        if rand1 > 80:
            response = "**"
        for x in range(rand2 + 1):
            response += "Y"
        for x in range(rand2 + 1):
            response += "E"
        for x in range(rand2 + 1):
            response += "A"
        for x in range(rand2 + 1):
            response += "H"
        response += " BRO!"
        if rand1 > 80:
            response += "**"

    elif user_data.life_state != ewcfg.life_state_juvenile:
        response = "Only Juveniles of pure heart and with nothing better to do can tend to their crops."
    elif cmd.message.channel.name not in [
            ewcfg.channel_jr_farms, ewcfg.channel_og_farms,
            ewcfg.channel_ab_farms
    ]:
        response = "Do you remember planting anything here in this barren wasteland? No, you don’t. Idiot."
    else:
        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)

        farm_action = farm_static.cmd_to_farm_action.get(cmd.tokens[0].lower())

        if farm.time_lastsow == 0:
            response = "You missed a step, you haven’t planted anything here yet."
        elif farm.action_required != farm_action.id_action:
            response = farm_action.str_execute_fail
            farm.slimes_onreap -= ewcfg.farm_slimes_peraction
            farm.slimes_onreap = max(farm.slimes_onreap, 0)
            farm.persist()
        else:
            response = farm_action.str_execute
            # farm actions award more slime
            farm.slimes_onreap += ewcfg.farm_slimes_peraction * 2
            farm.action_required = ewcfg.farm_action_none
            farm.persist()

    await fe_utils.send_message(
        cmd.client, cmd.message.channel,
        fe_utils.formatMessage(cmd.message.author, response))
コード例 #21
0
async def chemo(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. 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 operate on one.'
        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

    mutations = user_data.get_mutations()
    if len(mutations) == 0:
        response = '"I can chemo you all day long, sonny. You\'re not getting any cleaner than you are."'
        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
    elif len(cmd.tokens) <= 1:
        response = '"Are you into chemo for the thrill, boy? You have to tell me what you want taken out."'
        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
    elif cmd.tokens[1] == "all":
        finalprice = 0

        for mutation in mutations:
            finalprice += static_mutations.mutations_map.get(mutation).tier * 5000

        if finalprice > user_data.slimes:
            response = '"We\'re not selling gumballs here. It\'s chemotherapy. It\'ll cost at least {:,} slime, ya idjit!"'.format(finalprice)
            return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
        else:
            response = "\"Sure you got the slime for that, whelp? It's {:,}.\"\n**Accept** or **refuse?**".format(finalprice)
            await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
            try:
                accepted = False
                message = await cmd.client.wait_for('message', timeout=30, 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 Exception as e:
                print(e)
                accepted = False

            if not accepted:
                response = "\"Tch. Knew you weren't good for it.\""
            else:

                for mutation in mutations:

                    price = static_mutations.mutations_map.get(mutation).tier * 5000
                    user_data.change_slimes(n=-price, source=ewcfg.source_spending)

                    mutation_obj = EwMutation(id_mutation=mutation, id_user=user_data.id_user, id_server=cmd.message.guild.id)
                    if mutation_obj.artificial == 0:
                        try:
                            bknd_core.execute_sql_query(
                                "DELETE FROM mutations WHERE {id_server} = %s AND {id_user} = %s AND {mutation} = %s".format(
                                    id_server=ewcfg.col_id_server,
                                    id_user=ewcfg.col_id_user,
                                    mutation=ewcfg.col_id_mutation
                                ), (
                                    user_data.id_server,
                                    user_data.id_user,
                                    mutation,
                                ))
                        except:
                            ewutils.logMsg("Failed to clear mutations for user {}.".format(user_data.id_user))
                user_data.persist()
                response = '"Everything, eh? All right then. This might hurt a lottle!" Auntie Dusttrap takes a specialized shop vac and sucks the slime out of you. While you\'re reeling in slimeless existential dread, she runs it through a filtration process that gets rid of the carcinogens that cause mutation. She grabs the now purified canister and haphazardly dumps it back into you. You feel pure, energized, and ready to dirty up your slime some more!'
            return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
    else:
        target_name = ewutils.flattenTokenListToString(cmd.tokens[1:])
        target = ewutils.get_mutation_alias(target_name)
        mutation_obj = EwMutation(id_mutation=target, id_user=user_data.id_user, id_server=cmd.message.guild.id)

        if target == 0:
            response = '"I don\'t know what kind of gold-rush era disease that is, but I have no idea how to take it out of you."'
            return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
        elif target not in mutations:
            response = '"Oy vey, another hypochondriac. You don\'t have that mutation, so I can\'t remove it."'
            return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
        elif static_mutations.mutations_map.get(target).tier * 5000 > user_data.slimes:
            response = '"We\'re not selling gumballs here. It\'s chemotherapy. It\'ll cost at least {} slime, ya idjit!"'.format(static_mutations.mutations_map.get(target).tier * 5000)
            return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
        elif mutation_obj.artificial == 1:
            response = '"Hey, didn\'t I do that to ya? Well no refunds!"\n\nGuess you can\'t get rid of artificial mutations with chemo.'
            return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
        else:
            price = static_mutations.mutations_map.get(target).tier * 5000
            user_data.change_slimes(n=-price, source=ewcfg.source_spending)
            user_data.persist()

            try:
                bknd_core.execute_sql_query("DELETE FROM mutations WHERE {id_server} = %s AND {id_user} = %s AND {mutation} = %s".format(
                    id_server=ewcfg.col_id_server,
                    id_user=ewcfg.col_id_user,
                    mutation=ewcfg.col_id_mutation
                ), (
                    user_data.id_server,
                    user_data.id_user,
                    target,
                ))
            except:
                ewutils.logMsg("Failed to clear mutations for user {}.".format(user_data.id_user))
            response = '"Alright, dearie, let\'s get you purged." You enter a dingy looking operating room, with slime strewn all over the floor. Dr. Dusttrap pulls out a needle the size of your bicep and injects into odd places on your body. After a few minutes of this, you get fatigued and go under.\n\n You wake up and {} is gone. Nice! \nMutation Levels Added:{}/{}'.format(
                static_mutations.mutations_map.get(target).str_name, 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))
コード例 #22
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))
コード例 #23
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))
コード例 #24
0
ファイル: farmcmds.py プロジェクト: ConnorJMartin/endless-war
async def reap(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))

    forcereap = False
    if cmd.tokens[0] == ewcfg.cmd_reap_alt:
        if cmd.message.author.guild_permissions.administrator:
            forcereap = True
        else:
            return

    response = ""
    levelup_response = ""
    mutations = user_data.get_mutations()
    cosmetic_abilites = itm_utils.get_cosmetic_abilities(
        id_user=cmd.message.author.id, id_server=cmd.guild.id)
    poi = poi_static.id_to_poi.get(user_data.poi)

    # 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 reap 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 = "Do you remember planting anything here in this barren wasteland? No, you don’t. Idiot."
    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 missed a step, you haven’t planted anything here yet."
        else:
            cur_time_min = time.time() / 60
            time_grown = cur_time_min - farm.time_lastsow

            if farm.phase != ewcfg.farm_phase_reap and not forcereap:
                response = "Patience is a virtue and you are morally bankrupt. Just wait, asshole."
            else:  # Reaping
                if (time_grown > ewcfg.crops_time_to_grow *
                        16) and not forcereap:  # about 2 days
                    response = "You eagerly cultivate your crop, but what’s this? It’s dead and wilted! It seems as though you’ve let it lay fallow for far too long. Pay better attention to your farm next time. You gain no slime."
                    farm.time_lastsow = 0  # 0 means no seeds are currently planted
                    farm.persist()
                else:
                    user_initial_level = user_data.slimelevel

                    slime_gain = farm.slimes_onreap

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

                    if controlling_faction != "" and controlling_faction == user_data.faction:
                        slime_gain *= 2

                    if has_tool and weapon.id_weapon == ewcfg.weapon_id_hoe:
                        slime_gain *= 1.5

                    if ewcfg.mutation_id_greenfingers in mutations:
                        slime_gain *= 1.2

                    if user_data.poi == ewcfg.poi_id_jr_farms:
                        slime_gain = int(slime_gain / 4)

                    # trauma = se_static.trauma_map.get(user_data.trauma)
                    # if trauma != None and trauma.trauma_class == ewcfg.trauma_class_slimegain:
                    #	slime_gain *= (1 - 0.5 * user_data.degradation / 100)

                    slime_gain = max(0, round(slime_gain))

                    response = "You reap what you’ve sown. Your investment has yielded {:,} slime, ".format(
                        slime_gain)

                    # Determine if an item is found.
                    unearthed_item = False
                    unearthed_item_amount = 0

                    unearthed_item_chance = 50 / ewcfg.unearthed_item_rarity  # 1 in 30 chance

                    if ewcfg.mutation_id_lucky in mutations:
                        unearthed_item_chance *= 1.33  # 1 in 22.5 chance

                    if ewcfg.cosmeticAbility_id_lucky in cosmetic_abilites:
                        unearthed_item_chance *= 1.33  # 1 in ~17 chance with both

                    if has_tool and weapon.id_weapon == ewcfg.weapon_id_shovel:  # 1 in 6 chance
                        unearthed_item_chance *= 5

                    if random.random() < unearthed_item_chance:
                        unearthed_item = True
                        unearthed_item_amount = 1 if random.randint(
                            1, 3) != 1 else 2  # 33% chance of extra drop

                    if unearthed_item == True:
                        # If there are multiple possible products, randomly select one.
                        item = random.choice(vendors.mine_results)

                        item_props = itm_utils.gen_item_props(item)

                        if item is not None:

                            for creation in range(unearthed_item_amount):
                                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 unearthed_item_amount == 1:
                            response += "a {}, ".format(item.str_name)
                        elif unearthed_item_amount == 2:
                            response += "two {}s, ".format(item.str_name)

                    #  Determine what crop is grown.
                    vegetable = static_food.food_map.get(farm.crop)
                    if vegetable is None:
                        vegetable = random.choice(static_food.vegetable_list)

                    item_props = itm_utils.gen_item_props(vegetable)

                    #  Create and give a bushel of whatever crop was grown, unless it's a metal crop.
                    if item_props.get('id_food') in [
                            ewcfg.item_id_metallicaps,
                            ewcfg.item_id_steelbeans, ewcfg.item_id_aushucks
                    ]:
                        metallic_crop_ammount = 1
                        if random.randrange(10) == 0:
                            metallic_crop_ammount = 5 if random.randrange(
                                2) == 0 else 6

                        if has_tool and weapon.id_weapon == ewcfg.weapon_id_pitchfork:
                            metallic_crop_ammount *= 2

                        for vcreate in range(metallic_crop_ammount):
                            bknd_item.item_create(
                                id_user=cmd.message.author.id,
                                id_server=cmd.guild.id,
                                item_type=vegetable.item_type,
                                item_props=item_props)

                        if metallic_crop_ammount == 1:
                            response += "and a single {}!".format(
                                vegetable.str_name)
                        else:
                            response += "and a bushel or two of {}!".format(
                                vegetable.str_name)
                    # if random.randrange(10) == 0:
                    # 	for vcreate in range(6):
                    # 		bknd_item.item_create(
                    # 			id_user=cmd.message.author.id,
                    # 			id_server=cmd.guild.id,
                    # 			item_type=vegetable.item_type,
                    # 			item_props=item_props
                    # 		)
                    #
                    # 	response += "and a bushel of {}!".format(vegetable.str_name)
                    # else:
                    # 	response += "and a bushel of... hey, what the hell! You didn't reap anything! Must've been some odd seeds..."
                    else:
                        unearthed_vegetable_amount = 3
                        if has_tool and weapon.id_weapon == ewcfg.weapon_id_pitchfork:
                            unearthed_vegetable_amount *= 2

                        for vcreate in range(unearthed_vegetable_amount):
                            bknd_item.item_create(
                                id_user=cmd.message.author.id,
                                id_server=cmd.guild.id,
                                item_type=vegetable.item_type,
                                item_props=item_props)

                        response += "and a bushel of {}!".format(
                            vegetable.str_name)

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

                    was_levelup = True if user_initial_level < user_data.slimelevel else False

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

                    user_data.hunger += ewcfg.hunger_perfarm
                    user_data.persist()

                    farm.time_lastsow = 0  # 0 means no seeds are currently planted
                    farm.persist()

                    # gangsters don't need their roles updated
                    if user_data.life_state == ewcfg.life_state_juvenile:
                        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
ファイル: farmcmds.py プロジェクト: ConnorJMartin/endless-war
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))
コード例 #26
0
async def mine(cmd):
    market_data = EwMarket(id_server=cmd.message.author.guild.id)
    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))

    mutations = user_data.get_mutations()
    cosmetic_abilites = itm_utils.get_cosmetic_abilities(id_user=cmd.message.author.id, id_server=cmd.guild.id)
    time_now = int(time.time())
    poi = poi_static.id_to_poi.get(user_data.poi)

    response = ""
    # Kingpins can't mine.
    if user_data.life_state == ewcfg.life_state_kingpin or user_data.life_state == ewcfg.life_state_grandfoe:
        return

    # ghosts cant mine (anymore)
    if user_data.life_state == ewcfg.life_state_corpse:
        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, "You can't mine while you're dead. Try {}.".format(ewcfg.cmd_revive)))

    # Enlisted players only mine at certain times.
    if user_data.life_state == ewcfg.life_state_enlisted:
        if user_data.faction == ewcfg.faction_rowdys and (market_data.clock < 8 or market_data.clock > 17):
            return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, "Rowdies only mine in the daytime. Wait for full daylight at 8am.".format(ewcfg.cmd_revive)))

        if user_data.faction == ewcfg.faction_killers and (market_data.clock < 20 and market_data.clock > 5):
            return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, "Killers only mine under cover of darkness. Wait for nightfall at 8pm.".format(ewcfg.cmd_revive)))

    # Mine only in the mines.
    if cmd.message.channel.name in ewcfg.mining_channels:
        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.hunger >= user_data.get_hunger_max():
            return await mismine(cmd, user_data, "exhaustion")
        # return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, "You've exhausted yourself from mining. You'll need some refreshment before getting back to work."))

        else:
            printgrid = True
            hunger_cost_mod = ewutils.hunger_cost_mod(user_data.slimelevel)
            extra = hunger_cost_mod - int(hunger_cost_mod)  # extra is the fractional part of hunger_cost_mod

            world_events = bknd_worldevent.get_world_events(id_server=cmd.guild.id)
            mining_type = ewcfg.mines_mining_type_map.get(user_data.poi)
            for id_event in world_events:

                if world_events.get(id_event) == ewcfg.event_type_minecollapse:
                    event_data = EwWorldEvent(id_event=id_event)
                    if int(event_data.event_props.get('id_user')) == user_data.id_user and event_data.event_props.get('poi') == user_data.poi:
                        captcha = event_data.event_props.get('captcha').lower()
                        tokens_lower = []
                        for token in cmd.tokens[1:]:
                            tokens_lower.append(token.lower())

                        if captcha in tokens_lower:
                            bknd_worldevent.delete_world_event(id_event=id_event)
                            response = "You escape from the collapsing mineshaft."
                            return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
                        elif ewcfg.mutation_id_lightminer in mutations:
                            bknd_worldevent.delete_world_event(id_event=id_event)
                            response = "You nimbly step outside the collapse without even thinking about it."
                            return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
                        else:
                            return await mismine(cmd, user_data, ewcfg.event_type_minecollapse)

            if user_data.poi not in juviecmdutils.mines_map:
                response = "You can't mine here! Go to the mines in Juvie's Row, Toxington, or Cratersville!"
                return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
            elif user_data.id_server not in juviecmdutils.mines_map.get(user_data.poi):
                init_grid(user_data.poi, user_data.id_server)
                printgrid = True

            grid_cont = juviecmdutils.mines_map.get(user_data.poi).get(user_data.id_server)
            grid = grid_cont.grid

            grid_type = ewcfg.grid_type_by_mining_type.get(mining_type)
            if grid_type != grid_cont.grid_type:
                init_grid(user_data.poi, user_data.id_server)
                printgrid = True
                grid_cont = juviecmdutils.mines_map.get(user_data.poi).get(user_data.id_server)
                grid = grid_cont.grid

            # minesweeper = True
            # grid_multiplier = grid_cont.cells_mined ** 0.4
            # flag = False
            mining_yield = get_mining_yield_by_grid_type(cmd, grid_cont)

            if type(mining_yield) == type(""):
                response = mining_yield
                if len(response) > 0:
                    await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
                if time_now > grid_cont.time_last_posted + 10:
                    await print_grid(cmd)
                return

            if mining_yield == 0:
                user_data.hunger += ewcfg.hunger_permine * int(hunger_cost_mod)
                user_data.persist()
                # response = "This vein has already been mined dry."
                # await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
                if printgrid:
                    return await print_grid(cmd)
                else:
                    return

            has_pickaxe = 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 == ewcfg.weapon_id_pickaxe or weapon.id_weapon == ewcfg.weapon_id_diamondpickaxe)  and user_data.life_state != ewcfg.life_state_juvenile:
                    has_pickaxe = True
            # if user_data.sidearm >= 0:
            #	sidearm_item = EwItem(id_item=user_data.sidearm)
            #	sidearm = static_weapons.weapon_map.get(sidearm_item.item_props.get("weapon_type"))
            #	if sidearm.id_weapon == ewcfg.weapon_id_pickaxe:
            #		has_pickaxe = True

            # Determine if an item is found.
            unearthed_item = False
            unearthed_item_amount = (random.randrange(3) + 5)  # anywhere from 5-7 drops

            # juvies get items 4 times as often as enlisted players
            unearthed_item_chance = 1 / ewcfg.unearthed_item_rarity
            if user_data.life_state == ewcfg.life_state_juvenile:
                unearthed_item_chance *= 2
            if has_pickaxe == True:
                unearthed_item_chance *= 1.5
            if ewcfg.mutation_id_lucky in mutations:
                unearthed_item_chance *= 1.33
            if ewcfg.cosmeticAbility_id_lucky in cosmetic_abilites:
                unearthed_item_chance *= 1.33

            # event bonus
            for id_event in world_events:

                if world_events.get(id_event) == ewcfg.event_type_slimefrenzy:
                    event_data = EwWorldEvent(id_event=id_event)
                    if event_data.event_props.get('poi') == user_data.poi and int(event_data.event_props.get('id_user')) == user_data.id_user:
                        mining_yield *= 2

                if world_events.get(id_event) == ewcfg.event_type_poudrinfrenzy:
                    event_data = EwWorldEvent(id_event=id_event)
                    if event_data.event_props.get('poi') == user_data.poi and int(event_data.event_props.get('id_user')) == user_data.id_user:
                        unearthed_item_chance = 1
                        unearthed_item_amount = 1

            if random.random() < 0.05:
                id_event = create_mining_event(cmd)
                event_data = EwWorldEvent(id_event=id_event)

                if event_data.id_event == -1:
                    return ewutils.logMsg("Error couldn't find world event with id {}".format(id_event))

                if event_data.event_type == ewcfg.event_type_slimeglob:
                    mining_yield *= 4
                    bknd_worldevent.delete_world_event(id_event=id_event)

                if event_data.time_activate <= time.time():

                    event_def = poi_static.event_type_to_def.get(event_data.event_type)
                    if event_def == None:
                        return ewutils.logMsg("Error, couldn't find event def for event type {}".format(event_data.event_type))
                    str_event_start = event_def.str_event_start

                    if event_data.event_type == ewcfg.event_type_minecollapse:
                        str_event_start = str_event_start.format(cmd=ewcfg.cmd_mine, captcha=ewutils.text_to_regional_indicator(event_data.event_props.get('captcha')))
                        await fe_utils.send_response(str_event_start, cmd)
                        event_data.time_expir = time_now + 60
                        event_data.persist()
                        str_event_start = ""

                    if str_event_start != "":
                        response += str_event_start + "\n"

            if random.random() < unearthed_item_chance:
                unearthed_item = True

            if unearthed_item == True:
                # If there are multiple possible products, randomly select one.
                item = random.choice(vendors.mine_results)

                if bknd_item.check_inv_capacity(user_data=user_data, item_type=item.item_type):

                    item_props = itm_utils.gen_item_props(item)

                    for creation in range(unearthed_item_amount):
                        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 unearthed_item_amount == 1:
                        response += "You unearthed a {}! ".format(item.str_name)
                    else:
                        response += "You unearthed {} {}s! ".format(unearthed_item_amount, item.str_name)

                    ewstats.change_stat(user=user_data, metric=ewcfg.stat_lifetime_poudrins, n=unearthed_item_amount)

            # ewutils.logMsg('{} has found {} {}(s)!'.format(cmd.message.author.display_name, item.str_name, unearthed_item_amount))

            user_initial_level = user_data.slimelevel

            # Add mined slime to the user.
            slime_bylevel = ewutils.slime_bylevel(user_data.slimelevel)

            # mining_yield = math.floor((slime_bylevel / 10) + 1)
            # alternate_yield = math.floor(200 + slime_bylevel ** (1 / math.e))

            # mining_yield = min(mining_yield, alternate_yield)

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

            if controlling_faction != "" and controlling_faction == user_data.faction:
                mining_yield *= 2

            if has_pickaxe == True:
                mining_yield *= 2
            if user_data.life_state == ewcfg.life_state_juvenile:
                mining_yield *= 2

            # trauma = se_static.trauma_map.get(user_data.trauma)
            # if trauma != None and trauma.trauma_class == ewcfg.trauma_class_slimegain:
            #	mining_yield *= (1 - 0.5 * user_data.degradation / 100)

            mining_yield = max(0, round(mining_yield))

            # Fatigue the miner.

            user_data.hunger += ewcfg.hunger_permine * int(hunger_cost_mod)
            if extra > 0:  # if hunger_cost_mod is not an integer
                # there's an x% chance that an extra stamina is deducted, where x is the fractional part of hunger_cost_mod in percent (times 100)
                if random.randint(1, 100) <= extra * 100:
                    user_data.hunger += ewcfg.hunger_permine

            levelup_response = user_data.change_slimes(n=mining_yield, source=ewcfg.source_mining)

            was_levelup = True if user_initial_level < user_data.slimelevel else False

            # Tell the player their slime level increased and/or they unearthed an item.
            if was_levelup:
                response += levelup_response

            user_data.persist()

            if printgrid:
                await print_grid(cmd)

            # gangsters don't need their roles updated
            if user_data.life_state == ewcfg.life_state_juvenile:
                await ewrolemgr.updateRoles(client=cmd.client, member=cmd.message.author)

    else:
        return await mismine(cmd, user_data, "channel")
    # response = "You can't mine here! Go to the mines in Juvie's Row, Toxington, or Cratersville!"

    if len(response) > 0:
        await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
コード例 #27
0
def get_mining_yield_minesweeper(cmd, grid_cont):
    user_data = EwUser(member=cmd.message.author)
    grid = grid_cont.grid
    grid_multiplier = grid_cont.cells_mined**0.4

    hunger_cost_mod = ewutils.hunger_cost_mod(user_data.slimelevel)

    row = -1
    col = -1
    if cmd.tokens_count < 2:
        response = "Please specify which Minesweeper vein to mine."
        return response

    for token in cmd.tokens[1:]:

        coords = token.lower()
        if coords == "reset":
            user_data.hunger += int(ewcfg.hunger_perminereset *
                                    hunger_cost_mod)
            user_data.persist()
            init_grid_minesweeper(user_data.poi, user_data.id_server)
            return ""

        if col < 1:

            for char in coords:
                if char in ewcfg.alphabet:
                    col = ewcfg.alphabet.index(char)
                    coords = coords.replace(char, "")
        if row < 1:
            try:
                row = int(coords)
            except:
                row = -1

    row -= 1

    if row not in range(len(grid)) or col not in range(len(grid[row])):
        response = "Invalid Minesweeper vein."
        return response

    mining_yield = 0
    mining_accident = False

    if grid[row][col] in [ewcfg.cell_empty_marked, ewcfg.cell_mine_marked]:
        response = "This vein has been flagged as dangerous. Remove the flag to mine here."
        return response

    elif grid[row][col] == ewcfg.cell_empty_open:
        response = "This vein has already been mined dry."
        return response

    elif grid[row][col] == ewcfg.cell_mine:
        mining_accident = True

    elif grid[row][col] == ewcfg.cell_empty:
        grid[row][col] = ewcfg.cell_empty_open
        grid_cont.cells_mined += 1
        mining_yield = grid_multiplier * 1.7 * get_mining_yield_default(cmd)

    unmined_cells = get_unmined_cell_count(grid_cont)

    if unmined_cells == 0:
        init_grid_minesweeper(user_data.poi, user_data.id_server)

    if mining_accident:
        slimes_lost = 0.1 * grid_multiplier * user_data.slimes
        if slimes_lost <= 0:
            response = "You barely avoided getting into a mining accident."
        else:
            response = "You have lost an arm and a leg in a mining accident. Tis but a scratch."

            if random.randrange(4) == 0:
                response = "Big John arrives just in time to save you from your mining accident!\nhttps://cdn.discordapp.com/attachments/431275470902788107/743629505876197416/mine2.jpg"
            else:
                mutations = user_data.get_mutations()
                if ewcfg.mutation_id_lightminer in mutations:
                    response = "You instinctively jump out of the way of the live mine, barely escaping with your life. Whew, really gets your blood pumping."
                    user_data.hunger += int(ewcfg.hunger_perlmcollapse *
                                            hunger_cost_mod)
                    user_data.persist()
                else:
                    user_data.change_slimes(n=-(user_data.slimes * 0.3))
                    user_data.persist()

        init_grid_minesweeper(user_data.poi, user_data.id_server)

        return response

    else:
        return mining_yield
コード例 #28
0
async def flag(cmd):
    market_data = EwMarket(id_server=cmd.message.author.guild.id)
    user_data = EwUser(member=cmd.message.author)
    mutations = user_data.get_mutations()
    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))

    mutations = user_data.get_mutations()
    time_now = int(time.time())

    response = ""
    # Kingpins can't mine.
    if user_data.life_state == ewcfg.life_state_kingpin or user_data.life_state == ewcfg.life_state_grandfoe:
        return

    # ghosts cant mine (anymore)
    if user_data.life_state == ewcfg.life_state_corpse:
        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, "You can't mine while you're dead. Try {}.".format(ewcfg.cmd_revive)))

    # Enlisted players only mine at certain times.
    if user_data.life_state == ewcfg.life_state_enlisted:
        if user_data.faction == ewcfg.faction_rowdys and (market_data.clock < 8 or market_data.clock > 17) and ewcfg.mutation_id_lightminer not in mutations:
            return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, "Rowdies only mine in the daytime. Wait for full daylight at 8am.".format(ewcfg.cmd_revive)))

        if user_data.faction == ewcfg.faction_killers and (market_data.clock < 20 and market_data.clock > 5) and ewcfg.mutation_id_lightminer not in mutations:
            return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, "Killers only mine under cover of darkness. Wait for nightfall at 8pm.".format(ewcfg.cmd_revive)))

    # Mine only in the mines.
    if cmd.message.channel.name in ewcfg.mining_channels:
        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.hunger >= user_data.get_hunger_max():
            return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, "You've exhausted yourself from mining. You'll need some refreshment before getting back to work."))

        else:
            printgrid = True
            hunger_cost_mod = ewutils.hunger_cost_mod(user_data.slimelevel)
            extra = hunger_cost_mod - int(hunger_cost_mod)  # extra is the fractional part of hunger_cost_mod

            mining_type = ewcfg.mines_mining_type_map.get(user_data.poi)

            if mining_type != ewcfg.mining_type_minesweeper:
                response = "What do you think you can flag here?"
                return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

            if user_data.poi not in juviecmdutils.mines_map:
                response = "You can't mine here! Go to the mines in Juvie's Row, Toxington, or Cratersville!"
                return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
            elif user_data.id_server not in juviecmdutils.mines_map.get(user_data.poi):
                init_grid(user_data.poi, user_data.id_server)
                printgrid = True

            grid_cont = juviecmdutils.mines_map.get(user_data.poi).get(user_data.id_server)
            grid = grid_cont.grid

            grid_type = ewcfg.grid_type_by_mining_type.get(mining_type)
            if grid_type != grid_cont.grid_type:
                init_grid(user_data.poi, user_data.id_server)
                printgrid = True
                grid_cont = juviecmdutils.mines_map.get(user_data.poi).get(user_data.id_server)
                grid = grid_cont.grid

            row = -1
            col = -1
            if cmd.tokens_count < 2:
                response = "Please specify which Minesweeper vein to flag."
                return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

            for token in cmd.tokens[1:]:

                coords = token.lower()
                if col < 1:

                    for char in coords:
                        if char in ewcfg.alphabet:
                            col = ewcfg.alphabet.index(char)
                            coords = coords.replace(char, "")
                if row < 1:
                    try:
                        row = int(coords)
                    except:
                        row = -1

            row -= 1

            if row not in range(len(grid)) or col not in range(len(grid[row])):
                response = "Invalid Minesweeper vein."


            elif grid[row][col] == ewcfg.cell_empty_marked:
                grid[row][col] = ewcfg.cell_empty

            elif grid[row][col] == ewcfg.cell_mine_marked:
                grid[row][col] = ewcfg.cell_mine

            elif grid[row][col] == ewcfg.cell_empty_open:
                response = "This vein has already been mined dry."

            elif grid[row][col] == ewcfg.cell_mine:
                grid[row][col] = ewcfg.cell_mine_marked

            elif grid[row][col] == ewcfg.cell_empty:
                grid[row][col] = ewcfg.cell_empty_marked

            if printgrid:
                await print_grid(cmd)


    else:
        response = "You can't mine here! Go to the mines in Juvie's Row, Toxington, or Cratersville!"

    if len(response) > 0:
        await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, 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 scavenge(cmd):
    market_data = EwMarket(id_server=cmd.message.author.guild.id)
    user_data = EwUser(member=cmd.message.author)
    mutations = user_data.get_mutations()

    time_now = int(time.time())
    response = ""

    time_since_last_scavenge = time_now - user_data.time_lastscavenge

    # Kingpins can't scavenge.
    if user_data.life_state == ewcfg.life_state_kingpin or user_data.life_state == ewcfg.life_state_grandfoe:
        return

    # ghosts cant scavenge
    if user_data.life_state == ewcfg.life_state_corpse:
        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, "What would you want to do that for? You're a ghost, you have no need for such lowly materialistic possessions like slime. You only engage in intellectual pursuits now. {} if you want to give into your base human desire to see numbers go up.".format(ewcfg.cmd_revive)))
    # currently not active - no cooldown
    if time_since_last_scavenge < ewcfg.cd_scavenge:
        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, "Slow down, you filthy hyena."))

    if user_data.poi == ewcfg.poi_id_slimesea:
        if user_data.life_state == ewcfg.life_state_shambler:
            return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, "Are you trying to grab random trash instead of !searchingforbrainz? Pretty cringe bro..."))
        else:
            return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, "You consider diving down to the bottom of the sea to grab some sick loot, but quickly change your mind when you {}.".format(random.choice(ewcfg.sea_scavenge_responses))))

    # Scavenge only in location channels
    if ewutils.channel_name_is_poi(cmd.message.channel.name) == True:
        if user_data.hunger >= user_data.get_hunger_max():
            return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, "You are too exhausted to scrounge up scraps of slime off the street! Go get some grub!"))
        else:

            if juviecmdutils.scavenge_combos.get(user_data.id_user) == None:
                juviecmdutils.scavenge_combos[user_data.id_user] = 0

            combo = juviecmdutils.scavenge_combos.get(user_data.id_user)

            district_data = EwDistrict(district=user_data.poi, id_server=cmd.message.author.guild.id)

            user_initial_level = user_data.slimelevel
            # add scavenged slime to user
            if ewcfg.mutation_id_trashmouth in mutations:
                combo += 5

            time_since_last_scavenge = min(max(1, time_since_last_scavenge), ewcfg.soft_cd_scavenge)

            # scavenge_mod = 0.003 * (time_since_last_scavenge ** 0.9)
            scavenge_mod = 0.005 * combo

            if (ewcfg.mutation_id_whitenationalist in mutations or ewcfg.mutation_id_airlock in mutations) and market_data.weather == "snow":
                scavenge_mod *= 1.5

            if ewcfg.mutation_id_airlock in mutations and market_data.weather == "snow":
                scavenge_mod *= 1.5

            if ewcfg.mutation_id_webbedfeet in mutations:
                district_slimelevel = len(str(district_data.slimes))
                scavenge_mod *= max(1, min(district_slimelevel - 3, 4))

            scavenge_yield = math.floor(scavenge_mod * district_data.slimes)

            levelup_response = user_data.change_slimes(n=scavenge_yield, source=ewcfg.source_scavenging)
            district_data.change_slimes(n=-1 * scavenge_yield, source=ewcfg.source_scavenging)
            district_data.persist()

            if levelup_response != "":
                response += levelup_response + "\n\n"
            # response += "You scrape together {} slime from the streets.\n\n".format(scavenge_yield)
            if cmd.tokens_count > 1:

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

                if juviecmdutils.scavenge_combos.get(user_data.id_user) > 0 and (time_now - user_data.time_lastscavenge) < 60:
                    if juviecmdutils.scavenge_captchas.get(user_data.id_user).lower() == item_search.lower():
                        juviecmdutils.scavenge_combos[user_data.id_user] += 1
                        new_captcha = gen_scavenge_captcha(n=juviecmdutils.scavenge_combos.get(user_data.id_user), user_data=user_data)
                        response += "New captcha: **" + ewutils.text_to_regional_indicator(new_captcha) + "**"
                        if ewcfg.mutation_id_webbedfeet in mutations:
                            response += "\nYour flippers pick up {:,} slime.".format(scavenge_yield)
                        juviecmdutils.scavenge_captchas[user_data.id_user] = new_captcha
                        has_comboed = True

                        if ewcfg.mutation_id_dumpsterdiver in mutations:
                            has_comboed = False
                            item_search = item_search[random.randrange(len(item_search))]

                    else:
                        juviecmdutils.scavenge_combos[user_data.id_user] = 0

                if not has_comboed:
                    loot_resp = itm_utils.item_lootspecific(
                        user_data=user_data,
                        item_search=item_search
                    )

                    if loot_resp != "":
                        response = loot_resp + "\n\n" + response

            else:
                loot_multiplier = 1.0 + bknd_item.get_inventory_size(owner=user_data.poi, id_server=user_data.id_server)
                loot_chance = loot_multiplier / ewcfg.scavenge_item_rarity
                if ewcfg.mutation_id_dumpsterdiver in mutations:
                    loot_chance *= 10
                if random.random() < loot_chance:
                    loot_resp = itm_utils.item_lootrandom(
                        user_data
                    )

                    if loot_resp != "":
                        response += loot_resp + "\n\n"

                juviecmdutils.scavenge_combos[user_data.id_user] = 1
                new_captcha = gen_scavenge_captcha(n=1, user_data=user_data)
                response += "New captcha: **" + ewutils.text_to_regional_indicator(new_captcha) + "**"
                if ewcfg.mutation_id_webbedfeet in mutations:
                    response += "\nYour flippers pick up {:,} slime.".format(scavenge_yield)
                juviecmdutils.scavenge_captchas[user_data.id_user] = new_captcha

            # Fatigue the scavenger.
            hunger_cost_mod = ewutils.hunger_cost_mod(user_data.slimelevel)
            extra = hunger_cost_mod - int(hunger_cost_mod)  # extra is the fractional part of hunger_cost_mod

            user_data.hunger += ewcfg.hunger_perscavenge * int(hunger_cost_mod)
            if extra > 0:  # if hunger_cost_mod is not an integer
                # there's an x% chance that an extra stamina is deducted, where x is the fractional part of hunger_cost_mod in percent (times 100)
                if random.randint(1, 100) <= extra * 100:
                    user_data.hunger += ewcfg.hunger_perscavenge

            user_data.time_lastscavenge = time_now

            user_data.persist()

            # gangsters don't need their roles updated
            if user_data.life_state == ewcfg.life_state_juvenile:
                await ewrolemgr.updateRoles(client=cmd.client, member=cmd.message.author)

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

    else:
        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, "You'll find no slime here, this place has been picked clean. Head into the city to try and scavenge some slime."))